axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ami...@apache.org
Subject svn commit: r505176 - in /webservices/axis2/trunk/java/modules/adb-codegen: src/org/apache/axis2/schema/ src/org/apache/axis2/schema/template/ test-resources/testsuite/ test/org/apache/axis2/schema/extension/ test/org/apache/axis2/schema/list/ test/org...
Date Fri, 09 Feb 2007 04:42:31 GMT
Author: amilas
Date: Thu Feb  8 20:42:30 2007
New Revision: 505176

URL: http://svn.apache.org/viewvc?view=rev&rev=505176
Log:
svn commit add test cases to test both simple type and complex type restrictions

Modified:
    webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/SchemaCompiler.java
    webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl
    webservices/axis2/trunk/java/modules/adb-codegen/test-resources/testsuite/list.xsd
    webservices/axis2/trunk/java/modules/adb-codegen/test-resources/testsuite/restrictions.xsd
    webservices/axis2/trunk/java/modules/adb-codegen/test-resources/testsuite/union.xsd
    webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/extension/ComplexExtenstionTest.java
    webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/list/ListTest.java
    webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/restriction/SimpleRestrictionTest.java
    webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/union/UnionTest.java

Modified: webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/SchemaCompiler.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/SchemaCompiler.java?view=diff&rev=505176&r1=505175&r2=505176
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/SchemaCompiler.java
(original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/SchemaCompiler.java
Thu Feb  8 20:42:30 2007
@@ -1222,6 +1222,13 @@
                         metaInfHolder.addMemberType((QName) qname, (String) memberTypes.get(qname));
                     }
                 }
+
+                // we have to copy the list type data to parent if it is a list
+                if (baseMetaInfoHolder.isList()){
+                    metaInfHolder.setList(true);
+                    metaInfHolder.setItemTypeQName(baseMetaInfoHolder.getItemTypeQName());
+                    metaInfHolder.setItemTypeClassName(baseMetaInfoHolder.getItemTypeClassName());
+                }
                 metaInfHolder.setAsParent(baseMetaInfoHolder);
             }
 

Modified: webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl?view=diff&rev=505176&r1=505175&r2=505176
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl
(original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl
Thu Feb  8 20:42:30 2007
@@ -552,7 +552,7 @@
 
         </xsl:if>
 
-        <xsl:if test="$list" >
+        <xsl:if test="$list and not($restriction) and not($extension)" >
              <xsl:variable name="javaName"><xsl:value-of select="itemtype/@javaname"/></xsl:variable>
              <xsl:variable name="varName">local<xsl:value-of select="itemtype/@javaname"/></xsl:variable>
              <xsl:variable name="varType"><xsl:value-of select="itemtype/@type"/></xsl:variable>
@@ -1447,18 +1447,7 @@
                                          }else{
                                         <xsl:choose>
                                             <xsl:when test="$propertyType='javax.xml.namespace.QName'">
-                                                           java.lang.String prefix ="";
-                                                            java.lang.String namespaceURI
=<xsl:value-of select="$varName"/>.getNamespaceURI();
-                                                            if(namespaceURI !=null){
-                                                               prefix = <xsl:value-of
select="$varName"/>.getPrefix();
-                                                               if (prefix == null) {
-                                                                prefix = org.apache.axis2.databinding.utils.BeanUtil.getUniquePrefix();
-                                                              }
-                                                             xmlWriter.writeNamespace(prefix,namespaceURI
);
-                                                             xmlWriter.writeCharacters(prefix
+ ":"+ org.apache.axis2.databinding.utils.ConverterUtil.convertToString(<xsl:value-of select="$varName"/>));
-                                                            } else {
-                                                               xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(<xsl:value-of
select="$varName"/>));
-                                                            }
+                                                writeQName(<xsl:value-of select="$varName"/>,xmlWriter);
                                             </xsl:when>
                                             <xsl:when test="$propertyType='org.apache.axiom.om.OMElement'">
                                                 <xsl:value-of select="$varName"/>.serialize(xmlWriter);
