Skip to content

Commit 963c735

Browse files
committed
Issue #3: test and updated bindings.
1 parent 511878b commit 963c735

File tree

2 files changed

+45
-2
lines changed

2 files changed

+45
-2
lines changed

tests/simplify-01/src/main/resources/binding.xjb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111
<jaxb:schemaBindings>
1212
<jaxb:package name="org.jvnet.jaxb2_commons.plugin.simplify.tests01"/>
1313
</jaxb:schemaBindings>
14-
<jaxb:bindings node="xs:complexType[@name='ParentsType']/xs:sequence/xs:element/xs:complexType/xs:sequence/xs:choice/xs:element[@name='type2']">
15-
<simplify:as-element-property />
14+
<jaxb:bindings node="xs:complexType[@name='ParentsType']/xs:sequence/xs:element/xs:complexType">
15+
<simplify:property name="type2OrType3">
16+
<simplify:as-element-property/>
17+
</simplify:property>
1618
</jaxb:bindings>
1719
</jaxb:bindings>
1820

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package org.jvnet.jaxb2_commons.plugin.simplify.tests01;
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 RunSimplifyPlugin {
16+
17+
@Before
18+
public void setUp() {
19+
System.setProperty("javax.xml.accessExternalSchema", "all");
20+
}
21+
22+
@Test
23+
public void compilesSchema() 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+
final String[] arguments = new String[] { "-xmlschema",
30+
schema.toExternalForm(), "-b", binding.toExternalForm(), "-d",
31+
"target/generated-sources/xjc", "-extension", "-Xsimplify" };
32+
33+
Options options = new Options();
34+
options.parseArguments(arguments);
35+
ConsoleErrorReporter receiver = new ConsoleErrorReporter();
36+
Model model = ModelLoader.load(options, new JCodeModel(), receiver);
37+
model.generateCode(options, receiver);
38+
com.sun.codemodel.CodeWriter cw = options.createCodeWriter();
39+
model.codeModel.build(cw);
40+
}
41+
}

0 commit comments

Comments
 (0)