forked from highsource/jaxb-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue highsource#11. Added Object[] handling and a test schema.
- Loading branch information
1 parent
75200fa
commit 2b9c876
Showing
4 changed files
with
86 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
tests/simple-hashCode-equals-01/src/main/resources/cases.xsd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" | ||
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" elementFormDefault="qualified" | ||
attributeFormDefault="unqualified" targetNamespace="urn:t" xmlns:tns="urn:t" | ||
jaxb:version="2.1"> | ||
|
||
<xs:annotation> | ||
<xs:appinfo> | ||
<jaxb:schemaBindings> | ||
<jaxb:package | ||
name="org.jvnet.jaxb2_commons.tests.simple_hashcode_equals_01.cases" /> | ||
</jaxb:schemaBindings> | ||
</xs:appinfo> | ||
</xs:annotation> | ||
|
||
<xs:complexType name="arrays"> | ||
<xs:sequence> | ||
<xs:element name="objects" type="xs:string"> | ||
<xs:annotation> | ||
<xs:appinfo> | ||
<jaxb:property> | ||
<jaxb:baseType name="java.lang.Object[]" /> | ||
</jaxb:property> | ||
</xs:appinfo> | ||
</xs:annotation> | ||
</xs:element> | ||
</xs:sequence> | ||
</xs:complexType> | ||
|
||
</xs:schema> |
44 changes: 44 additions & 0 deletions
44
...ava/org/jvnet/jaxb2_commons/tests/simple_hashcode_equals_01/cases/RunPluginsForCases.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package org.jvnet.jaxb2_commons.tests.simple_hashcode_equals_01.cases; | ||
|
||
import java.io.File; | ||
import java.net.URL; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import com.sun.codemodel.JCodeModel; | ||
import com.sun.tools.xjc.ConsoleErrorReporter; | ||
import com.sun.tools.xjc.ModelLoader; | ||
import com.sun.tools.xjc.Options; | ||
import com.sun.tools.xjc.model.Model; | ||
|
||
public class RunPluginsForCases { | ||
|
||
@Before | ||
public void setUp() { | ||
System.setProperty("javax.xml.accessExternalSchema", "all"); | ||
} | ||
|
||
@Test | ||
public void compilesSchema() throws Exception { | ||
|
||
new File("target/generated-sources/xjc").mkdirs(); | ||
|
||
URL schema = getClass().getResource("/cases.xsd"); | ||
// URL binding = getClass().getResource("/cases.xjb"); | ||
final String[] arguments = new String[] { "-xmlschema", | ||
schema.toExternalForm(), | ||
// "-b", binding.toExternalForm(), | ||
"-d", | ||
"target/generated-sources/xjc", "-extension", | ||
"-XsimpleHashCode", "-XsimpleEquals", "-XsimpleToString" }; | ||
|
||
Options options = new Options(); | ||
options.parseArguments(arguments); | ||
ConsoleErrorReporter receiver = new ConsoleErrorReporter(); | ||
Model model = ModelLoader.load(options, new JCodeModel(), receiver); | ||
model.generateCode(options, receiver); | ||
com.sun.codemodel.CodeWriter cw = options.createCodeWriter(); | ||
model.codeModel.build(cw); | ||
} | ||
} |