cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ff...@apache.org
Subject svn commit: r1409770 - in /cxf/branches/2.6.x-fixes: ./ rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/ rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/ rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/ systests/ws-specs/src/tes...
Date Thu, 15 Nov 2012 13:28:33 GMT
Author: ffang
Date: Thu Nov 15 13:28:32 2012
New Revision: 1409770

URL: http://svn.apache.org/viewvc?rev=1409770&view=rev
Log:
Merged revisions 1409656,1409658-1409660 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1409656 | ffang | 2012-11-15 14:06:32 +0800 (四, 15 11 2012) | 1 line
  
  [CXF-4594]when use code first, If no setter method in Exception class, the property can't
get marshalled nor available in generated wsdl
........
  r1409658 | ffang | 2012-11-15 14:19:11 +0800 (四, 15 11 2012) | 1 line
  
  [CXF-4594]also add a testcase
........
  r1409659 | ffang | 2012-11-15 14:21:22 +0800 (四, 15 11 2012) | 1 line
  
  [CXF-4594]refactor org.apache.cxf.jaxb.Utils a little bit to make it more clear
........
  r1409660 | ffang | 2012-11-15 14:38:32 +0800 (四, 15 11 2012) | 1 line
  
  [CXF-4594]make checkstyle happy
........

Added:
    cxf/branches/2.6.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/AddNumbersException.java
Modified:
    cxf/branches/2.6.x-fixes/   (props changed)
    cxf/branches/2.6.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java
    cxf/branches/2.6.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java
    cxf/branches/2.6.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/Utils.java
    cxf/branches/2.6.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/CodeFirstTest.java
    cxf/branches/2.6.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/CodeFirstWSDLTest.java
    cxf/branches/2.6.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/Hello.java
    cxf/branches/2.6.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/Hello2.java
    cxf/branches/2.6.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/Hello3.java
    cxf/branches/2.6.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/HelloInterface.java
    cxf/branches/2.6.x-fixes/systests/ws-specs/src/test/resources/wsdl_systest_wsspec/add_numbers-fromjava.wsdl

Propchange: cxf/branches/2.6.x-fixes/
------------------------------------------------------------------------------
  Merged /cxf/trunk:r1409656-1409660

Propchange: cxf/branches/2.6.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.6.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java?rev=1409770&r1=1409769&r2=1409770&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java
(original)
+++ cxf/branches/2.6.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java
Thu Nov 15 13:28:32 2012
@@ -379,8 +379,9 @@ class JAXBContextInitializer extends Ser
     static boolean isMethodAccepted(Method method, XmlAccessType accessType) {
         // We only accept non static property getters which are not marked @XmlTransient
         if (Modifier.isStatic(method.getModifiers()) 
-            || method.isAnnotationPresent(XmlTransient.class)
-            || !Modifier.isPublic(method.getModifiers())) {
+                || method.isAnnotationPresent(XmlTransient.class)
+                || !Modifier.isPublic(method.getModifiers())
+                || "getClass".equals(method.getName())) {
             return false;
         }
 
@@ -390,11 +391,17 @@ class JAXBContextInitializer extends Ser
             || method.getDeclaringClass().equals(Throwable.class)) {
             return false;
         }
-
+        if (method.getName().startsWith("get")
+                || method.getName().startsWith("is")) { 
+                //continue with below check.
+        } else {
+            return false;
+        }
         int beginIndex = 3;
         if (method.getName().startsWith("is")) {
             beginIndex = 2;
         }
+        
         Method setter = null;
         try {
             setter = method.getDeclaringClass()
@@ -403,10 +410,11 @@ class JAXBContextInitializer extends Ser
         } catch (Exception e) {
             //getter, but no setter
         }
