Author: mmao
Date: Tue Dec  4 01:32:14 2007
New Revision: 600851

URL: http://svn.apache.org/viewvc?rev=600851&view=rev
Log:
CXF-1241 
 Add the testcase for the WS-A Action/FaultAction support From Java approach


Added:
    
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_fromjava/
    
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_fromjava/WSAFromJavaTest.java
    
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_fromjava/server/
    
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_fromjava/server/AddNumberImpl.java
    
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_fromjava/server/AddNumbersException.java
    
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_fromjava/server/Server.java
    
incubator/cxf/trunk/systests/src/test/resources/wsdl/add_numbers-fromjava.wsdl
Modified:
    incubator/cxf/trunk/systests/pom.xml
    
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_fromwsdl/AddNumberImpl.java

Modified: incubator/cxf/trunk/systests/pom.xml
URL: 
http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/pom.xml?rev=600851&r1=600850&r2=600851&view=diff
==============================================================================
--- incubator/cxf/trunk/systests/pom.xml (original)
+++ incubator/cxf/trunk/systests/pom.xml Tue Dec  4 01:32:14 2007
@@ -87,6 +87,14 @@
                                     
<wsdl>${basedir}/src/test/resources/wsdl/add_numbers.wsdl</wsdl>
                                 </wsdlOption>
 
+                                <wsdlOption>
+                                    
<wsdl>${basedir}/src/test/resources/wsdl/add_numbers-fromjava.wsdl</wsdl>
+                                    <extraargs>
+                                        <extraarg>-p</extraarg>
+                                        
<extraarg>org.apache.cxf.systest.ws.addr_fromjava.client</extraarg>
+                                    </extraargs>
+                                </wsdlOption>
+
                             </wsdlOptions>
                         </configuration>
                         <goals>

Added: 
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_fromjava/WSAFromJavaTest.java
URL: 
http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_fromjava/WSAFromJavaTest.java?rev=600851&view=auto
==============================================================================
--- 
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_fromjava/WSAFromJavaTest.java
 (added)
+++ 
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_fromjava/WSAFromJavaTest.java
 Tue Dec  4 01:32:14 2007
