axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ami...@apache.org
Subject svn commit: r576256 - in /webservices/axis2/trunk/java/modules/adb-codegen: ./ src/org/apache/axis2/schema/ src/org/apache/axis2/schema/template/ src/org/apache/axis2/schema/writer/ test-resources/testsuite/ test/org/apache/axis2/schema/innerparticleex...
Date Mon, 17 Sep 2007 05:03:13 GMT
Author: amilas
Date: Sun Sep 16 22:03:11 2007
New Revision: 576256

URL: http://svn.apache.org/viewvc?rev=576256&view=rev
Log:
fixed the issues with the AXIS2_3193.
fixed the union type isssue so that the union can be used with the 
attributes as well

Added:
    webservices/axis2/trunk/java/modules/adb-codegen/test-resources/testsuite/innerParticleExtension.xsd
    webservices/axis2/trunk/java/modules/adb-codegen/test-resources/testsuite/union2.xsd
    webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/innerparticleextension/
    webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/innerparticleextension/TestInnerParticleExtension.java
    webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/union2/
    webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/union2/Union2Test.java
Modified:
    webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/BeanWriterMetaInfoHolder.java
    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/src/org/apache/axis2/schema/writer/JavaBeanWriter.java
    webservices/axis2/trunk/java/modules/adb-codegen/sub-build.xml
    webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/particalmaxoccurs/ParticalMaxOccursTest.java

Modified: webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/BeanWriterMetaInfoHolder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/BeanWriterMetaInfoHolder.java?rev=576256&r1=576255&r2=576256&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/BeanWriterMetaInfoHolder.java
(original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/BeanWriterMetaInfoHolder.java
Sun Sep 16 22:03:11 2007
@@ -61,6 +61,8 @@
     protected String minInclusiveFacet = null;
 
     protected Map memberTypes = new HashMap();
+    protected List memberTypesKeys = new ArrayList();
+
     protected QName itemTypeQName;
     protected String itemTypeClassName;
     protected boolean isUnion;
@@ -809,8 +811,17 @@
         this.memberTypes = memberTypes;
     }
 
