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 sc...@apache.org on 2006/11/29 00:28:07 UTC

svn commit: r480278 - in /webservices/axis2/trunk/java/modules/jaxws: src/org/apache/axis2/jaxws/i18n/ src/org/apache/axis2/jaxws/marshaller/impl/alt/ src/org/apache/axis2/jaxws/message/databinding/ test/org/apache/axis2/jaxws/proxy/ test/org/apache/ax...

Author: scheu
Date: Tue Nov 28 15:28:04 2006
New Revision: 480278

URL: http://svn.apache.org/viewvc?view=rev&rev=480278
Log:
AXIS2-1730
Contributor:Rich Scheuerle
Completed the xsd:list rpc tests...disabled the qname and calendar tests due to problems

Modified:
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/i18n/resource.properties
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/MethodMarshallerUtils.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/XSDListUtils.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/proxy/RPCProxyTests.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/proxy/rpclit/RPCLitImpl.java

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/i18n/resource.properties
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/i18n/resource.properties?view=diff&rev=480278&r1=480277&r2=480278
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/i18n/resource.properties (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/i18n/resource.properties Tue Nov 28 15:28:04 2006
@@ -134,4 +134,5 @@
 ClassUtilsErr3=An IOException error was thrown when trying to get all of the resources for {0}
 MethodMarshallerErr1=A JAX-WS service exception for the {0} fault bean cannot be created.
 SourceReadErr=A problem was encountered while reading the Source object.  Please verify that your Source object is correct.  The class of the Source object is {0}
-JABGraphProblem=The system threw a StackOverflowError at the JAXB level.  This usually means that your JAXB object has a circular reference.  This is not supported by JAXB.
\ No newline at end of file
+JABGraphProblem=The system threw a StackOverflowError at the JAXB level.  This usually means that your JAXB object has a circular reference.  This is not supported by JAXB.
+XSDListNotSupported=An attempt was made to marshal or unmarshal an xsd:list with a component type that is a {0}.  This scenario is not supported for rpc/literal processing.  Please use document/literal processing.
\ No newline at end of file

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/MethodMarshallerUtils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/MethodMarshallerUtils.java?view=diff&rev=480278&r1=480277&r2=480278
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/MethodMarshallerUtils.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/marshaller/impl/alt/MethodMarshallerUtils.java Tue Nov 28 15:28:04 2006
@@ -185,6 +185,7 @@
                     block = message.getHeaderBlock(pd.getTargetNamespace(), localName, context, factory);
                 } else {
                     block = message.getBodyBlock(index, context, factory);
+                    index++;
                 }
                 
                 // The object is now ready for marshalling

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/XSDListUtils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/XSDListUtils.java?view=diff&rev=480278&r1=480277&r2=480278
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/XSDListUtils.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/databinding/XSDListUtils.java Tue Nov 28 15:28:04 2006
@@ -19,10 +19,17 @@
 import java.lang.reflect.Array;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.StringTokenizer;
 
+import javax.xml.datatype.DatatypeFactory;
+import javax.xml.datatype.XMLGregorianCalendar;
+import javax.xml.namespace.QName;
+
+import org.apache.axis2.jaxws.i18n.Messages;
+
 
 /**
  * Utilities to convert to/from xsd:list String to Object[]/List values.
@@ -66,7 +73,7 @@
      * @param container Object
      * @return xsd:list String
      */
