Author: sagara Date: Mon Jul 9 06:31:20 2012 New Revision: 1358931 URL: http://svn.apache.org/viewvc?rev=1358931&view=rev Log: Fix AXIS2-5363.
Added: axis/axis2/java/core/trunk/modules/adb-codegen/test-resources/schemas/custom_schemas/sampleSchema7.xsd (with props) Modified: axis/axis2/java/core/trunk/modules/adb-codegen/test/org/apache/axis2/schema/SchemaCompilerTest.java axis/axis2/java/core/trunk/modules/adb-codegen/test/org/apache/axis2/schema/XMLSchemaTest.java Added: axis/axis2/java/core/trunk/modules/adb-codegen/test-resources/schemas/custom_schemas/sampleSchema7.xsd URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/adb-codegen/test-resources/schemas/custom_schemas/sampleSchema7.xsd?rev=1358931&view=auto ============================================================================== --- axis/axis2/java/core/trunk/modules/adb-codegen/test-resources/schemas/custom_schemas/sampleSchema7.xsd (added) +++ axis/axis2/java/core/trunk/modules/adb-codegen/test-resources/schemas/custom_schemas/sampleSchema7.xsd Mon Jul 9 06:31:20 2012 @@ -0,0 +1,57 @@ +<!-- + ~ Licensed to the Apache Software Foundation (ASF) under one + ~ or more contributor license agreements. See the NOTICE file + ~ distributed with this work for additional information + ~ regarding copyright ownership. The ASF licenses this file + ~ to you under the Apache License, Version 2.0 (the + ~ "License"); you may not use this file except in compliance + ~ with the License. You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, + ~ software distributed under the License is distributed on an + ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + ~ KIND, either express or implied. See the License for the + ~ specific language governing permissions and limitations + ~ under the License. + --> + + +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> + <xs:element name="items" type="ItemsType"/> + <xs:complexType name="ItemsType"> + <xs:choice minOccurs="0" maxOccurs="unbounded"> + <xs:element name="shirt" type="ProductType"/> + <xs:element name="hat" type="ProductType"/> + <xs:element name="umbrella" type="ProductType"/> + </xs:choice> + </xs:complexType> + <!-- Element only content --> + <xs:complexType name="ProductType"> + <xs:sequence> + <xs:element name="number" type="xs:integer"/> + <xs:element name="name" type="xs:string"/> + <xs:choice minOccurs="0" maxOccurs="unbounded"> + <xs:element name="size" type="SizeType"/> + <xs:element name="color" type="ColorType"/> + <xs:element name="description" type="DescriptionType"/> + </xs:choice> + </xs:sequence> + <xs:attribute name="effDate" type="xs:date" + default="1900-01-01"/> + <xs:anyAttribute namespace="##other" processContents="lax"/> + </xs:complexType> + <!-- Simple content --> + <xs:complexType name="SizeType"> + <xs:simpleContent> + <xs:extension base="xs:integer"> + <xs:attribute name="system" type="xs:token"/> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + <!-- Empty content --> + <xs:complexType name="ColorType"> + <xs:attribute name="value" type="xs:string"/> + </xs:complexType> +</xs:schema> Propchange: axis/axis2/java/core/trunk/modules/adb-codegen/test-resources/schemas/custom_schemas/sampleSchema7.xsd ------------------------------------------------------------------------------ svn:eol-style = native Modified: axis/axis2/java/core/trunk/modules/adb-codegen/test/org/apache/axis2/schema/SchemaCompilerTest.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/adb-codegen/test/org/apache/axis2/schema/SchemaCompilerTest.java?rev=1358931&r1=1358930&r2=1358931&view=diff ============================================================================== --- axis/axis2/java/core/trunk/modules/adb-codegen/test/org/apache/axis2/schema/SchemaCompilerTest.java (original) +++ axis/axis2/java/core/trunk/modules/adb-codegen/test/org/apache/axis2/schema/SchemaCompilerTest.java Mon Jul 9 06:31:20 2012 @@ -23,13 +23,13 @@ import java.io.ByteArrayOutputStream; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; +import java.util.List; import java.util.Map; import javax.xml.namespace.QName; import org.apache.ws.commons.schema.XmlSchema; import org.apache.ws.commons.schema.XmlSchemaCollection; -import org.junit.Test; import org.w3c.dom.Document; public class SchemaCompilerTest extends XMLSchemaTest{ @@ -41,8 +41,7 @@ public class SchemaCompilerTest extends @Override protected void setUp() throws Exception { - schemas=new ArrayList<XmlSchema>(); - loadSampleSchemaFile(schemas); + schemas=new ArrayList<XmlSchema>(); schemaCompiler=new SchemaCompiler(null); } @@ -52,8 +51,11 @@ public class SchemaCompilerTest extends super.tearDown(); } - @Test + public void testCompileSchema() throws Exception{ + List<Integer> excludes = new ArrayList<Integer>(); + excludes.add(6); + loadSampleSchemaFile(schemas, excludes); Map map=schemaCompiler.getProcessedModelMap(); schemaCompiler.compile(schemas); processedElementMap=schemaCompiler.getProcessedElementMap(); @@ -73,9 +75,17 @@ public class SchemaCompilerTest extends } - - - - + public void testCompileSchemaForMixContent() throws Exception { + schemas.add(loadSampleSchemaFile(String.valueOf(6))); + Map map = schemaCompiler.getProcessedModelMap(); + try { + schemaCompiler.compile(schemas); + fail("Compiling sampleSchema6.xsd should throw SchemaCompilationException"); + } catch (SchemaCompilationException e) { + assertTrue(e.getMessage().contains( + "SD complexType with mix content not supported in ADB")); + } + + } } Modified: axis/axis2/java/core/trunk/modules/adb-codegen/test/org/apache/axis2/schema/XMLSchemaTest.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/adb-codegen/test/org/apache/axis2/schema/XMLSchemaTest.java?rev=1358931&r1=1358930&r2=1358931&view=diff ============================================================================== --- axis/axis2/java/core/trunk/modules/adb-codegen/test/org/apache/axis2/schema/XMLSchemaTest.java (original) +++ axis/axis2/java/core/trunk/modules/adb-codegen/test/org/apache/axis2/schema/XMLSchemaTest.java Mon Jul 9 06:31:20 2012 @@ -27,6 +27,7 @@ import java.io.FileReader; import java.io.FileWriter; import java.io.InputStream; import java.util.ArrayList; +import java.util.List; import javax.xml.transform.stream.StreamSource; @@ -70,22 +71,35 @@ public abstract class XMLSchemaTest exte } public void loadSampleSchemaFile(ArrayList<XmlSchema> schemas) throws Exception{ - XmlSchemaCollection xmlSchemaCollection = new XmlSchemaCollection(); + loadSampleSchemaFile(schemas, null); + } + + public void loadSampleSchemaFile(ArrayList<XmlSchema> schemas, List<Integer> excludeList) + throws Exception { File file = null; - int i = 1; - - file = new File(SampleSchemasDirectory + "sampleSchema" + i - + ".xsd"); - while (file.exists()) { - InputStream is = new FileInputStream(file); - XmlSchemaCollection schemaCol = new XmlSchemaCollection(); - XmlSchema schema = schemaCol.read(new StreamSource(is), null); - schemas.add(schema); - i++; - file = new File(SampleSchemasDirectory + "sampleSchema" + i - + ".xsd"); + int i = 0; + while (true) { + i++; + file = new File(SampleSchemasDirectory + "sampleSchema" + i + ".xsd"); + if (file.exists()) { + if (excludeList == null || !excludeList.contains(i)) { + InputStream is = new FileInputStream(file); + XmlSchemaCollection schemaCol = new XmlSchemaCollection(); + XmlSchema schema = schemaCol.read(new StreamSource(is), null); + schemas.add(schema); + } + } else { + break; } - + } + } + + public XmlSchema loadSampleSchemaFile(String id) throws Exception { + File file = new File(SampleSchemasDirectory + "sampleSchema" + id + ".xsd"); + InputStream is = new FileInputStream(file); + XmlSchemaCollection schemaCol = new XmlSchemaCollection(); + XmlSchema schema = schemaCol.read(new StreamSource(is), null); + return schema; } public XmlSchema loadSingleSchemaFile(int i) throws Exception{