cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ff...@apache.org
Subject svn commit: r1409658 - in /cxf/trunk: 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/test/resources/wsdl_systest_wsspec/
Date Thu, 15 Nov 2012 06:19:13 GMT
Author: ffang
Date: Thu Nov 15 06:19:11 2012
New Revision: 1409658

URL: http://svn.apache.org/viewvc?rev=1409658&view=rev
Log:
[CXF-4594]also add a testcase

Added:
    cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/AddNumbersException.java
Modified:
    cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/CodeFirstTest.java
    cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/CodeFirstWSDLTest.java
    cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/Hello.java
    cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/Hello2.java
    cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/Hello3.java
    cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/HelloInterface.java
    cxf/trunk/systests/ws-specs/src/test/resources/wsdl_systest_wsspec/add_numbers-fromjava.wsdl

Modified: cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/CodeFirstTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/CodeFirstTest.java?rev=1409658&r1=1409657&r2=1409658&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/CodeFirstTest.java (original)
+++ cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/CodeFirstTest.java Thu
Nov 15 06:19:11 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/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/CodeFirstWSDLTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/CodeFirstWSDLTest.java?rev=1409658&r1=1409657&r2=1409658&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/CodeFirstWSDLTest.java
(original)
+++ cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/CodeFirstWSDLTest.java
Thu Nov 15 06:19:11 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/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/AddNumbersException.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/AddNumbersException.java?rev=1409658&view=auto
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/AddNumbersException.java
(added)
+++ cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/AddNumbersException.java
Thu Nov 15 06:19:11 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/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/Hello.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/Hello.java?rev=1409658&r1=1409657&r2=1409658&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/Hello.java (original)
+++ cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/Hello.java Thu
Nov 15 06:19:11 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/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/Hello2.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/Hello2.java?rev=1409658&r1=1409657&r2=1409658&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/Hello2.java (original)
+++ cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/Hello2.java Thu
Nov 15 06:19:11 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/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/Hello3.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/Hello3.java?rev=1409658&r1=1409657&r2=1409658&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/Hello3.java (original)
+++ cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/Hello3.java Thu
Nov 15 06:19:11 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/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/HelloInterface.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/HelloInterface.java?rev=1409658&r1=1409657&r2=1409658&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/HelloInterface.java
(original)
+++ cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/service/HelloInterface.java
Thu Nov 15 06:19:11 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/trunk/systests/ws-specs/src/test/resources/wsdl_systest_wsspec/add_numbers-fromjava.wsdl
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/ws-specs/src/test/resources/wsdl_systest_wsspec/add_numbers-fromjava.wsdl?rev=1409658&r1=1409657&r2=1409658&view=diff
==============================================================================
--- cxf/trunk/systests/ws-specs/src/test/resources/wsdl_systest_wsspec/add_numbers-fromjava.wsdl
(original)
+++ cxf/trunk/systests/ws-specs/src/test/resources/wsdl_systest_wsspec/add_numbers-fromjava.wsdl
Thu Nov 15 06:19:11 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