cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject svn commit: r1452679 - in /cxf/trunk: rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/ tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/ tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/
Date Tue, 05 Mar 2013 07:26:01 GMT
Author: ema
Date: Tue Mar  5 07:26:00 2013
New Revision: 1452679

URL: http://svn.apache.org/r1452679
Log:
[CXF-4847]:Data types not correctly published in WSDL from Exception classes;Apply patch from
mustafa

Added:
    cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/Echo2.java
  (with props)
    cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/Echo2Impl.java
  (with props)
    cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/ListException.java
  (with props)
    cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/MyData.java
  (with props)
Modified:
    cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java
    cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/Utils.java
    cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java

Modified: cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java?rev=1452679&r1=1452678&r2=1452679&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java
(original)
+++ cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java
Tue Mar  5 07:26:00 2013
@@ -543,6 +543,12 @@ class JAXBSchemaInitializer extends Serv
         for (Method m : Utils.getGetters(cls, accessType)) {
             //map method
             Type type = Utils.getMethodReturnType(m);
+            // we want to return the right type for collections so if we get null
+            // from the return type we check if it's ParameterizedType and get the
+            // generic return type.
+            if ((type == null) && (m.getGenericReturnType() instanceof ParameterizedType))
{
+                type = m.getGenericReturnType();
+            }
             JAXBBeanInfo beanInfo = getBeanInfo(type);
             if (beanInfo != null) {
                 int idx = m.getName().startsWith("get") ? 3 : 2;

Modified: cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/Utils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/Utils.java?rev=1452679&r1=1452678&r2=1452679&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/Utils.java (original)
+++ cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/Utils.java Tue Mar  5
07:26:00 2013
@@ -211,8 +211,14 @@ final class Utils {
 
     static Class<?> getMethodReturnType(Method m) {
         XmlJavaTypeAdapter adapter = getMethodXJTA(m);
+        // if there is no adapter, yet we have a collection make sure
+        // we return the Generic type; if there is an annotation let the
+        // adapter handle what gets populated
+        if (adapter == null && m.getGenericReturnType() instanceof ParameterizedType)
{
+            return null;
+        }
         Class<?> adapterType = (Class<?>)getTypeFromXmlAdapter(adapter);
-        return adapterType != null ? adapterType : m.getReturnType(); 
+        return adapterType != null ? adapterType : m.getReturnType();
     }
 
     @SuppressWarnings({ "rawtypes", "unchecked" })

Added: cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/Echo2.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/Echo2.java?rev=1452679&view=auto
==============================================================================
--- cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/Echo2.java
(added)
+++ cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/Echo2.java
Tue Mar  5 07:26:00 2013
@@ -0,0 +1,26 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.cxf.tools.fortest.exception;
+
+import javax.jws.WebService;
+
+@WebService(targetNamespace = "http://cxf.apache.org/test/ListService", name = "ListService")
+public interface Echo2 {
+    String echo(String request) throws ListException;
+}

Propchange: cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/Echo2.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/Echo2.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/Echo2Impl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/Echo2Impl.java?rev=1452679&view=auto
==============================================================================
--- cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/Echo2Impl.java
(added)
+++ cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/Echo2Impl.java
Tue Mar  5 07:26:00 2013
@@ -0,0 +1,32 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.cxf.tools.fortest.exception;
+
+import javax.jws.WebService;
+
+@WebService(serviceName = "ListService", portName = "ListPort", 
+endpointInterface = "org.apache.cxf.tools.fortest.exception.Echo2", 
+targetNamespace = "http://cxf.apache.org/test/ListService")
+public class Echo2Impl implements Echo2 {
+    public String echo(String request) throws ListException {
+        return "Response";
+
+    }
+
+}

Propchange: cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/Echo2Impl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/Echo2Impl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/ListException.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/ListException.java?rev=1452679&view=auto
==============================================================================
--- cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/ListException.java
(added)
+++ cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/ListException.java
Tue Mar  5 07:26:00 2013
@@ -0,0 +1,38 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.cxf.tools.fortest.exception;
+
+import java.util.List;
+
+import javax.xml.ws.WebFault;
+
+@WebFault
+public class ListException extends Exception {
+
+    private static final long serialVersionUID = 1L;
+    private List<MyData> names;
+
+    public List<MyData> getNames() {
+        return names;
+    }
+
+    public void setNames(List<MyData> names) {
+        this.names = names;
+    }
+}

Propchange: cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/ListException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/ListException.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/MyData.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/MyData.java?rev=1452679&view=auto
==============================================================================
--- cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/MyData.java
(added)
+++ cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/MyData.java
Tue Mar  5 07:26:00 2013
@@ -0,0 +1,41 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.cxf.tools.fortest.exception;
+
+public class MyData {
+    private String city;
+    private String address;
+
+    public String getCity() {
+        return city;
+    }
+
+    public void setCity(String city) {
+        this.city = city;
+    }
+
+    public String getAddress() {
+        return address;
+    }
+
+    public void setAddress(String address) {
+        this.address = address;
+    }
+
+}

Propchange: cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/MyData.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/MyData.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

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=1452679&r1=1452678&r2=1452679&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
Tue Mar  5 07:26:00 2013
@@ -752,5 +752,26 @@ public class JavaToProcessorTest extends
         assertTrue(summaryIndex > idIndex && idIndex > fromIndex);        
     }
     
+    @Test
+    public void testExceptionList() throws Exception {
+        env.put(ToolConstants.CFG_OUTPUTFILE, output.getPath() + "/exception_list.wsdl");
+        env.put(ToolConstants.CFG_CLASSNAME, "org.apache.cxf.tools.fortest.exception.Echo2Impl");
+        env.put(ToolConstants.CFG_VERBOSE, ToolConstants.CFG_VERBOSE);
+        try {
+            processor.setEnvironment(env);
+            processor.process();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        
+        File wsdlFile = new File(output, "exception_list.wsdl");
+        assertTrue(wsdlFile.exists());
+        String wsdlContent = getStringFromFile(wsdlFile).replaceAll("  ", " ");
+        int unboundIndex = wsdlContent
+            .indexOf("<xs:element maxOccurs=\"unbounded\" minOccurs=\"0\" name=\"names\"
type=\"tns:myData\"/>");
+        assertTrue(unboundIndex > -1);
+    }
+    
+    
     
 }



Mime
View raw message