Author: ajith
Date: Sat Mar 22 13:36:26 2008
New Revision: 640074
URL: http://svn.apache.org/viewvc?rev=640074&view=rev
Log:
1. Added a test case to test Jira 309
Added:
webservices/commons/trunk/modules/XmlSchema/src/test/test-resources/anyZero.xsd
Modified:
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/AnyTest.java
Modified:
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/AnyTest.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/AnyTest.java?rev=640074&r1=640073&r2=640074&view=diff
==============================================================================
---
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/AnyTest.java
(original)
+++
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/AnyTest.java
Sat Mar 22 13:36:26 2008
@@ -24,6 +24,9 @@
import javax.xml.namespace.QName;
import javax.xml.transform.stream.StreamSource;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.HashSet;
@@ -81,7 +84,53 @@
XmlSchemaCollection schemaCol = new XmlSchemaCollection();
XmlSchema schema = schemaCol.read(new StreamSource(is), null);
- XmlSchemaElement elem = schemaCol.getElementByQName(ELEMENT_QNAME);
+ verifyAccuracy(ELEMENT_QNAME, schemaCol,5L,10L);
+
+ }
+
+
+ public void testAnyZeroOccurs() 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(Resources.asURI("anyZero.xsd"));
+ XmlSchemaCollection schemaCol = new XmlSchemaCollection();
+ XmlSchema schema = schemaCol.read(new StreamSource(is), null);
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ schema.write(baos);
+
+ XmlSchemaCollection schemaCol2 = new XmlSchemaCollection();
+ XmlSchema schema2 = schemaCol2.read(new StreamSource(new
ByteArrayInputStream(baos.toByteArray())), null);
+
+ verifyAccuracy(ELEMENT_QNAME, schemaCol2,0,0);
+
+
+ }
+
+ private void verifyAccuracy(QName ELEMENT_QNAME,
+ XmlSchemaCollection schemaCol,long minCount, long
maxCount) {
+ XmlSchemaElement elem =
schemaCol.getElementByQName(ELEMENT_QNAME);
assertNotNull(elem);
assertEquals("department", elem.getName());
assertEquals(new QName("http://soapinterop.org/types", "department"),
@@ -119,15 +168,14 @@
XmlSchemaContentProcessing xscp =
((XmlSchemaAny)o).getProcessContent();
assertEquals("none", xscp.toString());
- assertEquals(5L, ((XmlSchemaAny)o).getMinOccurs());
- assertEquals(10L, ((XmlSchemaAny)o).getMaxOccurs());
+ assertEquals(minCount, ((XmlSchemaAny)o).getMinOccurs());
+ assertEquals(maxCount, ((XmlSchemaAny)o).getMaxOccurs());
}
}
assertTrue("The set should have been empty, but instead contained: "
+ s + ".",
s.isEmpty());
-
- }
+ }
}
Added:
webservices/commons/trunk/modules/XmlSchema/src/test/test-resources/anyZero.xsd
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/test-resources/anyZero.xsd?rev=640074&view=auto
==============================================================================
---
webservices/commons/trunk/modules/XmlSchema/src/test/test-resources/anyZero.xsd
(added)
+++
webservices/commons/trunk/modules/XmlSchema/src/test/test-resources/anyZero.xsd
Sat Mar 22 13:36:26 2008
@@ -0,0 +1,35 @@
+<!--
+ ~ 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.
+ -->
+<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="0" maxOccurs="0"/>
+ </sequence>
+ </complexType>
+ </element>
+
+</schema>
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]