-        if (setter == null 
-            || setter.isAnnotationPresent(XmlTransient.class)
-            || !Modifier.isPublic(setter.getModifiers())) {
+        if ((setter != null) 
+                && ((setter.isAnnotationPresent(XmlTransient.class)
+                 || !Modifier.isPublic(setter.getModifiers())))) {
             return false;
+             
         }
 
         if (accessType == XmlAccessType.NONE

Modified: cxf/branches/2.6.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java?rev=1409770&r1=1409769&r2=1409770&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java
(original)
+++ cxf/branches/2.6.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java
Thu Nov 15 13:28:32 2012
@@ -488,7 +488,7 @@ public final class JAXBEncoderDecoder {
                         m = Utils.getMethod(cls, accessType, "is" + s);
                     }
                     Type type = m.getGenericReturnType();
-                    Method m2 = Utils.getMethod(cls, accessType, "set" + s, m.getReturnType());
+                    Object o = null;
                     if (JAXBSchemaInitializer.isArray(type)) {
                         Class<?> compType = JAXBSchemaInitializer
                             .getArrayComponentType(type);
@@ -496,7 +496,7 @@ public final class JAXBEncoderDecoder {
                                                            q,
                                                            compType,
                                                            createList(type));
-                        Object o = ret;
+                        o = ret;
                         if (!isList(type)) {
                             if (compType.isPrimitive()) {
                                 o = java.lang.reflect.Array.newInstance(compType, ret.size());
@@ -507,12 +507,23 @@ public final class JAXBEncoderDecoder {
                                 o = ret.toArray((Object[])Array.newInstance(compType, ret.size()));
                             }
                         }
-
-                        m2.invoke(obj, o);
                     } else {
-                        Object o = getElementValue(u.unmarshal(reader, Utils.getMethodReturnType(m)));
-                        Utils.setMethodValue(m, m2, obj, o);
+                        o = getElementValue(u.unmarshal(reader, Utils.getMethodReturnType(m)));
                     }
+                    Method m2 = Utils.getMethod(cls, accessType, "set" + s, m.getReturnType());
+                    if (m2 != null) {
+                        if (JAXBSchemaInitializer.isArray(type)) {
+                            m2.invoke(obj, o);
+                        } else {
+                            Utils.setMethodValue(m, m2, obj, o);
+                        }
+                    } else {
+                        Field fn = ReflectionUtil.getDeclaredField(cls, q.getLocalPart());
+                        if (fn != null) {
+                            ReflectionUtil.setAccessible(fn);
+                            fn.set(obj, o);
+                        }
+                    }                
                 }
             }
             return (Exception)obj;

Modified: cxf/branches/2.6.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/Utils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/Utils.java?rev=1409770&r1=1409769&r2=1409770&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/Utils.java
(original)
+++ cxf/branches/2.6.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/Utils.java
Thu Nov 15 13:28:32 2012
@@ -136,7 +136,8 @@ final class Utils {
         if (method.isBridge()
                 || Modifier.isStatic(method.getModifiers())
                 || method.isAnnotationPresent(XmlTransient.class)
-                || method.getDeclaringClass().equals(Throwable.class)) {
+                || method.getDeclaringClass().equals(Throwable.class)
+                || "getClass".equals(method.getName())) {
             return false;
         }
         // Allow only public methods if PUBLIC_MEMBER access is requested
@@ -169,9 +170,11 @@ final class Utils {
                 String setterName = "set" + m.getName().substring(index);
                 Class<?> paramTypes = m.getReturnType();
                 Method setter = getDeclaredMethod(declaringClass, setterName, paramTypes);
-                if (setter != null && !setter.isAnnotationPresent(XmlTransient.class))
{
-                    return true;
-                }
+                
+                if (setter != null && setter.isAnnotationPresent(XmlTransient.class))
{
+                    return false;
+                } 
+                return true;
             }
         }
         return false;

Modified: cxf/branches/2.6.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/CodeFirstTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/CodeFirstTest.java?rev=1409770&r1=1409769&r2=1409770&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/CodeFirstTest.java
(original)
+++ cxf/branches/2.6.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/CodeFirstTest.java
Thu Nov 15 13:28:32 2012
@@ -42,9 +42,11 @@ import org.w3c.dom.Node;
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.endpoint.Server;
+import org.apache.cxf.frontend.ClientProxy;
 import org.apache.cxf.frontend.ServerFactoryBean;
 import org.apache.cxf.interceptor.LoggingInInterceptor;
 import org.apache.cxf.interceptor.LoggingOutInterceptor;
+import org.apache.cxf.jaxws.service.AddNumbersException;
 import org.apache.cxf.jaxws.service.ArrayService;
 import org.apache.cxf.jaxws.service.ArrayServiceImpl;
 import org.apache.cxf.jaxws.service.Entity;
@@ -138,7 +140,7 @@ public class CodeFirstTest extends Abstr
         Service service = bean.create();
 
         InterfaceInfo i = service.getServiceInfos().get(0).getInterface();
-        assertEquals(4, i.getOperations().size());
+        assertEquals(5, i.getOperations().size());
 
         ServerFactoryBean svrFactory = new ServerFactoryBean();
         svrFactory.setBus(bus);
@@ -222,6 +224,32 @@ public class CodeFirstTest extends Abstr
         assertEquals(2, result.size());
     }
     
