cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject [1/6] cxf git commit: [CXF-7399, CXF-7392] Add testcase for CXF-7399 (still fails), but fix CXF-7392 discovered while writing testcase
Date Thu, 08 Jun 2017 17:02:48 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.1.x-fixes 060a7c132 -> ab78f3ac5


[CXF-7399, CXF-7392] Add testcase for CXF-7399 (still fails), but fix CXF-7392 discovered
while writing testcase


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/0fd31066
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/0fd31066
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/0fd31066

Branch: refs/heads/3.1.x-fixes
Commit: 0fd310667ba814a4065890df4ae7561a112092e2
Parents: 060a7c1
Author: Daniel Kulp <dkulp@apache.org>
Authored: Wed Jun 7 16:26:13 2017 -0400
Committer: Daniel Kulp <dkulp@apache.org>
Committed: Thu Jun 8 11:48:27 2017 -0400

----------------------------------------------------------------------
 .../java/org/apache/cxf/ws/rm/RMManager.java    |  2 +
 .../ws/rm/AbstractServerPersistenceTest.java    | 88 ++++++++++----------
 .../apache/cxf/systest/ws/rm/ControlImpl.java   |  5 ++
 .../systest/ws/rm/WSRM12ServerCycleTest.java    | 56 ++++++++++---
 .../org/apache/cxf/systest/ws/rm/simple.xml     | 32 +++++++
 5 files changed, 128 insertions(+), 55 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/0fd31066/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMManager.java
