Author: ajith
Date: Mon Mar 24 10:46:01 2008
New Revision: 640480

URL: http://svn.apache.org/viewvc?rev=640480&view=rev
Log:
1. Added a test case to test the issue 311. The test passes but I am not 
convinced whether the functionality is rightful - Hence till I further 
investigate the issue I will keep the issue open

Added:
    
webservices/commons/trunk/modules/XmlSchema/src/test/test-resources/redefine-include/
    
webservices/commons/trunk/modules/XmlSchema/src/test/test-resources/redefine-include/redefine-import1.xsd
    
webservices/commons/trunk/modules/XmlSchema/src/test/test-resources/redefine-include/redefine-import2.xsd
    
webservices/commons/trunk/modules/XmlSchema/src/test/test-resources/redefine10.xsd
    
webservices/commons/trunk/modules/XmlSchema/src/test/test-resources/redefine9.xsd
Modified:
    
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/RedefineTest.java

Modified: 
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/RedefineTest.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/RedefineTest.java?rev=640480&r1=640479&r2=640480&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/RedefineTest.java
 (original)
+++ 
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/RedefineTest.java
 Mon Mar 24 10:46:01 2008
@@ -454,4 +454,149 @@
     }
 
 
+    /**
+     * This method will test a complex type redefine. Similar
+     * to the first test but now there are multiple layers of includes
+     *
+     * @throws Exception Any exception encountered
+     */
+    public void testComplexTypeRedefineWithRelativeImports() throws Exception {
+
+       /*
+        * redefine-import2.xsd
+        * 
+                         <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="person">
+                   <sequence>
+                     <element name="firstname" type="string"/>
+                     <element name="lastname" type="string"/>
+                   </sequence>
+                 </complexType>
+               
+                 <element name="customer" type="tns:person"/>
+                
+                </schema>
+        * 
+        * 
+        */
+       
+       
+       /*
+        * redefine-import1.xsd
+        * 
+        * 
+                <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";>
+                <!--  relative import to this location -->       
+                <xsd:include 
schemaLocation="redefine-import2.xsd"></xsd:include>
+                
+                </schema>
+        * 
+        */
+        /*
+        redefine9.xsd
+        -----------------
+               
+               <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";>
+               
+         <!-- Relative import -->
+         <xsd:include 
schemaLocation="redefine-include/redefine-import1.xsd"></xsd:include>
+       
+       </schema>
+               
+                         
+        redefine10.xsd
+        -----------------
+        
+       <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";>
+       
+         <redefine schemaLocation="src/test/test-resources/redefine9.xsd">
+           <complexType name="person">
+             <complexContent>
+               <extension base="tns:person">
+                 <sequence>
+                   <element name="id" type="string"/>
+                 </sequence>
+               </extension>
+             </complexContent>
+           </complexType>
+         </redefine>
+       
+         <element name="vip" type="tns:person"/>
+       
+       </schema>
+        */
+
+        InputStream is = new 
FileInputStream(Resources.asURI("redefine10.xsd"));
+        XmlSchemaCollection schemaCol = new XmlSchemaCollection();
+        XmlSchema schema = schemaCol.read(new StreamSource(is), null);
+
+        XmlSchemaObjectTable xsot = schema.getElements();
+        assertEquals(1, xsot.getCount());
+
+        XmlSchemaElement xse = null;
+        for (Iterator i = xsot.getValues(); i.hasNext(); ) {
+            xse = (XmlSchemaElement)i.next();
+        }
+        assertEquals("vip", xse.getName());
+        assertEquals(new QName("http://soapinterop.org/types";,
+                               "person"),
+                     xse.getSchemaTypeName());
+
+        XmlSchemaObjectCollection xsoc = schema.getIncludes();
+        assertEquals(1, xsoc.getCount());
+        
+        XmlSchemaRedefine xsr = (XmlSchemaRedefine)xsoc.getItem(0);
+        xsot = xsr.getSchemaTypes();
+        assertEquals(1, xsot.getCount());
+
+        for (Iterator i = xsot.getNames(); i.hasNext(); ) {
+            QName qname = (QName)i.next();
+            assertEquals(new QName("http://soapinterop.org/types";,
+                                   "person"), qname);
+        }
+
+        XmlSchemaComplexType xsct = null;
+        for (Iterator i = xsot.getValues(); i.hasNext(); ) {
+            xsct = (XmlSchemaComplexType)i.next();
+        }
+        assertNotNull(xsct);
+
+        XmlSchemaContentModel xscm = xsct.getContentModel();
+        assertNotNull(xscm);
+
+        XmlSchemaComplexContentExtension xscce =
+            (XmlSchemaComplexContentExtension)xscm.getContent();
+        assertEquals(new QName("http://soapinterop.org/types";,
+                               "person"),
+                     xscce.getBaseTypeName());
+
+        XmlSchemaSequence xsp = (XmlSchemaSequence)xscce.getParticle();
+        assertNotNull(xsp);
+
+        XmlSchemaObjectCollection c = xsp.getItems();
+        assertEquals(1, c.getCount());
+
+        xse = null;
+        for (int i = 0; i < c.getCount(); i++) {
+            xse = (XmlSchemaElement)c.getItem(i);
+        }
+        assertEquals("id", xse.getName());
+        assertEquals(new QName("http://www.w3.org/2001/XMLSchema";,
+                               "string"),
+                     xse.getSchemaTypeName());
+
+    }
 }