+    @Test
+    public void testException() throws Exception {
+        Hello serviceImpl = new Hello();
+        EndpointImpl ep = new EndpointImpl(getBus(), serviceImpl, (String) null);
+        ep.publish("local://localhost:9090/hello");
+        ep.getServer().getEndpoint().getInInterceptors().add(new LoggingInInterceptor());
+        ep.getServer().getEndpoint().getOutInterceptors().add(new LoggingOutInterceptor());
+        QName serviceName = new QName("http://service.jaxws.cxf.apache.org/", "HelloService");
+        QName portName = new QName("http://service.jaxws.cxf.apache.org/", "HelloPort");
+
+        // need to set the same bus with service , so use the ServiceImpl
+        ServiceImpl service = new ServiceImpl(getBus(), (URL)null, serviceName, null);
+        service.addPort(portName, "http://schemas.xmlsoap.org/soap/", "local://localhost:9090/hello");
+
+        HelloInterface proxy = service.getPort(portName, HelloInterface.class);
+        ClientProxy.getClient(proxy).getInFaultInterceptors().add(new LoggingInInterceptor());
+        ClientProxy.getClient(proxy).getInInterceptors().add(new LoggingInInterceptor());
+        try {   
+            proxy.addNumbers(1, -2);
+            fail("should throw AddNumbersException");
+        } catch (AddNumbersException e) {
+            assertEquals(e.getInfo(), "Sum is less than 0.");
+        }
+
+    }
+
     
     @Test
     public void testRpcClient() throws Exception {

Modified: cxf/branches/2.6.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/CodeFirstWSDLTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/CodeFirstWSDLTest.java?rev=1409770&r1=1409769&r2=1409770&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/CodeFirstWSDLTest.java
(original)
+++ cxf/branches/2.6.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/CodeFirstWSDLTest.java
Thu Nov 15 13:28:32 2012
@@ -62,7 +62,7 @@ public class CodeFirstWSDLTest extends A
         Service service = bean.create();
 
         InterfaceInfo i = service.getServiceInfos().get(0).getInterface();
-        assertEquals(4, i.getOperations().size());
+        assertEquals(5, i.getOperations().size());
 
         ServerFactoryBean svrFactory = new ServerFactoryBean();
         svrFactory.setBus(bus);
@@ -100,7 +100,7 @@ public class CodeFirstWSDLTest extends A
         javax.wsdl.PortType portType = d.getPortType(portTypeName);
 
         assertNotNull(portType);
-        assertEquals(4, portType.getOperations().size());
+        assertEquals(5, portType.getOperations().size());
     }
 
     @Test
@@ -124,7 +124,7 @@ public class CodeFirstWSDLTest extends A
         javax.wsdl.PortType portType = d.getPortType(portTypeName);
 
         assertNotNull(portType);
