cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r686820 - in /cxf/trunk/tools/javato/ws/src: main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/ test/java/org/apache/cxf/tools/fortest/xmllist/ test/java/org/apache/cxf/tools/java2wsdl/processor/ test/java/org/apache/cxf/too...
Date Mon, 18 Aug 2008 17:12:24 GMT
Author: dkulp
Date: Mon Aug 18 10:12:23 2008
New Revision: 686820

URL: http://svn.apache.org/viewvc?rev=686820&view=rev
Log:
[CXF-1752] Fix problems in generated wrapper types

Modified:
    cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/RequestWrapper.java
    cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/xmllist/AddNumberImpl.java
    cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/xmllist/AddNumbersPortType.java
    cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java
    cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/RequestWrapperTest.java

Modified: cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/RequestWrapper.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/RequestWrapper.java?rev=686820&r1=686819&r2=686820&view=diff
==============================================================================
--- cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/RequestWrapper.java
(original)
+++ cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/RequestWrapper.java
Mon Aug 18 10:12:23 2008
@@ -20,12 +20,14 @@
 package org.apache.cxf.tools.java2wsdl.processor.internal.jaxws;
 
 import java.lang.annotation.Annotation;
+import java.lang.reflect.GenericArrayType;
 import java.lang.reflect.Method;
 import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Type;
 import java.util.ArrayList;
 import java.util.List;
 import javax.jws.WebParam;
+import javax.xml.ws.Holder;
 
 import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.service.model.MessageInfo;
@@ -61,39 +63,49 @@
         return buildFields(getMethod(), getOperationInfo().getUnwrappedOperation().getInput());
     }
 
+    private String getTypeString(Type t) {
+        String type = "Object";
+        if (t instanceof Class) {
+            Class clz = (Class) t;
+            if (clz.isArray()) {
+                if (isBuiltInTypes(clz.getComponentType())) {
+                    type = clz.getComponentType().getSimpleName() + "[]";
+                } else {
+                    type = clz.getComponentType().getName() + "[]";
+                }
+            } else {
+                type = clz.getName();
+            }
+        } else if (t instanceof ParameterizedType) {
+            ParameterizedType pt = (ParameterizedType) t;
+            Class c = (Class)pt.getRawType();
+            if (Holder.class.isAssignableFrom(c)
+                && pt.getActualTypeArguments().length == 1
+                && pt.getActualTypeArguments()[0] instanceof Class) {
+                type = getTypeString(pt.getActualTypeArguments()[0]);
+            } else {
+                type = t.toString();
+            }
+        } else if (t instanceof GenericArrayType) {
+            GenericArrayType gat = (GenericArrayType)t;
+            type = gat.toString();
+        }
+        type = type.replace('$', '.');
+        return type;
+    }
+    
+    
     protected List<JavaField> buildFields(final Method method, final MessageInfo message)
{
         List<JavaField> fields = new ArrayList<JavaField>();
-        String name;
-        String type = "Object";
 
         final Type[] paramClasses = method.getGenericParameterTypes();
         final Annotation[][] paramAnnotations = method.getParameterAnnotations();
 
         for (MessagePartInfo mpi : message.getMessageParts()) {
             int idx = mpi.getIndex();
-            name = mpi.getName().getLocalPart();
+            String name = mpi.getName().getLocalPart();
             Type t = paramClasses[idx];
-
-            Class clz = null;
-            if (t instanceof Class) {
-                clz = (Class) t;
-                if (clz.isArray()) {
-                    if (isBuiltInTypes(clz.getComponentType())) {
-                        type = clz.getComponentType().getSimpleName() + "[]";
-                    } else {
-                        type = clz.getComponentType().getName() + "[]";
-                    }
-                } else {
-                    type = clz.getName();
-                }
-            } else if (t instanceof ParameterizedType) {
-                ParameterizedType pt = (ParameterizedType) t;
-                if (pt.getActualTypeArguments().length > 0
-                    && pt.getActualTypeArguments()[0] instanceof Class) {
-                    clz = (Class)pt.getActualTypeArguments()[0];
-                    type = clz.getName();
-                }
-            }
+            String type = getTypeString(t);
 
             JavaField field = new JavaField(name, type, "");
 

Modified: cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/xmllist/AddNumberImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/xmllist/AddNumberImpl.java?rev=686820&r1=686819&r2=686820&view=diff
==============================================================================
--- cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/xmllist/AddNumberImpl.java
(original)
+++ cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/xmllist/AddNumberImpl.java
Mon Aug 18 10:12:23 2008
@@ -21,10 +21,19 @@
 import java.util.List;
 
 import javax.jws.WebService;
+
+import org.apache.cxf.tools.fortest.xmllist.AddNumbersPortType.UserObject;
 @WebService(endpointInterface = "org.apache.cxf.tools.fortest.xmllist.AddNumbersPortType")
 public class AddNumberImpl implements AddNumbersPortType {
     public List<Integer> addNumbers(List<String> arg) {
         return null;
     }
 
+    public UserObject testCXF1752(List<Long> receivers, UserObject item, 
+                                  byte[] binaryContent, UserObject[] objects,
+                                  List<UserObject> objects2,
+                                  String fileName) {
+        return null;
+    }
+
 }

Modified: cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/xmllist/AddNumbersPortType.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/xmllist/AddNumbersPortType.java?rev=686820&r1=686819&r2=686820&view=diff
==============================================================================
--- cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/xmllist/AddNumbersPortType.java
(original)
+++ cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/xmllist/AddNumbersPortType.java
Mon Aug 18 10:12:23 2008
@@ -47,5 +47,27 @@
         @WebParam(name = "arg", targetNamespace = "http://apache.org/xmllist")
         @XmlList
         List<String> arg);
-
+    
+    //test for CXF-1752 
+    @WebMethod(action = "testCXF1752")
+    @WebResult(name = "result") 
+    UserObject testCXF1752(
+        @WebParam(name = "receivers") List<Long> receivers, 
+        @WebParam(name = "item") UserObject item, 
+        @WebParam(name = "binaryContent") byte[] binaryContent, 
+        @WebParam(name = "userObjects") UserObject[] objects, 
+        @WebParam(name = "userObjectList") List<UserObject> objectList, 
+        @WebParam(name = "fileName") String fileName);
+    
+    
+    static class UserObject {
+        String myData;
+        
+        public void setMyData(String s) {
+            myData = s;
+        }
+        public String getMyData() {
+            return myData;
+        }
+    }
 }