----------------------------------------------------------------------
diff --git a/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMManager.java b/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMManager.java
index 603e8d6..732ae77 100644
--- a/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMManager.java
+++ b/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMManager.java
@@ -597,6 +597,8 @@ public class RMManager {
         if (s.getAssociatedSequence(null) == null && !ss.isExpired() && !ss.isLastMessage())
{
             s.setCurrent(ss);
         }
+        //make sure this is associated with the offering id
+        s.setCurrent(ss.getOfferingSequenceIdentifier(), ss);
         for (RMMessage m : ms) {                
             
             Message message = new MessageImpl();

http://git-wip-us.apache.org/repos/asf/cxf/blob/0fd31066/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/AbstractServerPersistenceTest.java
----------------------------------------------------------------------
diff --git a/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/AbstractServerPersistenceTest.java
b/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/AbstractServerPersistenceTest.java
index 48ec5d6..5d16d2c 100644
--- a/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/AbstractServerPersistenceTest.java
+++ b/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/AbstractServerPersistenceTest.java
@@ -57,7 +57,7 @@ import org.junit.Test;
  */
 public abstract class AbstractServerPersistenceTest extends AbstractBusClientServerTestBase
{
 
-    public static final String GREETMEONEWAY_ACTION 
+    public static final String GREETMEONEWAY_ACTION
         = "http://cxf.apache.org/greeter_control/Greeter/greetMeOneWayRequest";
     public static final String GREETME_ACTION
         = "http://cxf.apache.org/greeter_control/Greeter/greetMeRequest";
@@ -66,13 +66,13 @@ public abstract class AbstractServerPersistenceTest extends AbstractBusClientSer
 
     private static final Logger LOG = LogUtils.getLogger(ServerPersistenceTest.class);
     private static final String CFG = "/org/apache/cxf/systest/ws/rm/persistent.xml";
-    private static final String SERVER_LOSS_CFG 
+    private static final String SERVER_LOSS_CFG
         = "/org/apache/cxf/systest/ws/rm/persistent-message-loss-server.xml";
 
     private OutMessageRecorder out;
     private InMessageRecorder in;
     private Bus greeterBus;
-    
+
     public static class Server extends AbstractBusTestServerBase {
         String port;
         String pfx;
@@ -81,7 +81,7 @@ public abstract class AbstractServerPersistenceTest extends AbstractBusClientSer
             port = args[0];
             pfx = args[1];
         }
-        
+
         protected void run()  {
             SpringBusFactory factory = new SpringBusFactory();
             Bus bus = factory.createBus();
@@ -96,7 +96,7 @@ public abstract class AbstractServerPersistenceTest extends AbstractBusClientSer
             implementor.setImplementor(greeterImplementor);
             ep = Endpoint.publish("http://localhost:" + port + "/SoapContext/ControlPort",
implementor);
             BusFactory.setDefaultBus(null);
-            BusFactory.setThreadDefaultBus(null);            
+            BusFactory.setThreadDefaultBus(null);
         }
         public void tearDown() {
             ep.stop();
@@ -105,48 +105,48 @@ public abstract class AbstractServerPersistenceTest extends AbstractBusClientSer
         public static void main(String args[]) {
             new Server(args).start();
         }
-    }    
-    
+    }
+
     public abstract String getPort();
     public abstract String getDecoupledPort();
     public abstract String getPrefix();
-    
+
     public static void startServers(String port, String pfx) throws Exception {
         RMTxStore.deleteDatabaseFiles(pfx + "-recovery", true);
         RMTxStore.deleteDatabaseFiles(pfx + "-greeter", true);
-        assertTrue("server did not launch correctly", 
-                   launchServer(Server.class, null, new String[] {port, pfx}, true));  
+        assertTrue("server did not launch correctly",
+                   launchServer(Server.class, null, new String[] {port, pfx}, true));
     }
 
-    @Test 
+    @Test
     public void testRecovery() throws Exception {
         SpringBusFactory bf = new SpringBusFactory();
         bus = bf.createBus();
-        BusFactory.setDefaultBus(bus);        
+        BusFactory.setDefaultBus(bus);
         LOG.fine("Created bus " + bus + " with default cfg");
         ControlService cs = new ControlService();
         Control control = cs.getControlPort();
         ConnectionHelper.setKeepAliveConnection(control, false, true);
         updateAddressPort(control, getPort());
-        
-        assertTrue("Failed to start greeter", control.startGreeter(SERVER_LOSS_CFG)); 
+
+        assertTrue("Failed to start greeter", control.startGreeter(SERVER_LOSS_CFG));
         LOG.fine("Started greeter server.");
-        
+
         System.setProperty("db.name", getPrefix() + "-recovery");
         greeterBus = new SpringBusFactory().createBus(CFG);
         System.clearProperty("db.name");
-        LOG.fine("Created bus " + greeterBus + " with cfg : " + CFG);        
+        LOG.fine("Created bus " + greeterBus + " with cfg : " + CFG);
         BusFactory.setDefaultBus(greeterBus);
-        
+
         // avoid early client resends
         greeterBus.getExtension(RMManager.class).getConfiguration()
             .setBaseRetransmissionInterval(new Long(60000));
         GreeterService gs = new GreeterService();
         Greeter greeter = gs.getGreeterPort();
         updateAddressPort(greeter, getPort());
-        
+
         LOG.fine("Created greeter client.");
- 
+
         ConnectionHelper.setKeepAliveConnection(greeter, false, true);
 
         Client c = ClientProxy.getClient(greeter);
@@ -159,41 +159,41 @@ public abstract class AbstractServerPersistenceTest extends AbstractBusClientSer
 
         greeterBus.getOutInterceptors().add(out);
         greeterBus.getInInterceptors().add(in);
-        
+
         LOG.fine("Configured greeter client.");
 
         Response<GreetMeResponse> responses[] = cast(new Response[4]);
-        
+
         responses[0] = greeter.greetMeAsync("one");
         responses[1] = greeter.greetMeAsync("two");
         responses[2] = greeter.greetMeAsync("three");
-        
+
         verifyMissingResponse(responses);
         control.stopGreeter(SERVER_LOSS_CFG);
         LOG.fine("Stopped greeter server");
-       
+
         out.getOutboundMessages().clear();
         in.getInboundMessages().clear();
-        
+
         control.startGreeter(CFG);
         String nl = System.getProperty("line.separator");
         LOG.fine("Restarted greeter server" + nl + nl);
-        
+
         verifyServerRecovery(responses);
         responses[3] = greeter.greetMeAsync("four");
-        
+
         verifyRetransmissionQueue();
         verifyAcknowledgementRange(1, 4);
-        
+
         out.getOutboundMessages().clear();
         in.getInboundMessages().clear();
 
         greeterBus.shutdown(true);
-        
+
         control.stopGreeter(CFG);
         bus.shutdown(true);
     }
-    
+
     void verifyMissingResponse(Response<GreetMeResponse> responses[]) throws Exception
{
         awaitMessages(5, 3, 25000);
 
@@ -203,9 +203,9 @@ public abstract class AbstractServerPersistenceTest extends AbstractBusClientSer
                 nDone++;
             }
         }
-        
+
         assertEquals("Unexpected number of responses already received.", 2, nDone);
-        
+
         MessageFlow mf = new MessageFlow(out.getOutboundMessages(), in.getInboundMessages(),
             Names200408.WSA_NAMESPACE_NAME, RM10Constants.NAMESPACE_URI);
         String[] expectedActions = new String[] {RM10Constants.CREATE_SEQUENCE_ACTION,
@@ -216,7 +216,7 @@ public abstract class AbstractServerPersistenceTest extends AbstractBusClientSer
         mf.verifyActions(expectedActions, true);
         // mf.verifyMessageNumbers(new String[] {null, "1", "2", "3"}, true);
         // mf.verifyAcknowledgements(new boolean[] {false, false, true, false}, true);
-        
+
 //        mf.verifyPartialResponses(5);
 //        mf.purgePartialResponses();
         expectedActions = new String[] {RM10Constants.CREATE_SEQUENCE_RESPONSE_ACTION,
@@ -224,11 +224,11 @@ public abstract class AbstractServerPersistenceTest extends AbstractBusClientSer
                                         GREETME_RESPONSE_ACTION};
         mf.verifyActions(expectedActions, false);
         // mf.verifyMessageNumbers(new String[] {null, "1", "3"}, false);
-        // mf.verifyAcknowledgements(new boolean[] {false, true, true}, false);    
+        // mf.verifyAcknowledgements(new boolean[] {false, true, true}, false);
     }
-    
+
     void verifyServerRecovery(Response<GreetMeResponse> responses[]) throws Exception
{
-   
+
         // wait until all messages have received their responses
         int nDone = 0;
         long waited = 0;
@@ -245,11 +245,11 @@ public abstract class AbstractServerPersistenceTest extends AbstractBusClientSer
             Thread.sleep(500);
             waited++;
         }
-        
+
         assertEquals("Not all responses have been received.", 3, nDone);
 
         // verify that all inbound messages are resent responses
-        
+
         synchronized (this) {
             MessageFlow mf = new MessageFlow(out.getOutboundMessages(), in.getInboundMessages(),
                 Names200408.WSA_NAMESPACE_NAME, RM10Constants.NAMESPACE_URI);
@@ -264,16 +264,16 @@ public abstract class AbstractServerPersistenceTest extends AbstractBusClientSer
             mf.verifyActions(expectedActions, false);
         }
     }