-        assertEquals(4, portType.getOperations().size());
+        assertEquals(5, portType.getOperations().size());
     }
     @Test
     public void testExcludeOnInterface() throws Exception {

Added: cxf/branches/2.6.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/AddNumbersException.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/AddNumbersException.java?rev=1409770&view=auto
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/AddNumbersException.java
(added)
+++ cxf/branches/2.6.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/AddNumbersException.java
Thu Nov 15 13:28:32 2012
@@ -0,0 +1,37 @@
+/**
+ * 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.jaxws.service;
+
+import javax.xml.ws.WebFault;
+
+@WebFault
+public class AddNumbersException extends Exception {
+    private String info;
+
+    public AddNumbersException() {
+    }
+
+    public AddNumbersException(String info) { 
+        this.info = info; 
+    }
+
+    public String getInfo() { 
+        return info; 
+    }
+}

Modified: cxf/branches/2.6.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/Hello.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/Hello.java?rev=1409770&r1=1409769&r2=1409770&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/Hello.java
(original)
+++ cxf/branches/2.6.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/Hello.java
Thu Nov 15 13:28:32 2012
@@ -68,4 +68,12 @@ public class Hello {
         ret.add("Bonjour" + list.get(1));
         return ret;
     }
+    
+    @WebMethod
+    public String addNumbers(int arg0, int arg1) throws AddNumbersException {
+        if (arg0 + arg1 < 0) {
+            throw new AddNumbersException("Sum is less than 0.");
+        }
+        return "Result = " + String.valueOf(arg0 + arg1);
+    }
 }

Modified: cxf/branches/2.6.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/Hello2.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/Hello2.java?rev=1409770&r1=1409769&r2=1409770&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/Hello2.java
(original)
+++ cxf/branches/2.6.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/Hello2.java
Thu Nov 15 13:28:32 2012
@@ -21,6 +21,7 @@ package org.apache.cxf.jaxws.service;
 import java.util.ArrayList;
 import java.util.List;
 
+import javax.jws.WebMethod;
 import javax.jws.WebService;
 
 @WebService(endpointInterface = "org.apache.cxf.jaxws.service.HelloInterface")
@@ -50,4 +51,11 @@ public class Hello2 implements HelloInte
         return null;
     }
 
+    @Override
+    @WebMethod
+    public String addNumbers(int arg0, int arg1) throws AddNumbersException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
 }

Modified: cxf/branches/2.6.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/Hello3.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/Hello3.java?rev=1409770&r1=1409769&r2=1409770&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/Hello3.java
(original)
+++ cxf/branches/2.6.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/Hello3.java
Thu Nov 15 13:28:32 2012
@@ -21,6 +21,7 @@ package org.apache.cxf.jaxws.service;
 import java.util.ArrayList;
 import java.util.List;
 
+import javax.jws.WebMethod;
 import javax.jws.WebService;
 
 @WebService(serviceName = "MyService", 
@@ -53,4 +54,11 @@ public class Hello3 implements HelloInte
         return null;
     }
 
+    @Override
+    @WebMethod
+    public String addNumbers(int arg0, int arg1) throws AddNumbersException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
 }

Modified: cxf/branches/2.6.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/HelloInterface.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/HelloInterface.java?rev=1409770&r1=1409769&r2=1409770&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/HelloInterface.java
(original)
+++ cxf/branches/2.6.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/HelloInterface.java
Thu Nov 15 13:28:32 2012
@@ -33,4 +33,6 @@ public interface HelloInterface {
     String[] getStringArray(String[] strs);
     @WebMethod
     List<String> getStringList(List<String> list);
+    @WebMethod
+    String addNumbers(int arg0, int arg1) throws AddNumbersException;
 }

Modified: cxf/branches/2.6.x-fixes/systests/ws-specs/src/test/resources/wsdl_systest_wsspec/add_numbers-fromjava.wsdl
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/systests/ws-specs/src/test/resources/wsdl_systest_wsspec/add_numbers-fromjava.wsdl?rev=1409770&r1=1409769&r2=1409770&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/systests/ws-specs/src/test/resources/wsdl_systest_wsspec/add_numbers-fromjava.wsdl
(original)
+++ cxf/branches/2.6.x-fixes/systests/ws-specs/src/test/resources/wsdl_systest_wsspec/add_numbers-fromjava.wsdl
Thu Nov 15 13:28:32 2012
@@ -28,7 +28,9 @@ under the License.
 		    targetNamespace="http://server.addr_fromjava.ws.systest.cxf.apache.org/">
 	    <xsd:element name="AddNumbersException" type="tns:AddNumbersException"/>
 	    <xsd:complexType name="AddNumbersException">
-		<xsd:sequence/>
+		<xsd:sequence>
+                     <xsd:element name="detail" type="xsd:string"/>
+                </xsd:sequence>
 	    </xsd:complexType>
 	    <xsd:element name="addNumbers3" type="tns:addNumbers3"/>
 	    <xsd:complexType name="addNumbers3">
@@ -158,4 +160,4 @@ under the License.
 	    <soap:address location="http://localhost:9093/AddNumberImplPort"/>
 	</wsdl:port>
     </wsdl:service>
-</wsdl:definitions>
\ No newline at end of file
+</wsdl:definitions>



Mime
View raw message