-    public static String toXSDListString(Object container) {
+    public static String toXSDListString(Object container) throws NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException {
         // TODO only supports arrays right now.  Need to implement this for List
         if (container.getClass().isArray()) {
             String xsdString = "";
@@ -118,8 +125,19 @@
      * @param obj
      * @return xml text for this object
      */
-    private static String getAsText(Object obj) {
+    private static String getAsText(Object obj) throws NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException {
         // TODO Need to upgrade to handle more complicated objects like calendar and qname
+        if (obj instanceof QName) {
+            throw new RuntimeException(Messages.getMessage("XSDListNotSupported", QName.class.getName()));
+        } else if (obj instanceof XMLGregorianCalendar) {
+            throw new RuntimeException(Messages.getMessage("XSDListNotSupported", XMLGregorianCalendar.class.getName()));   
+        } else if (obj.getClass().isEnum()) {
+            // TODO Method should be cached for performance
+            Method method = 
+                obj.getClass().getDeclaredMethod("value", new Class[] {} );
+           return (String) method.invoke(obj, new Object[] {} );
+
+        }
         return obj.toString();
     }
     
@@ -137,6 +155,22 @@
         // TODO This needs to be upgraded to handle more complicated objects (enum, calendar, primitive, etc.)
         if (componentType == String.class) {
             return value;
+        }
+        if (componentType.isEnum()) {
+            // If you get an exception here, consider adding the code to convert the String value to the required component object
+            // Default: Call the constructor
+            // TODO Method should be cached for performance
+            Method method = 
+                componentType.getDeclaredMethod("fromValue", new Class[] {String.class} );
+            Object obj = method.invoke(null, new Object[] {value} );
+            return obj;
+        }
+        if (componentType.equals(QName.class)) {
+            // TODO Missing Support
+            throw new IllegalArgumentException(Messages.getMessage("XSDListNotSupported", componentType.getName()));
+        } else if (componentType.equals(XMLGregorianCalendar.class)) {
+            // TODO Missing Support
+            throw new IllegalArgumentException(Messages.getMessage("XSDListNotSupported", componentType.getName()));   
         }
         
         // If you get an exception here, consider adding the code to convert the String value to the required component object

Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/proxy/RPCProxyTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/proxy/RPCProxyTests.java?view=diff&rev=480278&r1=480277&r2=480278
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/proxy/RPCProxyTests.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/proxy/RPCProxyTests.java Tue Nov 28 15:28:04 2006
@@ -20,6 +20,7 @@
 
 import java.io.ByteArrayOutputStream;
 import java.io.File;
+import java.math.BigInteger;
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.ArrayList;
@@ -28,15 +29,18 @@
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBElement;
 import javax.xml.bind.Marshaller;
+import javax.xml.datatype.XMLGregorianCalendar;
 import javax.xml.namespace.QName;
 import javax.xml.ws.BindingProvider;
 import javax.xml.ws.Dispatch;
 import javax.xml.ws.Service;
 
 import org.apache.axis2.jaxws.dispatch.DispatchTestConstants;
+import org.apache.axis2.jaxws.proxy.rpclit.RPCLitImpl;
 import org.apache.axis2.jaxws.proxy.rpclit.sei.RPCLit;
 import org.test.proxy.rpclit.ObjectFactory;
 import org.test.proxy.rpclit.Enum;
+import org.test.proxy.rpclit.ComplexAll;
 
 import junit.framework.TestCase;
 
@@ -163,11 +167,6 @@
         }
     }
     
-    // TODO 
-    // Commented out while fixing this test.  The above test succeeds, but sends the message in an incorrect format.
-    // This test sends the message in the correct format, but currently fails.  
-    // We need to investigate the @XmlList processing.
-    //
     public void testStringList_Dispatch() throws Exception {
         // Send a payload that simulates
         // the rpc message
@@ -190,5 +189,102 @@
         assertTrue(response.contains("testStringList2Return"));
         assertTrue(response.contains("testStringList2Response"));
         assertTrue(response.contains("Hello World"));
+    }
+    /**
+     * Currently not enabled due to problems with 
+     * marshaling an xsd:list of QName.
+     * 
+     * Users should use document/literal processing if they 
+     * need such complicated scenarios.
+     */
+    public void _testLists() {
+        try{ 
+            RPCLit proxy = getProxy();
+            QName[] request = new QName[] {RPCLitImpl.qname1, RPCLitImpl.qname2};
+           
+            QName[] qNames = proxy.testLists(request,
+                    new XMLGregorianCalendar[0],
+                    new String[0],
+                    new BigInteger[0],
+                    new Long[0],
+                    new Enum[0],
+                    new String[0],
+                    new ComplexAll());
+            assertTrue(qNames.length==2);
+            assertTrue(qNames[0].equals(RPCLitImpl.qname1));
+            assertTrue(qNames[1].equals(RPCLitImpl.qname2));
+        }catch(Exception e){ 
+            e.printStackTrace(); 
+            fail("Exception received" + e);
+        }
+    }
+    
+    /**
+     * Currently not enabled due to problems marshalling/unmarshalling
+     * an xsd:list of XMLGregorianCalendar.
+     * 
+     * Users should use document/literal processing if they 
+     * need such complicated scenarios.
+     */
+    public void _testCalendars() {
+        try{ 
+            RPCLit proxy = getProxy();
+            XMLGregorianCalendar[] request = new XMLGregorianCalendar[] {RPCLitImpl.bday, RPCLitImpl.holiday};
+           
+            XMLGregorianCalendar[] cals  = proxy.testCalendarList1(request);
+            assertTrue(cals.length == 2);
+            assertTrue(cals[0].compare(RPCLitImpl.bday) == 0);
+            assertTrue(cals[1].compare(RPCLitImpl.holiday) == 0);
+        }catch(Exception e){ 
+            e.printStackTrace(); 
+            fail("Exception received" + e);
+        }
+    }
+    
+    public void testBigIntegers() {
+        try{ 
+            RPCLit proxy = getProxy();
+            BigInteger[] request = new BigInteger[] {RPCLitImpl.bigInt1, RPCLitImpl.bigInt2};
+           
+            BigInteger[] ints  = proxy.testBigIntegerList3(request);
+            assertTrue(ints.length==2);
+            assertTrue(ints[0].compareTo(RPCLitImpl.bigInt1) == 0);
+            assertTrue(ints[1].compareTo(RPCLitImpl.bigInt2) == 0);
+        }catch(Exception e){ 
+            e.printStackTrace(); 
+            fail("Exception received" + e);
+        }
+    }
+    
+    public void testLongs() {
+        try{ 
+            RPCLit proxy = getProxy();
+            Long[] request = new Long[] {new Long(0), new Long(1), new Long(2)};
+           
+            Long[] longs  = proxy.testLongList4(request);
+            assertTrue(longs.length==3);
+            assertTrue(longs[0] == 0);
+            assertTrue(longs[1] == 1);
+            assertTrue(longs[2] == 2);
+        }catch(Exception e){ 
+            e.printStackTrace(); 
+            fail("Exception received" + e);
+        }
+    }
+    
+    public void testEnums() {
+        try{ 
+            RPCLit proxy = getProxy();
+            Enum[] request = new Enum[] {Enum.ONE, Enum.TWO, Enum.THREE};
+           
+            Enum[] enums  = proxy.testEnumList5(request);
+            assertTrue(enums.length==3);
+            assertTrue(enums[0] == Enum.ONE);
+            assertTrue(enums[1] == Enum.TWO);
+            assertTrue(enums[2] == Enum.THREE);
+        }catch(Exception e){ 
+            e.printStackTrace(); 
+            fail("Exception received" + e);
+        }
     }
 }

Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/proxy/rpclit/RPCLitImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/proxy/rpclit/RPCLitImpl.java?view=diff&rev=480278&r1=480277&r2=480278
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/proxy/rpclit/RPCLitImpl.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/proxy/rpclit/RPCLitImpl.java Tue Nov 28 15:28:04 2006
@@ -21,6 +21,8 @@
 import javax.jws.WebParam;
 import javax.jws.WebService;
 import javax.xml.bind.annotation.XmlList;
+import javax.xml.datatype.DatatypeConstants;
+import javax.xml.datatype.DatatypeFactory;
 import javax.xml.datatype.XMLGregorianCalendar;
 import javax.xml.namespace.QName;
 import javax.xml.ws.WebServiceProvider;
@@ -37,6 +39,22 @@
         endpointInterface="org.apache.axis2.jaxws.proxy.rpclit.sei.RPCLit")
 public class RPCLitImpl implements RPCLit {
 
+    public static DatatypeFactory df ;
+    public static XMLGregorianCalendar bday;
+    public static XMLGregorianCalendar holiday;
+    public static BigInteger bigInt1 = new BigInteger("1");
+    public static BigInteger bigInt2 = new BigInteger("2");
+    public static QName qname1 = new QName("urn://sample", "hello" );
+    public static QName qname2 = new QName("urn://sample", "world" );
+    
+    static {
+        try {
+            df = DatatypeFactory.newInstance();
+            bday = df.newXMLGregorianCalendarDate(1964, 12, 3,  DatatypeConstants.FIELD_UNDEFINED);
+            holiday = bday = df.newXMLGregorianCalendarDate(2007, 1, 1,  DatatypeConstants.FIELD_UNDEFINED);
+        } catch (Exception e) {}
+    }
+    
     
     
     /**
@@ -55,13 +73,19 @@
             Enum[] enums,
             String[] text2,
             ComplexAll all) {
-        // TODO Auto-generated method stub
-        return null;
+        assertTrue(qNames.length==2);
+        assertTrue(qNames[0].equals(qname1));
+        assertTrue(qNames[1].equals(qname2));
+        
+        return qNames;
     }
 
     public XMLGregorianCalendar[] testCalendarList1(XMLGregorianCalendar[] cals) {
-        // TODO Auto-generated method stub
-        return null;
+       assertTrue(cals.length == 2);
+       assertTrue(cals[0].compare(bday) == 0);
+       assertTrue(cals[1].compare(holiday) == 0);
+       return cals;
+       
     }
 
     public String[] testStringList2(String[] arg20) {
@@ -73,8 +97,10 @@
     }
 
     public BigInteger[] testBigIntegerList3(BigInteger[] arg30) {
-        // TODO Auto-generated method stub
-        return null;
+        assertTrue(arg30.length==2);
+        assertTrue(arg30[0].compareTo(bigInt1) == 0);
+        assertTrue(arg30[1].compareTo(bigInt2) == 0);
+        return arg30;
     }
 
     public Long[] testLongList4(Long[] longs) {
@@ -99,13 +125,17 @@
     }
     
     public String[] testEnumList7(String[] arg70) {
-        // TODO Auto-generated method stub
-        return null;
+        assertTrue(arg70.length==2);
+        assertTrue(arg70[0].equals("Apple"));
+        assertTrue(arg70[0].equals("Orange"));
+        return arg70;
     }
 
     private void assertTrue(boolean value) throws RuntimeException {
         if (!value) {
-            throw new RuntimeException();
+            RuntimeException re = new RuntimeException();
+            System.out.println("Test FAILURE=" +re);
+            throw re;
         }
     }
 }



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