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 aj...@apache.org on 2007/07/02 08:02:59 UTC

svn commit: r552411 - in /webservices/commons/trunk/modules/XmlSchema/src/test: java/tests/AttributeRefTest.java test-resources/attributref.xsd

Author: ajith
Date: Sun Jul  1 23:02:58 2007
New Revision: 552411

URL: http://svn.apache.org/viewvc?view=rev&rev=552411
Log:
1.Adding  a new test case to test the WSCOMMONS-204

Added:
    webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/AttributeRefTest.java
    webservices/commons/trunk/modules/XmlSchema/src/test/test-resources/attributref.xsd

Added: webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/AttributeRefTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/AttributeRefTest.java?view=auto&rev=552411
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/AttributeRefTest.java (added)
+++ webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/AttributeRefTest.java Sun Jul  1 23:02:58 2007
@@ -0,0 +1,52 @@
+package tests;
+
+import junit.framework.TestCase;
+
+import javax.xml.namespace.QName;
+import javax.xml.transform.stream.StreamSource;
+import java.io.InputStream;
+import java.io.FileInputStream;
+
+import org.apache.ws.commons.schema.*;
+
+/*
+* Copyright 2004,2007 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 AttributeRefTest extends TestCase {
+
+    public void testAttRefsWithNS() throws Exception{
+        QName TYPE_QNAME = new QName("http://tempuri.org/attribute",
+                                        "TestAttributeReferenceType");
+
+
+        InputStream is = new FileInputStream(Resources.asURI("attributref.xsd"));
+        XmlSchemaCollection schema = new XmlSchemaCollection();
+        XmlSchema s = schema.read(new StreamSource(is), null);
+
+        XmlSchemaComplexType typeByName = (XmlSchemaComplexType)s.getTypeByName(TYPE_QNAME);
+        assertNotNull(typeByName);
+
+        XmlSchemaAttribute item = (XmlSchemaAttribute)typeByName.getAttributes().getItem(0);
+        QName qName = item.getRefName();
+        assertNotNull(qName);
+
+        String namspace = qName.getNamespaceURI();
+        assertEquals("http://tempuri.org/attribute",namspace);
+    }
+
+
+}

Added: webservices/commons/trunk/modules/XmlSchema/src/test/test-resources/attributref.xsd
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/test-resources/attributref.xsd?view=auto&rev=552411
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/test/test-resources/attributref.xsd (added)
+++ webservices/commons/trunk/modules/XmlSchema/src/test/test-resources/attributref.xsd Sun Jul  1 23:02:58 2007
@@ -0,0 +1,16 @@
+<xs:schema elementFormDefault="qualified"
+           xmlns:xs="http://www.w3.org/2001/XMLSchema"
+           xmlns:tns="http://tempuri.org/attribute"
+           targetNamespace="http://tempuri.org/attribute">
+
+    <xs:element name="TestAttributeReferenceElement" type="tns:TestAttributeReferenceType"/>
+    <xs:attribute name="TestAttribute1" type="xs:string"/>
+    <xs:complexType name="TestAttributeReferenceType">
+        <xs:sequence>
+            <xs:element name="param1" type="xs:string"/>
+            <xs:element name="param2" type="xs:string"/>
+        </xs:sequence>
+        <xs:attribute ref="tns:TestAttribute1"/>
+    </xs:complexType>
+
+</xs:schema>
\ 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