@@ -0,0 +1,94 @@
+/**
+ * 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.systest.ws.addr_fromjava;
+
+import java.io.ByteArrayOutputStream;
+import java.io.PrintWriter;
+import java.net.URL;
+import javax.xml.ws.soap.AddressingFeature;
+
+import org.apache.cxf.interceptor.LoggingInInterceptor;
+import org.apache.cxf.interceptor.LoggingOutInterceptor;
+import org.apache.cxf.systest.ws.addr_fromjava.client.AddNumberImpl;
+import org.apache.cxf.systest.ws.addr_fromjava.client.AddNumberImplService;
+import org.apache.cxf.systest.ws.addr_fromjava.server.Server;
+import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class WSAFromJavaTest extends AbstractBusClientServerTestBase {
+
+    @Before
+    public void setUp() throws Exception {
+        createBus();
+    }
+
+    @BeforeClass
+    public static void startServers() throws Exception {
+        assertTrue("server did not launch correctly", 
launchServer(Server.class));
+    }
+
+    private ByteArrayOutputStream setupInLogging() {
+        ByteArrayOutputStream bos = new ByteArrayOutputStream();
+        PrintWriter writer = new PrintWriter(bos, true);
+        LoggingInInterceptor in = new LoggingInInterceptor(writer);
+        this.bus.getInInterceptors().add(in);
+        return bos;
+    }
+
+    private ByteArrayOutputStream setupOutLogging() {
+        ByteArrayOutputStream bos = new ByteArrayOutputStream();
+        PrintWriter writer = new PrintWriter(bos, true);
+
+        LoggingOutInterceptor out = new LoggingOutInterceptor(writer);
+        this.bus.getOutInterceptors().add(out);
+
+        return bos;
+    }
+
+    @Test
+    public void testAddNumbers() throws Exception {
+        ByteArrayOutputStream input = setupInLogging();
+        ByteArrayOutputStream output = setupOutLogging();
+
+        AddNumberImpl port = getPort();
+
+        assertEquals(3, port.addNumbers(1, 2));
+
+        String expectedOut = "http://cxf.apache.org/input";;
+        assertTrue(output.toString().indexOf(expectedOut) != -1);
+        
+        // TODO: will support response action after the java2wsdl support the 
wsa:action
+        String expectedIn = "http://cxf.apache.org/output";;
+        assertTrue(input.toString().indexOf(expectedIn) == -1);
+    }
+
+    private AddNumberImpl getPort() {
+        URL wsdl = getClass().getResource("/wsdl/add_numbers-fromjava.wsdl");
+        assertNotNull("WSDL is null", wsdl);
+
+        AddNumberImplService service = new AddNumberImplService(wsdl);
+        assertNotNull("Service is null ", service);
+
+        // TODO, this is wrong, the addressing could be enabled by reading the 
wsdl extensions
+        return service.getAddNumberImplPort(new AddressingFeature());
+    }
+}
\ No newline at end of file

Added: 
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_fromjava/server/AddNumberImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_fromjava/server/AddNumberImpl.java?rev=600851&view=auto
==============================================================================
--- 
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_fromjava/server/AddNumberImpl.java
 (added)
+++ 
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_fromjava/server/AddNumberImpl.java
 Tue Dec  4 01:32:14 2007
@@ -0,0 +1,57 @@
+/**
+ * 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.systest.ws.addr_fromjava.server;
+
+import javax.jws.WebService;
+import javax.xml.ws.Action;
+import javax.xml.ws.FaultAction;
+import javax.xml.ws.soap.Addressing;
+
+// Jax-WS 2.1 WS-Addressing FromJava
+
[EMAIL PROTECTED]
[EMAIL PROTECTED]
+public class AddNumberImpl {
+    @Action(
+            input = "http://cxf.apache.org/input";,
+            output = "http://cxf.apache.org/output";)
+    public int addNumbers(int number1, int number2) throws AddNumbersException 
{
+        return execute(number1, number2);
+    }
+
+    public int addNumbers2(int number1, int number2) {
+        return number1 + number2;
+    }
+
+    @Action(input = "http://cxf.apache.org/input3";, output = 
"http://cxf.apache.org/output3";,
+            fault = [EMAIL PROTECTED](className = AddNumbersException.class, 
+                                  value = "http://cxf.apache.org/fault3";) })
+    public int addNumbers3(int number1, int number2) throws 
AddNumbersException {
+        return execute(number1, number2);
+    }
+
+    int execute(int number1, int number2) throws AddNumbersException {
+        if (number1 < 0 || number2 < 0) {
+            throw new AddNumbersException("Negative numbers can't be added!",
+                                          "Numbers: " + number1 + ", " + 
number2);
+        }
+        return number1 + number2;
+    }
+}

Added: 
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_fromjava/server/AddNumbersException.java
URL: 
http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_fromjava/server/AddNumbersException.java?rev=600851&view=auto
==============================================================================
--- 
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_fromjava/server/AddNumbersException.java
 (added)
+++ 
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_fromjava/server/AddNumbersException.java
 Tue Dec  4 01:32:14 2007
@@ -0,0 +1,33 @@
+/**
+ * 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.systest.ws.addr_fromjava.server;
+
+public class AddNumbersException extends Exception {
+    String detail;
+
+    public AddNumbersException(String message, String detail) {
+        super(message);
+        this.detail = detail;
+    }
+
+    public String getDetail() {
+        return detail;
+    }
+}

Added: 
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_fromjava/server/Server.java
URL: 
http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_fromjava/server/Server.java?rev=600851&view=auto
==============================================================================
--- 
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_fromjava/server/Server.java
 (added)
+++ 
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_fromjava/server/Server.java
 Tue Dec  4 01:32:14 2007
@@ -0,0 +1,49 @@
+/**
+ * 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.systest.ws.addr_fromjava.server;
+
+import org.apache.cxf.jaxws.EndpointImpl;
+import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
+import org.apache.cxf.ws.addressing.WSAddressingFeature;
+
+public class Server extends AbstractBusTestServerBase {
+
+    protected void run() {
+        Object implementor = new AddNumberImpl();
+        String address = "http://localhost:9092/AddNumberImplPort";;
+        
+        EndpointImpl ep = new EndpointImpl(implementor);
+
+        ep.getFeatures().add(new WSAddressingFeature());
+        ep.publish(address);
+    }
+
+    public static void main(String[] args) {
+        try {
+            Server s = new Server();
+            s.start();
+        } catch (Exception ex) {
+            ex.printStackTrace();
+            System.exit(-1);
+        } finally {
+            System.out.println("done!");
+        }
+    }
+}
\ No newline at end of file

Modified: 
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_fromwsdl/AddNumberImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_fromwsdl/AddNumberImpl.java?rev=600851&r1=600850&r2=600851&view=diff
==============================================================================
--- 
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_fromwsdl/AddNumberImpl.java
 (original)
+++ 
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addr_fromwsdl/AddNumberImpl.java
 Tue Dec  4 01:32:14 2007
@@ -20,7 +20,6 @@
 package org.apache.cxf.systest.ws.addr_fromwsdl;
 
 import javax.jws.WebService;
-import javax.xml.ws.soap.Addressing;
 
 import org.apache.cxf.systest.ws.addr_feature.AddNumbersFault;
 import org.apache.cxf.systest.ws.addr_feature.AddNumbersFault_Exception;
@@ -28,7 +27,6 @@
 
 // Jax-WS 2.1 WS-Addressing FromWsdl
 
[EMAIL PROTECTED]
 @WebService(serviceName = "AddNumbersService",
             targetNamespace = "http://apache.org/cxf/systest/ws/addr_feature/";)
 public class AddNumberImpl implements AddNumbersPortType {

Added: 
incubator/cxf/trunk/systests/src/test/resources/wsdl/add_numbers-fromjava.wsdl
URL: 
http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/resources/wsdl/add_numbers-fromjava.wsdl?rev=600851&view=auto
==============================================================================
--- 
incubator/cxf/trunk/systests/src/test/resources/wsdl/add_numbers-fromjava.wsdl 
(added)
+++ 
incubator/cxf/trunk/systests/src/test/resources/wsdl/add_numbers-fromjava.wsdl 
Tue Dec  4 01:32:14 2007
@@ -0,0 +1,161 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+
+<wsdl:definitions name="AddNumberImplService" 
targetNamespace="http://server.addr_fromjava.ws.systest.cxf.apache.org/"; 
+                 
xmlns:tns="http://server.addr_fromjava.ws.systest.cxf.apache.org/"; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
+                 xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl";
+                 xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"; 
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/";>
+    <wsdl:types>
+       <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
xmlns:tns="http://server.addr_fromjava.ws.systest.cxf.apache.org/"; 
+                   attributeFormDefault="unqualified" 
elementFormDefault="qualified" 
+                   
targetNamespace="http://server.addr_fromjava.ws.systest.cxf.apache.org/";>
+           <xsd:element name="AddNumbersException" 
type="tns:AddNumbersException"/>
+           <xsd:complexType name="AddNumbersException">
+               <xsd:sequence/>
+           </xsd:complexType>
+           <xsd:element name="addNumbers3" type="tns:addNumbers3"/>
+           <xsd:complexType name="addNumbers3">
+               <xsd:sequence>
+                   <xsd:element name="arg0" type="xsd:int"/>
+                   <xsd:element name="arg1" type="xsd:int"/>
+               </xsd:sequence>
+           </xsd:complexType>
+           <xsd:element name="addNumbers3Response" 
type="tns:addNumbers3Response"/>
+           <xsd:complexType name="addNumbers3Response">
+               <xsd:sequence>
+                   <xsd:element name="return" type="xsd:int"/>
+               </xsd:sequence>
+           </xsd:complexType>
+           <xsd:element name="addNumbers2" type="tns:addNumbers2"/>
+           <xsd:complexType name="addNumbers2">
+               <xsd:sequence>
+                   <xsd:element name="arg0" type="xsd:int"/>
+                   <xsd:element name="arg1" type="xsd:int"/>
+               </xsd:sequence>
+           </xsd:complexType>
+           <xsd:element name="addNumbers2Response" 
type="tns:addNumbers2Response"/>
+           <xsd:complexType name="addNumbers2Response">
+               <xsd:sequence>
+                   <xsd:element name="return" type="xsd:int"/>
+               </xsd:sequence>
+           </xsd:complexType>
+           <xsd:element name="addNumbers" type="tns:addNumbers"/>
+           <xsd:complexType name="addNumbers">
+               <xsd:sequence>
+                   <xsd:element name="arg0" type="xsd:int"/>
+                   <xsd:element name="arg1" type="xsd:int"/>
+               </xsd:sequence>
+           </xsd:complexType>
+           <xsd:element name="addNumbersResponse" 
type="tns:addNumbersResponse"/>
+           <xsd:complexType name="addNumbersResponse">
+               <xsd:sequence>
+                   <xsd:element name="return" type="xsd:int"/>
+               </xsd:sequence>
+           </xsd:complexType>
+       </xsd:schema>
+    </wsdl:types>
+    <wsdl:message name="addNumbers2Response">
+       <wsdl:part name="parameters" element="tns:addNumbers2Response">
+       </wsdl:part>
+    </wsdl:message>
+    <wsdl:message name="addNumbers2">
+       <wsdl:part name="parameters" element="tns:addNumbers2">
+       </wsdl:part>
+    </wsdl:message>
+    <wsdl:message name="addNumbers3Response">
+       <wsdl:part name="parameters" element="tns:addNumbers3Response">
+       </wsdl:part>
+    </wsdl:message>
+    <wsdl:message name="addNumbers">
+       <wsdl:part name="parameters" element="tns:addNumbers">
+       </wsdl:part>
+    </wsdl:message>
+    <wsdl:message name="addNumbers3">
+       <wsdl:part name="parameters" element="tns:addNumbers3">
+       </wsdl:part>
+    </wsdl:message>
+    <wsdl:message name="AddNumbersException">
+       <wsdl:part name="AddNumbersException" element="tns:AddNumbersException">
+       </wsdl:part>
+    </wsdl:message>
+    <wsdl:message name="addNumbersResponse">
+       <wsdl:part name="parameters" element="tns:addNumbersResponse">
+       </wsdl:part>
+    </wsdl:message>
+
+    <wsdl:portType name="AddNumberImpl">
+       <wsdl:operation name="addNumbers">
+           <wsdl:input name="addNumbers" message="tns:addNumbers" 
wsaw:Action="http://cxf.apache.org/input"/>
+           <wsdl:output name="addNumbersResponse" 
message="tns:addNumbersResponse" wsaw:Action="http://cxf.apache.org/output"/>
+           <wsdl:fault name="AddNumbersException" 
message="tns:AddNumbersException"/>
+       </wsdl:operation>
+       <wsdl:operation name="addNumbers2">
+           <wsdl:input name="addNumbers2" message="tns:addNumbers2"/>
+           <wsdl:output name="addNumbers2Response" 
message="tns:addNumbers2Response"/>
+       </wsdl:operation>
+       <wsdl:operation name="addNumbers3">
+           <wsdl:input name="addNumbers3" message="tns:addNumbers3" 
wsaw:Action="http://cxf.apache.org/input3"/>
+           <wsdl:output name="addNumbers3Response" 
message="tns:addNumbers3Response" wsaw:Action="http://cxf.apache.org/output3"/>
+           <wsdl:fault name="AddNumbersException" 
message="tns:AddNumbersException" wsaw:Action="http://cxf.apache.org/fault3"/>
+       </wsdl:operation>
+    </wsdl:portType>
+    <wsdl:binding name="AddNumberImplServiceSoapBinding" 
type="tns:AddNumberImpl">
+       <wsaw:UsingAddressing/>
+       <soap:binding style="document" 
transport="http://schemas.xmlsoap.org/soap/http"/>
+       <wsdl:operation name="addNumbers3">
+           <soap:operation soapAction="" style="document"/>
+           <wsdl:input name="addNumbers3">
+               <soap:body use="literal"/>
+           </wsdl:input>
+           <wsdl:output name="addNumbers3Response">
+               <soap:body use="literal"/>
+           </wsdl:output>
+           <wsdl:fault name="AddNumbersException">
+               <soap:fault name="AddNumbersException" use="literal"/>
+           </wsdl:fault>
+       </wsdl:operation>
+       <wsdl:operation name="addNumbers2">
+           <soap:operation soapAction="" style="document"/>
+           <wsdl:input name="addNumbers2">
+               <soap:body use="literal"/>
+           </wsdl:input>
+           <wsdl:output name="addNumbers2Response">
+               <soap:body use="literal"/>
+           </wsdl:output>
+       </wsdl:operation>
+       <wsdl:operation name="addNumbers">
+           <soap:operation soapAction="" style="document"/>
+           <wsdl:input name="addNumbers">
+               <soap:body use="literal"/>
+           </wsdl:input>
+           <wsdl:output name="addNumbersResponse">
+               <soap:body use="literal"/>
+           </wsdl:output>
+           <wsdl:fault name="AddNumbersException">
+               <soap:fault name="AddNumbersException" use="literal"/>
+           </wsdl:fault>
+       </wsdl:operation>
+    </wsdl:binding>
+    <wsdl:service name="AddNumberImplService">
+       <wsdl:port name="AddNumberImplPort" 
binding="tns:AddNumberImplServiceSoapBinding">
+           <soap:address location="http://localhost:9092/AddNumberImplPort"/>
+       </wsdl:port>
+    </wsdl:service>
+</wsdl:definitions>
\ No newline at end of file


Reply via email to