cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject svn commit: r1245591 - in /cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/rm: ControlImpl.java ServiceInvocationAckTest.java sync-ack-server.xml
Date Fri, 17 Feb 2012 14:59:37 GMT
Author: ay
Date: Fri Feb 17 14:59:36 2012
New Revision: 1245591

URL: http://svn.apache.org/viewvc?rev=1245591&view=rev
Log:
add a robust-inonly test case with wsrm usage

Added:
    cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/rm/ServiceInvocationAckTest.java
    cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/rm/sync-ack-server.xml
  (with props)
Modified:
    cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/rm/ControlImpl.java

Modified: cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/rm/ControlImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/rm/ControlImpl.java?rev=1245591&r1=1245590&r2=1245591&view=diff
==============================================================================
--- cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/rm/ControlImpl.java
(original)
+++ cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/rm/ControlImpl.java
Fri Feb 17 14:59:36 2012
@@ -72,10 +72,10 @@ public class ControlImpl  extends org.ap
             greeterBus.getOutFaultInterceptors().add(logOut);
 
             if (cfgResource.indexOf("provider") == -1) {
-                Endpoint.publish(address, implementor);
+                endpoint = Endpoint.publish(address, implementor);
                 LOG.info("Published greeter endpoint.");
             } else {
-                Endpoint.publish(address, new GreeterProvider());
+                endpoint = Endpoint.publish(address, new GreeterProvider());
                 LOG.info("Published greeter provider.");
             }
         } finally {

Added: cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/rm/ServiceInvocationAckTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/rm/ServiceInvocationAckTest.java?rev=1245591&view=auto
==============================================================================
--- cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/rm/ServiceInvocationAckTest.java
(added)
+++ cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/rm/ServiceInvocationAckTest.java
Fri Feb 17 14:59:36 2012
@@ -0,0 +1,203 @@
+/**
+ * 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.rm;
+
+import java.net.MalformedURLException;
+import java.util.logging.Logger;
+
+import javax.xml.ws.Endpoint;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.bus.spring.SpringBusFactory;
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.greeter_control.Control;
+import org.apache.cxf.greeter_control.ControlService;
+import org.apache.cxf.greeter_control.Greeter;
+import org.apache.cxf.greeter_control.GreeterService;
+import org.apache.cxf.greeter_control.types.FaultLocation;
+import org.apache.cxf.interceptor.ServiceInvokerInterceptor;
+import org.apache.cxf.phase.Phase;
+import org.apache.cxf.test.TestUtilities;
+import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
+import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
+import org.apache.cxf.ws.rm.RMManager;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Tests the acknowledgement delivery back to the non-decoupled port when there is some
+ * error at the provider side and how its behavior is affected by the robust in-only mode
setting.
+ */
+public class ServiceInvocationAckTest extends AbstractBusClientServerTestBase {
+    public static final String PORT = allocatePort(Server.class);
+    
+    private static final Logger LOG = LogUtils.getLogger(ServiceInvocationAckTest.class);
+
+    private static final String CONTROL_PORT_ADDRESS = 
+        "http://localhost:" + PORT + "/SoapContext/ControlPort";
+
+    public static class Server extends AbstractBusTestServerBase {
+
+        protected void run() {
+            SpringBusFactory factory = new SpringBusFactory();
+            Bus bus = factory.createBus();
+            BusFactory.setDefaultBus(bus);
+            setBus(bus);
+
+            ControlImpl implementor = new ControlImpl();
+            implementor.setAddress("http://localhost:" + PORT + "/SoapContext/GreeterPort");
+            GreeterImpl greeterImplementor = new GreeterImpl();
+            implementor.setImplementor(greeterImplementor);
+            Endpoint.publish(CONTROL_PORT_ADDRESS, implementor);
+            LOG.fine("Published control endpoint.");
+        }
+
+        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!");
+            }
+        }
+    }
+    
+    private Bus controlBus;
+    private Control control;
+    private Bus greeterBus;
+    private Greeter greeter;
+    
+
+    @BeforeClass
+    public static void startServers() throws Exception {
+        TestUtilities.setKeepAliveSystemProperty(false);
+        assertTrue("server did not launch correctly", launchServer(Server.class, true));
+    }
+    
+    @AfterClass
+    public static void cleanup() {
+        TestUtilities.recoverKeepAliveSystemProperty();
+    }
+    
+    @After
+    public void tearDown() {
+        if (null != greeter) {
+            assertTrue("Failed to stop greeter.", control.stopGreeter(null));
+            greeterBus.shutdown(true);
+            greeterBus = null;
+        }
+        if (null != control) {  
+            assertTrue("Failed to stop greeter", control.stopGreeter(null));
+            controlBus.shutdown(true);
+        }
+    }
+
+    @Test
+    public void testDefaultInvocationHandling() throws Exception {
+        setupGreeter("org/apache/cxf/systest/ws/rm/sync-ack-server.xml");
+
+        control.setRobustInOnlyMode(false);
+        
+        FaultLocation location = new org.apache.cxf.greeter_control.types.ObjectFactory()
+            .createFaultLocation();
+        location.setPhase(Phase.INVOKE);
+        location.setBefore(ServiceInvokerInterceptor.class.getName());
+        
+        RMManager manager = greeterBus.getExtension(RMManager.class);
+
+        // the message is acked and the invocation takes place
+        greeter.greetMeOneWay("one");
+        Thread.sleep(6000L);
+        assertTrue("RetransmissionQueue must be empty", manager.getRetransmissionQueue().isEmpty());
+    
+        control.setFaultLocation(location);
+
+        // the invocation fails but the message is acked because the delivery succeeds
+        greeter.greetMeOneWay("two");
+        Thread.sleep(6000L);
+        assertTrue("RetransmissionQueue must be empty", manager.getRetransmissionQueue().isEmpty());
+    }
+
+    @Test
+    public void testRobustInvocationHandling() throws Exception {
+        setupGreeter("org/apache/cxf/systest/ws/rm/sync-ack-server.xml");
+
+        control.setRobustInOnlyMode(true);
+        
+        FaultLocation location = new org.apache.cxf.greeter_control.types.ObjectFactory()
+            .createFaultLocation();
+        location.setPhase(Phase.INVOKE);
+        location.setBefore(ServiceInvokerInterceptor.class.getName());
+        
+        RMManager manager = greeterBus.getExtension(RMManager.class);
+
+        
+        // the message is acked and the invocation takes place
+        greeter.greetMeOneWay("one");
+        Thread.sleep(6000L);
+        assertTrue("RetransmissionQueue must be empty", manager.getRetransmissionQueue().isEmpty());
+
+        control.setFaultLocation(location);
+
+        // the invocation fails but the message is acked because the delivery succeeds
+        greeter.greetMeOneWay("two");
+        Thread.sleep(6000L);
+        assertFalse("RetransmissionQueue must not be empty", manager.getRetransmissionQueue().isEmpty());
+        
+        location.setPhase(null);
+        control.setFaultLocation(location);
+
+        // the retransmission succeeds and the invocation succeeds, the message is acked
+        Thread.sleep(6000L);
+        assertTrue("RetransmissionQueue must be empty", manager.getRetransmissionQueue().isEmpty());
+        
+    }
+
+    private void setupGreeter(String cfgResource) throws NumberFormatException, MalformedURLException
{
+        
+        SpringBusFactory bf = new SpringBusFactory();
+        
+        controlBus = bf.createBus();
+        BusFactory.setDefaultBus(controlBus);
+
+        ControlService cs = new ControlService();
+        control = cs.getControlPort();
+        updateAddressPort(control, PORT);
+        
+        assertTrue("Failed to start greeter", control.startGreeter(cfgResource));
+        
+        greeterBus = bf.createBus(cfgResource);
+        BusFactory.setDefaultBus(greeterBus);
+        LOG.fine("Initialised greeter bus with configuration: " + cfgResource);
+        
+        GreeterService gs = new GreeterService();
+
+        greeter = gs.getGreeterPort();
+        updateAddressPort(greeter, PORT);
+        LOG.fine("Created greeter client.");
+
+    }
+}

Added: cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/rm/sync-ack-server.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/rm/sync-ack-server.xml?rev=1245591&view=auto
==============================================================================
Binary file - no diff available.

Propchange: cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/rm/sync-ack-server.xml
------------------------------------------------------------------------------
    svn:mime-type = application/xml



Mime
View raw message