Modified: cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java?rev=686820&r1=686819&r2=686820&view=diff
==============================================================================
--- cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java
(original)
+++ cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java
Mon Aug 18 10:12:23 2008
@@ -501,10 +501,12 @@
         assertTrue(requestWrapperClass.exists());
         assertTrue(responseWrapperClass.exists());
 
-        assertTrue(getStringFromFile(requestWrapperClass).indexOf("String  arg0") != -1);
-        assertTrue(getStringFromFile(requestWrapperClass).indexOf("Holder") == -1);
-        assertTrue(getStringFromFile(responseWrapperClass).indexOf("String  arg0") != -1);
-        assertTrue(getStringFromFile(responseWrapperClass).indexOf("Holder") == -1);
+        String req = getStringFromFile(requestWrapperClass);
+        String resp = getStringFromFile(responseWrapperClass);
+        assertTrue(req.indexOf("String  arg0") != -1);
+        assertTrue(req.indexOf("Holder") == -1);
+        assertTrue(resp.indexOf("String  arg0") != -1);
+        assertTrue(resp.indexOf("Holder") == -1);
     }
 
     @Test

Modified: cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/RequestWrapperTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/RequestWrapperTest.java?rev=686820&r1=686819&r2=686820&view=diff
==============================================================================
--- cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/RequestWrapperTest.java
(original)
+++ cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/RequestWrapperTest.java
Mon Aug 18 10:12:23 2008
@@ -30,6 +30,7 @@
 import org.apache.cxf.tools.common.model.JavaField;
 import org.apache.cxf.tools.common.model.JavaMethod;
 import org.apache.cxf.tools.fortest.withannotation.doc.GreeterArray;
+import org.apache.cxf.tools.fortest.xmllist.AddNumbersPortType;
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -164,4 +165,21 @@
         assertEquals(pkgName, wrapper.getJavaClass().getPackageName());
         assertEquals("SayHi", wrapper.getJavaClass().getName());
     }
+    
+    @Test
+    public void testCXF1752() throws Exception {
+        OperationInfo opInfo = getOperation(AddNumbersPortType.class, "testCXF1752");
+        RequestWrapper wrapper = new RequestWrapper();
+        wrapper.setOperationInfo(opInfo);
+        
+        wrapper.buildWrapperBeanClass();
+        List<JavaField> fields = wrapper.getJavaClass().getFields();
+        assertEquals(6, fields.size());
+        assertEquals("java.util.List<java.lang.Long>", fields.get(0).getClassName());
+        assertEquals("byte[]", fields.get(2).getClassName());
+        assertEquals("org.apache.cxf.tools.fortest.xmllist.AddNumbersPortType.UserObject[]",
+                     fields.get(3).getClassName());
+        assertEquals("java.util.List<org.apache.cxf.tools.fortest.xmllist.AddNumbersPortType.UserObject>",
+                     fields.get(4).getClassName());
+    }
 }



Mime
View raw message