Added: 
webservices/commons/trunk/modules/XmlSchema/src/test/test-resources/redefine-include/redefine-import1.xsd
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/test-resources/redefine-include/redefine-import1.xsd?rev=640480&view=auto
==============================================================================
--- 
webservices/commons/trunk/modules/XmlSchema/src/test/test-resources/redefine-include/redefine-import1.xsd
 (added)
+++ 
webservices/commons/trunk/modules/XmlSchema/src/test/test-resources/redefine-include/redefine-import1.xsd
 Mon Mar 24 10:46:01 2008
@@ -0,0 +1,27 @@
+<!--
+  ~ 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";>
+ <!--  relative import to this location -->       
+ <xsd:include schemaLocation="redefine-import2.xsd"></xsd:include>
+ 
+ </schema>
\ No newline at end of file

Added: 
webservices/commons/trunk/modules/XmlSchema/src/test/test-resources/redefine-include/redefine-import2.xsd
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/test-resources/redefine-include/redefine-import2.xsd?rev=640480&view=auto
==============================================================================
--- 
webservices/commons/trunk/modules/XmlSchema/src/test/test-resources/redefine-include/redefine-import2.xsd
 (added)
+++ 
webservices/commons/trunk/modules/XmlSchema/src/test/test-resources/redefine-include/redefine-import2.xsd
 Mon Mar 24 10:46:01 2008
@@ -0,0 +1,34 @@
+<!--
+  ~ 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";>
+        
+       <complexType name="person">
+           <sequence>
+             <element name="firstname" type="string"/>
+             <element name="lastname" type="string"/>
+           </sequence>
+         </complexType>
+
+
+ 
+ </schema>

Added: 
webservices/commons/trunk/modules/XmlSchema/src/test/test-resources/redefine10.xsd
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/test-resources/redefine10.xsd?rev=640480&view=auto
==============================================================================
--- 
webservices/commons/trunk/modules/XmlSchema/src/test/test-resources/redefine10.xsd
 (added)
+++ 
webservices/commons/trunk/modules/XmlSchema/src/test/test-resources/redefine10.xsd
 Mon Mar 24 10:46:01 2008
@@ -0,0 +1,39 @@
+<!--
+  ~ 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";>
+
+  <redefine schemaLocation="src/test/test-resources/redefine9.xsd">
+    <complexType name="person">
+      <complexContent>
+        <extension base="tns:person">
+          <sequence>
+            <element name="id" type="string"/>
+          </sequence>
+        </extension>
+      </complexContent>
+    </complexType>
+  </redefine>
+
+  <element name="vip" type="tns:person"/>
+
+</schema>

Added: 
webservices/commons/trunk/modules/XmlSchema/src/test/test-resources/redefine9.xsd
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/test-resources/redefine9.xsd?rev=640480&view=auto
==============================================================================
--- 
webservices/commons/trunk/modules/XmlSchema/src/test/test-resources/redefine9.xsd
 (added)
+++ 
webservices/commons/trunk/modules/XmlSchema/src/test/test-resources/redefine9.xsd
 Mon Mar 24 10:46:01 2008
@@ -0,0 +1,28 @@
+<!--
+  ~ 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";>
+        
+  <!-- Relative import -->
+  <xsd:include 
schemaLocation="redefine-include/redefine-import1.xsd"></xsd:include>
+
+</schema>
\ No newline at end of file



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to