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/03/29 12:48:59 UTC

svn commit: r523667 - 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/booleantest/ adb/src/org/apache/axis2/databinding/utils/

Author: amilas
Date: Thu Mar 29 03:48:52 2007
New Revision: 523667

URL: http://svn.apache.org/viewvc?view=rev&rev=523667
Log:
fixed the issue AXIS2-2373 and AXIS2-2360

Added:
    webservices/axis2/trunk/java/modules/adb-codegen/test-resources/testsuite/boolean.xsd
    webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/booleantest/
    webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/booleantest/BooleanTest.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/SchemaCompiler.java
    webservices/axis2/trunk/java/modules/adb-codegen/test-resources/testsuite/testattribute.xsd
    webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/ConverterUtil.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=523667&r1=523666&r2=523667
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/maven.xml (original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/maven.xml Thu Mar 29 03:48:52 2007
@@ -262,6 +262,18 @@
         </java>
 
         <!-- ################################################################### -->
+        <!-- All simple derived types xsd -->
+        <ant:echo>Compiling boolean.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}/boolean.xsd"/>
+            <arg file="${schema.generated.src.dir}"/>
+        </java>
+
+
+        <!-- ################################################################### -->
         <!-- Compile the generated classes -->
         <javac destdir="${schema.generated.classes.dir}" srcdir="${schema.generated.src.dir}">
             <classpath refid="maven.dependency.classpath"></classpath>

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=523667&r1=523666&r2=523667
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/pom.xml (original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/pom.xml Thu Mar 29 03:48:52 2007
@@ -352,9 +352,19 @@
             <arg file="${testsuite.source.dir}/testattribute.xsd"/>
             <arg file="${schema.generated.src.dir}"/>
         </java>
+        <!-- ################################################################### -->
+        <!-- All simple derived types xsd -->
+        <ant:echo>Compiling boolean.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}/boolean.xsd"/>
+            <arg file="${schema.generated.src.dir}"/>
+        </java>
 
 
-			  </tasks>
+        </tasks>
             </configuration>
             <goals>
               <goal>run</goal>

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=523667&r1=523666&r2=523667
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/SchemaCompiler.java (original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/SchemaCompiler.java Thu Mar 29 03:48:52 2007
@@ -89,6 +89,10 @@
     public static final String ANY_ELEMENT_FIELD_NAME = "extraElement";
     public static final String EXTRA_ATTRIBUTE_FIELD_NAME = "extraAttributes";
 
+    public static final String USE_OPTIONAL = "optional";
+    public static final String USE_REQUIRED = "required";
+    public static final String USE_NONE = "none";
+
     private static int typeCounter = 0;
 
     /**
@@ -1507,8 +1511,8 @@
 
                     // add optional attribute status if set
                     String use = att.getUse().getValue();
-                    if (use.indexOf("optional") != -1) {
-                        metainf.addtStatus(att.getQName(), SchemaConstants.OPTIONAL_TYPE);
+                    if (USE_NONE.equals(use) || USE_OPTIONAL.equals(use)){
+                       metainf.addtStatus(att.getQName(), SchemaConstants.OPTIONAL_TYPE);
                     }
 
                     String className = findClassName(schemaTypeName, false);
@@ -1535,7 +1539,7 @@
                                     SchemaConstants.ATTRIBUTE_TYPE);
                             // add optional attribute status if set
                             String use = att.getUse().getValue();
-                            if (use.indexOf("optional") != -1) {
+                            if (USE_NONE.equals(use) || USE_OPTIONAL.equals(use)) {
                                 metainf.addtStatus(att.getQName(), SchemaConstants.OPTIONAL_TYPE);
                             }
                         }
@@ -1578,7 +1582,7 @@
                                     type.toString(), SchemaConstants.ATTRIBUTE_TYPE);
                             // add optional attribute status if set
                             String use = att.getUse().getValue();
-                            if (use.indexOf("optional") != -1) {
+                            if (USE_NONE.equals(use) || USE_OPTIONAL.equals(use)) {
                                 metainf.addtStatus(att.getQName(), SchemaConstants.OPTIONAL_TYPE);
                             }
                         }
@@ -1603,7 +1607,7 @@
                         SchemaConstants.ATTRIBUTE_TYPE);
                 // add optional attribute status if set
                 String use = att.getUse().getValue();
-                if (use.indexOf("optional") != -1) {
+                if (USE_NONE.equals(use) || USE_OPTIONAL.equals(use)) {
                     metainf.addtStatus(att.getQName(), SchemaConstants.OPTIONAL_TYPE);
                 }
             }

Added: webservices/axis2/trunk/java/modules/adb-codegen/test-resources/testsuite/boolean.xsd
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/test-resources/testsuite/boolean.xsd?view=auto&rev=523667
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/test-resources/testsuite/boolean.xsd (added)
+++ webservices/axis2/trunk/java/modules/adb-codegen/test-resources/testsuite/boolean.xsd Thu Mar 29 03:48:52 2007
@@ -0,0 +1,15 @@
+<xs:schema elementFormDefault="qualified"
+           xmlns:xs="http://www.w3.org/2001/XMLSchema"
+           xmlns:tns="http://tempuri.org/attribute"
+           targetNamespace="http://tempuri.org/attribute">
+
+    <xs:element name="TestBoolean1" type="xs:boolean"/>
+    <xs:element name="TestBoolean2" >
+        <xs:complexType>
+            <xs:sequence>
+                <xs:element name="param1" type="xs:boolean"/>
+            </xs:sequence>
+            <xs:attribute name="attribute1" type="xs:boolean"/>
+        </xs:complexType>
+    </xs:element>
+</xs:schema>
\ No newline at end of file

Modified: webservices/axis2/trunk/java/modules/adb-codegen/test-resources/testsuite/testattribute.xsd
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/test-resources/testsuite/testattribute.xsd?view=diff&rev=523667&r1=523666&r2=523667
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/test-resources/testsuite/testattribute.xsd (original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/test-resources/testsuite/testattribute.xsd Thu Mar 29 03:48:52 2007
@@ -5,22 +5,22 @@
 
     <xs:element name="TestElement1">
         <xs:complexType>
-            <xs:attribute name="attribute1" type="xs:int" use="optional"/>
+            <xs:attribute name="attribute1" type="xs:int" />
         </xs:complexType>
     </xs:element>
     <xs:element name="TestElement2">
         <xs:complexType>
-            <xs:attribute name="attribute1" type="xs:int"/>
+            <xs:attribute name="attribute1" type="xs:int" use="required"/>
         </xs:complexType>
     </xs:element>
     <xs:element name="TestElement3">
         <xs:complexType>
-            <xs:attribute name="attribute1" type="xs:string" use="optional"/>
+            <xs:attribute name="attribute1" type="xs:string"/>
         </xs:complexType>
     </xs:element>
     <xs:element name="TestElement4">
         <xs:complexType>
-            <xs:attribute name="attribute1"  type="xs:string"/>
+            <xs:attribute name="attribute1"  type="xs:string"  use="required"/>
         </xs:complexType>
     </xs:element>
     <xs:element name="TestAttributeSimpleType">

Added: webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/booleantest/BooleanTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/booleantest/BooleanTest.java?view=auto&rev=523667
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/booleantest/BooleanTest.java (added)
+++ webservices/axis2/trunk/java/modules/adb-codegen/test/org/apache/axis2/schema/booleantest/BooleanTest.java Thu Mar 29 03:48:52 2007
@@ -0,0 +1,65 @@
+/*
+ * 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.booleantest;
+
+import junit.framework.TestCase;
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.util.StAXUtils;
+import org.tempuri.attribute.TestBoolean1;
+import org.tempuri.attribute.TestBoolean2;
+
+import javax.xml.stream.XMLStreamReader;
+import java.io.ByteArrayInputStream;
+
+
+public class BooleanTest extends TestCase {
+
+    public void testBooleanTest1(){
+        TestBoolean1 testBoolean = new TestBoolean1();
+        testBoolean.setTestBoolean1(true);
+
+        OMElement omElement = testBoolean.getOMElement(TestBoolean1.MY_QNAME, OMAbstractFactory.getOMFactory());
+        try {
+            String omElementString = omElement.toStringWithConsume();
+            System.out.println("String ==> " + omElementString);
+            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
+            TestBoolean1 result = TestBoolean1.Factory.parse(xmlReader);
+            assertEquals(result.getTestBoolean1(),true);
+        } catch (Exception e) {
+            fail();
+        }
+    }
+
+    public void testBooleanTest2(){
+        TestBoolean2 testBoolean = new TestBoolean2();
+        testBoolean.setParam1(false);
+        testBoolean.setAttribute1(true);
+
+        OMElement omElement = testBoolean.getOMElement(TestBoolean2.MY_QNAME, OMAbstractFactory.getOMFactory());
+        try {
+            String omElementString = omElement.toStringWithConsume();
+            System.out.println("String ==> " + omElementString);
+            XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
+            TestBoolean2 result = TestBoolean2.Factory.parse(xmlReader);
+            assertEquals(result.getParam1(),false);
+            assertEquals(result.getAttribute1(),true);
+        } catch (Exception e) {
+            fail();
+        }
+    }
+
+}

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=523667&r1=523666&r2=523667
==============================================================================
--- 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 Thu Mar 29 03:48:52 2007
@@ -282,7 +282,16 @@
     }
 
     public static boolean convertToBoolean(String s) {
-        return Boolean.valueOf(s).booleanValue();
+
+        boolean returnValue = false;
+        if ((s != null) && (s.length() > 0)){
+            if ("1".equals(s) || s.toLowerCase().equals("true")){
+                returnValue = true;
+            } else if (!"0".equals(s) && !s.toLowerCase().equals("false")){
+                throw new RuntimeException("in valid string -" + s + " for boolean value");
+            }
+        }
+        return returnValue;
     }
 
     public static String convertToAnySimpleType(String s) {



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