@@ -1523,11 +1512,12 @@
                                 javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException
{
             java.lang.String namespaceURI = qname.getNamespaceURI();
             if (namespaceURI != null) {
-                java.lang.String prefix = qname.getPrefix();
+                java.lang.String prefix = xmlWriter.getPrefix(namespaceURI);
                 if (prefix == null) {
                     prefix = org.apache.axis2.databinding.utils.BeanUtil.getUniquePrefix();
+                    xmlWriter.writeNamespace(prefix, namespaceURI);
+                    xmlWriter.setPrefix(prefix,namespaceURI);
                 }
-                xmlWriter.writeNamespace(prefix, namespaceURI);
                 xmlWriter.writeCharacters(prefix + ":" + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qname));
             } else {
                 xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qname));
@@ -1935,8 +1925,6 @@
              <xsl:variable name="javaName"><xsl:value-of select="itemtype/@javaname"/></xsl:variable>
              <xsl:variable name="varType"><xsl:value-of select="itemtype/@type"/></xsl:variable>
              <xsl:variable name="ours"><xsl:value-of select="itemtype/@ours"/></xsl:variable>
-             <xsl:variable name="nsuri"><xsl:value-of select="itemtype/@nsuri"/></xsl:variable>
-             <xsl:variable name="originalName"><xsl:value-of select="itemtype/@originalName"/></xsl:variable>
 
             public static <xsl:value-of select="$name"/> fromString(javax.xml.stream.XMLStreamReader
xmlStreamReader, java.lang.String content) {
 
@@ -2042,10 +2030,10 @@
                            <xsl:otherwise>
                                <xsl:choose>
                                    <xsl:when test="$propertyType='javax.xml.namespace.QName'">
-                                       return fromValue(new <xsl:value-of select="$propertyType"/>(namespaceURI,value));
+                                       return fromValue(org.apache.axis2.databinding.utils.ConverterUtil.convertToQName(value,namespaceURI));
                                    </xsl:when>
                                    <xsl:otherwise>
-                                       return fromValue(new <xsl:value-of select="$propertyType"/>(value));
+                                       return fromValue(org.apache.axis2.databinding.utils.ConverterUtil.convertTo<xsl:value-of
select="$shortTypeName"/>(value));
                                    </xsl:otherwise>
                                </xsl:choose>
                            </xsl:otherwise>
@@ -4216,18 +4204,7 @@
                                          }else{
                                         <xsl:choose>
                                             <xsl:when test="$propertyType='javax.xml.namespace.QName'">
-                                                           java.lang.String prefix ="";
-                                                            java.lang.String namespaceURI
=<xsl:value-of select="$varName"/>.getNamespaceURI();
-                                                            if(namespaceURI !=null){
-                                                               prefix = <xsl:value-of
select="$varName"/>.getPrefix();
-                                                               if (prefix == null) {
-                                                                prefix = org.apache.axis2.databinding.utils.BeanUtil.getUniquePrefix();
-                                                              }
-                                                             xmlWriter.writeNamespace(prefix,namespaceURI
);
-                                                             xmlWriter.writeCharacters(prefix
+ ":"+ org.apache.axis2.databinding.utils.ConverterUtil.convertToString(<xsl:value-of select="$varName"/>));
-                                                            } else {
-                                                               xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(<xsl:value-of
select="$varName"/>));
-                                                            }
+                                                writeQName(<xsl:value-of select="$varName"/>,xmlWriter);
                                             </xsl:when>
                                             <xsl:when test="$propertyType='org.apache.axiom.om.OMElement'">
                                                 <xsl:value-of select="$varName"/>.serialize(xmlWriter);

