Author: ajith
Date: Mon Oct 22 20:42:51 2007
New Revision: 587379
URL: http://svn.apache.org/viewvc?rev=587379&view=rev
Log:
1. Added a new test case to test WSCOMMONS-259
2. Renamed an existing test
Added:
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/ElementRefs2Test.java
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/ElementRefsTest.java
- copied, changed from r587361,
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/TestElementRefs.java
webservices/commons/trunk/modules/XmlSchema/src/test/test-resources/elementreferences2.xsd
Removed:
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/TestElementRefs.java
Added:
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/ElementRefs2Test.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/ElementRefs2Test.java?rev=587379&view=auto
==============================================================================
---
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/ElementRefs2Test.java
(added)
+++
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/ElementRefs2Test.java
Mon Oct 22 20:42:51 2007
@@ -0,0 +1,65 @@
+package tests;
+
+import junit.framework.TestCase;
+
+import javax.xml.namespace.QName;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.DocumentBuilder;
+import java.io.InputStream;
+import java.io.FileInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ByteArrayInputStream;
+import java.util.Iterator;
+
+import org.apache.ws.commons.schema.*;
+import org.w3c.dom.Document;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Node;
+import org.w3c.dom.Element;
+
+public class ElementRefs2Test extends TestCase {
+
+ public void testElementRefs() throws Exception {
+ QName ELEMENT_QNAME = new QName("http://soapinterop.org/types",
+ "attTests");
+ InputStream is = new
FileInputStream(Resources.asURI("elementreferences2.xsd"));
+ XmlSchemaCollection schemaCol = new XmlSchemaCollection();
+ XmlSchema schema = schemaCol.read(new StreamSource(is), null);
+
+ XmlSchemaElement elem = schemaCol.getElementByQName(ELEMENT_QNAME);
+
+ assertNotNull(elem);
+
+ XmlSchemaComplexType cmplxType =
(XmlSchemaComplexType)elem.getSchemaType();
+ XmlSchemaObjectCollection items =
((XmlSchemaSequence)cmplxType.getParticle()).getItems();
+
+ Iterator it = items.getIterator();
+ while (it.hasNext()) {
+ XmlSchemaElement innerElement = (XmlSchemaElement)it.next();
+ assertNotNull(innerElement.getRefName());
+ }
+
+ // test writing
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ schema.write(bos);
+
+ //read this as a plain DOM and inspect our reference in question
+ DocumentBuilder documentBuilder =
DocumentBuilderFactory.newInstance().newDocumentBuilder();
+ Document document = documentBuilder.parse(new
ByteArrayInputStream(bos.toByteArray()));
+
+ //find the element with name="atttest" and test its type attribute
+ //to see whether it serialized a colon
+ NodeList elementList = document.getElementsByTagName("element");
+ for(int i=0;i < elementList.getLength();i++){
+ Node n = elementList.item(i);
+ if (n.getNodeType() == Node.ELEMENT_NODE &&
+ ((Element)n).hasAttribute("type")){
+ assertTrue(((Element)n).getAttribute("type").indexOf(':') < 0);
+ }
+ }
+
+
+ }
+
+}
Copied:
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/ElementRefsTest.java
(from r587361,
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/TestElementRefs.java)
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/ElementRefsTest.java?p2=webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/ElementRefsTest.java&p1=webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/TestElementRefs.java&r1=587361&r2=587379&rev=587379&view=diff
==============================================================================
---
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/TestElementRefs.java
(original)
+++
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/ElementRefsTest.java
Mon Oct 22 20:42:51 2007
@@ -29,7 +29,7 @@
import java.io.InputStream;
import java.util.Iterator;
-public class TestElementRefs extends TestCase {
+public class ElementRefsTest extends TestCase {
public void testElementRefs() throws Exception {
QName ELEMENT_QNAME = new QName("http://soapinterop.org/types",
"attTests");
Added:
webservices/commons/trunk/modules/XmlSchema/src/test/test-resources/elementreferences2.xsd
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/test-resources/elementreferences2.xsd?rev=587379&view=auto
==============================================================================
---
webservices/commons/trunk/modules/XmlSchema/src/test/test-resources/elementreferences2.xsd
(added)
+++
webservices/commons/trunk/modules/XmlSchema/src/test/test-resources/elementreferences2.xsd
Mon Oct 22 20:42:51 2007
@@ -0,0 +1,44 @@
+<!--
+ ~ 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.
+ -->
+
+<xsd:schema
+ xmlns="http://soapinterop.org/types"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:tns="http://soapinterop.org/types"
+ targetNamespace="http://soapinterop.org/types">
+
+ <xsd:complexType name="Struct">
+ <xsd:sequence>
+ <xsd:element name="varString" type="xsd:string"/>
+ <xsd:element name="varInt" type="xsd:int"/>
+ <xsd:element name="varFloat" type="xsd:float"/>
+ <xsd:element name="varStruct" type="tns:Struct"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:element name="attrTest" type="Struct"/>
+
+ <xsd:element name="attTests">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element ref="tns:attrTest" maxOccurs="5"></xsd:element>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+</xsd:schema>
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]