Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e5c8212
commit c66218c
Showing
4 changed files
with
313 additions
and
5 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
76 changes: 76 additions & 0 deletions
76
compiler/src/test/java/org/hisrc/jsonix/xjc/plugin/tests/basic/JsonixPluginZeroTest.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,76 @@ | ||
/** | ||
* Jsonix is a JavaScript library which allows you to convert between XML | ||
* and JavaScript object structures. | ||
* | ||
* Copyright (c) 2010 - 2014, Alexey Valikov, Highsource.org | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without modification, | ||
* are permitted provided that the following conditions are met: | ||
* | ||
* * Redistributions of source code must retain the above copyright notice, this | ||
* list of conditions and the following disclaimer. | ||
* | ||
* * Redistributions in binary form must reproduce the above copyright notice, this | ||
* list of conditions and the following disclaimer in the documentation and/or | ||
* other materials provided with the distribution. | ||
* | ||
* * Neither the name of the copyright holder nor the names of its | ||
* contributors may be used to endorse or promote products derived from | ||
* this software without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR | ||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | ||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
package org.hisrc.jsonix.xjc.plugin.tests.basic; | ||
|
||
import java.io.File; | ||
|
||
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 JsonixPluginZeroTest { | ||
|
||
@Before | ||
public void setUp() { | ||
System.setProperty("javax.xml.accessExternalSchema", "all"); | ||
} | ||
|
||
@Test | ||
public void compilesBasicZero() throws Exception { | ||
|
||
new File("target/generated-sources/basic/zero").mkdirs(); | ||
|
||
final String[] arguments = new String[] { | ||
"-xmlschema", | ||
getClass().getResource("/basic/zero/schema.xsd") | ||
.toExternalForm(), "-d", | ||
"target/generated-sources/basic/zero", "-extension", "-Xjsonix" | ||
|
||
}; | ||
|
||
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); | ||
} | ||
|
||
} |
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,235 @@ | ||
<?xml version="1.0"?> | ||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" | ||
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" | ||
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" | ||
jaxb:extensionBindingPrefixes="xjc" | ||
jaxb:version="2.0"> | ||
|
||
<xs:annotation> | ||
<xs:appinfo> | ||
<jaxb:globalBindings typesafeEnumBase="xs:token"/> | ||
<jaxb:schemaBindings> | ||
<jaxb:package name="org.hisrc.jsonix.tests.zero"/> | ||
</jaxb:schemaBindings> | ||
</xs:appinfo> | ||
</xs:annotation> | ||
|
||
<xs:element name="simpleTypes" type="simpleTypesType"/> | ||
<xs:complexType name="simpleTypesType"> | ||
<xs:sequence> | ||
<xs:element name="base64Binary" type="xs:base64Binary" minOccurs="0"/> | ||
<xs:element name="hexBinary" type="xs:hexBinary" minOccurs="0"/> | ||
<xs:element name="duration" type="xs:duration" minOccurs="0"/> | ||
<xs:element name="dateTime" type="xs:dateTime" minOccurs="0"/> | ||
<xs:element name="date" type="xs:date" minOccurs="0"/> | ||
<xs:element name="time" type="xs:time" minOccurs="0"/> | ||
<xs:element name="gYearMonth" type="xs:gYearMonth" minOccurs="0"/> | ||
<xs:element name="gYear" type="xs:gYear" minOccurs="0"/> | ||
<xs:element name="gMonthDay" type="xs:gMonthDay" minOccurs="0"/> | ||
<xs:element name="gDay" type="xs:gDay" minOccurs="0"/> | ||
<xs:element name="gMonth" type="xs:gMonth" minOccurs="0"/> | ||
<xs:element name="float" type="xs:float" minOccurs="0"/> | ||
<xs:element name="double" type="xs:double" minOccurs="0"/> | ||
<xs:element name="decimal" type="xs:decimal" minOccurs="0"/> | ||
<xs:element name="integer" type="xs:integer" minOccurs="0"/> | ||
<xs:element name="long" type="xs:long" minOccurs="0"/> | ||
<xs:element name="int" type="xs:int" minOccurs="0"/> | ||
<xs:element name="short" type="xs:short" minOccurs="0"/> | ||
<xs:element name="byte" type="xs:byte" minOccurs="0"/> | ||
<xs:element name="unsignedLong" type="xs:unsignedLong" minOccurs="0"/> | ||
<xs:element name="unsignedInt" type="xs:unsignedInt" minOccurs="0"/> | ||
<xs:element name="unsignedShort" type="xs:unsignedShort" minOccurs="0"/> | ||
<xs:element name="unsignedByte" type="xs:unsignedByte" minOccurs="0"/> | ||
<xs:element name="nonNegativeInteger" type="xs:nonNegativeInteger" minOccurs="0"/> | ||
<xs:element name="nonPositiveInteger" type="xs:nonPositiveInteger" minOccurs="0"/> | ||
<xs:element name="positiveInteger" type="xs:positiveInteger" | ||
minOccurs="0"/> | ||
<xs:element name="negativeInteger" type="xs:negativeInteger" | ||
minOccurs="0"/> | ||
<xs:element name="boolean" type="xs:boolean" minOccurs="0"/> | ||
<xs:element name="anyURI" type="xs:anyURI" minOccurs="0"/> | ||
<xs:element name="QName" type="xs:QName" minOccurs="0"/> | ||
<!-- | ||
<xs:element name="NOTATION" type="xs:NOTATION" minOccurs="0"/> | ||
--> | ||
|
||
<xs:element name="string" type="xs:string" minOccurs="0"/> | ||
<xs:element name="normalizedString" type="xs:normalizedString" | ||
minOccurs="0"/> | ||
<xs:element name="token" type="xs:token" minOccurs="0"/> | ||
<xs:element name="language" type="xs:language" minOccurs="0"/> | ||
<xs:element name="Name" type="xs:Name" minOccurs="0"/> | ||
<xs:element name="NCName" type="xs:NCName" minOccurs="0"/> | ||
<xs:element name="ID" type="xs:ID" minOccurs="0"/> | ||
<xs:element name="IDREF" type="xs:IDREF" minOccurs="0"/> | ||
<xs:element name="IDREFS" type="xs:IDREFS"/> | ||
<xs:element name="ENTITY" type="xs:ENTITY" minOccurs="0"/> | ||
<xs:element name="ENTITIES" type="xs:ENTITIES" minOccurs="0"/> | ||
<xs:element name="NMTOKEN" type="xs:NMTOKEN" minOccurs="0"/> | ||
<xs:element name="NMTOKENS" type="xs:NMTOKENS" minOccurs="0"/> | ||
</xs:sequence> | ||
</xs:complexType> | ||
|
||
<!-- Element with a simple type --> | ||
<xs:element name="string" type="xs:string"/> | ||
|
||
<!-- Complex type with simple content --> | ||
<xs:element name="value" type="valueType"/> | ||
<xs:complexType name="valueType"> | ||
<xs:simpleContent> | ||
<xs:extension base="xs:string"> | ||
<xs:attribute name="attribute" type="xs:string" use="optional"/> | ||
</xs:extension> | ||
</xs:simpleContent> | ||
</xs:complexType> | ||
|
||
<!-- Any attribute --> | ||
<xs:element name="anyAttribute" type="anyAttributeType"/> | ||
<xs:complexType name="anyAttributeType"> | ||
<xs:simpleContent> | ||
<xs:extension base="xs:string"> | ||
<xs:anyAttribute/> | ||
</xs:extension> | ||
</xs:simpleContent> | ||
</xs:complexType> | ||
|
||
<!-- attribute --> | ||
<xs:element name="attribute" type="attributeType"/> | ||
<xs:complexType name="attributeType"> | ||
<xs:simpleContent> | ||
<xs:extension base="xs:string"> | ||
<xs:attribute name="string" type="xs:string" use="optional"/> | ||
<xs:attribute name="integers" use="optional"> | ||
<xs:simpleType> | ||
<xs:list itemType="xs:integer"/> | ||
</xs:simpleType> | ||
</xs:attribute> | ||
</xs:extension> | ||
</xs:simpleContent> | ||
</xs:complexType> | ||
|
||
<!-- anyElement --> | ||
<xs:element name="anyElementLax" type="anyElementLaxType"/> | ||
<xs:complexType name="anyElementLaxType"> | ||
<xs:sequence> | ||
<xs:any processContents="lax"/> | ||
</xs:sequence> | ||
</xs:complexType> | ||
<xs:element name="anyElementStrict" type="anyElementStrictType"/> | ||
<xs:complexType name="anyElementStrictType"> | ||
<xs:sequence> | ||
<xs:any processContents="strict"/> | ||
</xs:sequence> | ||
</xs:complexType> | ||
<xs:element name="anyElementSkip" type="anyElementSkipType"/> | ||
<xs:complexType name="anyElementSkipType"> | ||
<xs:sequence> | ||
<xs:any processContents="skip"/> | ||
</xs:sequence> | ||
</xs:complexType> | ||
|
||
<xs:simpleType name="strings"> | ||
<xs:list itemType="xs:string"/> | ||
</xs:simpleType> | ||
|
||
<!-- element --> | ||
<xs:element name="element" type="elementType"/> | ||
<xs:complexType name="elementType"> | ||
<xs:sequence> | ||
<xs:element name="element" type="xs:string" minOccurs="0"/> | ||
<xs:element name="elements" type="xs:string" minOccurs="0" maxOccurs="unbounded"/> | ||
<xs:element name="item" type="strings" minOccurs="0"/> | ||
<xs:element name="items" type="strings" minOccurs="0" maxOccurs="unbounded"/> | ||
</xs:sequence> | ||
</xs:complexType> | ||
|
||
<!-- elements --> | ||
<xs:element name="elements" type="elementsType"/> | ||
<xs:complexType name="elementsType"> | ||
<xs:sequence> | ||
<xs:choice maxOccurs="unbounded"> | ||
<xs:element name="string" type="xs:string"/> | ||
<xs:element name="integer" type="xs:integer"/> | ||
</xs:choice> | ||
</xs:sequence> | ||
</xs:complexType> | ||
|
||
<!-- Element reference --> | ||
<xs:element name="elementRef" type="elementRefType"/> | ||
<xs:complexType name="elementRefType"> | ||
<xs:sequence> | ||
<xs:element ref="base" maxOccurs="unbounded"/> | ||
</xs:sequence> | ||
</xs:complexType> | ||
|
||
<!-- element refs --> | ||
<xs:element name="elementRefs" type="elementRefsType"/> | ||
<xs:complexType name="elementRefsType"> | ||
<xs:sequence> | ||
<xs:choice maxOccurs="unbounded"> | ||
<xs:element name="alpha" type="valueType"/> | ||
<xs:element name="beta" type="valueType"/> | ||
</xs:choice> | ||
</xs:sequence> | ||
</xs:complexType> | ||
|
||
<!-- Mixed --> | ||
<xs:element name="elementRefMixed" type="elementRefMixedType"/> | ||
<xs:complexType name="elementRefMixedType" mixed="true"> | ||
<xs:sequence> | ||
<xs:element name="value" type="xs:string" minOccurs="0" maxOccurs="unbounded"/> | ||
</xs:sequence> | ||
</xs:complexType> | ||
|
||
<!-- Derivation by extension --> | ||
<xs:element name="base" type="baseType"/> | ||
<xs:complexType name="baseType"> | ||
<xs:sequence> | ||
<xs:element name="alpha" type="xs:string" minOccurs="0"/> | ||
<xs:element name="beta" type="xs:integer" minOccurs="0" maxOccurs="unbounded"/> | ||
</xs:sequence> | ||
</xs:complexType> | ||
|
||
<xs:element name="extended" type="extendedType" substitutionGroup="base"/> | ||
<xs:complexType name="extendedType"> | ||
<xs:complexContent> | ||
<xs:extension base="baseType"> | ||
<xs:sequence> | ||
<xs:element name="gamma" type="xs:anyURI" minOccurs="0"/> | ||
<xs:element name="delta" type="xs:dateTime" minOccurs="0" maxOccurs="unbounded"/> | ||
</xs:sequence> | ||
</xs:extension> | ||
</xs:complexContent> | ||
</xs:complexType> | ||
|
||
<xs:element name="extendedExtended" type="extendedExtendedType" substitutionGroup="base"/> | ||
<xs:complexType name="extendedExtendedType"> | ||
<xs:complexContent> | ||
<xs:extension base="extendedType"> | ||
<xs:sequence> | ||
<xs:element name="epsilon" type="xs:double" minOccurs="0"/> | ||
<xs:element name="zeta" type="xs:decimal" minOccurs="0" maxOccurs="unbounded"/> | ||
</xs:sequence> | ||
</xs:extension> | ||
</xs:complexContent> | ||
</xs:complexType> | ||
|
||
<xs:element name="enum" type="enumType"/> | ||
<xs:simpleType name="enumType"> | ||
<xs:restriction base="xs:token"> | ||
<xs:enumeration value="Male"/> | ||
<xs:enumeration value="Female"/> | ||
</xs:restriction> | ||
</xs:simpleType> | ||
|
||
<xs:complexType name="abstractBaseType" abstract="true"/> | ||
|
||
<xs:complexType name="extendedMixedType"> | ||
<xs:complexContent mixed="true"> | ||
<xs:extension base="abstractBaseType"/> | ||
</xs:complexContent> | ||
</xs:complexType> | ||
|
||
<xs:element name="abstractElement" abstract="true"/> | ||
|
||
</xs:schema> |