Modified: webservices/axis2/trunk/java/modules/adb-codegen/test-resources/testsuite/list.xsd
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/test-resources/testsuite/list.xsd?view=diff&rev=505176&r1=505175&r2=505176
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/test-resources/testsuite/list.xsd (original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/test-resources/testsuite/list.xsd Thu
Feb  8 20:42:30 2007
@@ -28,4 +28,10 @@
 
     <xs:element name="TestListOursElement" type="tns:TestListOurs"/>
 
+    <xs:simpleType name="SuperTestListString">
+        <xs:restriction base="tns:TestListString"/>
+    </xs:simpleType>
+
+    <xs:element name="SuperTestListStringElement" type="tns:SuperTestListString"/>
+
 </schema>

Modified: webservices/axis2/trunk/java/modules/adb-codegen/test-resources/testsuite/restrictions.xsd
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/test-resources/testsuite/restrictions.xsd?view=diff&rev=505176&r1=505175&r2=505176
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/test-resources/testsuite/restrictions.xsd
(original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/test-resources/testsuite/restrictions.xsd
Thu Feb  8 20:42:30 2007
@@ -1,25 +1,58 @@
 <xsd:schema elementFormDefault="qualified"
             xmlns:xsd="http://www.w3.org/2001/XMLSchema"
             xmlns:tns="http://tempuri.org/"
+            xmlns:ns1="http://google.com"
             targetNamespace="http://tempuri.org/">
 
-    <xsd:simpleType name="NewNormalizedStringType">
-        <xsd:restriction base="xsd:normalizedString"/>
+    <xsd:simpleType name="ChildSimpleType">
+        <xsd:restriction base="xsd:string"/>
     </xsd:simpleType>
-    <xsd:simpleType name="NormalizedStringType">
-        <xsd:restriction base="tns:NewNormalizedStringType"/>
+    <xsd:simpleType name="ParentSimpleType">
+        <xsd:restriction base="tns:ChildSimpleType"/>
     </xsd:simpleType>
-    <xsd:complexType name="BusinessObjectDocumentType">
-        <xsd:attribute name="releaseID" type="tns:NormalizedStringType" use="required"></xsd:attribute>
-        <xsd:attribute name="versionID" type="tns:NormalizedStringType" use="optional"></xsd:attribute>
+    <xsd:complexType name="TestSimpleAttribute">
+        <xsd:attribute name="attrib1" type="tns:ParentSimpleType" use="required"></xsd:attribute>
+        <xsd:attribute name="attrib2" type="tns:ParentSimpleType" use="optional"></xsd:attribute>
+        <xsd:all>
+            <xsd:element name="testElement1" type="xsd:QName"/>
+            <xsd:element name="testElement2" type="xsd:QName"/>
+            <xsd:element name="testElement3" type="xsd:QName"/>
+        </xsd:all>
     </xsd:complexType>
-    <xsd:element name="SimpleRestriction" type="tns:BusinessObjectDocumentType"/>
+
+    <xsd:element name="TestSimpleAttributeElement" type="tns:TestSimpleAttribute"/>
+
+
+    <xsd:simpleType name="NormalSimpleType">
+        <xsd:restriction base="xsd:QName"/>
+    </xsd:simpleType>
+
+    <xsd:simpleType name="EnumerationSimpleType">
+        <xsd:restriction base="xsd:QName">
+            <xsd:enumeration value="ns1:test1"/>
+            <xsd:enumeration value="ns1:test2"/>
+            <xsd:enumeration value="ns1:test3"/>
+        </xsd:restriction>
+    </xsd:simpleType>
+
+    <xsd:simpleType name="ParentNormalSimpleType">
+        <xsd:restriction base = "tns:NormalSimpleType"/>
+    </xsd:simpleType>
+
+    <xsd:simpleType name="ParentEnumerationSimpleType">
+        <xsd:restriction base="tns:EnumerationSimpleType"/>
+    </xsd:simpleType>
+
+    <xsd:element name="NormalSimpleTypeElement" type="tns:ParentNormalSimpleType"/>
+    <xsd:element name="EnumerationSimpleTypeElement" type="tns:ParentEnumerationSimpleType"/>
+
     <xsd:complexType name="BaseRestrictionType">
         <xsd:sequence>
             <xsd:element name="baseTypeElement1" minOccurs="0" type="xsd:string"/>
             <xsd:element name="baseTypeElement2" minOccurs="0" type="xsd:int"/>
         </xsd:sequence>
     </xsd:complexType>
+
     <xsd:complexType name="ParentRestrictionType">
         <xsd:complexContent>
             <xsd:restriction base="tns:BaseRestrictionType">
@@ -31,27 +64,6 @@
         </xsd:complexContent>
     </xsd:complexType>
 
-    <xsd:simpleType name="RSuperChildType">
-        <xsd:restriction base="xsd:string"/>
-    </xsd:simpleType>
-    <xsd:simpleType name="ESuperChildType">
-        <xsd:restriction base="xsd:string">
-            <xsd:enumeration value="test1"/>
-            <xsd:enumeration value="test2"/>
-            <xsd:enumeration value="test3"/>
-        </xsd:restriction>
-    </xsd:simpleType>
-
-    <xsd:simpleType name="USuperChildType">
-        <xsd:union memberTypes="xsd:string xsd:int xsd:boolean"/>
-    </xsd:simpleType>
-
-    <xsd:simpleType name="UChildType">
-        <xsd:restriction base = "tns:USuperChildType"/>
-    </xsd:simpleType>
-
-    <xsd:simpleType name="UParentType">
-        <xsd:restriction base="tns:UChildType"/>
-    </xsd:simpleType>
+    <xsd:element name="ComplexRestrictionTypeTestElement" type="tns:ParentRestrictionType"/>
 
 </xsd:schema>

Modified: webservices/axis2/trunk/java/modules/adb-codegen/test-resources/testsuite/union.xsd
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/test-resources/testsuite/union.xsd?view=diff&rev=505176&r1=505175&r2=505176
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/test-resources/testsuite/union.xsd (original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/test-resources/testsuite/union.xsd Thu
Feb  8 20:42:30 2007
@@ -35,5 +35,11 @@
             </s:sequence>
         </s:complexType>
     </s:element>
+
+    <s:simpleType name="UnionQNameTest">
+        <s:union memberTypes="s:QName s:string"/>
+    </s:simpleType>
+
+    <s:element name="UnionQNameTestElement" type="s0:UnionQNameTest"/>
     
 </s:schema>

Modified: webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/extension/ComplexExtenstionTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/extension/ComplexExtenstionTest.java?view=diff&rev=505176&r1=505175&r2=505176
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/extension/ComplexExtenstionTest.java
(original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/extension/ComplexExtenstionTest.java
Thu Feb  8 20:42:30 2007
@@ -16,9 +16,44 @@
 package org.apache.axis2.schema.extension;
 
 import junit.framework.TestCase;
+import test.axis2.apache.org.TestComplexElement;
+import test.axis2.apache.org.ExtendedComplexType;
+import test.axis2.apache.org.FullName;
+import test.axis2.apache.org.BaseType;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.util.StAXUtils;
+
+import javax.xml.stream.XMLStreamReader;
+import java.io.ByteArrayInputStream;
 
 public class ComplexExtenstionTest extends TestCase {
-    public void testComplexExtension(){
-        
+
+    public void testComplexExtension() {
+
+        TestComplexElement testComplexElement = new TestComplexElement();
+        ExtendedComplexType extendedComplexType = new ExtendedComplexType();
+        testComplexElement.setTestComplexElement(extendedComplexType);
+        extendedComplexType.setFirst("Amila");
+        extendedComplexType.setMiddle("Chinthaka");
+        extendedComplexType.setLast("Suriarachchi");
+        extendedComplexType.setParentElement1("test1");
+        extendedComplexType.setParentElement2("test2");
+
+        OMElement omElement = testComplexElement.getOMElement(TestComplexElement.MY_QNAME,
OMAbstractFactory.getSOAP11Factory());
+        try {
+            String omElementString = omElement.toStringWithConsume();
+            System.out.println("OM String ==> " + omElementString);
+            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
+            TestComplexElement result = TestComplexElement.Factory.parse(xmlReader);
+            assertEquals(result.getTestComplexElement().getFirst(),"Amila");
+            assertEquals(result.getTestComplexElement().getMiddle(),"Chinthaka");
+            assertEquals(result.getTestComplexElement().getLast(),"Suriarachchi");
+            assertEquals(result.getTestComplexElement().getParentElement1(),"test1");
+            assertEquals(result.getTestComplexElement().getParentElement2(),"test2");
+        } catch (Exception e) {
+            assertFalse(true);
+        }
+
     }
 }

Modified: webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/list/ListTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/list/ListTest.java?view=diff&rev=505176&r1=505175&r2=505176
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/list/ListTest.java
(original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/list/ListTest.java
Thu Feb  8 20:42:30 2007
@@ -69,7 +69,6 @@
             assertEquals(result.getTestListQNameElement().getQName()[1],testListQName.getQName()[1]);
             assertEquals(result.getTestListQNameElement().getQName()[2],testListQName.getQName()[2]);
         } catch (Exception e) {
-            e.printStackTrace();
             assertFalse(true);
         }
     }
@@ -97,8 +96,29 @@
             assertEquals(result.getTestListOursElement().getTestString()[1].getTestString(),testString2.getTestString());
             assertEquals(result.getTestListOursElement().getTestString()[2].getTestString(),testString3.getTestString());
         } catch (Exception e) {
-            e.printStackTrace();
             assertFalse(true);
         }
     }
+
+    public void testListSuper(){
+
+        SuperTestListStringElement superTestListStringElement = new SuperTestListStringElement();
+        SuperTestListString superTestListString = new SuperTestListString();
+        superTestListStringElement.setSuperTestListStringElement(superTestListString);
+        superTestListString.setString(new String[]{"test1","test2","test3"});
+
+        OMElement omElement = superTestListStringElement.getOMElement(SuperTestListStringElement.MY_QNAME,
+                OMAbstractFactory.getOMFactory());
+        try {
+            String omElementString = omElement.toStringWithConsume();
+            System.out.println("OM Element ==> " + omElementString);
+            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
+            SuperTestListStringElement result = SuperTestListStringElement.Factory.parse(xmlReader);
+            assertEquals(superTestListString.getString()[0],result.getSuperTestListStringElement().getString()[0]);
+        } catch (Exception e) {
+            assertTrue(false);
+        }
+    }
+
+
 }

Modified: webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/restriction/SimpleRestrictionTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/restriction/SimpleRestrictionTest.java?view=diff&rev=505176&r1=505175&r2=505176
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/restriction/SimpleRestrictionTest.java
(original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/restriction/SimpleRestrictionTest.java
Thu Feb  8 20:42:30 2007
@@ -19,44 +19,112 @@
 import org.apache.axiom.om.OMAbstractFactory;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.util.StAXUtils;
-import org.apache.axis2.databinding.types.NormalizedString;
-import org.tempuri.BusinessObjectDocumentType;
-import org.tempuri.NormalizedStringType;
-import org.tempuri.SimpleRestriction;
+import org.tempuri.*;
 
+import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamReader;
 import java.io.ByteArrayInputStream;
 
 
 public class SimpleRestrictionTest extends TestCase {
 
-    public void testSimpleRestriction() {
+    public void testSimpleAttribute() {
 
-        SimpleRestriction simpleRestriction = new SimpleRestriction();
-        BusinessObjectDocumentType businessObjectDocumentType = new BusinessObjectDocumentType();
-        simpleRestriction.setSimpleRestriction(businessObjectDocumentType);
-        NormalizedStringType releaseID = new NormalizedStringType();
-        NormalizedStringType versionID = new NormalizedStringType();
-        businessObjectDocumentType.setReleaseID(releaseID);
-        businessObjectDocumentType.setVersionID(versionID);
-        releaseID.setNewNormalizedStringType(new NormalizedString("releaseID"));
-        versionID.setNewNormalizedStringType(new NormalizedString("versionID"));
+        TestSimpleAttributeElement testSimpleAttributeElement = new TestSimpleAttributeElement();
 
-        OMElement omElement = simpleRestriction.getOMElement(SimpleRestriction.MY_QNAME,
-                OMAbstractFactory.getOMFactory());
+        TestSimpleAttribute testSimpleAttribute = new TestSimpleAttribute();
+        testSimpleAttributeElement.setTestSimpleAttributeElement(testSimpleAttribute);
+        testSimpleAttribute.setTestElement1(new QName("http://wso2.com","test1"));
+        testSimpleAttribute.setTestElement2(new QName("http://wso2.com","test2"));
+        testSimpleAttribute.setTestElement3(new QName("http://wso2.com","test3"));
 
+        ParentSimpleType parentSimpleType1 = new ParentSimpleType();
+        parentSimpleType1.setChildSimpleType("test simple type 1");
+
+        ParentSimpleType parentSimpleType2 = new ParentSimpleType();
+        parentSimpleType2.setChildSimpleType("test simple type 2");
+
+        testSimpleAttribute.setAttrib1(parentSimpleType1);
+        testSimpleAttribute.setAttrib2(parentSimpleType2);
+
+        OMElement omElement = testSimpleAttributeElement.getOMElement(TestSimpleAttributeElement.MY_QNAME,OMAbstractFactory.getOMFactory());
+        try {
+            String omElementString = omElement.toStringWithConsume();
+            System.out.println("OM String ==> " + omElementString);
+            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
+            TestSimpleAttributeElement result = TestSimpleAttributeElement.Factory.parse(xmlReader);
+            assertEquals(result.getTestSimpleAttributeElement().getTestElement1(),testSimpleAttribute.getTestElement1());
+            assertEquals(result.getTestSimpleAttributeElement().getTestElement2(),testSimpleAttribute.getTestElement2());
+            assertEquals(result.getTestSimpleAttributeElement().getTestElement3(),testSimpleAttribute.getTestElement3());
+            assertEquals(result.getTestSimpleAttributeElement().getAttrib1().getChildSimpleType(),parentSimpleType1.getChildSimpleType());
+            assertEquals(result.getTestSimpleAttributeElement().getAttrib2().getChildSimpleType(),parentSimpleType2.getChildSimpleType());
+        } catch (Exception e) {
+            assertFalse(true);
+        }
+
+    }
+
+    public void testNormalSimpleTypeElement(){
+
+        NormalSimpleTypeElement normalSimpleTypeElement = new NormalSimpleTypeElement();
+        ParentNormalSimpleType parentNormalSimpleType = new ParentNormalSimpleType();
+        normalSimpleTypeElement.setNormalSimpleTypeElement(parentNormalSimpleType);
+        parentNormalSimpleType.setNormalSimpleType(new QName("http://wso2.com","test"));
+
+        OMElement omElement = normalSimpleTypeElement.getOMElement(NormalSimpleTypeElement.MY_QNAME,OMAbstractFactory.getOMFactory());
         try {
             String omElementString = omElement.toStringWithConsume();
-            System.out.println("OM Element ==>" + omElement);
+            System.out.println("OM Element ==> " + omElementString);
             XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
-            SimpleRestriction newSimpleRestriction = SimpleRestriction.Factory.parse(xmlReader);
-            assertEquals(newSimpleRestriction.getSimpleRestriction().getVersionID().toString(),
"versionID");
-            assertEquals(newSimpleRestriction.getSimpleRestriction().getReleaseID().toString(),
"releaseID");
+            NormalSimpleTypeElement result = NormalSimpleTypeElement.Factory.parse(xmlReader);
+            assertEquals(result.getNormalSimpleTypeElement().getNormalSimpleType(),parentNormalSimpleType.getNormalSimpleType());
         } catch (Exception e) {
             assertFalse(true);
         }
 
 
     }
+
+    public void testEnumerationSimpleTypeElement(){
+
+            EnumerationSimpleTypeElement enumerationSimpleTypeElement = new EnumerationSimpleTypeElement();
+            enumerationSimpleTypeElement.setEnumerationSimpleTypeElement(ParentEnumerationSimpleType.value1);
+
+            OMElement omElement = enumerationSimpleTypeElement.getOMElement(EnumerationSimpleTypeElement.MY_QNAME,OMAbstractFactory.getOMFactory());
+            try {
+                String omElementString = omElement.toStringWithConsume();
+                System.out.println("OM Element ==> " + omElementString);
+                XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
+                EnumerationSimpleTypeElement result = EnumerationSimpleTypeElement.Factory.parse(xmlReader);
+                assertEquals(result.getEnumerationSimpleTypeElement().getValue(),ParentEnumerationSimpleType.value1.getValue());
+            } catch (Exception e) {
+                assertFalse(true);
+            }
+
+        }
+
+    public void testComplexRestrictionType(){
+
+        ComplexRestrictionTypeTestElement complexRestrictionTypeTestElement = new ComplexRestrictionTypeTestElement();
+        ParentRestrictionType parentRestrictionType = new ParentRestrictionType();
+        complexRestrictionTypeTestElement.setComplexRestrictionTypeTestElement(parentRestrictionType);
+        parentRestrictionType.setBaseTypeElement1("test 1");
+        parentRestrictionType.setBaseTypeElement2(5);
+
+        OMElement omElement = complexRestrictionTypeTestElement.getOMElement(ComplexRestrictionTypeTestElement.MY_QNAME,OMAbstractFactory.getOMFactory());
+            try {
+                String omElementString = omElement.toStringWithConsume();
+                System.out.println("OM Element ==> " + omElementString);
+                XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
+                ComplexRestrictionTypeTestElement result = ComplexRestrictionTypeTestElement.Factory.parse(xmlReader);
+                assertEquals(result.getComplexRestrictionTypeTestElement().getBaseTypeElement1(),parentRestrictionType.getBaseTypeElement1());
+                assertEquals(result.getComplexRestrictionTypeTestElement().getBaseTypeElement2(),parentRestrictionType.getBaseTypeElement2());
+            } catch (Exception e) {
+                e.printStackTrace();
+                assertFalse(true);
+            }
+
+    }
+
 
 }

Modified: webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/union/UnionTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/union/UnionTest.java?view=diff&rev=505176&r1=505175&r2=505176
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/union/UnionTest.java
(original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/union/UnionTest.java
Thu Feb  8 20:42:30 2007
@@ -23,6 +23,7 @@
 import org.apache.axis2.databinding.types.URI;
 
 import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamException;
 import javax.xml.namespace.QName;
 import java.io.ByteArrayInputStream;
 
@@ -86,8 +87,21 @@
         return null;
     }
 
-    public void testQName(){
-        QName qname = new QName("http://www.google.com","test","tns");
-        System.out.println(qname);
+    public void testUnionQName(){
+        UnionQNameTestElement unionQNameTestElement = new UnionQNameTestElement();
+        UnionQNameTest unionQNameTest = new UnionQNameTest();
+        unionQNameTestElement.setUnionQNameTestElement(unionQNameTest);
+        unionQNameTest.setObject(new QName("http://www.google.com","test"));
+
+        OMElement omElement = unionQNameTestElement.getOMElement(UnionQNameTestElement.MY_QNAME,OMAbstractFactory.getOMFactory());
+        try {
+            String omElementString = omElement.toStringWithConsume();
+            System.out.println("OM Element ==> " + omElementString);
+            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
+            UnionQNameTestElement result = UnionQNameTestElement.Factory.parse(xmlReader);
+            assertEquals(unionQNameTest.getObject(),result.getUnionQNameTestElement().getObject());
+        } catch (Exception e) {
+            assertTrue(false);
+        }
     }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org


Mime
View raw message