You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by am...@apache.org on 2007/02/19 14:02:56 UTC
svn commit: r509189 - in /webservices/axis2/trunk/java/modules: adb-codegen/
adb-codegen/src/org/apache/axis2/schema/
adb-codegen/test-resources/testsuite/
adb-codegen/test/org/apache/axis2/schema/populate/simple/
adb-codegen/test/org/apache/axis2/sche...
Author: amilas
Date: Mon Feb 19 05:02:54 2007
New Revision: 509189
URL: http://svn.apache.org/viewvc?view=rev&rev=509189
Log:
change the date time serialization format to GMT format.
change the parse method to parse times with local time (eg +05:30)
change the schema compiler to get element references from the correct schema
Added:
webservices/axis2/trunk/java/modules/adb-codegen/test-resources/testsuite/element_references.xsd
webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/references/
webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/references/ElementReferenceTest.java
Modified:
webservices/axis2/trunk/java/modules/adb-codegen/maven.xml
webservices/axis2/trunk/java/modules/adb-codegen/pom.xml
webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/ExtensionUtility.java
webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/SchemaCompiler.java
webservices/axis2/trunk/java/modules/adb-codegen/test-resources/testsuite/restrictions.xsd
webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/populate/simple/SimpleTypeDatePopulateTest.java
webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/populate/simple/SimpleTypeDateTimePopulateTest.java
webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/populate/simple/SimpleTypeTimePopulateTest.java
webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/restriction/SimpleRestrictionTest.java
webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/types/Time.java
webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/ConverterUtil.java
webservices/axis2/trunk/java/modules/adb/test/org/apache/axis2/databinding/utils/ConverterUtilTest.java
Modified: webservices/axis2/trunk/java/modules/adb-codegen/maven.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/maven.xml?view=diff&rev=509189&r1=509188&r2=509189
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/maven.xml (original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/maven.xml Mon Feb 19 05:02:54 2007
@@ -228,6 +228,17 @@
<arg file="${testsuite.source.dir}/list.xsd"/>
<arg file="${schema.generated.src.dir}"/>
</java>
+
+ <!-- ################################################################### -->
+ <!-- All simple derived types xsd -->
+ <ant:echo>Compiling element_references.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}/element_references.xsd"/>
+ <arg file="${schema.generated.src.dir}"/>
+ </java>
<!-- ################################################################### -->
Modified: webservices/axis2/trunk/java/modules/adb-codegen/pom.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/pom.xml?view=diff&rev=509189&r1=509188&r2=509189
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/pom.xml (original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/pom.xml Mon Feb 19 05:02:54 2007
@@ -321,6 +321,16 @@
<arg file="${testsuite.source.dir}/list.xsd"/>
<arg file="${schema.generated.src.dir}"/>
</java>
+ <!-- ################################################################### -->
+ <!-- All simple derived types xsd -->
+ <ant:echo>Compiling element_references.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}/element_references.xsd"/>
+ <arg file="${schema.generated.src.dir}"/>
+ </java>
</tasks>
Modified: webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/ExtensionUtility.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/ExtensionUtility.java?view=diff&rev=509189&r1=509188&r2=509189
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/ExtensionUtility.java (original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/ExtensionUtility.java Mon Feb 19 05:02:54 2007
@@ -323,7 +323,7 @@
*
* @param eltSchemaType
*/
- private static void populateClassName(XmlSchemaType eltSchemaType,
+ private static void populateClassName(XmlSchemaType eltSchemaType,
TypeMapper typeMap,
String opName,
XmlSchemaElement xmlSchemaElement) {
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=509189&r1=509188&r2=509189
==============================================================================
--- 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 Mon Feb 19 05:02:54 2007
@@ -1809,12 +1809,14 @@
return typeByName;
}
- private XmlSchemaElement getReferencedElement(XmlSchema parentSchema, QName referencedQName) {
- XmlSchemaElement refElement = parentSchema.getElementByName(referencedQName);
+ private XmlSchemaElement getReferencedElement(XmlSchema parentSchema, QName referencedQName)
+ throws SchemaCompilationException {
+ XmlSchema schema = resolveParentSchema(referencedQName,parentSchema);
+ XmlSchemaElement refElement = schema.getElementByName(referencedQName);
if (refElement == null) {
// The referenced element seems to come from an imported
// schema.
- XmlSchemaObjectCollection includes = parentSchema.getIncludes();
+ XmlSchemaObjectCollection includes = schema.getIncludes();
if (includes != null) {
Iterator tempIterator = includes.getIterator();
while (tempIterator.hasNext()) {
Added: webservices/axis2/trunk/java/modules/adb-codegen/test-resources/testsuite/element_references.xsd
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/test-resources/testsuite/element_references.xsd?view=auto&rev=509189
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/test-resources/testsuite/element_references.xsd (added)
+++ webservices/axis2/trunk/java/modules/adb-codegen/test-resources/testsuite/element_references.xsd Mon Feb 19 05:02:54 2007
@@ -0,0 +1,33 @@
+<schema elementFormDefault="qualified"
+ targetNamespace="http://www.americanexpress.com/wsdl/ctn/utilities/atb"
+ xmlns:tns="http://www.americanexpress.com/wsdl/ctn/utilities/atb"
+ xmlns="http://www.w3.org/2001/XMLSchema">
+ <import namespace="http://www.americanexpress.com/schemas/ctn/utilities/atb"/>
+
+ <element name="checkEligibility1">
+ <complexType>
+ <sequence>
+ <element ref="tns:atb-request-check-eligibility"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <element name="checkEligibility2">
+ <complexType>
+ <sequence>
+ <element ref="tns:atb-request-check-eligibility" minOccurs="0" maxOccurs="5"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="atb-request-check-eligibility">
+ <complexType>
+ <sequence>
+ <element minOccurs="0" name="cardNumber" type="string"/>
+ <element minOccurs="0" name="nameAsOnCard" type="string"/>
+ <element minOccurs="0" name="expirationDate" type="string"/>
+ <element minOccurs="0" name="yearOfRedemption" type="int"/>
+ <element minOccurs="0" name="clientId" type="string"/>
+ </sequence>
+ </complexType>
+ </element>
+</schema>
\ No newline at end of file
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=509189&r1=509188&r2=509189
==============================================================================
--- 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 Mon Feb 19 05:02:54 2007
@@ -101,5 +101,46 @@
</xs:restriction>
</xs:simpleType>
+ <xsd:complexType name="Person">
+ <xsd:sequence>
+ <xsd:element name="name" type="xsd:string"></xsd:element>
+ <xsd:element name="age" type="xsd:int"></xsd:element>
+ <xsd:element name="hairColor">
+ <xsd:simpleType>
+ <xsd:restriction base="xsd:string">
+ <xsd:enumeration value="black"></xsd:enumeration>
+ <xsd:enumeration value="brown"></xsd:enumeration>
+ <xsd:enumeration value="blonde"></xsd:enumeration>
+ <xsd:enumeration value="gray"></xsd:enumeration>
+ </xsd:restriction>
+ </xsd:simpleType>
+ </xsd:element>
+ <xsd:element name="birthDate" type="xsd:date"></xsd:element>
+ <xsd:element name="address" type="tns:Address" maxOccurs="1" minOccurs="0"></xsd:element>
+ </xsd:sequence>
+ </xsd:complexType>
+
+
+
+ <xsd:complexType name="Address">
+ <xsd:sequence>
+ <xsd:element name="line1" type="xsd:string"></xsd:element>
+ <xsd:element name="line2" type="xsd:string" maxOccurs="1"
+ minOccurs="0">
+ </xsd:element>
+ <xsd:element name="city" type="xsd:string"></xsd:element>
+ <xsd:element name="state" type="xsd:string"></xsd:element>
+ <xsd:element name="zip">
+ <xsd:simpleType>
+ <xsd:restriction base="xsd:string">
+ <xsd:pattern value="[A-Z]"></xsd:pattern>
+ </xsd:restriction>
+ </xsd:simpleType>
+ </xsd:element>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:element name="PersonElement" type="tns:Person"/>
+
</xsd:schema>
Modified: webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/populate/simple/SimpleTypeDatePopulateTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/populate/simple/SimpleTypeDatePopulateTest.java?view=diff&rev=509189&r1=509188&r2=509189
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/populate/simple/SimpleTypeDatePopulateTest.java (original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/populate/simple/SimpleTypeDatePopulateTest.java Mon Feb 19 05:02:54 2007
@@ -3,6 +3,7 @@
import org.apache.axis2.databinding.utils.ConverterUtil;
import java.util.Date;
+import java.util.TimeZone;
import java.text.SimpleDateFormat;
/*
* Copyright 2004,2005 The Apache Software Foundation.
@@ -40,7 +41,8 @@
// force others to implement this method
public void testPopulate() throws Exception {
- SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-ddZ");
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'Z'");
+ simpleDateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
Date date = null;
for (int i = 0; i < values.length; i++) {
Modified: webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/populate/simple/SimpleTypeDateTimePopulateTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/populate/simple/SimpleTypeDateTimePopulateTest.java?view=diff&rev=509189&r1=509188&r2=509189
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/populate/simple/SimpleTypeDateTimePopulateTest.java (original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/populate/simple/SimpleTypeDateTimePopulateTest.java Mon Feb 19 05:02:54 2007
@@ -3,6 +3,7 @@
import org.apache.axis2.databinding.utils.ConverterUtil;
import java.util.Calendar;
+import java.util.TimeZone;
import java.text.SimpleDateFormat;
/*
* Copyright 2004,2005 The Apache Software Foundation.
@@ -21,8 +22,8 @@
*/
public class SimpleTypeDateTimePopulateTest extends AbstractSimplePopulater{
- private String values[] ={"2002-10-10T12:00:00+0500",
- "2000-12-31T11:59:59-0500",
+ private String values[] ={"2002-10-10T12:00:00+05:00",
+ "2000-12-31T11:59:59-05:00",
"2002-10-10T07:00:00Z"
};
private String xmlString[] = {
@@ -34,7 +35,8 @@
public void testPopulate() throws Exception {
Calendar calendar;
- SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
+ simpleDateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
for (int i = 0; i < values.length; i++) {
calendar = ConverterUtil.convertToDateTime(values[i]);
checkValue(xmlString[i],simpleDateFormat.format(calendar.getTime()));
Modified: webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/populate/simple/SimpleTypeTimePopulateTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/populate/simple/SimpleTypeTimePopulateTest.java?view=diff&rev=509189&r1=509188&r2=509189
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/populate/simple/SimpleTypeTimePopulateTest.java (original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/populate/simple/SimpleTypeTimePopulateTest.java Mon Feb 19 05:02:54 2007
@@ -21,7 +21,7 @@
public class SimpleTypeTimePopulateTest extends AbstractSimplePopulater{
private String values[]= {
"13:20:00Z",
- "23:59:59+0530",
+ "23:59:59+05:30",
"23:59:59"
};
private String xmlString[] = {
Added: webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/references/ElementReferenceTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/references/ElementReferenceTest.java?view=auto&rev=509189
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/references/ElementReferenceTest.java (added)
+++ webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/references/ElementReferenceTest.java Mon Feb 19 05:02:54 2007
@@ -0,0 +1,98 @@
+/*
+ * 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.references;
+
+import com.americanexpress.www.wsdl.ctn.utilities.atb.AtbRequestCheckEligibility_type0;
+import com.americanexpress.www.wsdl.ctn.utilities.atb.CheckEligibility1;
+import com.americanexpress.www.wsdl.ctn.utilities.atb.CheckEligibility2;
+import junit.framework.TestCase;
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.util.StAXUtils;
+
+import javax.xml.stream.XMLStreamReader;
+import java.io.ByteArrayInputStream;
+
+
+public class ElementReferenceTest extends TestCase {
+
+ public void testSingleElementReference() {
+ CheckEligibility1 echCheckEligibility1 = new CheckEligibility1();
+ AtbRequestCheckEligibility_type0 atbRequestCheckEligibility = new AtbRequestCheckEligibility_type0();
+ echCheckEligibility1.setAtbRequestCheckEligibility(atbRequestCheckEligibility);
+ atbRequestCheckEligibility.setCardNumber("carnumber");
+ atbRequestCheckEligibility.setClientId("clientid");
+ atbRequestCheckEligibility.setExpirationDate("date");
+ atbRequestCheckEligibility.setNameAsOnCard("cardname");
+ atbRequestCheckEligibility.setYearOfRedemption(2);
+
+ OMElement omElement = echCheckEligibility1.getOMElement(CheckEligibility1.MY_QNAME, OMAbstractFactory.getSOAP12Factory());
+
+ try {
+ String omElementString = omElement.toStringWithConsume();
+ XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
+ CheckEligibility1 result = CheckEligibility1.Factory.parse(xmlReader);
+ assertEquals(result.getAtbRequestCheckEligibility().getCardNumber(), "carnumber");
+ assertEquals(result.getAtbRequestCheckEligibility().getClientId(), "clientid");
+ assertEquals(result.getAtbRequestCheckEligibility().getExpirationDate(), "date");
+ assertEquals(result.getAtbRequestCheckEligibility().getNameAsOnCard(), "cardname");
+ assertEquals(result.getAtbRequestCheckEligibility().getYearOfRedemption(), 2);
+ } catch (Exception e) {
+ fail();
+ }
+ }
+
+ public void testMultipleElementReference() {
+ CheckEligibility2 echCheckEligibility2 = new CheckEligibility2();
+ AtbRequestCheckEligibility_type0[] atbRequestCheckEligibility = new AtbRequestCheckEligibility_type0[2];
+ echCheckEligibility2.setAtbRequestCheckEligibility(atbRequestCheckEligibility);
+
+ atbRequestCheckEligibility[0] = new AtbRequestCheckEligibility_type0();
+ atbRequestCheckEligibility[0].setCardNumber("carnumber");
+ atbRequestCheckEligibility[0].setClientId("clientid");
+ atbRequestCheckEligibility[0].setExpirationDate("date");
+ atbRequestCheckEligibility[0].setNameAsOnCard("cardname");
+ atbRequestCheckEligibility[0].setYearOfRedemption(2);
+
+ atbRequestCheckEligibility[1] = new AtbRequestCheckEligibility_type0();
+ atbRequestCheckEligibility[1].setCardNumber("carnumber");
+ atbRequestCheckEligibility[1].setClientId("clientid");
+ atbRequestCheckEligibility[1].setExpirationDate("date");
+ atbRequestCheckEligibility[1].setNameAsOnCard("cardname");
+ atbRequestCheckEligibility[1].setYearOfRedemption(2);
+
+ OMElement omElement = echCheckEligibility2.getOMElement(CheckEligibility2.MY_QNAME, OMAbstractFactory.getSOAP12Factory());
+
+ try {
+ String omElementString = omElement.toStringWithConsume();
+ XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
+ CheckEligibility2 result = CheckEligibility2.Factory.parse(xmlReader);
+ assertEquals(result.getAtbRequestCheckEligibility()[0].getCardNumber(), "carnumber");
+ assertEquals(result.getAtbRequestCheckEligibility()[0].getClientId(), "clientid");
+ assertEquals(result.getAtbRequestCheckEligibility()[0].getExpirationDate(), "date");
+ assertEquals(result.getAtbRequestCheckEligibility()[0].getNameAsOnCard(), "cardname");
+ assertEquals(result.getAtbRequestCheckEligibility()[0].getYearOfRedemption(), 2);
+
+ assertEquals(result.getAtbRequestCheckEligibility()[1].getCardNumber(), "carnumber");
+ assertEquals(result.getAtbRequestCheckEligibility()[1].getClientId(), "clientid");
+ assertEquals(result.getAtbRequestCheckEligibility()[1].getExpirationDate(), "date");
+ assertEquals(result.getAtbRequestCheckEligibility()[1].getNameAsOnCard(), "cardname");
+ assertEquals(result.getAtbRequestCheckEligibility()[1].getYearOfRedemption(), 2);
+ } catch (Exception e) {
+ fail();
+ }
+ }
+}
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=509189&r1=509188&r2=509189
==============================================================================
--- 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 Mon Feb 19 05:02:54 2007
@@ -20,10 +20,15 @@
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.util.StAXUtils;
import org.tempuri.*;
+import org.tempuri.HairColor_type0;
+import org.tempuri.Person;
+import org.tempuri.Address;
+import org.tempuri.Zip_type1;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamReader;
import java.io.ByteArrayInputStream;
+import java.util.Date;
public class SimpleRestrictionTest extends TestCase {
@@ -34,9 +39,9 @@
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"));
+ 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");
@@ -47,37 +52,37 @@
testSimpleAttribute.setAttrib1(parentSimpleType1);
testSimpleAttribute.setAttrib2(parentSimpleType2);
- OMElement omElement = testSimpleAttributeElement.getOMElement(TestSimpleAttributeElement.MY_QNAME,OMAbstractFactory.getOMFactory());
+ 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());
+ 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(){
+ public void testNormalSimpleTypeElement() {
NormalSimpleTypeElement normalSimpleTypeElement = new NormalSimpleTypeElement();
ParentNormalSimpleType parentNormalSimpleType = new ParentNormalSimpleType();
normalSimpleTypeElement.setNormalSimpleTypeElement(parentNormalSimpleType);
- parentNormalSimpleType.setNormalSimpleType(new QName("http://wso2.com","test"));
+ parentNormalSimpleType.setNormalSimpleType(new QName("http://wso2.com", "test"));
- OMElement omElement = normalSimpleTypeElement.getOMElement(NormalSimpleTypeElement.MY_QNAME,OMAbstractFactory.getOMFactory());
+ OMElement omElement = normalSimpleTypeElement.getOMElement(NormalSimpleTypeElement.MY_QNAME, OMAbstractFactory.getOMFactory());
try {
String omElementString = omElement.toStringWithConsume();
System.out.println("OM Element ==> " + omElementString);
XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
NormalSimpleTypeElement result = NormalSimpleTypeElement.Factory.parse(xmlReader);
- assertEquals(result.getNormalSimpleTypeElement().getNormalSimpleType(),parentNormalSimpleType.getNormalSimpleType());
+ assertEquals(result.getNormalSimpleTypeElement().getNormalSimpleType(), parentNormalSimpleType.getNormalSimpleType());
} catch (Exception e) {
assertFalse(true);
}
@@ -85,25 +90,25 @@
}
- public void testEnumerationSimpleTypeElement(){
+ 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);
- }
+ 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(){
+ }
+
+ public void testComplexRestrictionType() {
ComplexRestrictionTypeTestElement complexRestrictionTypeTestElement = new ComplexRestrictionTypeTestElement();
ParentRestrictionType parentRestrictionType = new ParentRestrictionType();
@@ -111,18 +116,60 @@
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);
- }
+ 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);
+ }
+
+ }
+
+ public void testPersonElement() {
+ PersonElement personElement = new PersonElement();
+ Person person = new Person();
+ personElement.setPersonElement(person);
+ person.setName("amila");
+ person.setAge(23);
+ person.setHairColor(HairColor_type0.black);
+ Date date = new Date();
+ person.setBirthDate(date);
+ Address address = new Address();
+ person.setAddress(address);
+ address.setCity("Galle");
+ address.setLine1("line1");
+ address.setLine2("line2");
+ address.setState("state");
+ Zip_type1 ziptype = new Zip_type1();
+ address.setZip(ziptype);
+ ziptype.setZip("C");
+
+ OMElement omElement = personElement.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()));
+ PersonElement result = PersonElement.Factory.parse(xmlReader);
+ assertEquals(result.getPersonElement().getName(),"amila");
+ assertEquals(result.getPersonElement().getAge(),23);
+ assertEquals(result.getPersonElement().getHairColor(),HairColor_type0.black);
+ Address resultAddress = result.getPersonElement().getAddress();
+ assertEquals(resultAddress.getCity(),"Galle");
+ assertEquals(resultAddress.getLine1(),"line1");
+ assertEquals(resultAddress.getLine2(),"line2");
+ assertEquals(resultAddress.getState(),"state");
+ assertEquals(resultAddress.getZip().getZip(),"C");
+ } catch (Exception e) {
+ e.printStackTrace();
+ assertFalse(true);
+ }
+
}
Modified: webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/types/Time.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/types/Time.java?view=diff&rev=509189&r1=509188&r2=509189
==============================================================================
--- webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/types/Time.java (original)
+++ webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/types/Time.java Mon Feb 19 05:02:54 2007
@@ -38,7 +38,11 @@
* component of the timestamp
*/
private static SimpleDateFormat zulu =
- new SimpleDateFormat("HH:mm:ss.SSSZ");
+ new SimpleDateFormat("HH:mm:ss.SSS'Z'");
+
+ static {
+ zulu.setTimeZone(TimeZone.getTimeZone("GMT"));
+ }
/**
* Initializes with a Calender. Year, month and date are ignored.
@@ -112,7 +116,14 @@
} else if ((rest.indexOf("+") > 0) || (rest.indexOf("-") > 0)) {
// this is given in a general time zione
- simpleDateFormat = new SimpleDateFormat("HH:mm:ss.SSSZ");
+ simpleDateFormat = new SimpleDateFormat("HH:mm:ss.SSSz");
+ if (rest.lastIndexOf("+") > 0) {
+ source = source.substring(0, source.lastIndexOf("+")) + "GMT" +
+ rest.substring(rest.lastIndexOf("+"));
+ } else if (rest.lastIndexOf("-") > 0) {
+ source = source.substring(0, source.lastIndexOf("-")) + "GMT" +
+ rest.substring(rest.lastIndexOf("-"));
+ }
} else {
// i.e it does not have time zone
simpleDateFormat = new SimpleDateFormat("HH:mm:ss.SSS");
@@ -125,7 +136,8 @@
simpleDateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
} else if (rest.startsWith("+") || rest.startsWith("-")) {
// this is given in a general time zione
- simpleDateFormat = new SimpleDateFormat("HH:mm:ssZ");
+ simpleDateFormat = new SimpleDateFormat("HH:mm:ssz");
+ source = source.substring(0, 8) + "GMT" + rest;
} else {
throw new NumberFormatException("in valid time zone attribute");
}
Modified: webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/ConverterUtil.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/ConverterUtil.java?view=diff&rev=509189&r1=509188&r2=509189
==============================================================================
--- webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/ConverterUtil.java (original)
+++ webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/ConverterUtil.java Mon Feb 19 05:02:54 2007
@@ -122,14 +122,16 @@
public static String convertToString(Date value) {
// lexical form of the date is '-'? yyyy '-' mm '-' dd zzzzzz?
- // we have to serialize it with the timezone
- SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-ddZ");
+ // we have to serialize it with the GMT timezone
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'Z'");
+ simpleDateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
return simpleDateFormat.format(value);
}
public static String convertToString(Calendar value) {
// lexical form of the calendar is '-'? yyyy '-' mm '-' dd 'T' hh ':' mm ':' ss ('.' s+)? (zzzzzz)?
- SimpleDateFormat zulu = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
+ SimpleDateFormat zulu = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
+ zulu.setTimeZone(TimeZone.getTimeZone("GMT"));
// Sun JDK bug http://developer.java.sun.com/developer/bugParade/bugs/4229798.html
return zulu.format(value.getTime());
}
@@ -241,7 +243,7 @@
return Integer.parseInt(s);
}
- public static BigDecimal convertToBigDecimal(String s){
+ public static BigDecimal convertToBigDecimal(String s) {
return new BigDecimal(s);
}
@@ -369,7 +371,9 @@
simpleDateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
} else if (restpart.startsWith("+") || restpart.startsWith("-")) {
// this is a specific time format string
- simpleDateFormat = new SimpleDateFormat("yyyy-MM-ddZ");
+ simpleDateFormat = new SimpleDateFormat("yyyy-MM-ddz");
+ // have to add the GMT part to process the message
+ source = source.substring(0, 10) + "GMT" + restpart;
} else {
throw new RuntimeException("In valid string sufix");
}
@@ -543,9 +547,17 @@
simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
simpleDateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
- } else if ((rest.indexOf("+") > 0) || (rest.indexOf("-") > 0)) {
+ } else if ((rest.lastIndexOf("+") > 0) || (rest.lastIndexOf("-") > 0)) {
// this is given in a general time zione
- simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
+ simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSz");
+ if (rest.lastIndexOf("+") > 0) {
+ source = source.substring(0, source.lastIndexOf("+")) + "GMT" +
+ rest.substring(rest.lastIndexOf("+"));
+ } else if (rest.lastIndexOf("-") > 0) {
+ source = source.substring(0, source.lastIndexOf("-")) + "GMT" +
+ rest.substring(rest.lastIndexOf("-"));
+ }
+
} else {
// i.e it does not have time zone
simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS");
@@ -559,6 +571,7 @@
} else if (rest.startsWith("+") || rest.startsWith("-")) {
// this is given in a general time zione
simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
+ source = source.substring(0, 19) + "GMT" + rest;
} else {
throw new NumberFormatException("in valid time zone attribute");
}
Modified: webservices/axis2/trunk/java/modules/adb/test/org/apache/axis2/databinding/utils/ConverterUtilTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb/test/org/apache/axis2/databinding/utils/ConverterUtilTest.java?view=diff&rev=509189&r1=509188&r2=509189
==============================================================================
--- webservices/axis2/trunk/java/modules/adb/test/org/apache/axis2/databinding/utils/ConverterUtilTest.java (original)
+++ webservices/axis2/trunk/java/modules/adb/test/org/apache/axis2/databinding/utils/ConverterUtilTest.java Mon Feb 19 05:02:54 2007
@@ -90,12 +90,12 @@
System.out.println("String ==> " + "2007-02-15T14:54:29.399");
System.out.println("calendar ==> " + simpleDateFormat.format(calendar.getTime()));
- calendar = ConverterUtil.convertToDateTime("2007-02-15T14:54:29+0530");
- System.out.println("String ==> " + "2007-02-15T14:54:29+0530");
+ calendar = ConverterUtil.convertToDateTime("2007-02-15T14:54:29+05:30");
+ System.out.println("String ==> " + "2007-02-15T14:54:29+05:30");
System.out.println("calendar ==> " + simpleDateFormat.format(calendar.getTime()));
- calendar = ConverterUtil.convertToDateTime("2007-02-15T14:54:29.399+0530");
- System.out.println("String ==> " + "2007-02-15T14:54:29.399+0530");
+ calendar = ConverterUtil.convertToDateTime("2007-02-15T14:54:29.399+05:30");
+ System.out.println("String ==> " + "2007-02-15T14:54:29.399+05:30");
System.out.println("calendar ==> " + simpleDateFormat.format(calendar.getTime()));
calendar = ConverterUtil.convertToDateTime("2007-02-15T14:54:29Z");
@@ -106,8 +106,8 @@
System.out.println("String ==> " + "2007-02-15T14:54:29.399Z");
System.out.println("calendar ==> " + simpleDateFormat.format(calendar.getTime()));
- calendar = ConverterUtil.convertToDateTime("2007-02-15T14:54:29.399-0530");
- System.out.println("String ==> " + "2007-02-15T14:54:29.399-0530");
+ calendar = ConverterUtil.convertToDateTime("2007-02-15T14:54:29.399-05:30");
+ System.out.println("String ==> " + "2007-02-15T14:54:29.399-05:30");
System.out.println("calendar ==> " + simpleDateFormat.format(calendar.getTime()));
@@ -140,8 +140,8 @@
// System.out.println("String ==> " + "2007-02-15+0530");
// System.out.println("calendar ==> " + simpleDateFormat.format(date));
- date = ConverterUtil.convertToDate("2007-02-15-1230");
- System.out.println("String ==> " + "2007-02-15-1230");
+ date = ConverterUtil.convertToDate("2007-02-15-12:30");
+ System.out.println("String ==> " + "2007-02-15-12:30");
System.out.println("calendar ==> " + simpleDateFormat.format(date));
}
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org