You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commons-dev@ws.apache.org by di...@apache.org on 2006/06/24 04:54:06 UTC
svn commit: r416855 - in /webservices/commons/trunk/modules/XmlSchema:
test-resources/ test/tests/
Author: dims
Date: Fri Jun 23 19:54:05 2006
New Revision: 416855
URL: http://svn.apache.org/viewvc?rev=416855&view=rev
Log:
Fix for WSCOMMONS-47 - additional schema tests
Added:
webservices/commons/trunk/modules/XmlSchema/test-resources/any.xsd
webservices/commons/trunk/modules/XmlSchema/test-resources/attributegroup.xsd
webservices/commons/trunk/modules/XmlSchema/test-resources/choice.xsd
webservices/commons/trunk/modules/XmlSchema/test-resources/deriverestriction.xsd
webservices/commons/trunk/modules/XmlSchema/test-resources/group.xsd
webservices/commons/trunk/modules/XmlSchema/test-resources/include.xsd
webservices/commons/trunk/modules/XmlSchema/test-resources/include2.xsd
webservices/commons/trunk/modules/XmlSchema/test-resources/include3.xsd
webservices/commons/trunk/modules/XmlSchema/test-resources/list.xsd
webservices/commons/trunk/modules/XmlSchema/test-resources/screstriction.xsd
webservices/commons/trunk/modules/XmlSchema/test-resources/simplecontentextension.xsd
webservices/commons/trunk/modules/XmlSchema/test-resources/union.xsd
webservices/commons/trunk/modules/XmlSchema/test/tests/AnyTest.java
webservices/commons/trunk/modules/XmlSchema/test/tests/AttributeGroupTest.java
webservices/commons/trunk/modules/XmlSchema/test/tests/ChoiceTest.java
webservices/commons/trunk/modules/XmlSchema/test/tests/ComplexContentRestrictionTest.java
webservices/commons/trunk/modules/XmlSchema/test/tests/GroupTest.java
webservices/commons/trunk/modules/XmlSchema/test/tests/IncludeTest.java
webservices/commons/trunk/modules/XmlSchema/test/tests/ListTest.java
webservices/commons/trunk/modules/XmlSchema/test/tests/SimpleContentExtensionTest.java
webservices/commons/trunk/modules/XmlSchema/test/tests/SimpleContentRestrictionTest.java
webservices/commons/trunk/modules/XmlSchema/test/tests/UnionTest.java
Added: webservices/commons/trunk/modules/XmlSchema/test-resources/any.xsd
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/test-resources/any.xsd?rev=416855&view=auto
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/test-resources/any.xsd (added)
+++ webservices/commons/trunk/modules/XmlSchema/test-resources/any.xsd Fri Jun 23 19:54:05 2006
@@ -0,0 +1,33 @@
+<!--
+ * Copyright 2004,2005 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * Licensed 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.
+-->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:tns="http://soapinterop.org/types"
+ targetNamespace="http://soapinterop.org/types"
+ elementFormDefault="qualified">
+
+ <element name="department">
+ <complexType>
+ <sequence>
+ <element name="id" type="xsd:integer"/>
+ <element name="name" type="xsd:string"/>
+ <any minOccurs="5" maxOccurs="10"/>
+ </sequence>
+ </complexType>
+ </element>
+
+</schema>
\ No newline at end of file
Added: webservices/commons/trunk/modules/XmlSchema/test-resources/attributegroup.xsd
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/test-resources/attributegroup.xsd?rev=416855&view=auto
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/test-resources/attributegroup.xsd (added)
+++ webservices/commons/trunk/modules/XmlSchema/test-resources/attributegroup.xsd Fri Jun 23 19:54:05 2006
@@ -0,0 +1,34 @@
+<!--
+ * Copyright 2004,2005 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * Licensed 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.
+ *
+-->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:tns="http://soapinterop.org/types"
+ targetNamespace="http://soapinterop.org/types">
+
+ <attributeGroup name="department">
+ <attribute name="name" type="string"/>
+ <attribute name="id" type="integer"/>
+ </attributeGroup>
+
+ <element name="member">
+ <complexType>
+ <attributeGroup ref="tns:department"/>
+ </complexType>
+ </element>
+
+</schema>
\ No newline at end of file
Added: webservices/commons/trunk/modules/XmlSchema/test-resources/choice.xsd
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/test-resources/choice.xsd?rev=416855&view=auto
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/test-resources/choice.xsd (added)
+++ webservices/commons/trunk/modules/XmlSchema/test-resources/choice.xsd Fri Jun 23 19:54:05 2006
@@ -0,0 +1,32 @@
+<!--
+ * Copyright 2004,2005 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * Licensed 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.
+ *
+-->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:tns="http://soapinterop.org/types"
+ targetNamespace="http://soapinterop.org/types">
+
+ <element name="computer">
+ <complexType>
+ <choice>
+ <element name="desktop" type="string"/>
+ <element name="laptop" type="string"/>
+ </choice>
+ </complexType>
+ </element>
+
+</schema>
\ No newline at end of file
Added: webservices/commons/trunk/modules/XmlSchema/test-resources/deriverestriction.xsd
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/test-resources/deriverestriction.xsd?rev=416855&view=auto
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/test-resources/deriverestriction.xsd (added)
+++ webservices/commons/trunk/modules/XmlSchema/test-resources/deriverestriction.xsd Fri Jun 23 19:54:05 2006
@@ -0,0 +1,44 @@
+<!--
+ * Copyright 2004,2005 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * Licensed 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.
+ *
+-->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:tns="http://soapinterop.org/types"
+ targetNamespace="http://soapinterop.org/types">
+
+
+ <complexType name="AssemblyRequiredProduct">
+ <sequence>
+ <element name="Name" type="string"/>
+ <element name="Description" type="string" nillable="true"/>
+ <element name="Parts" type="string" maxOccurs="unbounded"/>
+ </sequence>
+ </complexType>
+
+ <complexType name="NoAssemblyRequiredProduct">
+ <complexContent>
+ <restriction base="tns:AssemblyRequiredProduct">
+ <sequence>
+ <element name="Name" type="string"/>
+ <element name="Description" type="string" nillable="true"/>
+ <element name="Parts" type="string"/>
+ </sequence>
+ </restriction>
+ </complexContent>
+ </complexType>
+
+</schema>
\ No newline at end of file
Added: webservices/commons/trunk/modules/XmlSchema/test-resources/group.xsd
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/test-resources/group.xsd?rev=416855&view=auto
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/test-resources/group.xsd (added)
+++ webservices/commons/trunk/modules/XmlSchema/test-resources/group.xsd Fri Jun 23 19:54:05 2006
@@ -0,0 +1,47 @@
+<!--
+ * Copyright 2004,2005 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * Licensed 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.
+ *
+-->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:tns="http://soapinterop.org/types"
+ targetNamespace="http://soapinterop.org/types">
+
+ <group name="priceGroup">
+ <annotation>
+ <documentation xml:lang="en">
+ A price is any one of the following:
+ * Full Price (with amount)
+ * Sale Price (with amount and authorization)
+ * Clearance Price (with amount and authorization)
+ * Free (with authorization)
+ </documentation>
+ </annotation>
+ <choice id="pg.choice">
+ <element name="fullPrice" type="decimal"/>
+ <element name="salePrice" type="decimal"/>
+ <element name="clearancePrice" type="decimal"/>
+ <element name="freePrice" type="decimal"/>
+ </choice>
+ </group>
+
+ <element name="price">
+ <complexType>
+ <group ref="tns:priceGroup" />
+ </complexType>
+ </element>
+
+</schema>
\ No newline at end of file
Added: webservices/commons/trunk/modules/XmlSchema/test-resources/include.xsd
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/test-resources/include.xsd?rev=416855&view=auto
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/test-resources/include.xsd (added)
+++ webservices/commons/trunk/modules/XmlSchema/test-resources/include.xsd Fri Jun 23 19:54:05 2006
@@ -0,0 +1,26 @@
+<!--
+ * Copyright 2004,2005 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * Licensed 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.
+ *
+-->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:tns="http://soapinterop.org/types"
+ targetNamespace="http://soapinterop.org/types">
+
+ <include schemaLocation="test-resources/include2.xsd"/>
+ <include schemaLocation="test-resources/include3.xsd"/>
+
+</schema>
\ No newline at end of file
Added: webservices/commons/trunk/modules/XmlSchema/test-resources/include2.xsd
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/test-resources/include2.xsd?rev=416855&view=auto
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/test-resources/include2.xsd (added)
+++ webservices/commons/trunk/modules/XmlSchema/test-resources/include2.xsd Fri Jun 23 19:54:05 2006
@@ -0,0 +1,25 @@
+<!--
+ * Copyright 2004,2005 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * Licensed 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.
+ *
+-->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:tns="http://soapinterop.org/types"
+ targetNamespace="http://soapinterop.org/types">
+
+ <element name="test1include" type="string"/>
+
+</schema>
\ No newline at end of file
Added: webservices/commons/trunk/modules/XmlSchema/test-resources/include3.xsd
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/test-resources/include3.xsd?rev=416855&view=auto
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/test-resources/include3.xsd (added)
+++ webservices/commons/trunk/modules/XmlSchema/test-resources/include3.xsd Fri Jun 23 19:54:05 2006
@@ -0,0 +1,25 @@
+<!--
+ * Copyright 2004,2005 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * Licensed 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.
+ *
+-->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:tns="http://soapinterop.org/types"
+ targetNamespace="http://soapinterop.org/types">
+
+ <element name="test2include" type="integer"/>
+
+</schema>
\ No newline at end of file
Added: webservices/commons/trunk/modules/XmlSchema/test-resources/list.xsd
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/test-resources/list.xsd?rev=416855&view=auto
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/test-resources/list.xsd (added)
+++ webservices/commons/trunk/modules/XmlSchema/test-resources/list.xsd Fri Jun 23 19:54:05 2006
@@ -0,0 +1,36 @@
+<!--
+ *
+ * Copyright 2004,2005 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * Licensed 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.
+ *
+-->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:tns="http://soapinterop.org/types"
+ targetNamespace="http://soapinterop.org/types">
+
+ <element name="workDays">
+ <simpleType>
+ <restriction base="tns:daysInWeek">
+ <length value="5"/>
+ </restriction>
+ </simpleType>
+ </element>
+
+ <simpleType name="daysInWeek">
+ <list itemType="xsd:integer"/>
+ </simpleType>
+
+</schema>
\ No newline at end of file
Added: webservices/commons/trunk/modules/XmlSchema/test-resources/screstriction.xsd
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/test-resources/screstriction.xsd?rev=416855&view=auto
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/test-resources/screstriction.xsd (added)
+++ webservices/commons/trunk/modules/XmlSchema/test-resources/screstriction.xsd Fri Jun 23 19:54:05 2006
@@ -0,0 +1,42 @@
+<!--
+ * Copyright 2004,2005 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * Licensed 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.
+ *
+-->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:tns="http://soapinterop.org/types"
+ targetNamespace="http://soapinterop.org/types">
+
+ <simpleType name="drinksize">
+ <restriction base="string">
+ <enumeration value="small"/>
+ <enumeration value="medium"/>
+ <enumeration value="large"/>
+ </restriction>
+ </simpleType>
+
+ <complexType name="dietdrinksize">
+ <simpleContent>
+ <restriction base="tns:drinksize">
+ <enumeration value="small"/>
+ <enumeration value="medium"/>
+ <attribute name="units" type="string" use="required"/>
+ <attribute name="id" type="integer" use="required" default="001"/>
+ </restriction>
+ </simpleContent>
+ </complexType>
+
+</schema>
\ No newline at end of file
Added: webservices/commons/trunk/modules/XmlSchema/test-resources/simplecontentextension.xsd
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/test-resources/simplecontentextension.xsd?rev=416855&view=auto
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/test-resources/simplecontentextension.xsd (added)
+++ webservices/commons/trunk/modules/XmlSchema/test-resources/simplecontentextension.xsd Fri Jun 23 19:54:05 2006
@@ -0,0 +1,35 @@
+<!--
+ * Copyright 2004,2005 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * Licensed 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.
+ *
+-->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:tns="http://soapinterop.org/types"
+ targetNamespace="http://soapinterop.org/types">
+
+ <element name="height">
+ <complexType>
+ <simpleContent>
+ <extension base="integer">
+ <attribute name="units" type="string" use="required"/>
+ <attribute name="id" type="integer" use="required" default="001"/>
+ <attribute name="desc" type="decimal" fixed="1.1"/>
+ </extension>
+ </simpleContent>
+ </complexType>
+ </element>
+
+</schema>
\ No newline at end of file
Added: webservices/commons/trunk/modules/XmlSchema/test-resources/union.xsd
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/test-resources/union.xsd?rev=416855&view=auto
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/test-resources/union.xsd (added)
+++ webservices/commons/trunk/modules/XmlSchema/test-resources/union.xsd Fri Jun 23 19:54:05 2006
@@ -0,0 +1,29 @@
+<!--
+ * Copyright 2004,2005 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * Licensed 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.
+ *
+-->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:tns="http://soapinterop.org/types"
+ targetNamespace="http://soapinterop.org/types">
+
+ <element name="unionTest">
+ <simpleType>
+ <union memberTypes="float decimal"/>
+ </simpleType>
+ </element>
+
+</schema>
\ No newline at end of file
Added: webservices/commons/trunk/modules/XmlSchema/test/tests/AnyTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/test/tests/AnyTest.java?rev=416855&view=auto
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/test/tests/AnyTest.java (added)
+++ webservices/commons/trunk/modules/XmlSchema/test/tests/AnyTest.java Fri Jun 23 19:54:05 2006
@@ -0,0 +1,133 @@
+package tests;
+
+import java.io.ByteArrayOutputStream;
+import java.io.FileInputStream;
+import java.io.InputStream;
+
+import java.util.Iterator;
+import java.util.Set;
+import java.util.HashSet;
+
+import javax.xml.namespace.QName;
+import javax.xml.transform.stream.StreamSource;
+
+import junit.framework.TestCase;
+
+import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaContentModel;
+import org.apache.ws.commons.schema.XmlSchemaComplexContent;
+import org.apache.ws.commons.schema.XmlSchemaType;
+import org.apache.ws.commons.schema.XmlSchemaElement;
+import org.apache.ws.commons.schema.XmlSchemaUnique;
+import org.apache.ws.commons.schema.XmlSchemaObjectCollection;
+import org.apache.ws.commons.schema.XmlSchemaCollection;
+import org.apache.ws.commons.schema.XmlSchemaXPath;
+import org.apache.ws.commons.schema.XmlSchemaParticle;
+import org.apache.ws.commons.schema.XmlSchemaComplexType;
+import org.apache.ws.commons.schema.XmlSchemaAll;
+import org.apache.ws.commons.schema.XmlSchemaAny;
+import org.apache.ws.commons.schema.XmlSchemaSequence;
+import org.apache.ws.commons.schema.XmlSchemaContentProcessing;
+
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * Licensed 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.
+ *
+ */
+public class AnyTest extends TestCase {
+
+ /**
+ * This method will test the any.
+ *
+ * @throws Exception Any exception encountered
+ */
+ public void testAny() throws Exception {
+
+ /*
+ <schema xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:tns="http://soapinterop.org/types"
+ targetNamespace="http://soapinterop.org/types"
+ elementFormDefault="qualified">
+
+ <element name="department">
+ <complexType>
+ <sequence>
+ <element name="id" type="xsd:integer"/>
+ <element name="name" type="xsd:string"/>
+ <any minOccurs="5" maxOccurs="10"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ </schema>
+ */
+
+ QName ELEMENT_QNAME = new QName("http://soapinterop.org/types",
+ "department");
+ InputStream is = new FileInputStream("test-resources/any.xsd");
+ XmlSchemaCollection schemaCol = new XmlSchemaCollection();
+ XmlSchema schema = schemaCol.read(new StreamSource(is), null);
+
+ XmlSchemaElement elem = schemaCol.getElementByQName(ELEMENT_QNAME);
+ assertNotNull(elem);
+ assertEquals("department", elem.getName());
+ assertEquals(new QName("http://soapinterop.org/types", "department"),
+ elem.getQName());
+
+ XmlSchemaComplexType type =
+ (XmlSchemaComplexType)elem.getSchemaType();
+ assertNotNull(type);
+
+ XmlSchemaSequence xss = (XmlSchemaSequence)type.getParticle();
+ assertNotNull(xss);
+
+ XmlSchemaObjectCollection c = xss.getItems();
+ assertEquals(3, c.getCount());
+
+ Set s = new HashSet();
+ s.add("id");
+ s.add("name");
+ Object o = null;
+ for (int i = 0; i < c.getCount(); i++) {
+ o = c.getItem(i);
+ if (o instanceof XmlSchemaElement) {
+ String name = ((XmlSchemaElement)o).getName();
+ if (name.equals("id")) {
+ assertEquals(new QName("http://www.w3.org/2001/XMLSchema",
+ "integer"),
+ ((XmlSchemaElement)o).getSchemaTypeName());
+ } else if (name.equals("name")) {
+ assertEquals(new QName("http://www.w3.org/2001/XMLSchema",
+ "string"),
+ ((XmlSchemaElement)o).getSchemaTypeName());
+ }
+ s.remove(name);
+ } else if (o instanceof XmlSchemaAny) {
+ XmlSchemaContentProcessing xscp =
+ ((XmlSchemaAny)o).getProcessContent();
+ assertEquals("none", xscp.toString());
+ assertEquals(5L, ((XmlSchemaAny)o).getMinOccurs());
+ assertEquals(10L, ((XmlSchemaAny)o).getMaxOccurs());
+ }
+ }
+
+ assertTrue("The set should have been empty, but instead contained: "
+ + s + ".",
+ s.isEmpty());
+
+ }
+
+}
\ No newline at end of file
Added: webservices/commons/trunk/modules/XmlSchema/test/tests/AttributeGroupTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/test/tests/AttributeGroupTest.java?rev=416855&view=auto
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/test/tests/AttributeGroupTest.java (added)
+++ webservices/commons/trunk/modules/XmlSchema/test/tests/AttributeGroupTest.java Fri Jun 23 19:54:05 2006
@@ -0,0 +1,139 @@
+package tests;
+
+import java.io.FileInputStream;
+import java.io.InputStream;
+
+import java.util.Iterator;
+import java.util.Set;
+import java.util.HashSet;
+
+import javax.xml.namespace.QName;
+import javax.xml.transform.stream.StreamSource;
+
+import junit.framework.TestCase;
+
+import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaType;
+import org.apache.ws.commons.schema.XmlSchemaCollection;
+import org.apache.ws.commons.schema.XmlSchemaComplexType;
+import org.apache.ws.commons.schema.XmlSchemaElement;
+import org.apache.ws.commons.schema.XmlSchemaObjectCollection;
+import org.apache.ws.commons.schema.XmlSchemaObjectTable;
+import org.apache.ws.commons.schema.XmlSchemaAttributeGroupRef;
+import org.apache.ws.commons.schema.XmlSchemaAttributeGroup;
+import org.apache.ws.commons.schema.XmlSchemaAttribute;
+
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * Licensed 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.
+ *
+ */
+public class AttributeGroupTest extends TestCase {
+
+ /**
+ * This method will test the list.
+ *
+ * @throws Exception Any exception encountered
+ */
+ public void testAttributeGroup() throws Exception {
+
+ /*
+ <schema xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:tns="http://soapinterop.org/types"
+ targetNamespace="http://soapinterop.org/types">
+
+ <attributeGroup name="department">
+ <attribute name="name" type="string"/>
+ <attribute name="id" type="integer"/>
+ </attributeGroup>
+
+ <element name="member">
+ <complexType>
+ <attributeGroup ref="tns:department"/>
+ </complexType>
+ </element>
+
+ </schema>
+ */
+
+ QName ELEMENT_QNAME = new QName("http://soapinterop.org/types",
+ "member");
+ InputStream is = new FileInputStream("test-resources/attributegroup.xsd");
+ XmlSchemaCollection schemaCol = new XmlSchemaCollection();
+ XmlSchema schema = schemaCol.read(new StreamSource(is), null);
+
+ XmlSchemaElement elem = schemaCol.getElementByQName(ELEMENT_QNAME);
+ assertNotNull(elem);
+ assertEquals("member", elem.getName());
+ assertEquals(new QName("http://soapinterop.org/types", "member"),
+ elem.getQName());
+
+ XmlSchemaComplexType t = (XmlSchemaComplexType)elem.getSchemaType();
+ assertNotNull(t);
+
+ XmlSchemaObjectCollection c = t.getAttributes();
+ for (Iterator i = c.getIterator(); i.hasNext(); ) {
+ XmlSchemaAttributeGroupRef agrn = (XmlSchemaAttributeGroupRef)i.next();
+ assertEquals(new QName("http://soapinterop.org/types",
+ "department"), agrn.getRefName());
+ }
+
+ XmlSchemaObjectTable attG = schema.getAttributeGroups();
+ assertNotNull(attG);
+ assertEquals(1, attG.getCount());
+
+ for (Iterator i = attG.getNames(); i.hasNext(); ) {
+ assertEquals("department", (String)i.next());
+ }
+
+ for (Iterator i = attG.getValues(); i.hasNext(); ) {
+ Object obj1 = i.next();
+ if (obj1 instanceof XmlSchemaAttributeGroup) {
+ assertEquals("department", ((XmlSchemaAttributeGroup)obj1).getName());
+ XmlSchemaObjectCollection attributes =
+ ((XmlSchemaAttributeGroup)obj1).getAttributes();
+ assertNotNull(attributes);
+ assertEquals(2, attributes.getCount());
+ for (Iterator j = attributes.getIterator(); j.hasNext(); ) {
+ XmlSchemaAttribute obj2 = (XmlSchemaAttribute)j.next();
+ String name = obj2.getName();
+ if (name.equals("id")) {
+ assertEquals(new QName("http://soapinterop.org/types", "id"),
+ obj2.getQName());
+ assertEquals(new QName("http://www.w3.org/2001/XMLSchema",
+ "integer"), obj2.getSchemaTypeName());
+ } else if (name.equals("name")) {
+ assertEquals(new QName("http://soapinterop.org/types", "name"),
+ obj2.getQName());
+ assertEquals(new QName("http://www.w3.org/2001/XMLSchema",
+ "string"), obj2.getSchemaTypeName());
+ } else {
+ fail("The name \"" + name + "\" should not have been found "
+ + "for an attribute.");
+
+ }
+ }
+ } else {
+ fail("There should have been one instance of the "
+ + "class " + XmlSchemaAttributeGroup.class.getName()
+ + " , but instead " + obj1.getClass().getName() + " was"
+ + " found.");
+ }
+ }
+
+ }
+
+}
\ No newline at end of file
Added: webservices/commons/trunk/modules/XmlSchema/test/tests/ChoiceTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/test/tests/ChoiceTest.java?rev=416855&view=auto
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/test/tests/ChoiceTest.java (added)
+++ webservices/commons/trunk/modules/XmlSchema/test/tests/ChoiceTest.java Fri Jun 23 19:54:05 2006
@@ -0,0 +1,115 @@
+package tests;
+
+import java.io.FileInputStream;
+import java.io.InputStream;
+
+import java.util.Iterator;
+import java.util.Set;
+import java.util.HashSet;
+
+import javax.xml.namespace.QName;
+import javax.xml.transform.stream.StreamSource;
+
+import junit.framework.TestCase;
+
+import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaType;
+import org.apache.ws.commons.schema.XmlSchemaCollection;
+import org.apache.ws.commons.schema.XmlSchemaChoice;
+import org.apache.ws.commons.schema.XmlSchemaComplexType;
+import org.apache.ws.commons.schema.XmlSchemaElement;
+import org.apache.ws.commons.schema.XmlSchemaObjectCollection;
+
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * Licensed 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.
+ *
+ */
+public class ChoiceTest extends TestCase {
+
+ /**
+ * This method will test the choice.
+ *
+ * @throws Exception Any exception encountered
+ */
+ public void testChoice() throws Exception {
+
+ /*
+ <schema xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:tns="http://soapinterop.org/types"
+ targetNamespace="http://soapinterop.org/types">
+
+ <element name="computer">
+ <complexType>
+ <choice>
+ <element name="desktop" type="string"/>
+ <element name="laptop" type="string"/>
+ </choice>
+ </complexType>
+ </element>
+
+ </schema>
+ */
+
+ QName ELEMENT_QNAME = new QName("http://soapinterop.org/types",
+ "computer");
+ InputStream is = new FileInputStream("test-resources/choice.xsd");
+ XmlSchemaCollection schemaCol = new XmlSchemaCollection();
+ XmlSchema schema = schemaCol.read(new StreamSource(is), null);
+
+ QName WRONG_QNAME = new QName("http://soapinterop.org/types",
+ "machine");
+ XmlSchemaElement elem = schemaCol.getElementByQName(WRONG_QNAME);
+ assertNull(elem);
+ elem = schemaCol.getElementByQName(ELEMENT_QNAME);
+ assertEquals("computer", elem.getName());
+ assertEquals(new QName("http://soapinterop.org/types", "computer"),
+ elem.getQName());
+
+ XmlSchemaComplexType cType = (XmlSchemaComplexType)elem.getSchemaType();
+ assertNotNull(cType);
+
+ XmlSchemaChoice choice = (XmlSchemaChoice)cType.getParticle();
+ assertNotNull(choice);
+
+ Set s = new HashSet();
+ s.add("desktop");
+ s.add("laptop");
+ XmlSchemaObjectCollection items = choice.getItems();
+ Iterator iterator = items.getIterator();
+ while (iterator.hasNext()) {
+ XmlSchemaElement e = (XmlSchemaElement)iterator.next();
+ String eName = e.getName();
+ if (eName.equals("desktop")) {
+ assertEquals(new QName("", "desktop"), e.getQName());
+ assertEquals(e.getName(), "desktop");
+ } else if (eName.equals("laptop")) {
+ assertEquals(new QName("", "laptop"), e.getQName());
+ assertEquals(e.getName(), "laptop");
+ } else {
+ fail("Should have had a name of desktop or laptop, but"
+ + " instead had " + eName);
+ }
+ assertEquals(new QName("http://www.w3.org/2001/XMLSchema",
+ "string"), e.getSchemaTypeName());
+ assertTrue(s.remove(e.getName()));
+ }
+ assertTrue("The set should have been empty, but instead contained: "
+ + s + ".",
+ s.isEmpty());
+ }
+
+}
\ No newline at end of file
Added: webservices/commons/trunk/modules/XmlSchema/test/tests/ComplexContentRestrictionTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/test/tests/ComplexContentRestrictionTest.java?rev=416855&view=auto
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/test/tests/ComplexContentRestrictionTest.java (added)
+++ webservices/commons/trunk/modules/XmlSchema/test/tests/ComplexContentRestrictionTest.java Fri Jun 23 19:54:05 2006
@@ -0,0 +1,146 @@
+package tests;
+
+import java.io.FileInputStream;
+import java.io.InputStream;
+
+import java.util.Iterator;
+import java.util.Set;
+import java.util.HashSet;
+
+import javax.xml.namespace.QName;
+import javax.xml.transform.stream.StreamSource;
+
+import junit.framework.TestCase;
+
+import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaElement;
+import org.apache.ws.commons.schema.XmlSchemaContentModel;
+import org.apache.ws.commons.schema.XmlSchemaContent;
+import org.apache.ws.commons.schema.XmlSchemaComplexContentRestriction;
+import org.apache.ws.commons.schema.XmlSchemaSequence;
+import org.apache.ws.commons.schema.XmlSchemaObjectCollection;
+import org.apache.ws.commons.schema.XmlSchemaCollection;
+import org.apache.ws.commons.schema.XmlSchemaComplexType;
+
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * Licensed 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.
+ *
+ */
+public class ComplexContentRestrictionTest extends TestCase {
+
+ /**
+ * This method will test complex content restriction.
+ *
+ * @throws Exception Any exception encountered
+ */
+ public void testComplexContentRestriction() throws Exception {
+
+ /*
+ <schema xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:tns="http://soapinterop.org/types"
+ targetNamespace="http://soapinterop.org/types">
+
+
+ <complexType name="AssemblyRequiredProduct">
+ <sequence>
+ <element name="Name" type="string"/>
+ <element name="Description" type="string" nillable="true"/>
+ <element name="Parts" type="string" maxOccurs="unbounded"/>
+ </sequence>
+ </complexType>
+
+ <complexType name="NoAssemblyRequiredProduct">
+ <complexContent>
+ <restriction base="tns:AssemblyRequiredProduct">
+ <sequence>
+ <element name="Name" type="string"/>
+ <element name="Description" type="string" nillable="true"/>
+ <element name="Parts" type="string"/>
+ </sequence>
+ </restriction>
+ </complexContent>
+ </complexType>
+
+ </schema>
+ */
+
+ QName TYPE_QNAME = new QName("http://soapinterop.org/types",
+ "NoAssemblyRequiredProduct");
+ InputStream is = new FileInputStream("test-resources/deriverestriction.xsd");
+ XmlSchemaCollection schemaCol = new XmlSchemaCollection();
+ XmlSchema schema = schemaCol.read(new StreamSource(is), null);
+
+ XmlSchemaComplexType cType =
+ (XmlSchemaComplexType)schemaCol.getTypeByQName(TYPE_QNAME);
+ assertNotNull(cType);
+
+ XmlSchemaContentModel xscm = cType.getContentModel();
+ assertNotNull(xscm);
+
+ XmlSchemaComplexContentRestriction xsccr =
+ (XmlSchemaComplexContentRestriction)xscm.getContent();
+ assertEquals(new QName("http://soapinterop.org/types",
+ "AssemblyRequiredProduct"),
+ xsccr.getBaseTypeName());
+
+ XmlSchemaSequence xsp = (XmlSchemaSequence)xsccr.getParticle();
+ assertNotNull(xsp);
+
+ XmlSchemaObjectCollection col = xsp.getItems();
+
+ Set s = new HashSet();
+ s.add("Name");
+ s.add("Description");
+ s.add("Parts");
+ for (int i = 0; i < col.getCount(); i++) {
+ XmlSchemaElement xse = (XmlSchemaElement)col.getItem(i);
+ String name = xse.getName();
+ if (name.equals("Name")) {
+ assertEquals(new QName("", "Name"),
+ xse.getQName());
+ assertEquals(new QName("http://www.w3.org/2001/XMLSchema",
+ "string"),
+ xse.getSchemaTypeName());
+ assertTrue(!xse.isAbstract());
+ assertTrue(!xse.isNillable());
+ } else if (name.equals("Description")) {
+ assertEquals(new QName("", "Description"),
+ xse.getQName());
+ assertEquals(new QName("http://www.w3.org/2001/XMLSchema",
+ "string"),
+ xse.getSchemaTypeName());
+ assertTrue(!xse.isAbstract());
+ assertTrue(xse.isNillable());
+ } else if (name.equals("Parts")) {
+ assertEquals(new QName("", "Parts"),
+ xse.getQName());
+ assertEquals(new QName("http://www.w3.org/2001/XMLSchema",
+ "string"),
+ xse.getSchemaTypeName());
+ } else {
+ fail("An invalid name of \"" + name + "\" was found.");
+ }
+ s.remove(name);
+ }
+
+ assertTrue("The set should have been empty, but instead contained: "
+ + s + ".",
+ s.isEmpty());
+
+ }
+
+}
\ No newline at end of file
Added: webservices/commons/trunk/modules/XmlSchema/test/tests/GroupTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/test/tests/GroupTest.java?rev=416855&view=auto
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/test/tests/GroupTest.java (added)
+++ webservices/commons/trunk/modules/XmlSchema/test/tests/GroupTest.java Fri Jun 23 19:54:05 2006
@@ -0,0 +1,170 @@
+package tests;
+
+import java.io.FileInputStream;
+import java.io.InputStream;
+
+import java.util.Iterator;
+import java.util.Set;
+import java.util.HashSet;
+
+import javax.xml.namespace.QName;
+import javax.xml.transform.stream.StreamSource;
+
+import junit.framework.TestCase;
+
+import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaCollection;
+import org.apache.ws.commons.schema.XmlSchemaComplexType;
+import org.apache.ws.commons.schema.XmlSchemaElement;
+import org.apache.ws.commons.schema.XmlSchemaObjectCollection;
+import org.apache.ws.commons.schema.XmlSchemaSequence;
+import org.apache.ws.commons.schema.XmlSchemaGroupRef;
+import org.apache.ws.commons.schema.XmlSchemaGroup;
+import org.apache.ws.commons.schema.XmlSchemaChoice;
+import org.apache.ws.commons.schema.XmlSchemaGroupBase;
+import org.apache.ws.commons.schema.XmlSchemaObject;
+import org.apache.ws.commons.schema.XmlSchemaObjectTable;
+
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * Licensed 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.
+ *
+ */
+public class GroupTest extends TestCase {
+
+ /**
+ * This method will test the group.
+ *
+ * @throws Exception Any exception encountered
+ */
+ public void testGroup() throws Exception {
+
+ /*
+ <schema xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:tns="http://soapinterop.org/types"
+ targetNamespace="http://soapinterop.org/types">
+
+ <group name="priceGroup">
+ <annotation>
+ <documentation xml:lang="en">
+ A price is any one of the following:
+ * Full Price (with amount)
+ * Sale Price (with amount and authorization)
+ * Clearance Price (with amount and authorization)
+ * Free (with authorization)
+ </documentation>
+ </annotation>
+ <choice id="pg.choice">
+ <element name="fullPrice" type="decimal"/>
+ <element name="salePrice" type="decimal"/>
+ <element name="clearancePrice" type="decimal"/>
+ <element name="freePrice" type="decimal"/>
+ </choice>
+ </group>
+
+ <element name="price">
+ <complexType>
+ <group ref="tns:priceGroup" />
+ </complexType>
+ </element>
+
+ </schema>
+ */
+
+ QName ELEMENT_QNAME = new QName("http://soapinterop.org/types",
+ "price");
+ InputStream is = new FileInputStream("test-resources/group.xsd");
+ XmlSchemaCollection schemaCol = new XmlSchemaCollection();
+ XmlSchema schema = schemaCol.read(new StreamSource(is), null);
+
+ XmlSchemaElement elem = schemaCol.getElementByQName(ELEMENT_QNAME);
+ assertNotNull(elem);
+ assertEquals("price", elem.getName());
+ assertEquals(new QName("http://soapinterop.org/types", "price"),
+ elem.getQName());
+
+ XmlSchemaComplexType cType = (XmlSchemaComplexType)elem.getSchemaType();
+ assertNotNull(cType);
+
+ XmlSchemaGroupRef ref = (XmlSchemaGroupRef)cType.getParticle();
+ assertEquals(new QName("http://soapinterop.org/types", "priceGroup"),
+ ref.getRefName());
+
+ XmlSchemaObjectTable t = schema.getGroups();
+ assertEquals(1, t.getCount());
+
+ XmlSchemaObject o = t.getItem(ref.getRefName());
+
+ Set s = new HashSet();
+ s.add("priceGroup");
+ for (Iterator i = t.getNames(); i.hasNext(); ) {
+ String name = (String)i.next();
+ assertEquals("priceGroup", name);
+ s.remove(name);
+ }
+ assertTrue("The set should have been empty, but instead contained: "
+ + s + ".",
+ s.isEmpty());
+
+ s.clear();
+ s.add("org.apache.ws.commons.schema.XmlSchemaGroup");
+ XmlSchemaGroup xsg = null;
+ for (Iterator i = t.getValues(); i.hasNext(); ) {
+ xsg = (XmlSchemaGroup)i.next();
+ s.remove(xsg.getClass().getName());
+ }
+ assertTrue("The set should have been empty, but instead contained: "
+ + s + ".",
+ s.isEmpty());
+
+ assertEquals("priceGroup", xsg.getName());
+
+ XmlSchemaChoice xsc = (XmlSchemaChoice)xsg.getParticle();
+ assertNotNull(xsc);
+
+ s.clear();
+ s.add("fullPrice");
+ s.add("salePrice");
+ s.add("clearancePrice");
+ s.add("freePrice");
+ XmlSchemaObjectCollection items = xsc.getItems();
+ Iterator iterator = items.getIterator();
+ while (iterator.hasNext()) {
+ XmlSchemaElement e = (XmlSchemaElement)iterator.next();
+ String eName = e.getName();
+ if (eName.equals("fullPrice")) {
+ assertEquals(new QName("", "fullPrice"), e.getQName());
+ } else if (eName.equals("salePrice")) {
+ assertEquals(new QName("", "salePrice"), e.getQName());
+ } else if (eName.equals("clearancePrice")) {
+ assertEquals(new QName("", "clearancePrice"), e.getQName());
+ } else if (eName.equals("freePrice")) {
+ assertEquals(new QName("", "freePrice"), e.getQName());
+ } else {
+ fail("The name \"" + eName + "\" was found but shouldn't "
+ + "have been found.");
+ }
+ assertEquals(new QName("http://www.w3.org/2001/XMLSchema",
+ "decimal"), e.getSchemaTypeName());
+ assertTrue(s.remove(e.getName()));
+ }
+ assertTrue("The set should have been empty, but instead contained: "
+ + s + ".",
+ s.isEmpty());
+
+ }
+
+}
\ No newline at end of file
Added: webservices/commons/trunk/modules/XmlSchema/test/tests/IncludeTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/test/tests/IncludeTest.java?rev=416855&view=auto
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/test/tests/IncludeTest.java (added)
+++ webservices/commons/trunk/modules/XmlSchema/test/tests/IncludeTest.java Fri Jun 23 19:54:05 2006
@@ -0,0 +1,124 @@
+package tests;
+
+import java.io.FileInputStream;
+import java.io.InputStream;
+
+import java.util.Iterator;
+import java.util.Set;
+import java.util.HashSet;
+
+import javax.xml.namespace.QName;
+import javax.xml.transform.stream.StreamSource;
+
+import junit.framework.TestCase;
+
+import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaCollection;
+import org.apache.ws.commons.schema.XmlSchemaElement;
+import org.apache.ws.commons.schema.XmlSchemaObjectCollection;
+import org.apache.ws.commons.schema.XmlSchemaInclude;
+
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * Licensed 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.
+ *
+ */
+public class IncludeTest extends TestCase {
+
+ /**
+ * This method will test the include.
+ *
+ * @throws Exception Any exception encountered
+ */
+ public void testInclude() throws Exception {
+
+ /*
+ <schema xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:tns="http://soapinterop.org/types"
+ targetNamespace="http://soapinterop.org/types">
+
+ <include schemaLocation="include2.xsd"/>
+ <include schemaLocation="include3.xsd"/>
+
+ </schema>
+
+
+ <schema xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:tns="http://soapinterop.org/types"
+ targetNamespace="http://soapinterop.org/types">
+
+ <element name="test1include" type="string"/>
+
+ </schema>
+
+
+ <schema xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:tns="http://soapinterop.org/types"
+ targetNamespace="http://soapinterop.org/types">
+
+ <element name="test2include" type="integer"/>
+
+ </schema>
+ */
+
+ QName ELEMENT_QNAME = new QName("http://soapinterop.org/types",
+ "test1include");
+ InputStream is = new FileInputStream("test-resources/include.xsd");
+ XmlSchemaCollection schemaCol = new XmlSchemaCollection();
+ XmlSchema schema = schemaCol.read(new StreamSource(is), null);
+
+ XmlSchemaObjectCollection c = schema.getIncludes();
+ assertEquals(2, c.getCount());
+
+ Set set = new HashSet();
+ set.add("test-resources/include2.xsd");
+ set.add("test-resources/include3.xsd");
+ for (int i = 0; i < c.getCount(); i++) {
+ XmlSchemaInclude include = (XmlSchemaInclude)c.getItem(i);
+ assertNotNull(include);
+ XmlSchema s = include.getSchema();
+ assertNotNull(s);
+ String schemaLocation = include.getSchemaLocation();
+ if (schemaLocation.equals("test-resources/include2.xsd")) {
+ XmlSchemaElement xse =
+ s.getElementByName(new
+ QName("http://soapinterop.org/types", "test1include"));
+ assertEquals("test1include", xse.getName());
+ assertEquals(new QName("http://www.w3.org/2001/XMLSchema", "string"),
+ xse.getSchemaTypeName());
+ } else if (schemaLocation.equals("test-resources/include3.xsd")) {
+ XmlSchemaElement xse =
+ s.getElementByName(new
+ QName("http://soapinterop.org/types", "test2include"));
+ assertEquals("test2include", xse.getName());
+ assertEquals(new QName("http://www.w3.org/2001/XMLSchema", "integer"),
+ xse.getSchemaTypeName());
+ } else {
+ fail("The schemaLocation of \"" + schemaLocation + "\" was"
+ + " not expected.");
+ }
+ set.remove(schemaLocation);
+ }
+
+ assertTrue("The set should have been empty, but instead contained: "
+ + set + ".",
+ set.isEmpty());
+
+ }
+
+}
\ No newline at end of file
Added: webservices/commons/trunk/modules/XmlSchema/test/tests/ListTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/test/tests/ListTest.java?rev=416855&view=auto
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/test/tests/ListTest.java (added)
+++ webservices/commons/trunk/modules/XmlSchema/test/tests/ListTest.java Fri Jun 23 19:54:05 2006
@@ -0,0 +1,103 @@
+package tests;
+
+import java.io.FileInputStream;
+import java.io.InputStream;
+
+import java.util.Iterator;
+import java.util.Set;
+import java.util.HashSet;
+
+import javax.xml.namespace.QName;
+import javax.xml.transform.stream.StreamSource;
+
+import javax.xml.namespace.QName;
+
+import junit.framework.TestCase;
+
+import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaType;
+import org.apache.ws.commons.schema.XmlSchemaCollection;
+import org.apache.ws.commons.schema.XmlSchemaSimpleType;
+import org.apache.ws.commons.schema.XmlSchemaSimpleTypeList;
+import org.apache.ws.commons.schema.XmlSchemaSimpleTypeRestriction;
+import org.apache.ws.commons.schema.XmlSchemaSimpleTypeContent;
+import org.apache.ws.commons.schema.XmlSchemaElement;
+
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * Licensed 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.
+ *
+ */
+public class ListTest extends TestCase {
+
+ /**
+ * This method will test the list.
+ *
+ * @throws Exception Any exception encountered
+ */
+ public void testList() throws Exception {
+
+ /*
+ <schema xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:tns="http://soapinterop.org/types"
+ targetNamespace="http://soapinterop.org/types">
+
+ <element name="workDays">
+ <simpleType>
+ <restriction base="tns:daysInWeek">
+ <length value="5"/>
+ </restriction>
+ </simpleType>
+ </element>
+
+ <simpleType name="daysInWeek">
+ <list itemType="xsd:integer"/>
+ </simpleType>
+
+ </schema>
+ */
+
+ QName ELEMENT_QNAME = new QName("http://soapinterop.org/types",
+ "workDays");
+ InputStream is = new FileInputStream("test-resources/list.xsd");
+ XmlSchemaCollection schemaCol = new XmlSchemaCollection();
+ XmlSchema schema = schemaCol.read(new StreamSource(is), null);
+
+ XmlSchemaElement elem = schemaCol.getElementByQName(ELEMENT_QNAME);
+ assertNotNull(elem);
+ assertEquals("workDays", elem.getName());
+ assertEquals(new QName("http://soapinterop.org/types", "workDays"),
+ elem.getQName());
+
+ XmlSchemaSimpleType simpleType = (XmlSchemaSimpleType)elem.getSchemaType();
+ assertNotNull(simpleType);
+
+ XmlSchemaSimpleTypeRestriction r =
+ (XmlSchemaSimpleTypeRestriction)simpleType.getContent();
+ assertNotNull(r);
+
+ QName baseTypeName = r.getBaseTypeName();
+ assertEquals(new QName("http://soapinterop.org/types", "daysInWeek"),
+ baseTypeName);
+ XmlSchemaType type = schemaCol.getTypeByQName(baseTypeName);
+
+ XmlSchemaSimpleTypeContent content = ((XmlSchemaSimpleType)type).getContent();
+ assertEquals(new QName("http://www.w3.org/2001/XMLSchema", "integer"),
+ ((XmlSchemaSimpleTypeList)content).getItemTypeName());
+
+ }
+
+}
\ No newline at end of file
Added: webservices/commons/trunk/modules/XmlSchema/test/tests/SimpleContentExtensionTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/test/tests/SimpleContentExtensionTest.java?rev=416855&view=auto
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/test/tests/SimpleContentExtensionTest.java (added)
+++ webservices/commons/trunk/modules/XmlSchema/test/tests/SimpleContentExtensionTest.java Fri Jun 23 19:54:05 2006
@@ -0,0 +1,141 @@
+package tests;
+
+import java.io.ByteArrayOutputStream;
+import java.io.FileInputStream;
+import java.io.InputStream;
+
+import java.util.Iterator;
+import java.util.Set;
+import java.util.HashSet;
+
+import javax.xml.namespace.QName;
+import javax.xml.transform.stream.StreamSource;
+
+import junit.framework.TestCase;
+
+import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaObject;
+import org.apache.ws.commons.schema.XmlSchemaCollection;
+import org.apache.ws.commons.schema.XmlSchemaElement;
+import org.apache.ws.commons.schema.XmlSchemaObjectCollection;
+import org.apache.ws.commons.schema.XmlSchemaComplexType;
+import org.apache.ws.commons.schema.XmlSchemaSimpleContent;
+import org.apache.ws.commons.schema.XmlSchemaSimpleContentExtension;
+import org.apache.ws.commons.schema.XmlSchemaAttribute;
+
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * Licensed 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.
+ *
+ */
+public class SimpleContentExtensionTest extends TestCase {
+
+ /**
+ * This method will test the simple content extension.
+ *
+ * @throws Exception Any exception encountered
+ */
+ public void testSimpleContentExtension() throws Exception {
+
+ /*
+ <schema xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:tns="http://soapinterop.org/types"
+ targetNamespace="http://soapinterop.org/types">
+
+ <element name="height">
+ <complexType>
+ <simpleContent>
+ <extension base="integer">
+ <attribute name="units" type="string" use="required"/>
+ <attribute name="id" type="integer" use="required" default="001"/>
+ <attribute name="desc" type="decimal" fixed="1.1"/>
+ </extension>
+ </simpleContent>
+ </complexType>
+ </element>
+
+ </schema>
+ */
+
+ QName ELEMENT_QNAME = new QName("http://soapinterop.org/types",
+ "height");
+ InputStream is = new FileInputStream("test-resources/simplecontentextension.xsd");
+ XmlSchemaCollection schemaCol = new XmlSchemaCollection();
+ XmlSchema schema = schemaCol.read(new StreamSource(is), null);
+
+ XmlSchemaElement elem = schema.getElementByName(ELEMENT_QNAME);
+ assertNotNull(elem);
+ assertEquals("height", elem.getName());
+ assertEquals(new QName("http://soapinterop.org/types", "height"),
+ elem.getQName());
+
+ XmlSchemaComplexType xsct = (XmlSchemaComplexType)elem.getSchemaType();
+ assertNotNull(xsct);
+ XmlSchemaSimpleContent xssc = (XmlSchemaSimpleContent)xsct.getContentModel();
+ assertNotNull(xssc);
+
+ XmlSchemaSimpleContentExtension xssce
+ = (XmlSchemaSimpleContentExtension)xssc.getContent();
+ assertNotNull(xssce);
+ assertEquals(new QName("http://www.w3.org/2001/XMLSchema", "integer"),
+ xssce.getBaseTypeName());
+
+ XmlSchemaObjectCollection xsoc = xssce.getAttributes();
+ assertEquals(3, xsoc.getCount());
+
+ Set s = new HashSet();
+ s.add("units");
+ s.add("id");
+ s.add("desc");
+ for (int i = 0; i < xsoc.getCount(); i++) {
+ XmlSchemaAttribute xsa = (XmlSchemaAttribute)xsoc.getItem(i);
+ String name = xsa.getName();
+ if (name.equals("units")) {
+ assertEquals(new QName("http://soapinterop.org/types", "units"),
+ xsa.getQName());
+ assertEquals(new QName("http://www.w3.org/2001/XMLSchema", "string"),
+ xsa.getSchemaTypeName());
+ assertNull(xsa.getDefaultValue());
+ assertEquals("required", xsa.getUse().getValue());
+ assertNull(xsa.getFixedValue());
+ } else if (name.equals("id")) {
+ assertEquals(new QName("http://soapinterop.org/types", "id"),
+ xsa.getQName());
+ assertEquals(new QName("http://www.w3.org/2001/XMLSchema", "integer"),
+ xsa.getSchemaTypeName());
+ assertEquals("001", xsa.getDefaultValue());
+ assertEquals("required", xsa.getUse().getValue());
+ assertNull(xsa.getFixedValue());
+ } else if (name.equals("desc")) {
+ assertEquals(new QName("http://soapinterop.org/types", "desc"),
+ xsa.getQName());
+ assertEquals(new QName("http://www.w3.org/2001/XMLSchema", "decimal"),
+ xsa.getSchemaTypeName());
+ assertEquals("none", xsa.getUse().getValue());
+ assertEquals("1.1", xsa.getFixedValue());
+ } else {
+ fail("The name \"" + name + "\" was not expected.");
+ }
+ s.remove(name);
+ }
+
+ assertTrue("The set should have been empty, but instead contained: "
+ + s + ".",
+ s.isEmpty());
+
+ }
+
+}
\ No newline at end of file
Added: webservices/commons/trunk/modules/XmlSchema/test/tests/SimpleContentRestrictionTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/test/tests/SimpleContentRestrictionTest.java?rev=416855&view=auto
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/test/tests/SimpleContentRestrictionTest.java (added)
+++ webservices/commons/trunk/modules/XmlSchema/test/tests/SimpleContentRestrictionTest.java Fri Jun 23 19:54:05 2006
@@ -0,0 +1,155 @@
+package tests;
+
+import java.io.ByteArrayOutputStream;
+import java.io.FileInputStream;
+import java.io.InputStream;
+
+import java.util.Iterator;
+import java.util.Set;
+import java.util.HashSet;
+
+import javax.xml.namespace.QName;
+import javax.xml.transform.stream.StreamSource;
+
+import junit.framework.TestCase;
+
+import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaCollection;
+import org.apache.ws.commons.schema.XmlSchemaObjectCollection;
+import org.apache.ws.commons.schema.XmlSchemaComplexType;
+import org.apache.ws.commons.schema.XmlSchemaSimpleContent;
+import org.apache.ws.commons.schema.XmlSchemaSimpleContentRestriction;
+import org.apache.ws.commons.schema.XmlSchemaAttribute;
+import org.apache.ws.commons.schema.XmlSchemaEnumerationFacet;
+
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * Licensed 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.
+ *
+ */
+public class SimpleContentRestrictionTest extends TestCase {
+
+ /**
+ * This method will test the simple content restriction.
+ *
+ * @throws Exception Any exception encountered
+ */
+ public void testSimpleContentRestriction() throws Exception {
+
+ /*
+ <schema xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:tns="http://soapinterop.org/types"
+ targetNamespace="http://soapinterop.org/types">
+
+ <simpleType name="drinksize">
+ <restriction base="string">
+ <enumeration value="small"/>
+ <enumeration value="medium"/>
+ <enumeration value="large"/>
+ </restriction>
+ </simpleType>
+
+ <complexType name="dietdrinksize">
+ <simpleContent>
+ <restriction base="tns:drinksize">
+ <enumeration value="small"/>
+ <enumeration value="medium"/>
+ <attribute name="units" type="string" use="required"/>
+ <attribute name="id" type="integer" use="required" default="001"/>
+ </restriction>
+ </simpleContent>
+ </complexType>
+
+ </schema>
+ */
+
+ QName TYPE_QNAME = new QName("http://soapinterop.org/types",
+ "dietdrinksize");
+ InputStream is = new FileInputStream("test-resources/screstriction.xsd");
+ XmlSchemaCollection schemaCol = new XmlSchemaCollection();
+ XmlSchema schema = schemaCol.read(new StreamSource(is), null);
+
+ XmlSchemaComplexType xsct =
+ (XmlSchemaComplexType)schema.getTypeByName(TYPE_QNAME);
+ assertNotNull(xsct);
+
+ XmlSchemaSimpleContent xssc = (XmlSchemaSimpleContent)xsct.getContentModel();
+ assertNotNull(xssc);
+
+ XmlSchemaSimpleContentRestriction xsscr
+ = (XmlSchemaSimpleContentRestriction)xssc.getContent();
+ assertNotNull(xsscr);
+ assertEquals(new QName("http://soapinterop.org/types", "drinksize"),
+ xsscr.getBaseTypeName());
+ XmlSchemaObjectCollection xsoc = xsscr.getAttributes();
+ assertNotNull(xsoc);
+ assertEquals(2, xsoc.getCount());
+
+ Set s = new HashSet();
+ s.add("units");
+ s.add("id");
+ for (int i = 0; i < xsoc.getCount(); i++) {
+ XmlSchemaAttribute xsa = (XmlSchemaAttribute)xsoc.getItem(i);
+ String name = xsa.getName();
+ if (name.equals("units")) {
+ assertEquals(new QName("http://soapinterop.org/types", "units"),
+ xsa.getQName());
+ assertEquals(new QName("http://www.w3.org/2001/XMLSchema", "string"),
+ xsa.getSchemaTypeName());
+ assertNull(xsa.getDefaultValue());
+ assertEquals("required", xsa.getUse().getValue());
+ assertNull(xsa.getFixedValue());
+ } else if (name.equals("id")) {
+ assertEquals(new QName("http://soapinterop.org/types", "id"),
+ xsa.getQName());
+ assertEquals(new QName("http://www.w3.org/2001/XMLSchema", "integer"),
+ xsa.getSchemaTypeName());
+ assertEquals("001", xsa.getDefaultValue());
+ assertEquals("required", xsa.getUse().getValue());
+ assertNull(xsa.getFixedValue());
+ } else {
+ fail("The name \"" + name + "\" was not expected.");
+ }
+ assertTrue(s.remove(name));
+ }
+ assertTrue("The set should have been empty, but instead contained: "
+ + s + ".",
+ s.isEmpty());
+
+ XmlSchemaObjectCollection xsoc2 = xsscr.getFacets();
+ assertNotNull(xsoc2);
+ assertEquals(2, xsoc2.getCount());
+
+ s.clear();
+ s.add("small");
+ s.add("medium");
+ for (int i = 0; i < xsoc2.getCount(); i++) {
+ XmlSchemaEnumerationFacet xsef =
+ (XmlSchemaEnumerationFacet)xsoc2.getItem(i);
+ String value = (String)xsef.getValue();
+ if (!(value.equals("small") || value.equals("medium"))) {
+ fail("Unexpected enumeration value of \"" + value
+ + "\" found.");
+ }
+ assertTrue(s.remove(value));
+ }
+ assertTrue("The set should have been empty, but instead contained: "
+ + s + ".",
+ s.isEmpty());
+
+ }
+
+}
\ No newline at end of file
Added: webservices/commons/trunk/modules/XmlSchema/test/tests/UnionTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/test/tests/UnionTest.java?rev=416855&view=auto
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/test/tests/UnionTest.java (added)
+++ webservices/commons/trunk/modules/XmlSchema/test/tests/UnionTest.java Fri Jun 23 19:54:05 2006
@@ -0,0 +1,98 @@
+package tests;
+
+import java.io.FileInputStream;
+import java.io.InputStream;
+
+import java.util.Iterator;
+import java.util.Set;
+import java.util.HashSet;
+
+import javax.xml.namespace.QName;
+import javax.xml.transform.stream.StreamSource;
+
+import junit.framework.TestCase;
+
+import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaCollection;
+import org.apache.ws.commons.schema.XmlSchemaSimpleType;
+import org.apache.ws.commons.schema.XmlSchemaSimpleTypeUnion;
+import org.apache.ws.commons.schema.XmlSchemaElement;
+import org.apache.ws.commons.schema.XmlSchemaObjectCollection;
+
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * Licensed 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.
+ *
+ */
+public class UnionTest extends TestCase {
+
+ /**
+ * This method will test the union.
+ *
+ * @throws Exception Any exception encountered
+ */
+ public void testUnion() throws Exception {
+
+ /*
+ <schema xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:tns="http://soapinterop.org/types"
+ targetNamespace="http://soapinterop.org/types">
+
+ <element name="unionTest">
+ <simpleType>
+ <union memberTypes="float decimal"/>
+ </simpleType>
+ </element>
+
+ </schema>
+ */
+
+ QName ELEMENT_QNAME = new QName("http://soapinterop.org/types",
+ "unionTest");
+ InputStream is = new FileInputStream("test-resources/union.xsd");
+ XmlSchemaCollection schemaCol = new XmlSchemaCollection();
+ XmlSchema schema = schemaCol.read(new StreamSource(is), null);
+
+
+ XmlSchemaElement elem = schemaCol.getElementByQName(ELEMENT_QNAME);
+ assertNotNull(elem);
+ assertEquals("unionTest", elem.getName());
+ assertEquals(new QName("http://soapinterop.org/types", "unionTest"),
+ elem.getQName());
+
+ XmlSchemaSimpleType simpleType = (XmlSchemaSimpleType)elem.getSchemaType();
+ assertNotNull(simpleType);
+
+ XmlSchemaSimpleTypeUnion xsstu =
+ (XmlSchemaSimpleTypeUnion)simpleType.getContent();
+ assertNotNull(xsstu);
+
+ QName[] qname = xsstu.getMemberTypesQNames();
+ Set s = new HashSet();
+ s.add(new QName("http://www.w3.org/2001/XMLSchema", "float"));
+ s.add(new QName("http://www.w3.org/2001/XMLSchema", "decimal"));
+ for (int i = 0; i < qname.length; i++) {
+ assertTrue(s.remove(qname[i]));
+ }
+ assertTrue("The set should have been empty, but instead contained: "
+ + s + ".",
+ s.isEmpty());
+
+ assertEquals("float decimal", xsstu.getMemberTypesSource());
+
+ }
+
+}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: commons-dev-help@ws.apache.org