cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject cxf git commit: [CXF-7399, CXF-7392] Add testcase for CXF-7399 (still fails), but fix CXF-7392 discovered while writing testcase
Date Wed, 07 Jun 2017 20:27:33 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 8ef43effe -> 37ae9f2b6


[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/37ae9f2b
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/37ae9f2b
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/37ae9f2b

Branch: refs/heads/master
Commit: 37ae9f2b6ed0b2f54705734122182eb2e50f36cc
Parents: 8ef43ef
Author: Daniel Kulp <dkulp@apache.org>
Authored: Wed Jun 7 16:26:13 2017 -0400
Committer: Daniel Kulp <dkulp@apache.org>
Committed: Wed Jun 7 16:27:26 2017 -0400

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


http://git-wip-us.apache.org/repos/asf/cxf/blob/37ae9f2b/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 70590bd..8918936 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/37ae9f2b/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 c42f4d5..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
@@ -267,7 +267,7 @@ public abstract class AbstractServerPersistenceTest extends AbstractBusClientSer
 
 
     void verifyRetransmissionQueue() throws Exception {
-        awaitMessages(2, 3, 60000);
+        awaitMessages(2, 2, 60000);
 
         Thread.sleep(5000);
         boolean empty = greeterBus.getExtension(RMManager.class).getRetransmissionQueue().isEmpty();

http://git-wip-us.apache.org/repos/asf/cxf/blob/37ae9f2b/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 45f78d5..93e315d 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);
-        greeterBus = bf.createBus(cfgResource);
+        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/37ae9f2b/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/37ae9f2b/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