Skip to content

Commit b1b9aa9

Browse files
committed
Issue #60.
1 parent 6a1efd6 commit b1b9aa9

File tree

5 files changed

+224
-0
lines changed

5 files changed

+224
-0
lines changed

tests/issues/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/target/
2+
.settings
3+
.project
4+
.classpath

tests/issues/pom.xml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
2+
<modelVersion>4.0.0</modelVersion>
3+
<artifactId>jsonix-schema-compiler-test-issues</artifactId>
4+
<packaging>jar</packaging>
5+
<name>Jsonix Schema Compiler Test [issues]</name>
6+
<parent>
7+
<groupId>org.hisrc.jsonix</groupId>
8+
<artifactId>jsonix-schema-compiler-tests</artifactId>
9+
<version>2.3.8-SNAPSHOT</version>
10+
</parent>
11+
<dependencies>
12+
<!--dependency>
13+
<groupId>org.hisrc.jsonix</groupId>
14+
<artifactId>jsonix-scripts</artifactId>
15+
</dependency-->
16+
<!--dependency>
17+
<groupId>org.glassfish.jaxb</groupId>
18+
<artifactId>jaxb-runtime</artifactId>
19+
<scope>provided</scope>
20+
</dependency-->
21+
<!--dependency>
22+
<groupId>net.disy.legato</groupId>
23+
<artifactId>legato-testing</artifactId>
24+
<scope>test</scope>
25+
</dependency-->
26+
<dependency>
27+
<groupId>org.jvnet.jaxb2.maven2</groupId>
28+
<artifactId>maven-jaxb2-plugin-testing</artifactId>
29+
<scope>test</scope>
30+
</dependency>
31+
<dependency>
32+
<groupId>org.hisrc.jsonix</groupId>
33+
<artifactId>jsonix-schema-compiler</artifactId>
34+
</dependency>
35+
</dependencies>
36+
<build>
37+
<!--resources>
38+
<resource>
39+
<directory>src/main/resources</directory>
40+
</resource>
41+
<resource>
42+
<directory>src/main/javascript</directory>
43+
</resource>
44+
<resource>
45+
<directory>target/generated-sources/xjc</directory>
46+
<includes>
47+
<include>META-INF/**/*.*</include>
48+
<include>**/*.js</include>
49+
</includes>
50+
</resource>
51+
</resources>
52+
<testResources>
53+
<testResource>
54+
<directory>src/test/resources</directory>
55+
</testResource>
56+
<testResource>
57+
<directory>src/test/javascript</directory>
58+
</testResource>
59+
</testResources-->
60+
<plugins>
61+
<plugin>
62+
<groupId>org.jvnet.jaxb2.maven2</groupId>
63+
<artifactId>maven-jaxb2-plugin</artifactId>
64+
<configuration>
65+
<extension>true</extension>
66+
<args>
67+
<arg>-Xjsonix</arg>
68+
<!--arg>-Xjsonix-compact</arg-->
69+
</args>
70+
<plugins>
71+
<plugin>
72+
<groupId>org.hisrc.jsonix</groupId>
73+
<artifactId>jsonix-schema-compiler</artifactId>
74+
<version>${project.version}</version>
75+
</plugin>
76+
</plugins>
77+
</configuration>
78+
</plugin>
79+
</plugins>
80+
</build>
81+
</project>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<jaxb:bindings version="1.0"
2+
xmlns:xs="http://www.w3.org/2001/XMLSchema"
3+
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
4+
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
5+
xmlns:jsonix="http://jsonix.highsource.org/customizations"
6+
jaxb:extensionBindingPrefixes="xjc jsonix">
7+
8+
<jaxb:bindings schemaLocation="schema.xsd"
9+
node="/xs:schema">
10+
<jaxb:globalBindings
11+
fixedAttributeAsConstantProperty="false"
12+
typesafeEnumBase="xs:string"
13+
typesafeEnumMemberName="generateName"
14+
generateIsSetMethod="true">
15+
</jaxb:globalBindings>
16+
<jaxb:schemaBindings>
17+
<jaxb:package name="org.hisrc.jsonix.tests.issues"/>
18+
</jaxb:schemaBindings>
19+
20+
<jsonix:mapping
21+
package="org.hisrc.jsonix.tests.issues"
22+
name="Issues"/>
23+
24+
</jaxb:bindings>
25+
26+
</jaxb:bindings>
27+
28+
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?xml version="1.0"?>
2+
<xs:schema
3+
xmlns:xs="http://www.w3.org/2001/XMLSchema"
4+
targetNamespace="urn:jsonix:tests:issues"
5+
xmlns:test="urn:jsonix:tests:issues"
6+
elementFormDefault="qualified"
7+
attributeFormDefault="unqualified">
8+
9+
<xs:complexType name="issueGH60Type">
10+
<xs:sequence>
11+
<xs:element name="base64Binary" type="xs:base64Binary" minOccurs="0"/>
12+
<xs:element name="hexBinary" type="xs:hexBinary" minOccurs="0"/>
13+
<xs:element name="duration" type="xs:duration" minOccurs="0"/>
14+
<xs:element name="dateTime" type="xs:dateTime" minOccurs="0"/>
15+
<xs:element name="date" type="xs:date" minOccurs="0"/>
16+
<xs:element name="time" type="xs:time" minOccurs="0"/>
17+
<xs:element name="gYearMonth" type="xs:gYearMonth" minOccurs="0"/>
18+
<xs:element name="gYear" type="xs:gYear" minOccurs="0"/>
19+
<xs:element name="gMonthDay" type="xs:gMonthDay" minOccurs="0"/>
20+
<xs:element name="gDay" type="xs:gDay" minOccurs="0"/>
21+
<xs:element name="gMonth" type="xs:gMonth" minOccurs="0"/>
22+
<xs:element name="float" type="xs:float" minOccurs="0"/>
23+
<xs:element name="double" type="xs:double" minOccurs="0"/>
24+
<xs:element name="decimal" type="xs:decimal" minOccurs="0"/>
25+
<xs:element name="integer" type="xs:integer" minOccurs="0"/>
26+
<xs:element name="long" type="xs:long" minOccurs="0"/>
27+
<xs:element name="int" type="xs:int" minOccurs="0"/>
28+
<xs:element name="short" type="xs:short" minOccurs="0"/>
29+
<xs:element name="byte" type="xs:byte" minOccurs="0"/>
30+
<xs:element name="unsignedLong" type="xs:unsignedLong" minOccurs="0"/>
31+
<xs:element name="unsignedInt" type="xs:unsignedInt" minOccurs="0"/>
32+
<xs:element name="unsignedShort" type="xs:unsignedShort" minOccurs="0"/>
33+
<xs:element name="unsignedByte" type="xs:unsignedByte" minOccurs="0"/>
34+
<xs:element name="nonNegativeInteger" type="xs:nonNegativeInteger" minOccurs="0"/>
35+
<xs:element name="nonPositiveInteger" type="xs:nonPositiveInteger" minOccurs="0"/>
36+
<xs:element name="positiveInteger" type="xs:positiveInteger"
37+
minOccurs="0"/>
38+
<xs:element name="negativeInteger" type="xs:negativeInteger"
39+
minOccurs="0"/>
40+
<xs:element name="boolean" type="xs:boolean" minOccurs="0"/>
41+
<xs:element name="anyURI" type="xs:anyURI" minOccurs="0"/>
42+
<xs:element name="QName" type="xs:QName" minOccurs="0"/>
43+
<!--
44+
<xs:element name="NOTATION" type="xs:NOTATION" minOccurs="0"/>
45+
-->
46+
47+
<xs:element name="string" type="xs:string" minOccurs="0"/>
48+
<xs:element name="normalizedString" type="xs:normalizedString"
49+
minOccurs="0"/>
50+
<xs:element name="token" type="xs:token" minOccurs="0"/>
51+
<xs:element name="language" type="xs:language" minOccurs="0"/>
52+
<xs:element name="Name" type="xs:Name" minOccurs="0"/>
53+
<xs:element name="NCName" type="xs:NCName" minOccurs="0"/>
54+
<xs:element name="ID" type="xs:ID" minOccurs="0"/>
55+
<xs:element name="IDREF" type="xs:IDREF" minOccurs="0"/>
56+
<xs:element name="IDREFS" type="xs:IDREFS"/>
57+
<xs:element name="ENTITY" type="xs:ENTITY" minOccurs="0"/>
58+
<xs:element name="ENTITIES" type="xs:ENTITIES" minOccurs="0"/>
59+
<xs:element name="NMTOKEN" type="xs:NMTOKEN" minOccurs="0"/>
60+
<xs:element name="NMTOKENS" type="xs:NMTOKENS" minOccurs="0"/>
61+
</xs:sequence>
62+
</xs:complexType>
63+
64+
</xs:schema>
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package org.hisrc.jsonix.tests.issues;
2+
3+
import java.io.File;
4+
import java.net.URL;
5+
6+
import org.junit.Before;
7+
import org.junit.Test;
8+
9+
import com.sun.codemodel.JCodeModel;
10+
import com.sun.tools.xjc.ConsoleErrorReporter;
11+
import com.sun.tools.xjc.ModelLoader;
12+
import com.sun.tools.xjc.Options;
13+
import com.sun.tools.xjc.model.Model;
14+
15+
public class CompileIssues {
16+
17+
@Before
18+
public void setUp() {
19+
System.setProperty("javax.xml.accessExternalSchema", "all");
20+
}
21+
22+
@Test
23+
public void compilesIssues() throws Exception {
24+
25+
new File("target/generated-sources/xjc").mkdirs();
26+
27+
URL schema = getClass().getResource("/schema.xsd");
28+
URL binding = getClass().getResource("/binding.xjb");
29+
30+
final String[] arguments = new String[] {
31+
"-xmlschema", schema.toExternalForm(),
32+
"-b", binding.toExternalForm(),
33+
"-d", "target/generated-sources/xjc",
34+
"-extension",
35+
"-Xjsonix"
36+
37+
};
38+
39+
Options options = new Options();
40+
options.parseArguments(arguments);
41+
ConsoleErrorReporter receiver = new ConsoleErrorReporter();
42+
Model model = ModelLoader.load(options, new JCodeModel(), receiver);
43+
model.generateCode(options, receiver);
44+
com.sun.codemodel.CodeWriter cw = options.createCodeWriter();
45+
model.codeModel.build(cw);
46+
}
47+
}

0 commit comments

Comments
 (0)