+    public List getMemberTypesKeys() {
+        return memberTypesKeys;
+    }
+
+    public void setMemberTypesKeys(List memberTypesKeys) {
+        this.memberTypesKeys = memberTypesKeys;
+    }
+
     public void addMemberType(QName qname,String className){
         this.memberTypes.put(qname,className);
+        this.memberTypesKeys.add(qname);
     }
 
     public boolean isList() {

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?rev=576256&r1=576255&r2=576256&view=diff
==============================================================================
--- 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
Sun Sep 16 22:03:11 2007
@@ -1619,9 +1619,7 @@
                     if (type instanceof XmlSchemaSimpleType) {
                         XmlSchemaSimpleType simpleType = (XmlSchemaSimpleType) type;
 
-                        if ((simpleType != null) &&
-                                (simpleType.getContent() instanceof XmlSchemaSimpleTypeRestriction))
{
-                            // we only support simple type restriction
+                        if (simpleType != null) {
                             if (!isAlreadyProcessed(schemaTypeName)) {
                                 //process simple type
                                 processSimpleSchemaType(simpleType, null, parentSchema, null);

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?rev=576256&r1=576255&r2=576256&view=diff
==============================================================================
--- 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
Sun Sep 16 22:03:11 2007
@@ -637,7 +637,7 @@
                             this.localObject = object;
                   </xsl:for-each>
                       } else {
-                          throw new RuntimeException("Invalid object type");
+                          throw new java.lang.RuntimeException("Invalid object type");
                       }
               }
 
@@ -863,7 +863,7 @@
 
 
                 <!-- write the type attribute if needed -->
-               <xsl:if test="$extension">
+               <xsl:if test="$extension and not(@anon)">
                java.lang.String namespacePrefix = registerPrefix(xmlWriter,"<xsl:value-of
select="$nsuri"/>");
                if ((namespacePrefix != null) &amp;&amp; (namespacePrefix.trim().length()
> 0)){
                    writeAttribute("xsi","http://www.w3.org/2001/XMLSchema-instance","type",
@@ -2243,6 +2243,50 @@
                         throw new org.apache.axis2.databinding.ADBException("Error in parsing
value");
                     }
                }
+
+               public static <xsl:value-of select="$name"/> fromString(java.lang.String
value,
+                                                        java.lang.String namespaceURI){
+                    <xsl:value-of select="$name"/> object = new <xsl:value-of select="$name"/>();
+                    boolean isValueSet = false;
+                    <xsl:for-each select="memberType">
+                      // we have to set the object with the first matching type.
+                      if (!isValueSet) {
+                        <xsl:choose>
+                            <xsl:when test="@nsuri='http://www.w3.org/2001/XMLSchema'">
+                                try {
+                                    java.lang.reflect.Method converterMethod =
+                                            org.apache.axis2.databinding.utils.ConverterUtil.class.getMethod(
+                                                    "convertTo<xsl:value-of select="@shorttypename"/>",
+                                                    new java.lang.Class[]{java.lang.String.class});
+                                    object.setObject(converterMethod.invoke(null, new java.lang.Object[]{value}));
+                                    isValueSet = true;
+                                } catch (java.lang.Exception e) {
+                                }
+                            </xsl:when>
+                            <xsl:otherwise>
+                                try {
+                                   object.setObject(<xsl:value-of select="@type"/>.Factory.fromString(value,
namespaceURI));
+                                   isValueSet = true;
+                                } catch (java.lang.Exception e) {
+                                }
+                            </xsl:otherwise>
+                        </xsl:choose>
+                      }
+                    </xsl:for-each>
+                    return object;
+                }
+
+                public static <xsl:value-of select="$name"/> fromString(javax.xml.stream.XMLStreamReader
xmlStreamReader,
+                                                                    java.lang.String content)
{
+                    if (content.indexOf(":") > -1){
+                        java.lang.String prefix = content.substring(0,content.indexOf(":"));
+                        java.lang.String namespaceUri = xmlStreamReader.getNamespaceContext().getNamespaceURI(prefix);
+                        return <xsl:value-of select="$name"/>.Factory.fromString(content,namespaceUri);
+                    } else {
+                       return <xsl:value-of select="$name"/>.Factory.fromString(content,"");
+                    }
+                }
+
         </xsl:if>
 
         <xsl:if test="$list and $simple">
@@ -2338,6 +2382,17 @@
                     return returnValue;
                 }
 
+                public static <xsl:value-of select="$name"/> fromString(javax.xml.stream.XMLStreamReader
xmlStreamReader,
+                                                                    java.lang.String content)
{
+                    if (content.indexOf(":") > -1){
+                        java.lang.String prefix = content.substring(0,content.indexOf(":"));
+                        java.lang.String namespaceUri = xmlStreamReader.getNamespaceContext().getNamespaceURI(prefix);
+                        return <xsl:value-of select="$name"/>.Factory.fromString(content,namespaceUri);
+                    } else {
+                       return <xsl:value-of select="$name"/>.Factory.fromString(content,"");
+                    }
+                }
+
             </xsl:if>
             <xsl:if test="enumFacet">
                 public static <xsl:value-of select="$name"/> fromValue(<xsl:value-of
select="$propertyType"/> value)
@@ -2378,6 +2433,17 @@
                         throw new java.lang.IllegalArgumentException();
                     }
                 }
+
+                public static <xsl:value-of select="$name"/> fromString(javax.xml.stream.XMLStreamReader
xmlStreamReader,
+                                                                    java.lang.String content)
{
+                    if (content.indexOf(":") > -1){
+                        java.lang.String prefix = content.substring(0,content.indexOf(":"));
+                        java.lang.String namespaceUri = xmlStreamReader.getNamespaceContext().getNamespaceURI(prefix);
+                        return <xsl:value-of select="$name"/>.Factory.fromString(content,namespaceUri);
+                    } else {
+                       return <xsl:value-of select="$name"/>.Factory.fromString(content,"");
+                    }
+                }
             </xsl:if>
 
         </xsl:for-each>
@@ -2481,8 +2547,22 @@
                     </xsl:if>
 
                   }
+                <xsl:if test="$union">
+                  } else {
+                    // i.e this is an union type with out specific xsi:type
+                    java.lang.String content = reader.getElementText();
+                    if (content.indexOf(":") > -1){
+                        // i.e. this could be a qname
+                        prefix = content.substring(0,content.indexOf(":"));
+                        namespaceuri = reader.getNamespaceContext().getNamespaceURI(prefix);
+                        object = <xsl:value-of select="$name"/>.Factory.fromString(content,namespaceuri);
+                    } else {
+                        object = <xsl:value-of select="$name"/>.Factory.fromString(content,"");
+                    }
+                </xsl:if>
 
                 }
