From c66218c2912a5dfa05a3441ad923ce00099a4f3a Mon Sep 17 00:00:00 2001 From: highsource Date: Sun, 28 Jun 2015 13:39:24 +0200 Subject: [PATCH] Issue #43, #44. --- .../CreateTypeInfoDeclarationVisitor.java | 1 - .../xjc/plugin/tests/JsonixPluginTest.java | 6 +- .../tests/basic/JsonixPluginZeroTest.java | 76 ++++++ .../src/test/resources/basic/zero/schema.xsd | 235 ++++++++++++++++++ 4 files changed, 313 insertions(+), 5 deletions(-) create mode 100644 compiler/src/test/java/org/hisrc/jsonix/xjc/plugin/tests/basic/JsonixPluginZeroTest.java create mode 100644 compiler/src/test/resources/basic/zero/schema.xsd diff --git a/compiler/src/main/java/org/hisrc/jsonix/compilation/mapping/CreateTypeInfoDeclarationVisitor.java b/compiler/src/main/java/org/hisrc/jsonix/compilation/mapping/CreateTypeInfoDeclarationVisitor.java index 1ca668b..9f35776 100644 --- a/compiler/src/main/java/org/hisrc/jsonix/compilation/mapping/CreateTypeInfoDeclarationVisitor.java +++ b/compiler/src/main/java/org/hisrc/jsonix/compilation/mapping/CreateTypeInfoDeclarationVisitor.java @@ -113,7 +113,6 @@ final class CreateTypeInfoDeclarationVisitor implements XSD_TYPE_MAPPING.put(XmlSchemaConstants.QNAME, "QName"); // XSD_TYPE_MAPPING.put(XmlSchemaConstants.NOTATION, "Notation"); XSD_TYPE_MAPPING.put(XmlSchemaConstants.DURATION, "Duration"); - XSD_TYPE_MAPPING.put(XmlSchemaConstants.DURATION, "String"); XSD_TYPE_MAPPING.put(XmlSchemaConstants.DATETIME, "DateTime"); XSD_TYPE_MAPPING.put(XmlSchemaConstants.TIME, "Time"); XSD_TYPE_MAPPING.put(XmlSchemaConstants.DATE, "Date"); diff --git a/compiler/src/test/java/org/hisrc/jsonix/xjc/plugin/tests/JsonixPluginTest.java b/compiler/src/test/java/org/hisrc/jsonix/xjc/plugin/tests/JsonixPluginTest.java index 7d8e1fe..a1c5160 100644 --- a/compiler/src/test/java/org/hisrc/jsonix/xjc/plugin/tests/JsonixPluginTest.java +++ b/compiler/src/test/java/org/hisrc/jsonix/xjc/plugin/tests/JsonixPluginTest.java @@ -74,7 +74,7 @@ public void compilesOWS_V_1_1_0() throws Exception { com.sun.codemodel.CodeWriter cw = options.createCodeWriter(); model.codeModel.build(cw); } - + @Test public void compilesWFS_V_2_0() throws Exception { @@ -84,8 +84,7 @@ public void compilesWFS_V_2_0() throws Exception { URL binding = getClass().getResource("/ogc/wfs-v_2_0.xjb"); final String[] arguments = new String[] { "-xmlschema", schema.toExternalForm(), "-b", binding.toExternalForm(), "-d", - "target/generated-sources/wfs-v_2_0", "-extension", - "-Xjsonix" + "target/generated-sources/wfs-v_2_0", "-extension", "-Xjsonix" }; @@ -98,7 +97,6 @@ public void compilesWFS_V_2_0() throws Exception { model.codeModel.build(cw); } - @Test public void compilesContext_V_1_1_0() throws Exception { diff --git a/compiler/src/test/java/org/hisrc/jsonix/xjc/plugin/tests/basic/JsonixPluginZeroTest.java b/compiler/src/test/java/org/hisrc/jsonix/xjc/plugin/tests/basic/JsonixPluginZeroTest.java new file mode 100644 index 0000000..b2ae899 --- /dev/null +++ b/compiler/src/test/java/org/hisrc/jsonix/xjc/plugin/tests/basic/JsonixPluginZeroTest.java @@ -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); + } + +} diff --git a/compiler/src/test/resources/basic/zero/schema.xsd b/compiler/src/test/resources/basic/zero/schema.xsd new file mode 100644 index 0000000..ceb6882 --- /dev/null +++ b/compiler/src/test/resources/basic/zero/schema.xsd @@ -0,0 +1,235 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file