-  
-    
+
+
     void verifyRetransmissionQueue() throws Exception {
-        awaitMessages(2, 3, 60000);
-        
+        awaitMessages(2, 2, 60000);
+
         Thread.sleep(5000);
         boolean empty = greeterBus.getExtension(RMManager.class).getRetransmissionQueue().isEmpty();
         assertTrue("Retransmission Queue is not empty", empty);
     }
-    
+
     void verifyAcknowledgementRange(long lower, long higher) throws Exception {
         MessageFlow mf = new MessageFlow(out.getOutboundMessages(), in.getInboundMessages(),
             Names200408.WSA_NAMESPACE_NAME, RM10Constants.NAMESPACE_URI);
@@ -283,12 +283,12 @@ public abstract class AbstractServerPersistenceTest extends AbstractBusClientSer
     protected void awaitMessages(int nExpectedOut, int nExpectedIn) {
         awaitMessages(nExpectedOut, nExpectedIn, 20000);
     }
-    
+
     private void awaitMessages(int nExpectedOut, int nExpectedIn, int timeout) {
         MessageRecorder mr = new MessageRecorder(out, in);
         mr.awaitMessages(nExpectedOut, nExpectedIn, timeout);
     }
-    
+
     @SuppressWarnings("unchecked")
     <T> Response<T>[] cast(Response<?>[] val) {
         return (Response<T>[])val;

http://git-wip-us.apache.org/repos/asf/cxf/blob/0fd31066/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/ControlImpl.java
----------------------------------------------------------------------
diff --git a/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/ControlImpl.java b/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/ControlImpl.java
index 59394b5..10a8127 100644
--- a/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/ControlImpl.java
+++ b/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/ControlImpl.java
@@ -40,6 +40,7 @@ import org.w3c.dom.Node;
 import org.apache.cxf.BusFactory;
 import org.apache.cxf.bus.spring.SpringBusFactory;
 import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.ext.logging.LoggingFeature;
 import org.apache.cxf.helpers.XPathUtils;
 import org.apache.cxf.staxutils.StaxUtils;
@@ -62,7 +63,11 @@ public class ControlImpl  extends org.apache.cxf.greeter_control.ControlImpl
{
     public boolean startGreeter(String cfgResource) {
         SpringBusFactory bf = new SpringBusFactory();
         System.setProperty("db.name", dbName);
+        if (StringUtils.isEmpty(cfgResource)) {
+            greeterBus = bf.createBus();
+        } else {
         greeterBus = bf.createBus(cfgResource);
+        }
         System.clearProperty("db.name");
         BusFactory.setDefaultBus(greeterBus);
         LOG.info("Initialised bus " + greeterBus + " with cfg file resource: " + cfgResource);

http://git-wip-us.apache.org/repos/asf/cxf/blob/0fd31066/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/WSRM12ServerCycleTest.java
----------------------------------------------------------------------
diff --git a/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/WSRM12ServerCycleTest.java
b/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/WSRM12ServerCycleTest.java
index 8a4a5d8..de471b7 100644
--- a/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/WSRM12ServerCycleTest.java
+++ b/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/WSRM12ServerCycleTest.java
@@ -23,6 +23,7 @@ import java.io.Closeable;
 
 import javax.xml.ws.Endpoint;
 import javax.xml.ws.soap.AddressingFeature;
+import javax.xml.ws.soap.SOAPFaultException;
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.BusFactory;
@@ -53,7 +54,8 @@ import org.junit.Test;
  */
 public class WSRM12ServerCycleTest extends AbstractBusClientServerTestBase {
     public static final String PORT = allocatePort(WSRM12ServerCycleTest.class);
-    private static final String CFG = "/org/apache/cxf/systest/ws/rm/persistent.xml";
+    private static final String CFG_PERSISTENT = "/org/apache/cxf/systest/ws/rm/persistent.xml";
+    private static final String CFG_SIMPLE = "/org/apache/cxf/systest/ws/rm/simple.xml";
 
     private static final long DEFAULT_BASE_RETRANSMISSION_INTERVAL = 4000L;
     private static final long DEFAULT_ACKNOWLEDGEMENT_INTERVAL = 2000L;
@@ -95,8 +97,7 @@ public class WSRM12ServerCycleTest extends AbstractBusClientServerTestBase
{
 
     @BeforeClass
     public static void setUpBeforeClass() throws Exception {
-        RMTxStore.deleteDatabaseFiles("cxf7392-recovery", true);
-        RMTxStore.deleteDatabaseFiles("cxf7392-greeter", true);
+        RMTxStore.deleteDatabaseFiles("cxf7392-server", true);
         assertTrue("server did not launch correctly",
                    launchServer(Server.class, null, new String[] {PORT, "cxf7392"}, true));
 
@@ -134,10 +135,30 @@ public class WSRM12ServerCycleTest extends AbstractBusClientServerTestBase
{
         return feature;
     }
 
-    
+    @Test
+    public void testPersistentSequences() throws Exception {
+        runTest(CFG_PERSISTENT, false);
+    }
+
+    @Test
+    public void testNonPersistentSequence() throws Exception {
+        runTest(CFG_SIMPLE, true);
+    }
 
     @Test
-    public void testCXF7392() throws Exception {
+    @org.junit.Ignore 
+    public void testNonPersistentSequenceNoTransformer() throws Exception {
+        try {
+            //CXF-7392
+            System.setProperty("javax.xml.transform.TransformerFactory", "foo.snarf");
+            runTest(CFG_SIMPLE, true);
+        } finally {
+            System.clearProperty("javax.xml.transform.TransformerFactory");
+        }
+    }
+        
+
+    public void runTest(String cfg, boolean faultOnRestart) throws Exception {
         SpringBusFactory bf = new SpringBusFactory();
         bus = bf.createBus();
         BusFactory.setDefaultBus(bus);
@@ -146,7 +167,7 @@ public class WSRM12ServerCycleTest extends AbstractBusClientServerTestBase
{
         ConnectionHelper.setKeepAliveConnection(control, false, true);
         updateAddressPort(control, PORT);
 
-        Assert.assertTrue("Failed to start greeter", control.startGreeter(CFG));
+        Assert.assertTrue("Failed to start greeter", control.startGreeter(cfg));
 
         System.setProperty("db.name", getPrefix() + "-recovery");
         Bus greeterBus = new SpringBusFactory().createBus();
@@ -165,16 +186,29 @@ public class WSRM12ServerCycleTest extends AbstractBusClientServerTestBase
{
         greeter.greetMe("three");
 
 
-        control.stopGreeter(CFG);
-        //control.startGreeter(CFG);
+        control.stopGreeter(cfg);
+        
+        //make sure greeter is down
+        Thread.sleep(1000);
+        control.startGreeter(cfg);
         
-        // this will cause an exception as the sequence is no longer valid
-        //greeter.greetMe("four");
+        //CXF-7392
+        if (faultOnRestart) {
+            try {
+                greeter.greetMe("four");
+            } catch (SOAPFaultException ex) {
+                assertTrue(ex.getMessage().contains("wsrm:Identifier"));
+                //expected, sequence identifier doesn't exist on other side
+            }
+        } else {
+            // this should work as the sequence should be recovered on the server side
+            greeter.greetMe("four");
+        }
         
 
         ((Closeable)greeter).close();
         greeterBus.shutdown(true);
-        control.stopGreeter(CFG);
+        control.stopGreeter(cfg);
         bus.shutdown(true);
     }
 

http://git-wip-us.apache.org/repos/asf/cxf/blob/0fd31066/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/simple.xml
----------------------------------------------------------------------
diff --git a/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/simple.xml b/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/simple.xml
new file mode 100644
index 0000000..641ac1b
--- /dev/null
+++ b/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/simple.xml
@@ -0,0 +1,32 @@
+<?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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cxf="http://cxf.apache.org/core" xmlns:wsa="http://cxf.apache.org/ws/addressing" xmlns:wsrm-mgr="http://cxf.apache.org/ws/rm/manager"
xsi:schemaLocation=" http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd http://cxf.apache.org/ws/rm/manager
http://cxf.apache.org/schemas/configuration/wsrm-manager.xsd http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.2.xsd">
+    <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
+    <cxf:bus>
+        <cxf:features>
+            <wsa:addressing/>
+            <wsrm-mgr:reliableMessaging>
+                <wsrm-mgr:sourcePolicy>
+                    <wsrm-mgr:sequenceTerminationPolicy terminateOnShutdown="false"/>
+                </wsrm-mgr:sourcePolicy>
+            </wsrm-mgr:reliableMessaging>
+        </cxf:features>
+    </cxf:bus>
+</beans>


Mime
View raw message