You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by di...@apache.org on 2006/10/18 13:16:25 UTC
svn commit: r465209 - in /webservices/axis2/branches/java/1_1/modules:
adb-codegen/ adb-codegen/src/org/apache/axis2/schema/template/
adb-codegen/test-resources/testsuite/
adb-codegen/test/org/apache/axis2/schema/testsuite/
adb/src/org/apache/axis2/dat...
Author: dims
Date: Wed Oct 18 04:16:20 2006
New Revision: 465209
URL: http://svn.apache.org/viewvc?view=rev&rev=465209
Log:
patch from Amila for http://marc.theaimsgroup.com/?l=axis-dev&m=116109186230994&w=2 and AXIS2-1434 - Incorrect WSDL2Java code generation for option "-d none"
Added:
webservices/axis2/branches/java/1_1/modules/adb-codegen/test-resources/testsuite/
webservices/axis2/branches/java/1_1/modules/adb-codegen/test-resources/testsuite/complete.xsd
webservices/axis2/branches/java/1_1/modules/adb-codegen/test/org/apache/axis2/schema/testsuite/
webservices/axis2/branches/java/1_1/modules/adb-codegen/test/org/apache/axis2/schema/testsuite/AbstractTest.java
webservices/axis2/branches/java/1_1/modules/adb-codegen/test/org/apache/axis2/schema/testsuite/CustomElementsTest.java
webservices/axis2/branches/java/1_1/modules/adb-codegen/test/org/apache/axis2/schema/testsuite/IntElementsTest.java
webservices/axis2/branches/java/1_1/modules/adb-codegen/test/org/apache/axis2/schema/testsuite/StringElementsTest.java
Modified:
webservices/axis2/branches/java/1_1/modules/adb-codegen/maven.xml
webservices/axis2/branches/java/1_1/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl
webservices/axis2/branches/java/1_1/modules/adb/src/org/apache/axis2/databinding/utils/ConverterUtil.java
webservices/axis2/branches/java/1_1/modules/codegen/src/org/apache/axis2/wsdl/template/java/NoneDatabindingTemplate.xsl
Modified: webservices/axis2/branches/java/1_1/modules/adb-codegen/maven.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/modules/adb-codegen/maven.xml?view=diff&rev=465209&r1=465208&r2=465209
==============================================================================
--- webservices/axis2/branches/java/1_1/modules/adb-codegen/maven.xml (original)
+++ webservices/axis2/branches/java/1_1/modules/adb-codegen/maven.xml Wed Oct 18 04:16:20 2006
@@ -24,6 +24,7 @@
<j:set var="compiled.classes.dir" value="target/classes"/>
<!-- Theres got to be a better way to do this -->
<j:set var="schema.source.dir" value="test-resources/xsd"/>
+ <j:set var="testsuite.source.dir" value="test-resources/testsuite"/>
<j:set var="schema.output.base.dir" value="target/schema"/>
<j:set var="schema.generated.src.dir" value="${schema.output.base.dir}/src"/>
<j:set var="schema.generated.classes.dir" value="${schema.output.base.dir}/classes"/>
@@ -142,6 +143,16 @@
<classpath refid="maven.dependency.classpath"/>
<classpath location="${compiled.classes.dir}"/>
<arg file="${schema.source.dir}/derived/derivedType-All.xsd"/>
+ <arg file="${schema.generated.src.dir}"/>
+ </java>
+ <!-- ################################################################### -->
+ <!-- All simple derived types xsd -->
+ <ant:echo>Compiling complete.xsd</ant: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}/complete.xsd"/>
<arg file="${schema.generated.src.dir}"/>
</java>
<!-- ################################################################### -->
Modified: webservices/axis2/branches/java/1_1/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl?view=diff&rev=465209&r1=465208&r2=465209
==============================================================================
--- webservices/axis2/branches/java/1_1/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl (original)
+++ webservices/axis2/branches/java/1_1/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl Wed Oct 18 04:16:20 2006
@@ -1765,7 +1765,14 @@
<xsl:variable name="basePropertyType"><xsl:value-of select="@arrayBaseType"/></xsl:variable>
<xsl:choose>
<xsl:when test="@ours">
- <xsl:value-of select="$listName"/>.add(<xsl:value-of select="$basePropertyType"/>.Factory.parse(reader));
+ <xsl:if test="@nillable">
+ if ("true".equals(reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance","nil"))){
+ <xsl:value-of select="$listName"/>.add(null);
+ reader.next();
+ } else {
+ </xsl:if>
+ <xsl:value-of select="$listName"/>.add(<xsl:value-of select="$basePropertyType"/>.Factory.parse(reader));
+ <xsl:if test="@nillable">}</xsl:if>
//loop until we find a start element that is not part of this array
boolean <xsl:value-of select="$loopBoolName"/> = false;
while(!<xsl:value-of select="$loopBoolName"/>){
@@ -1782,7 +1789,14 @@
<xsl:value-of select="$loopBoolName"/> = true;
} else {
if (<xsl:value-of select="$propQName"/>.equals(reader.getName())){
+ <xsl:if test="@nillable">
+ if ("true".equals(reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance","nil"))){
+ <xsl:value-of select="$listName"/>.add(null);
+ reader.next();
+ } else {
+ </xsl:if>
<xsl:value-of select="$listName"/>.add(<xsl:value-of select="$basePropertyType"/>.Factory.parse(reader));
+ <xsl:if test="@nillable">}</xsl:if>
}else{
<xsl:value-of select="$loopBoolName"/> = true;
}
@@ -1884,7 +1898,14 @@
</xsl:when>
<!-- End of Array handling of default class - that is the OMElement -->
<xsl:otherwise>
+ <xsl:if test="@nillable">
+ if ("true".equals(reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance","nil"))){
+ <xsl:value-of select="$listName"/>.add(null);
+ reader.next();
+ } else {
+ </xsl:if>
<xsl:value-of select="$listName"/>.add(reader.getElementText());
+ <xsl:if test="@nillable">}</xsl:if>
//loop until we find a start element that is not part of this array
boolean <xsl:value-of select="$loopBoolName"/> = false;
while(!<xsl:value-of select="$loopBoolName"/>){
@@ -1902,7 +1923,14 @@
<xsl:value-of select="$loopBoolName"/> = true;
} else {
if (<xsl:value-of select="$propQName"/>.equals(reader.getName())){
+ <xsl:if test="@nillable">
+ if ("true".equals(reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance","nil"))){
+ <xsl:value-of select="$listName"/>.add(null);
+ reader.next();
+ } else {
+ </xsl:if>
<xsl:value-of select="$listName"/>.add(reader.getElementText());
+ <xsl:if test="@nillable">}</xsl:if>
}else{
<xsl:value-of select="$loopBoolName"/> = true;
}
@@ -1919,10 +1947,17 @@
</xsl:choose>
</xsl:when>
<xsl:when test="@ours">
- object.set<xsl:value-of select="$javaName"/>(<xsl:value-of select="$propertyType"/>.Factory.parse(reader));
+ <xsl:if test="@nillable">
+ if ("true".equals(reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance","nil"))){
+ object.set<xsl:value-of select="$javaName"/>(null);
+ reader.next();
+ }else{
+ </xsl:if>
+ object.set<xsl:value-of select="$javaName"/>(<xsl:value-of select="$propertyType"/>.Factory.parse(reader));
<xsl:if test="$isType or $anon"> <!-- This is a subelement property to be consumed -->
reader.next();
</xsl:if>
+ <xsl:if test="@nillable">}</xsl:if>
</xsl:when>
<!-- start of any handling. Any can also be @default so we need to handle the any case before default! -->
<xsl:when test="@any">
Added: webservices/axis2/branches/java/1_1/modules/adb-codegen/test-resources/testsuite/complete.xsd
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/modules/adb-codegen/test-resources/testsuite/complete.xsd?view=auto&rev=465209
==============================================================================
--- webservices/axis2/branches/java/1_1/modules/adb-codegen/test-resources/testsuite/complete.xsd (added)
+++ webservices/axis2/branches/java/1_1/modules/adb-codegen/test-resources/testsuite/complete.xsd Wed Oct 18 04:16:20 2006
@@ -0,0 +1,341 @@
+<schema targetNamespace="http://types.echo.services"
+ xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:tns="http://types.echo.services"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ elementFormDefault="qualified">
+
+
+ <!-- test elements for xsd:anyType -->
+ <element name="TestAnyType1">
+ <complexType>
+ <sequence>
+ <element name="testValue" type="xsd:anyType" minOccurs="0" maxOccurs="unbounded"
+ nillable="true"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="TestAnyType2">
+ <complexType>
+ <sequence>
+ <element name="testValue" type="xsd:anyType" minOccurs="0" nillable="true"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="TestAnyType3">
+ <complexType>
+ <sequence>
+ <element name="testValue" type="xsd:anyType" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="TestAnyType4">
+ <complexType>
+ <sequence>
+ <element name="testValue" type="xsd:anyType" minOccurs="0"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="TestAnyType5">
+ <complexType>
+ <sequence>
+ <element name="testValue" type="xsd:anyType" nillable="true" maxOccurs="unbounded"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="TestAnyType6">
+ <complexType>
+ <sequence>
+ <element name="testValue" type="xsd:anyType" nillable="true"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="TestAnyType7">
+ <complexType>
+ <sequence>
+ <element name="testValue" type="xsd:anyType" maxOccurs="unbounded"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="TestAnyType8">
+ <complexType>
+ <sequence>
+ <element name="testValue" type="xsd:anyType"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <!-- generating elemens for primitive types -->
+ <element name="testInt1">
+ <complexType>
+ <sequence>
+ <element name="testValue" minOccurs="0" nillable="true" maxOccurs="unbounded" type="xsd:int"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="testInt2">
+ <complexType>
+ <sequence>
+ <element name="testValue" minOccurs="0" nillable="true" type="xsd:int"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="testInt3">
+ <complexType>
+ <sequence>
+ <element name="testValue" minOccurs="0" maxOccurs="unbounded" type="xsd:int"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="testInt4">
+ <complexType>
+ <sequence>
+ <element name="testValue" minOccurs="0" type="xsd:int"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="testInt5">
+ <complexType>
+ <sequence>
+ <element name="testValue" nillable="true" maxOccurs="unbounded" type="xsd:int"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="testInt6">
+ <complexType>
+ <sequence>
+ <element name="testValue" nillable="true" type="xsd:int"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="testInt7">
+ <complexType>
+ <sequence>
+ <element name="testValue" maxOccurs="unbounded" type="xsd:int"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="testInt8">
+ <complexType>
+ <sequence>
+ <element name="testValue" type="xsd:int"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <!-- generating elemens for string types -->
+ <element name="testString1">
+ <complexType>
+ <sequence>
+ <element name="testValue" minOccurs="0" nillable="true" maxOccurs="unbounded"
+ type="xsd:string"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="testString2">
+ <complexType>
+ <sequence>
+ <element name="testValue" minOccurs="0" nillable="true" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="testString3">
+ <complexType>
+ <sequence>
+ <element name="testValue" minOccurs="0" maxOccurs="unbounded" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="testString4">
+ <complexType>
+ <sequence>
+ <element name="testValue" minOccurs="0" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="testString5">
+ <complexType>
+ <sequence>
+ <element name="testValue" nillable="true" maxOccurs="unbounded" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="testString6">
+ <complexType>
+ <sequence>
+ <element name="testValue" nillable="true" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="testString7">
+ <complexType>
+ <sequence>
+ <element name="testValue" maxOccurs="unbounded" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="testString8">
+ <complexType>
+ <sequence>
+ <element name="testValue" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <!-- generating elemens for custem types -->
+ <element name="testBookInformation1">
+ <complexType>
+ <sequence>
+ <element name="testValue" minOccurs="0" nillable="true" maxOccurs="unbounded"
+ type="tns:BookInformation"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="testBookInformation2">
+ <complexType>
+ <sequence>
+ <element name="testValue" minOccurs="0" nillable="true" type="tns:BookInformation"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="testBookInformation3">
+ <complexType>
+ <sequence>
+ <element name="testValue" minOccurs="0" maxOccurs="unbounded" type="tns:BookInformation"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="testBookInformation4">
+ <complexType>
+ <sequence>
+ <element name="testValue" minOccurs="0" type="tns:BookInformation"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="testBookInformation5">
+ <complexType>
+ <sequence>
+ <element name="testValue" nillable="true" maxOccurs="unbounded" type="tns:BookInformation"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="testBookInformation6">
+ <complexType>
+ <sequence>
+ <element name="testValue" nillable="true" type="tns:BookInformation"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="testBookInformation7">
+ <complexType>
+ <sequence>
+ <element name="testValue" maxOccurs="unbounded" type="tns:BookInformation"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="testBookInformation8">
+ <complexType>
+ <sequence>
+ <element name="testValue" type="tns:BookInformation"/>
+ </sequence>
+ </complexType>
+ </element>
+
+
+ <!-- generating elemens for any types -->
+ <element name="testOM1">
+ <complexType>
+ <sequence>
+ <element name="testValue" minOccurs="0" nillable="true" maxOccurs="unbounded"
+ type="xsd:anyType"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="testOM2">
+ <complexType>
+ <sequence>
+ <element name="testValue" minOccurs="0" nillable="true" type="xsd:anyType"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="testOM3">
+ <complexType>
+ <sequence>
+ <element name="testValue" minOccurs="0" maxOccurs="unbounded" type="xsd:anyType"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="testOM4">
+ <complexType>
+ <sequence>
+ <element name="testValue" minOccurs="0" type="xsd:anyType"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="testOM5">
+ <complexType>
+ <sequence>
+ <element name="testValue" nillable="true" maxOccurs="unbounded" type="xsd:anyType"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="testOM6">
+ <complexType>
+ <sequence>
+ <element name="testValue" nillable="true" type="xsd:anyType"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="testOM7">
+ <complexType>
+ <sequence>
+ <element name="testValue" maxOccurs="unbounded" type="xsd:anyType"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="testOM8">
+ <complexType>
+ <sequence>
+ <element name="testValue" type="xsd:anyType"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <!-- generating elemens for any elements -->
+ <element name="testAny1">
+ <complexType>
+ <sequence>
+ <any minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="testAny2">
+ <complexType>
+ <sequence>
+ <any minOccurs="0"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="testAny3">
+ <complexType>
+ <sequence>
+ <any maxOccurs="unbounded"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="testAny4">
+ <complexType>
+ <sequence>
+ <any/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <complexType name="BookInformation">
+ <sequence>
+ <element name="author" minOccurs="0" maxOccurs="unbounded" type="string"/>
+ <element name="title" type="string"/>
+ </sequence>
+ <attribute name="type" use="required" type="string"/>
+ <attribute name="isbn" use="required" type="string"/>
+ </complexType>
+</schema>
\ No newline at end of file
Added: webservices/axis2/branches/java/1_1/modules/adb-codegen/test/org/apache/axis2/schema/testsuite/AbstractTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/modules/adb-codegen/test/org/apache/axis2/schema/testsuite/AbstractTest.java?view=auto&rev=465209
==============================================================================
--- webservices/axis2/branches/java/1_1/modules/adb-codegen/test/org/apache/axis2/schema/testsuite/AbstractTest.java (added)
+++ webservices/axis2/branches/java/1_1/modules/adb-codegen/test/org/apache/axis2/schema/testsuite/AbstractTest.java Wed Oct 18 04:16:20 2006
@@ -0,0 +1,107 @@
+/*
+ * 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.testsuite;
+
+import junit.framework.TestCase;
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+import services.echo.types.BookInformation;
+
+
+public class AbstractTest extends TestCase {
+
+ protected OMElement getOMElement(){
+ OMFactory fac = OMAbstractFactory.getSOAP12Factory();
+ OMNamespace omNamespace = fac.createOMNamespace("http://test.ws02.com","ns1");
+ OMElement omElement = fac.createOMElement("TestValue", omNamespace);
+ omElement.addChild(fac.createOMText("testString"));
+ return omElement;
+ }
+
+ protected boolean isOMElementsEqual(OMElement omElement1,OMElement omElement2){
+ boolean isEqual = false;
+ if ((omElement1 == null) || (omElement2 == null)){
+ isEqual = (omElement1 == omElement2);
+ } else {
+ isEqual = omElement1.getLocalName().equals(omElement2.getLocalName());
+ }
+ return isEqual;
+ }
+
+ protected boolean assertArrayEqual(Object[] objectArray1, Object[] objectArray2) {
+ boolean isEqual = false;
+ if ((objectArray1 == null) || (objectArray2 == null)) {
+ isEqual = (objectArray1 == objectArray2);
+ } else {
+ // i.e both are not null
+ if (objectArray1.length == objectArray2.length) {
+ isEqual = true;
+ for (int i = 0; i < objectArray1.length; i++) {
+ if (!isObjectContains(objectArray2, objectArray1[i])) {
+ isEqual = false;
+ break;
+ }
+ }
+ }
+ }
+ return isEqual;
+ }
+
+ protected boolean isObjectContains(Object[] objectArray, Object object) {
+ boolean isContain = false;
+ for (int i = 0; i < objectArray.length; i++) {
+ if ((objectArray[i] == null) || (object == null)) {
+ isContain = (objectArray[i] == object);
+ } else {
+ if (object instanceof BookInformation){
+ isContain = isBookInformationObjectsEquals((BookInformation)objectArray[i],(BookInformation)object);
+ } else {
+ isContain = objectArray[i].equals(object);
+ }
+ }
+ if (isContain) {
+ break;
+ }
+ }
+ return isContain;
+ }
+
+ protected boolean isBookInformationObjectsEquals(BookInformation bookInformation1,
+ BookInformation bookInformation2){
+ boolean isEqual;
+ if ((bookInformation1 == null) || (bookInformation2 == null)){
+ isEqual = (bookInformation1 == bookInformation2);
+ } else {
+ isEqual = bookInformation1.getType().equals(bookInformation2.getType()) &&
+ bookInformation1.getTitle().equals(bookInformation2.getTitle()) &&
+ bookInformation1.getIsbn().equals(bookInformation2.getIsbn());
+ }
+ return isEqual;
+ }
+
+ protected BookInformation getBookInformation() {
+ BookInformation bookInformation = new BookInformation();
+ bookInformation.setType("test");
+ bookInformation.setTitle("test");
+ bookInformation.setIsbn("test");
+ return bookInformation;
+ }
+
+
+}
Added: webservices/axis2/branches/java/1_1/modules/adb-codegen/test/org/apache/axis2/schema/testsuite/CustomElementsTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/modules/adb-codegen/test/org/apache/axis2/schema/testsuite/CustomElementsTest.java?view=auto&rev=465209
==============================================================================
--- webservices/axis2/branches/java/1_1/modules/adb-codegen/test/org/apache/axis2/schema/testsuite/CustomElementsTest.java (added)
+++ webservices/axis2/branches/java/1_1/modules/adb-codegen/test/org/apache/axis2/schema/testsuite/CustomElementsTest.java Wed Oct 18 04:16:20 2006
@@ -0,0 +1,245 @@
+/*
+ * 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.testsuite;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import services.echo.types.*;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+import java.io.ByteArrayInputStream;
+
+
+public class CustomElementsTest extends AbstractTest {
+
+ public static final int MIN_EQUALS_ZERO_NILLABLE_TRUE_TEST = 1;
+ public static final int MIN_EQUALS_ZERO_NILLABLE_FALSE_TEST = 2;
+ public static final int MIN_EQUALS_ONE_NILLABLE_TRUE_TEST = 3;
+ public static final int MIN_EQUALS_ONE_NILLABLE_FALSE_TEST = 4;
+
+ public void testCustomArray() {
+
+ BookInformation[] returnObject;
+ System.out.println("minOccurs = 0 and nillable true");
+ try {
+ returnObject = testCustomArray(null, MIN_EQUALS_ZERO_NILLABLE_TRUE_TEST);
+ assertTrue(assertArrayEqual(returnObject,new BookInformation[]{null}));
+ returnObject = testCustomArray(new BookInformation[]{null}, MIN_EQUALS_ZERO_NILLABLE_TRUE_TEST);
+ assertTrue(assertArrayEqual(returnObject,new BookInformation[]{null}));
+ returnObject = testCustomArray(new BookInformation[]{getBookInformation()}, MIN_EQUALS_ZERO_NILLABLE_TRUE_TEST);
+ assertTrue(assertArrayEqual(returnObject,new BookInformation[]{getBookInformation()}));
+ returnObject = testCustomArray(new BookInformation[]{getBookInformation(), null}, MIN_EQUALS_ZERO_NILLABLE_TRUE_TEST);
+ assertTrue(assertArrayEqual(returnObject,new BookInformation[]{getBookInformation(), null}));
+ } catch (Exception e) {
+ fail();
+ }
+ System.out.println("minOccurs = 0 and nillable false");
+ try {
+ returnObject = testCustomArray(null, MIN_EQUALS_ZERO_NILLABLE_FALSE_TEST);
+ assertTrue(assertArrayEqual(returnObject,null));
+ returnObject = testCustomArray(new BookInformation[]{null}, MIN_EQUALS_ZERO_NILLABLE_FALSE_TEST);
+ assertTrue(assertArrayEqual(returnObject,null));
+ returnObject = testCustomArray(new BookInformation[]{getBookInformation()}, MIN_EQUALS_ZERO_NILLABLE_FALSE_TEST);
+ assertTrue(assertArrayEqual(returnObject,new BookInformation[]{getBookInformation()}));
+ returnObject = testCustomArray(new BookInformation[]{getBookInformation(), null}, MIN_EQUALS_ZERO_NILLABLE_FALSE_TEST);
+ assertTrue(assertArrayEqual(returnObject,new BookInformation[]{getBookInformation()}));
+ } catch (Exception e) {
+ fail();
+ }
+ System.out.println("minOccurs = 1 and nillable true");
+ try {
+ returnObject = testCustomArray(null, MIN_EQUALS_ONE_NILLABLE_TRUE_TEST);
+ assertTrue(assertArrayEqual(returnObject,new BookInformation[]{null}));
+ returnObject = testCustomArray(new BookInformation[]{null}, MIN_EQUALS_ONE_NILLABLE_TRUE_TEST);
+ assertTrue(assertArrayEqual(returnObject,new BookInformation[]{null}));
+ returnObject = testCustomArray(new BookInformation[]{getBookInformation()}, MIN_EQUALS_ONE_NILLABLE_TRUE_TEST);
+ assertTrue(assertArrayEqual(returnObject,new BookInformation[]{getBookInformation()}));
+ returnObject = testCustomArray(new BookInformation[]{getBookInformation(), null}, MIN_EQUALS_ONE_NILLABLE_TRUE_TEST);
+ assertTrue(assertArrayEqual(returnObject,new BookInformation[]{getBookInformation(), null}));
+ } catch (Exception e) {
+ fail();
+ }
+
+ System.out.println("minOccurs = 1 and nillable false");
+ try {
+ returnObject = testCustomArray(null, MIN_EQUALS_ONE_NILLABLE_FALSE_TEST);
+ fail();
+ } catch (Exception e) {
+ assertTrue(true);
+ }
+
+ try {
+ returnObject = testCustomArray(new BookInformation[]{null}, MIN_EQUALS_ONE_NILLABLE_FALSE_TEST);
+ fail();
+ } catch (Exception e) {
+ assertTrue(true);
+ }
+
+ try {
+ returnObject = testCustomArray(new BookInformation[]{getBookInformation(), null}, MIN_EQUALS_ONE_NILLABLE_FALSE_TEST);
+ fail();
+ } catch (Exception e) {
+ assertTrue(true);
+ }
+
+ try {
+ returnObject = testCustomArray(new BookInformation[]{getBookInformation()}, MIN_EQUALS_ONE_NILLABLE_FALSE_TEST);
+ assertTrue(assertArrayEqual(returnObject,new BookInformation[]{getBookInformation()}));
+ } catch (Exception e) {
+ fail();
+ }
+
+
+ }
+
+ private BookInformation[] testCustomArray(BookInformation[] innerElement, int type) throws Exception{
+ OMElement omElement;
+ BookInformation[] returnObject = null;
+ switch (type) {
+ case MIN_EQUALS_ZERO_NILLABLE_TRUE_TEST : {
+ TestBookInformation1 testBookInformation = new TestBookInformation1();
+ testBookInformation.setTestValue(innerElement);
+ omElement = testBookInformation.getOMElement(TestBookInformation1.MY_QNAME, OMAbstractFactory.getSOAP12Factory());
+ System.out.println("OMElement ==> " + omElement);
+ XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new ByteArrayInputStream(omElement.toString().getBytes()));
+ returnObject = TestBookInformation1.Factory.parse(reader).getTestValue();
+ break;
+ }
+ case MIN_EQUALS_ZERO_NILLABLE_FALSE_TEST : {
+ TestBookInformation3 testBookInformation = new TestBookInformation3();
+ testBookInformation.setTestValue(innerElement);
+ omElement = testBookInformation.getOMElement(TestBookInformation3.MY_QNAME, OMAbstractFactory.getSOAP12Factory());
+ System.out.println("OMElement ==> " + omElement);
+ XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new ByteArrayInputStream(omElement.toString().getBytes()));
+ returnObject = TestBookInformation3.Factory.parse(reader).getTestValue();
+ break;
+ }
+ case MIN_EQUALS_ONE_NILLABLE_TRUE_TEST : {
+ TestBookInformation5 testBookInformation = new TestBookInformation5();
+ testBookInformation.setTestValue(innerElement);
+ omElement = testBookInformation.getOMElement(TestBookInformation5.MY_QNAME, OMAbstractFactory.getSOAP12Factory());
+ System.out.println("OMElement ==> " + omElement);
+ XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new ByteArrayInputStream(omElement.toString().getBytes()));
+ returnObject = TestBookInformation5.Factory.parse(reader).getTestValue();
+ break;
+ }
+ case MIN_EQUALS_ONE_NILLABLE_FALSE_TEST : {
+ TestBookInformation7 testBookInformation = new TestBookInformation7();
+ testBookInformation.setTestValue(innerElement);
+ omElement = testBookInformation.getOMElement(TestBookInformation7.MY_QNAME, OMAbstractFactory.getSOAP12Factory());
+ System.out.println("OMElement ==> " + omElement);
+ XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new ByteArrayInputStream(omElement.toString().getBytes()));
+ returnObject = TestBookInformation7.Factory.parse(reader).getTestValue();
+ break;
+ }
+ }
+ return returnObject;
+ }
+
+ public void testCustom() {
+ BookInformation returnObject;
+ System.out.println("minOccurs = 0 and nillable true");
+ try {
+ returnObject = testCustom(null, MIN_EQUALS_ZERO_NILLABLE_TRUE_TEST);
+ assertTrue(isBookInformationObjectsEquals(returnObject,null));
+ returnObject = testCustom(getBookInformation(), MIN_EQUALS_ZERO_NILLABLE_TRUE_TEST);
+ assertTrue(isBookInformationObjectsEquals(returnObject,getBookInformation()));
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail();
+ }
+ System.out.println("minOccurs = 0 and nillable false");
+ try {
+ returnObject = testCustom(null, MIN_EQUALS_ZERO_NILLABLE_FALSE_TEST);
+ assertTrue(isBookInformationObjectsEquals(returnObject,null));
+ returnObject = testCustom(getBookInformation(), MIN_EQUALS_ZERO_NILLABLE_FALSE_TEST);
+ assertTrue(isBookInformationObjectsEquals(returnObject,getBookInformation()));
+ } catch (Exception e) {
+ fail();
+ }
+ System.out.println("minOccurs = 1 and nillable true");
+ try {
+ returnObject = testCustom(null, MIN_EQUALS_ONE_NILLABLE_TRUE_TEST);
+ assertTrue(isBookInformationObjectsEquals(returnObject,null));
+ returnObject = testCustom(getBookInformation(), MIN_EQUALS_ONE_NILLABLE_TRUE_TEST);
+ assertTrue(isBookInformationObjectsEquals(returnObject,getBookInformation()));
+ } catch (Exception e) {
+ fail();
+ }
+ System.out.println("minOccurs = 1 and nillable false");
+ try {
+ returnObject = testCustom(null, MIN_EQUALS_ONE_NILLABLE_FALSE_TEST);
+ fail();
+ } catch (Exception e) {
+ assertTrue(true);
+ }
+
+ try {
+ returnObject = testCustom(getBookInformation(), MIN_EQUALS_ONE_NILLABLE_FALSE_TEST);
+ assertTrue(isBookInformationObjectsEquals(returnObject,getBookInformation()));
+ } catch (Exception e) {
+ fail();
+ }
+
+ }
+
+ private BookInformation testCustom(BookInformation innerElement, int type) throws Exception {
+ OMElement omElement;
+ BookInformation returnObject = null;
+ switch (type) {
+ case MIN_EQUALS_ZERO_NILLABLE_TRUE_TEST : {
+ TestBookInformation2 testBookInformation = new TestBookInformation2();
+ testBookInformation.setTestValue(innerElement);
+ omElement = testBookInformation.getOMElement(TestBookInformation2.MY_QNAME, OMAbstractFactory.getSOAP12Factory());
+ System.out.println("OMElement ==> " + omElement);
+ XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new ByteArrayInputStream(omElement.toString().getBytes()));
+ returnObject = TestBookInformation2.Factory.parse(reader).getTestValue();
+ break;
+ }
+ case MIN_EQUALS_ZERO_NILLABLE_FALSE_TEST : {
+ TestBookInformation4 testBookInformation = new TestBookInformation4();
+ testBookInformation.setTestValue(innerElement);
+ omElement = testBookInformation.getOMElement(TestBookInformation4.MY_QNAME, OMAbstractFactory.getSOAP12Factory());
+ System.out.println("OMElement ==> " + omElement);
+ XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new ByteArrayInputStream(omElement.toString().getBytes()));
+ returnObject = TestBookInformation4.Factory.parse(reader).getTestValue();
+ break;
+ }
+ case MIN_EQUALS_ONE_NILLABLE_TRUE_TEST : {
+ TestBookInformation6 testBookInformation = new TestBookInformation6();
+ testBookInformation.setTestValue(innerElement);
+ omElement = testBookInformation.getOMElement(TestBookInformation6.MY_QNAME, OMAbstractFactory.getSOAP12Factory());
+ System.out.println("OMElement ==> " + omElement);
+ XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new ByteArrayInputStream(omElement.toString().getBytes()));
+ returnObject = TestBookInformation6.Factory.parse(reader).getTestValue();
+ break;
+ }
+ case MIN_EQUALS_ONE_NILLABLE_FALSE_TEST : {
+ TestBookInformation8 testBookInformation = new TestBookInformation8();
+ testBookInformation.setTestValue(innerElement);
+ omElement = testBookInformation.getOMElement(TestBookInformation8.MY_QNAME, OMAbstractFactory.getSOAP12Factory());
+ System.out.println("OMElement ==> " + omElement);
+ XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new ByteArrayInputStream(omElement.toString().getBytes()));
+ returnObject = TestBookInformation8.Factory.parse(reader).getTestValue();
+ break;
+ }
+ }
+ return returnObject;
+ }
+
+
+}
Added: webservices/axis2/branches/java/1_1/modules/adb-codegen/test/org/apache/axis2/schema/testsuite/IntElementsTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/modules/adb-codegen/test/org/apache/axis2/schema/testsuite/IntElementsTest.java?view=auto&rev=465209
==============================================================================
--- webservices/axis2/branches/java/1_1/modules/adb-codegen/test/org/apache/axis2/schema/testsuite/IntElementsTest.java (added)
+++ webservices/axis2/branches/java/1_1/modules/adb-codegen/test/org/apache/axis2/schema/testsuite/IntElementsTest.java Wed Oct 18 04:16:20 2006
@@ -0,0 +1,183 @@
+/*
+ * 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.testsuite;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import services.echo.types.*;
+import services.echo.*;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+import java.io.ByteArrayInputStream;
+import java.util.Arrays;
+
+
+public class IntElementsTest extends AbstractTest {
+
+ public static final int MIN_EQUALS_ZERO_NILLABLE_TRUE_TEST = 1;
+ public static final int MIN_EQUALS_ZERO_NILLABLE_FALSE_TEST = 2;
+ public static final int MIN_EQUALS_ONE_NILLABLE_TRUE_TEST = 3;
+ public static final int MIN_EQUALS_ONE_NILLABLE_FALSE_TEST = 4;
+
+ public void testIntArray() {
+ int[] returnObject;
+ System.out.println("minOccurs = 0 nillable true");
+ try {
+ returnObject = testIntArray(null, MIN_EQUALS_ZERO_NILLABLE_TRUE_TEST);
+ assertTrue(Arrays.equals(returnObject, new int[]{0}));
+ returnObject = testIntArray(new int[]{5}, MIN_EQUALS_ZERO_NILLABLE_TRUE_TEST);
+ assertTrue(Arrays.equals(returnObject, new int[]{5}));
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail();
+ }
+ System.out.println("minOccurs = 0 nillable false");
+ try {
+ returnObject = testIntArray(null, MIN_EQUALS_ZERO_NILLABLE_FALSE_TEST);
+ assertTrue(Arrays.equals(returnObject, null));
+ returnObject = testIntArray(new int[]{5}, MIN_EQUALS_ZERO_NILLABLE_FALSE_TEST);
+ assertTrue(Arrays.equals(returnObject, new int[]{5}));
+ } catch (Exception e) {
+ fail();
+ }
+ System.out.println("minOccurs = 1 nillable true");
+ try {
+ returnObject = testIntArray(null, MIN_EQUALS_ONE_NILLABLE_TRUE_TEST);
+ assertTrue(Arrays.equals(returnObject, new int[]{0}));
+ returnObject = testIntArray(new int[]{5}, MIN_EQUALS_ONE_NILLABLE_TRUE_TEST);
+ assertTrue(Arrays.equals(returnObject, new int[]{5}));
+ } catch (Exception e) {
+ fail();
+ }
+
+ System.out.println("minOccurs = 1 nillable false");
+ try {
+ returnObject = testIntArray(null, MIN_EQUALS_ONE_NILLABLE_FALSE_TEST);
+ fail();
+ } catch (Exception e) {
+ assertTrue(true);
+ }
+ try {
+ returnObject = testIntArray(new int[]{5}, MIN_EQUALS_ONE_NILLABLE_FALSE_TEST);
+ assertTrue(Arrays.equals(returnObject, new int[]{5}));
+ } catch (Exception e) {
+ fail();
+ }
+ }
+
+ private int[] testIntArray(int[] innerElement, int type) throws Exception {
+ OMElement omElement;
+ int[] returnObject = null;
+ switch (type) {
+ case MIN_EQUALS_ZERO_NILLABLE_TRUE_TEST : {
+ TestInt1 testInt = new TestInt1();
+ testInt.setTestValue(innerElement);
+ omElement = testInt.getOMElement(TestInt1.MY_QNAME, OMAbstractFactory.getSOAP12Factory());
+ System.out.println("OMElement ==> " + omElement);
+ XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new ByteArrayInputStream(omElement.toString().getBytes()));
+ returnObject = TestInt1.Factory.parse(reader).getTestValue();
+ break;
+ }
+ case MIN_EQUALS_ZERO_NILLABLE_FALSE_TEST : {
+ TestInt3 testInt = new TestInt3();
+ testInt.setTestValue(innerElement);
+ omElement = testInt.getOMElement(TestInt3.MY_QNAME, OMAbstractFactory.getSOAP12Factory());
+ System.out.println("OMElement ==> " + omElement);
+ XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new ByteArrayInputStream(omElement.toString().getBytes()));
+ returnObject = TestInt3.Factory.parse(reader).getTestValue();
+ break;
+ }
+ case MIN_EQUALS_ONE_NILLABLE_TRUE_TEST : {
+ TestInt5 testInt = new TestInt5();
+ testInt.setTestValue(innerElement);
+ omElement = testInt.getOMElement(TestInt5.MY_QNAME, OMAbstractFactory.getSOAP12Factory());
+ System.out.println("OMElement ==> " + omElement);
+ XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new ByteArrayInputStream(omElement.toString().getBytes()));
+ returnObject = TestInt5.Factory.parse(reader).getTestValue();
+ break;
+ }
+ case MIN_EQUALS_ONE_NILLABLE_FALSE_TEST : {
+ TestInt7 testInt = new TestInt7();
+ testInt.setTestValue(innerElement);
+ omElement = testInt.getOMElement(TestInt7.MY_QNAME, OMAbstractFactory.getSOAP12Factory());
+ System.out.println("OMElement ==> " + omElement);
+ XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new ByteArrayInputStream(omElement.toString().getBytes()));
+ returnObject = TestInt7.Factory.parse(reader).getTestValue();
+ break;
+ }
+ }
+ return returnObject;
+ }
+
+
+ public void testInt() {
+ try {
+ assertEquals(testInt(1, MIN_EQUALS_ZERO_NILLABLE_TRUE_TEST), 1);
+ assertEquals(testInt(1, MIN_EQUALS_ZERO_NILLABLE_FALSE_TEST), 1);
+ assertEquals(testInt(1, MIN_EQUALS_ONE_NILLABLE_TRUE_TEST), 1);
+ assertEquals(testInt(1, MIN_EQUALS_ONE_NILLABLE_FALSE_TEST), 1);
+ } catch (Exception e) {
+ fail();
+ }
+
+ }
+
+ public int testInt(int innerElement, int type) throws Exception {
+ OMElement omElement;
+ int returnInt = 0;
+
+ switch (type) {
+ case MIN_EQUALS_ZERO_NILLABLE_TRUE_TEST : {
+ TestInt2 testInt = new TestInt2();
+ testInt.setTestValue(innerElement);
+ omElement = testInt.getOMElement(TestInt2.MY_QNAME, OMAbstractFactory.getSOAP12Factory());
+ System.out.println("OMElement ==> " + omElement);
+ XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new ByteArrayInputStream(omElement.toString().getBytes()));
+ returnInt = TestInt2.Factory.parse(reader).getTestValue();
+ break;
+ }
+ case MIN_EQUALS_ZERO_NILLABLE_FALSE_TEST : {
+ TestInt4 testInt = new TestInt4();
+ testInt.setTestValue(innerElement);
+ omElement = testInt.getOMElement(TestInt4.MY_QNAME, OMAbstractFactory.getSOAP12Factory());
+ System.out.println("OMElement ==> " + omElement);
+ XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new ByteArrayInputStream(omElement.toString().getBytes()));
+ returnInt = TestInt4.Factory.parse(reader).getTestValue();
+ break;
+ }
+ case MIN_EQUALS_ONE_NILLABLE_TRUE_TEST : {
+ TestInt6 testInt = new TestInt6();
+ testInt.setTestValue(innerElement);
+ omElement = testInt.getOMElement(TestInt6.MY_QNAME, OMAbstractFactory.getSOAP12Factory());
+ System.out.println("OMElement ==> " + omElement);
+ XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new ByteArrayInputStream(omElement.toString().getBytes()));
+ returnInt = TestInt6.Factory.parse(reader).getTestValue();
+ break;
+ }
+ case MIN_EQUALS_ONE_NILLABLE_FALSE_TEST : {
+ TestInt8 testInt = new TestInt8();
+ testInt.setTestValue(innerElement);
+ omElement = testInt.getOMElement(TestInt8.MY_QNAME, OMAbstractFactory.getSOAP12Factory());
+ System.out.println("OMElement ==> " + omElement);
+ XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new ByteArrayInputStream(omElement.toString().getBytes()));
+ returnInt = TestInt6.Factory.parse(reader).getTestValue();
+ break;
+ }
+ }
+ return returnInt;
+ }
+}
Added: webservices/axis2/branches/java/1_1/modules/adb-codegen/test/org/apache/axis2/schema/testsuite/StringElementsTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/modules/adb-codegen/test/org/apache/axis2/schema/testsuite/StringElementsTest.java?view=auto&rev=465209
==============================================================================
--- webservices/axis2/branches/java/1_1/modules/adb-codegen/test/org/apache/axis2/schema/testsuite/StringElementsTest.java (added)
+++ webservices/axis2/branches/java/1_1/modules/adb-codegen/test/org/apache/axis2/schema/testsuite/StringElementsTest.java Wed Oct 18 04:16:20 2006
@@ -0,0 +1,255 @@
+/*
+ * 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.testsuite;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import services.echo.types.*;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+import java.io.ByteArrayInputStream;
+
+public class StringElementsTest extends AbstractTest {
+
+ public static final int MIN_EQUALS_ZERO_NILLABLE_TRUE_TEST = 1;
+ public static final int MIN_EQUALS_ZERO_NILLABLE_FALSE_TEST = 2;
+ public static final int MIN_EQUALS_ONE_NILLABLE_TRUE_TEST = 3;
+ public static final int MIN_EQUALS_ONE_NILLABLE_FALSE_TEST = 4;
+
+ public void testStringArray() {
+ System.out.println("Test minOccurs 0 nillable true");
+ String[] returnObject = null;
+
+ try {
+ returnObject = testStringArray(null, MIN_EQUALS_ZERO_NILLABLE_TRUE_TEST);
+ assertTrue(assertArrayEqual(returnObject, new String[]{null}));
+ returnObject = testStringArray(new String[]{null}, MIN_EQUALS_ZERO_NILLABLE_TRUE_TEST);
+ assertTrue(assertArrayEqual(returnObject, new String[]{null}));
+ returnObject = testStringArray(new String[]{"test"}, MIN_EQUALS_ZERO_NILLABLE_TRUE_TEST);
+ assertTrue(assertArrayEqual(returnObject, new String[]{"test"}));
+ returnObject = testStringArray(new String[]{"test", null}, MIN_EQUALS_ZERO_NILLABLE_TRUE_TEST);
+ assertTrue(assertArrayEqual(returnObject, new String[]{"test", null}));
+ } catch (Exception e) {
+ fail();
+ }
+
+ System.out.println("Test minOccurs = 0 nillable false");
+ try {
+ returnObject = testStringArray(null, MIN_EQUALS_ZERO_NILLABLE_FALSE_TEST);
+ assertTrue(assertArrayEqual(returnObject, null));
+ returnObject = testStringArray(new String[]{null}, MIN_EQUALS_ZERO_NILLABLE_FALSE_TEST);
+ assertTrue(assertArrayEqual(returnObject, null));
+ returnObject = testStringArray(new String[]{"test"}, MIN_EQUALS_ZERO_NILLABLE_FALSE_TEST);
+ assertTrue(assertArrayEqual(returnObject, new String[]{"test"}));
+ returnObject = testStringArray(new String[]{"test", null}, MIN_EQUALS_ZERO_NILLABLE_FALSE_TEST);
+ assertTrue(assertArrayEqual(returnObject, new String[]{"test"}));
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail();
+ }
+
+ System.out.println("Test minOccurs = 1 nillable true");
+ try {
+ returnObject = testStringArray(null, MIN_EQUALS_ONE_NILLABLE_TRUE_TEST);
+ assertTrue(assertArrayEqual(returnObject, new String[]{null}));
+ returnObject = testStringArray(new String[]{null}, MIN_EQUALS_ONE_NILLABLE_TRUE_TEST);
+ assertTrue(assertArrayEqual(returnObject, new String[]{null}));
+ returnObject = testStringArray(new String[]{"test"}, MIN_EQUALS_ONE_NILLABLE_TRUE_TEST);
+ assertTrue(assertArrayEqual(returnObject, new String[]{"test"}));
+ returnObject = testStringArray(new String[]{"test", null}, MIN_EQUALS_ONE_NILLABLE_TRUE_TEST);
+ assertTrue(assertArrayEqual(returnObject, new String[]{"test", null}));
+ } catch (Exception e) {
+ fail();
+ }
+
+ System.out.println("Test minOccurs = 1 nillable false");
+
+ try {
+ returnObject = testStringArray(null, MIN_EQUALS_ONE_NILLABLE_FALSE_TEST);
+ fail();
+ } catch (Exception e) {
+ assertTrue(true);
+ }
+
+ try {
+ returnObject = testStringArray(new String[]{null}, MIN_EQUALS_ONE_NILLABLE_FALSE_TEST);
+ fail();
+ } catch (Exception e) {
+ assertTrue(true);
+ }
+
+ try {
+ returnObject = testStringArray(new String[]{"test", null}, MIN_EQUALS_ONE_NILLABLE_FALSE_TEST);
+ fail();
+ } catch (Exception e) {
+ assertTrue(true);
+ }
+
+ try {
+ returnObject = testStringArray(new String[]{"test"}, MIN_EQUALS_ONE_NILLABLE_FALSE_TEST);
+ assertTrue(assertArrayEqual(returnObject, new String[]{"test"}));
+ } catch (Exception e) {
+ fail();
+ }
+
+
+ }
+
+ private String[] testStringArray(String[] innerString, int type) throws Exception {
+
+ String[] returnObject = null;
+ OMElement omElement;
+
+ switch (type) {
+ case MIN_EQUALS_ZERO_NILLABLE_TRUE_TEST : {
+ TestString1 testString = new TestString1();
+ testString.setTestValue(innerString);
+ omElement = testString.getOMElement(TestString1.MY_QNAME, OMAbstractFactory.getSOAP12Factory());
+ System.out.println("OMElement " + omElement);
+ XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new ByteArrayInputStream(omElement.toString().getBytes()));
+ returnObject = TestString1.Factory.parse(reader).getTestValue();
+ break;
+ }
+ case MIN_EQUALS_ZERO_NILLABLE_FALSE_TEST : {
+ TestString3 testString = new TestString3();
+ testString.setTestValue(innerString);
+ omElement = testString.getOMElement(TestString3.MY_QNAME, OMAbstractFactory.getSOAP12Factory());
+ System.out.println("OMElement " + omElement);
+ XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new ByteArrayInputStream(omElement.toString().getBytes()));
+ returnObject = TestString3.Factory.parse(reader).getTestValue();
+ break;
+ }
+ case MIN_EQUALS_ONE_NILLABLE_TRUE_TEST : {
+ TestString5 testString = new TestString5();
+ testString.setTestValue(innerString);
+ omElement = testString.getOMElement(TestString5.MY_QNAME, OMAbstractFactory.getSOAP12Factory());
+ System.out.println("OMElement " + omElement);
+ XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new ByteArrayInputStream(omElement.toString().getBytes()));
+ returnObject = TestString5.Factory.parse(reader).getTestValue();
+ break;
+ }
+ case MIN_EQUALS_ONE_NILLABLE_FALSE_TEST : {
+ TestString7 testString = new TestString7();
+ testString.setTestValue(innerString);
+ omElement = testString.getOMElement(TestString7.MY_QNAME, OMAbstractFactory.getSOAP12Factory());
+ System.out.println("OMElement " + omElement);
+ XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new ByteArrayInputStream(omElement.toString().getBytes()));
+ returnObject = TestString7.Factory.parse(reader).getTestValue();
+ break;
+ }
+
+ }
+ return returnObject;
+ }
+
+ public void testString() {
+
+ String returnObject;
+ System.out.println("Test minOccurs 0 nillable true");
+ try {
+ returnObject = testString(null, MIN_EQUALS_ZERO_NILLABLE_TRUE_TEST);
+ assertEquals(returnObject, null);
+ returnObject = testString("Test", MIN_EQUALS_ZERO_NILLABLE_TRUE_TEST);
+ assertEquals(returnObject, "Test");
+ } catch (Exception e) {
+ fail();
+ }
+
+ System.out.println("Test minOccurs = 0 nillable false");
+ try {
+ returnObject = testString(null, MIN_EQUALS_ZERO_NILLABLE_FALSE_TEST);
+ assertEquals(returnObject, null);
+ returnObject = testString("Test", MIN_EQUALS_ZERO_NILLABLE_FALSE_TEST);
+ assertEquals(returnObject, "Test");
+ } catch (Exception e) {
+ fail();
+ }
+
+ System.out.println("Test minOccurs = 1 nillable true");
+ try {
+ returnObject = testString(null, MIN_EQUALS_ONE_NILLABLE_TRUE_TEST);
+ assertEquals(returnObject, null);
+ returnObject = testString("Test", MIN_EQUALS_ONE_NILLABLE_TRUE_TEST);
+ assertEquals(returnObject, "Test");
+ } catch (Exception e) {
+ fail();
+ }
+ System.out.println("Test minOccurs = 1 nillable false");
+ try {
+ returnObject = testString(null, MIN_EQUALS_ONE_NILLABLE_FALSE_TEST);
+ fail();
+ } catch (Exception e) {
+ assertTrue(true);
+ }
+
+ try {
+ returnObject = testString("Test", MIN_EQUALS_ONE_NILLABLE_FALSE_TEST);
+ assertEquals(returnObject, "Test");
+ } catch (Exception e) {
+ fail();
+ }
+
+ }
+
+ private String testString(String innerString, int type) throws Exception {
+
+ String returnObject = null;
+ OMElement omElement;
+
+ switch (type) {
+ case MIN_EQUALS_ZERO_NILLABLE_TRUE_TEST : {
+ TestString2 testString = new TestString2();
+ testString.setTestValue(innerString);
+ omElement = testString.getOMElement(TestString2.MY_QNAME, OMAbstractFactory.getSOAP12Factory());
+ System.out.println("OMElement " + omElement);
+ XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new ByteArrayInputStream(omElement.toString().getBytes()));
+ returnObject = TestString2.Factory.parse(reader).getTestValue();
+ break;
+ }
+ case MIN_EQUALS_ZERO_NILLABLE_FALSE_TEST : {
+ TestString4 testString = new TestString4();
+ testString.setTestValue(innerString);
+ omElement = testString.getOMElement(TestString4.MY_QNAME, OMAbstractFactory.getSOAP12Factory());
+ System.out.println("OMElement " + omElement);
+ XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new ByteArrayInputStream(omElement.toString().getBytes()));
+ returnObject = TestString4.Factory.parse(reader).getTestValue();
+ break;
+ }
+ case MIN_EQUALS_ONE_NILLABLE_TRUE_TEST : {
+ TestString6 testString = new TestString6();
+ testString.setTestValue(innerString);
+ omElement = testString.getOMElement(TestString6.MY_QNAME, OMAbstractFactory.getSOAP12Factory());
+ System.out.println("OMElement " + omElement);
+ XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new ByteArrayInputStream(omElement.toString().getBytes()));
+ returnObject = TestString6.Factory.parse(reader).getTestValue();
+ break;
+ }
+ case MIN_EQUALS_ONE_NILLABLE_FALSE_TEST : {
+ TestString8 testString = new TestString8();
+ testString.setTestValue(innerString);
+ omElement = testString.getOMElement(TestString8.MY_QNAME, OMAbstractFactory.getSOAP12Factory());
+ System.out.println("OMElement " + omElement);
+ XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new ByteArrayInputStream(omElement.toString().getBytes()));
+ returnObject = TestString8.Factory.parse(reader).getTestValue();
+ break;
+ }
+
+ }
+ return returnObject;
+ }
+
+}
Modified: webservices/axis2/branches/java/1_1/modules/adb/src/org/apache/axis2/databinding/utils/ConverterUtil.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/modules/adb/src/org/apache/axis2/databinding/utils/ConverterUtil.java?view=diff&rev=465209&r1=465208&r2=465209
==============================================================================
--- webservices/axis2/branches/java/1_1/modules/adb/src/org/apache/axis2/databinding/utils/ConverterUtil.java (original)
+++ webservices/axis2/branches/java/1_1/modules/adb/src/org/apache/axis2/databinding/utils/ConverterUtil.java Wed Oct 18 04:16:20 2006
@@ -166,12 +166,13 @@
public static String convertToString(UnsignedLong o) {
return o.toString();
}
- public static String convertToString(QName o) {
- if(o!=null){
- return o.getLocalPart();
- } else {
- return "";
- }
+
+ public static String convertToString(QName o) {
+ if (o != null) {
+ return o.getLocalPart();
+ } else {
+ return "";
+ }
}
public static String convertToString(Object o) {
@@ -299,8 +300,7 @@
return new HexBinary(s);
}
- public static javax.activation.DataHandler convertToBase64Binary(String s)
- {
+ public static javax.activation.DataHandler convertToBase64Binary(String s) {
// reusing the byteArrayDataSource from the Axiom classes
ByteArrayDataSource byteArrayDataSource = new ByteArrayDataSource(
Base64.decode(s)
@@ -308,8 +308,7 @@
return new DataHandler(byteArrayDataSource);
}
- public static javax.activation.DataHandler convertToDataHandler(String s)
- {
+ public static javax.activation.DataHandler convertToDataHandler(String s) {
return convertToBase64Binary(s);
}
@@ -605,8 +604,8 @@
int colon = source.lastIndexOf(":");
//context.getNamespaceURI(source.substring(0, colon));
String localPart = colon < 0 ? source : source.substring(colon + 1);
- String perfix = colon <= 0 ? "" : source.substring(0,colon);
- return new QName(nameSpaceuri, localPart,perfix);
+ String perfix = colon <= 0 ? "" : source.substring(0, colon);
+ return new QName(nameSpaceuri, localPart, perfix);
}
/* ################################################################# */
@@ -661,35 +660,51 @@
Object returnArray = Array.newInstance(baseArrayClass, listSize);
if (int.class.equals(baseArrayClass)) {
for (int i = 0; i < listSize; i++) {
- Array.setInt(returnArray, i, Integer.parseInt(objectList.get(i).toString()));
+ if (objectList.get(i) != null) {
+ Array.setInt(returnArray, i, Integer.parseInt(objectList.get(i).toString()));
+ }
}
} else if (float.class.equals(baseArrayClass)) {
for (int i = 0; i < listSize; i++) {
- Array.setFloat(returnArray, i, Float.parseFloat(objectList.get(i).toString()));
+ if (objectList.get(i) != null) {
+ Array.setFloat(returnArray, i, Float.parseFloat(objectList.get(i).toString()));
+ }
}
} else if (short.class.equals(baseArrayClass)) {
for (int i = 0; i < listSize; i++) {
- Array.setShort(returnArray, i, Short.parseShort(objectList.get(i).toString()));
+ if (objectList.get(i) != null) {
+ Array.setShort(returnArray, i, Short.parseShort(objectList.get(i).toString()));
+ }
}
} else if (long.class.equals(baseArrayClass)) {
for (int i = 0; i < listSize; i++) {
- Array.setLong(returnArray, i, Long.parseLong(objectList.get(i).toString()));
+ if (objectList.get(i) != null) {
+ Array.setLong(returnArray, i, Long.parseLong(objectList.get(i).toString()));
+ }
}
} else if (boolean.class.equals(baseArrayClass)) {
for (int i = 0; i < listSize; i++) {
- Array.setBoolean(returnArray, i, Boolean.getBoolean(objectList.get(i).toString()));
+ if (objectList.get(i) != null) {
+ Array.setBoolean(returnArray, i, Boolean.getBoolean(objectList.get(i).toString()));
+ }
}
} else if (char.class.equals(baseArrayClass)) {
for (int i = 0; i < listSize; i++) {
- Array.setChar(returnArray, i, objectList.get(i).toString().toCharArray()[0]);
+ if (objectList.get(i) != null) {
+ Array.setChar(returnArray, i, objectList.get(i).toString().toCharArray()[0]);
+ }
}
} else if (double.class.equals(baseArrayClass)) {
for (int i = 0; i < listSize; i++) {
- Array.setDouble(returnArray, i, Double.parseDouble(objectList.get(i).toString()));
+ if (objectList.get(i) != null) {
+ Array.setDouble(returnArray, i, Double.parseDouble(objectList.get(i).toString()));
+ }
}
} else if (Calendar.class.equals(baseArrayClass)) {
for (int i = 0; i < listSize; i++) {
- Array.set(returnArray, i, convertToDateTime(objectList.get(i).toString()));
+ if (objectList.get(i) != null) {
+ Array.set(returnArray, i, convertToDateTime(objectList.get(i).toString()));
+ }
}
} else {
ConvertToArbitraryObjectArray(returnArray, baseArrayClass, objectList);
@@ -761,7 +776,7 @@
public static String getStringFromDatahandler(DataHandler dataHandler) {
try {
InputStream inStream;
- if(dataHandler == null) {
+ if (dataHandler == null) {
return "";
}
inStream = dataHandler.getDataSource().getInputStream();
Modified: webservices/axis2/branches/java/1_1/modules/codegen/src/org/apache/axis2/wsdl/template/java/NoneDatabindingTemplate.xsl
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/modules/codegen/src/org/apache/axis2/wsdl/template/java/NoneDatabindingTemplate.xsl?view=diff&rev=465209&r1=465208&r2=465209
==============================================================================
--- webservices/axis2/branches/java/1_1/modules/codegen/src/org/apache/axis2/wsdl/template/java/NoneDatabindingTemplate.xsl (original)
+++ webservices/axis2/branches/java/1_1/modules/codegen/src/org/apache/axis2/wsdl/template/java/NoneDatabindingTemplate.xsl Wed Oct 18 04:16:20 2006
@@ -1,34 +1,34 @@
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
- <xsl:output method="text"/>
-
-
- <!-- ################################################################################# -->
- <!-- ############################ none template!!! ############################## -->
- <xsl:template match="databinders[@dbtype='none']">
- private org.apache.axiom.om.OMElement fromOM(
- org.apache.axiom.om.OMElement param,
- java.lang.Class type,
- java.util.Map extraNamespaces){
- return param;
- }
-
- private org.apache.axiom.om.OMElement toOM(org.apache.axiom.om.OMElement param){
- return param;
- }
-
- private org.apache.axiom.soap.SOAPEnvelope toEnvelope(org.apache.axiom.soap.SOAPFactory factory, org.apache.axiom.om.OMElement param, boolean optimizeContent){
- org.apache.axiom.soap.SOAPEnvelope envelope = factory.getDefaultEnvelope();
- envelope.getBody().addChild(param);
- return envelope;
- }
-
- /**
- * get the default envelope
- */
- private org.apache.axiom.soap.SOAPEnvelope toEnvelope(org.apache.axiom.soap.SOAPFactory factory){
- return factory.getDefaultEnvelope();
- }
-
- </xsl:template>
-
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+ <xsl:output method="text"/>
+
+
+ <!-- ################################################################################# -->
+ <!-- ############################ none template!!! ############################## -->
+ <xsl:template match="databinders[@dbtype='none']">
+ private org.apache.axiom.om.OMElement fromOM(
+ org.apache.axiom.om.OMElement param,
+ java.lang.Class type,
+ java.util.Map extraNamespaces){
+ return param;
+ }
+
+ private org.apache.axiom.om.OMElement toOM(org.apache.axiom.om.OMElement param, boolean optimizeContent){
+ return param;
+ }
+
+ private org.apache.axiom.soap.SOAPEnvelope toEnvelope(org.apache.axiom.soap.SOAPFactory factory, org.apache.axiom.om.OMElement param, boolean optimizeContent){
+ org.apache.axiom.soap.SOAPEnvelope envelope = factory.getDefaultEnvelope();
+ envelope.getBody().addChild(param);
+ return envelope;
+ }
+
+ /**
+ * get the default envelope
+ */
+ private org.apache.axiom.soap.SOAPEnvelope toEnvelope(org.apache.axiom.soap.SOAPFactory factory){
+ return factory.getDefaultEnvelope();
+ }
+
+ </xsl:template>
+
</xsl:stylesheet>
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org