+
                 </xsl:if>
 
                 <xsl:if test="$list">
@@ -2550,18 +2630,8 @@
                                     <xsl:otherwise>
                                         <xsl:choose>
                                             <xsl:when test="@ours">
-                                                if (<xsl:value-of select="$attribName"/>.indexOf(":")
> 0) {
-                                                    // this seems to be a Qname so find the
namespace and send
-                                                    prefix = <xsl:value-of select="$attribName"/>.substring(0,
<xsl:value-of select="$attribName"/>.indexOf(":"));
-                                                    namespaceuri = reader.getNamespaceURI(prefix);
-                                                    object.set<xsl:value-of select="$javaName"/>(
-                                                        <xsl:value-of select="@type"/>.Factory.fromString(<xsl:value-of
select="$attribName"/>,namespaceuri));
-                                                } else {
-                                                    // this seems to be not a qname send
and empty namespace incase of it is
-                                                    // check is done in fromString method
-                                                    object.set<xsl:value-of select="$javaName"/>(
-                                                        <xsl:value-of select="@type"/>.Factory.fromString(<xsl:value-of
select="$attribName"/>,""));
-                                                }
+                                                  object.set<xsl:value-of select="$javaName"/>(
+                                                        <xsl:value-of select="@type"/>.Factory.fromString(reader,<xsl:value-of
select="$attribName"/>));
                                             </xsl:when>
                                             <xsl:otherwise>
                                                  object.set<xsl:value-of select="$javaName"/>(
@@ -3395,7 +3465,7 @@
 
                         <xsl:if test="property[not(@attribute)]">  <!-- this if
is needed to skip all this when there are no propoerties-->
                         <xsl:if test="$unordered and not($particleClass)">
-                          <xsl:if test="not(property/enumFacet) and not($choice and $hasParticleType)">
+                          <xsl:if test="not(property/enumFacet) and not($choice or $hasParticleType)">
                              else{
                                         // A start element we are not expecting indicates
an invalid parameter was passed
                                         throw new org.apache.axis2.databinding.ADBException("Unexpected
subelement " + reader.getLocalName());

Modified: webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java?rev=576256&r1=576255&r2=576256&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java
(original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java
Sun Sep 16 22:03:11 2007
@@ -51,7 +51,7 @@
  */
 public class JavaBeanWriter implements BeanWriter {
 
-    private static final Log log = LogFactory.getLog(JavaBeanWriter .class);
+    private static final Log log = LogFactory.getLog(JavaBeanWriter.class);
 
     public static final String WRAPPED_DATABINDING_CLASS_NAME = "WrappedDatabinder";
 
@@ -602,7 +602,7 @@
                                       Map typeMap) {
         Map memberTypes = metainf.getMemberTypes();
         QName memberQName;
-        for (Iterator iter = memberTypes.keySet().iterator(); iter.hasNext();) {
+        for (Iterator iter = metainf.getMemberTypesKeys().iterator(); iter.hasNext();) {
             memberQName = (QName) iter.next();
             String memberClass = (String) memberTypes.get(memberQName);
             if (PrimitiveTypeFinder.isPrimitive(memberClass)) {
@@ -740,6 +740,13 @@
             // set the is particle class
             if (metainf.getParticleTypeStatusForQName(name)){
                 XSLTUtils.addAttribute(model, "particleClassType", "yes", property);
+            }
+
+            // if we have an particle class in a extension class then we have
+            // to consider the whole class has a particle type.
+
+            if (metainf.isHasParticleType()) {
+                XSLTUtils.addAttribute(model, "hasParticleType", "yes", rootElt);
             }
 
             // what happed if this contain attributes

Modified: webservices/axis2/trunk/java/modules/adb-codegen/sub-build.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/sub-build.xml?rev=576256&r1=576255&r2=576256&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/sub-build.xml (original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/sub-build.xml Sun Sep 16 22:03:11 2007
@@ -362,6 +362,22 @@
 			<arg file="${testsuite.source.dir}/rampart.xsd"/>
 			<arg file="${schema.generated.src.dir}"/>
 		</java>
+        <echo>Compiling innerParticleExtension.xsd</echo>
+		<java classname="org.apache.axis2.schema.XSD2Java" fork="true">
+			<jvmarg line="${maven.junit.jvmargs}"/>
+			<classpath refid="maven.dependency.classpath"/>
+			<classpath location="${compiled.classes.dir}"/>
+			<arg file="${testsuite.source.dir}/innerParticleExtension.xsd"/>
+			<arg file="${schema.generated.src.dir}"/>
+		</java>
+        <echo>Compiling union2.xsd</echo>
+		<java classname="org.apache.axis2.schema.XSD2Java" fork="true">
+			<jvmarg line="${maven.junit.jvmargs}"/>
+			<classpath refid="maven.dependency.classpath"/>
+			<classpath location="${compiled.classes.dir}"/>
+			<arg file="${testsuite.source.dir}/union2.xsd"/>
+			<arg file="${schema.generated.src.dir}"/>
+		</java>
     </target>
 
 </project>

Added: webservices/axis2/trunk/java/modules/adb-codegen/test-resources/testsuite/innerParticleExtension.xsd
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/test-resources/testsuite/innerParticleExtension.xsd?rev=576256&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/test-resources/testsuite/innerParticleExtension.xsd
(added)
+++ webservices/axis2/trunk/java/modules/adb-codegen/test-resources/testsuite/innerParticleExtension.xsd
Sun Sep 16 22:03:11 2007
@@ -0,0 +1,28 @@
+<s:schema elementFormDefault="qualified"
+          xmlns:s="http://www.w3.org/2001/XMLSchema"
+          xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+          xmlns:tns="http://tempuri.org/innerparticalextension"
+          targetNamespace="http://tempuri.org/innerparticalextension">
+
+    <s:complexType name="ParentType">
+        <s:choice minOccurs="0" maxOccurs="unbounded">
+            <s:element name="param1" type="s:string"/>
+            <s:element name="param2" type="s:string"/>
+        </s:choice>
+    </s:complexType>
+    <s:element name="TestElement">
+        <s:complexType>
+            <s:sequence>
+                <s:element name="ChildElement" maxOccurs="unbounded">
+                    <s:complexType>
+                        <s:complexContent>
+                            <s:extension base="tns:ParentType">
+                                <s:attribute name="testAttribute" type="s:string"/>
+                            </s:extension>
+                        </s:complexContent>
+                    </s:complexType>
+                </s:element>
+            </s:sequence>
+        </s:complexType>
+    </s:element>
+</s:schema>
\ No newline at end of file

Added: webservices/axis2/trunk/java/modules/adb-codegen/test-resources/testsuite/union2.xsd
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/test-resources/testsuite/union2.xsd?rev=576256&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/test-resources/testsuite/union2.xsd (added)
+++ webservices/axis2/trunk/java/modules/adb-codegen/test-resources/testsuite/union2.xsd Sun
Sep 16 22:03:11 2007
@@ -0,0 +1,34 @@
+<s:schema elementFormDefault="qualified"
+          xmlns:s="http://www.w3.org/2001/XMLSchema"
+          xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+          xmlns:tns="http://tempuri.org/union2"
+          targetNamespace="http://tempuri.org/union2">
+
+    <s:simpleType name="TestUnion1">
+        <s:union memberTypes="s:string s:boolean tns:TestRestriction"/>
+    </s:simpleType>
+    <s:simpleType name="TestRestriction">
+        <s:restriction base="s:string">
+        </s:restriction>
+    </s:simpleType>
+    <s:element name="TestUnionElement1" type="tns:TestUnion1"/>
+    <s:element name="TestUnionElement2">
+        <s:complexType>
+            <s:sequence>
+                <s:element name="param1" type="tns:TestUnion1"/>
+            </s:sequence>
+            <s:attribute name="attribute1" type="tns:TestUnion1"/>
+        </s:complexType>
+    </s:element>
+    <s:simpleType name="TestList1">
+        <s:list itemType="s:string"/>
+    </s:simpleType>
+    <s:element name="TestListElement1">
+        <s:complexType>
+            <s:sequence>
+                <s:element name="param1" type="tns:TestList1"/>
+            </s:sequence>
+            <s:attribute name="attribute1" type="tns:TestList1"/>
+        </s:complexType>
+    </s:element>
+</s:schema>
\ No newline at end of file

Added: webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/innerparticleextension/TestInnerParticleExtension.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/innerparticleextension/TestInnerParticleExtension.java?rev=576256&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/innerparticleextension/TestInnerParticleExtension.java
(added)
+++ webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/innerparticleextension/TestInnerParticleExtension.java
Sun Sep 16 22:03:11 2007
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * 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.
+ */
+package org.apache.axis2.schema.innerparticleextension;
+
+import junit.framework.TestCase;
+import org.tempuri.innerparticalextension.TestElement;
+import org.tempuri.innerparticalextension.ChildElement_type0;
+import org.tempuri.innerparticalextension.ParentTypeChoice;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.util.StAXUtils;
+import org.apache.axis2.databinding.ADBException;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import java.io.ByteArrayInputStream;
+
+public class TestInnerParticleExtension extends TestCase {
+
+    public void testTestElement(){
+        TestElement testElement = new TestElement();
+
+        ChildElement_type0 childElement_type0[] = new ChildElement_type0[2];
+        childElement_type0[0] = new ChildElement_type0();
+        childElement_type0[0].setTestAttribute("Test Attribute");
+
+        ParentTypeChoice[] parentTypeChoices = new ParentTypeChoice[2];
+        parentTypeChoices[0] = new ParentTypeChoice();
+        parentTypeChoices[0].setParam1("param1");
+        parentTypeChoices[1] = new ParentTypeChoice();
+        parentTypeChoices[1].setParam2("param2");
+
+        childElement_type0[0].setParentTypeChoice(parentTypeChoices);
+
+        childElement_type0[1] = new ChildElement_type0();
+        childElement_type0[1].setTestAttribute("Test Attribute");
+
+        parentTypeChoices = new ParentTypeChoice[2];
+        parentTypeChoices[0] = new ParentTypeChoice();
+        parentTypeChoices[0].setParam1("param1");
+        parentTypeChoices[1] = new ParentTypeChoice();
+        parentTypeChoices[1].setParam2("param2");
+
+        childElement_type0[1].setParentTypeChoice(parentTypeChoices);
+
+        testElement.setChildElement(childElement_type0);
+
+        try {
+            OMElement omElement = testElement.getOMElement(TestElement.MY_QNAME, OMAbstractFactory.getOMFactory());
+            String omElementString = omElement.toStringWithConsume();
+            System.out.println("OM Element string ==> " + omElementString);
+            XMLStreamReader xmlReader =
+                    StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
+            TestElement result = TestElement.Factory.parse(xmlReader);
+            assertEquals(result.getChildElement()[0].getTestAttribute(),"Test Attribute");
+            assertEquals(result.getChildElement()[1].getTestAttribute(),"Test Attribute");
+
+            assertEquals(result.getChildElement()[0].getParentTypeChoice()[0].getParam1(),"param1");
+            assertEquals(result.getChildElement()[0].getParentTypeChoice()[1].getParam2(),"param2");
+            assertEquals(result.getChildElement()[1].getParentTypeChoice()[0].getParam1(),"param1");
+            assertEquals(result.getChildElement()[1].getParentTypeChoice()[1].getParam2(),"param2");
+
+        } catch (ADBException e) {
+            fail();
+        } catch (XMLStreamException e) {
+            fail();
+        } catch (Exception e) {
+            fail();
+        }
+
+
+    }
+}

Modified: webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/particalmaxoccurs/ParticalMaxOccursTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/particalmaxoccurs/ParticalMaxOccursTest.java?rev=576256&r1=576255&r2=576256&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/particalmaxoccurs/ParticalMaxOccursTest.java
(original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/particalmaxoccurs/ParticalMaxOccursTest.java
Sun Sep 16 22:03:11 2007
@@ -346,8 +346,10 @@
             assertEquals(resultChoices[0].getParm1(), "Param11");
             assertEquals(resultChoices[1].getParm2(), "Param12");
         } catch (XMLStreamException e) {
+           e.printStackTrace();
             fail();
         } catch (Exception e) {
+           e.printStackTrace();
             fail();
         }
     }

Added: webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/union2/Union2Test.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/union2/Union2Test.java?rev=576256&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/union2/Union2Test.java
(added)
+++ webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/union2/Union2Test.java
Sun Sep 16 22:03:11 2007
@@ -0,0 +1,106 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * 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.
+ */
+package org.apache.axis2.schema.union2;
+
+import org.tempuri.union2.TestUnionElement2;
+import org.tempuri.union2.TestUnion1;
+import org.tempuri.union2.TestListElement1;
+import org.tempuri.union2.TestList1;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.util.StAXUtils;
+import org.apache.axis2.databinding.ADBException;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import junit.framework.TestCase;
+
+import java.io.ByteArrayInputStream;
+
+
+public class Union2Test extends TestCase {
+
+    public void testUnionElement2() {
+        TestUnionElement2 testUnionElement2 = new TestUnionElement2();
+
+        TestUnion1 param1 = new TestUnion1();
+        param1.setObject(Boolean.TRUE);
+        testUnionElement2.setParam1(param1);
+
+        TestUnion1 attribute1 = new TestUnion1();
+        attribute1.setObject("test attribute");
+
+        testUnionElement2.setAttribute1(attribute1);
+
+        try {
+            OMElement omElement = testUnionElement2.getOMElement(
+                    TestUnionElement2.MY_QNAME,
+                    OMAbstractFactory.getOMFactory());
+            String omElementString = omElement.toStringWithConsume();
+            System.out.println("OM Element String ==> " + omElementString);
+            XMLStreamReader xmlReader =
+                    StAXUtils.createXMLStreamReader(
+                            new ByteArrayInputStream(omElementString.getBytes()));
+            TestUnionElement2 result = TestUnionElement2.Factory.parse(xmlReader);
+            assertEquals(result.getParam1().getObject(), Boolean.TRUE);
+            assertEquals(result.getAttribute1().getObject(), "test attribute");
+        } catch (ADBException e) {
+            fail();
+        } catch (XMLStreamException e) {
+            fail();
+        } catch (Exception e) {
+            fail();
+        }
+    }
+
+    public void testListElement2() {
+        TestListElement1 testListElement1 = new TestListElement1();
+
+        TestList1 param1 = new TestList1();
+        param1.setString(new String[]{"param1", "param2"});
+        testListElement1.setParam1(param1);
+
+        TestList1 attribute1 = new TestList1();
+        attribute1.setString(new String[]{"attribute1","attribute2"});
+        testListElement1.setAttribute1(attribute1);
+
+        try {
+            OMElement omElement = testListElement1.getOMElement(
+                    TestListElement1.MY_QNAME,
+                    OMAbstractFactory.getOMFactory());
+            String omElementString = omElement.toStringWithConsume();
+            System.out.println("OM Element String ==> " + omElementString);
+            XMLStreamReader xmlReader =
+                    StAXUtils.createXMLStreamReader(
+                            new ByteArrayInputStream(omElementString.getBytes()));
+            TestListElement1 result = TestListElement1.Factory.parse(xmlReader);
+            assertEquals(result.getParam1().getString()[0], "param1");
+            assertEquals(result.getParam1().getString()[1], "param2");
+            assertEquals(result.getAttribute1().getString()[0], "attribute1");
+            assertEquals(result.getAttribute1().getString()[1], "attribute2");
+        } catch (ADBException e) {
+            e.printStackTrace();
+            fail();
+        } catch (XMLStreamException e) {
+            fail();
+        } catch (Exception e) {
+            fail();
+        }
+
+
+    }
+}



---------------------------------------------------------------------
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