cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject svn commit: r1331106 - in /cxf/trunk: rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/ rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/ systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/
Date Thu, 26 Apr 2012 21:33:20 GMT
Author: ay
Date: Thu Apr 26 21:33:20 2012
New Revision: 1331106

URL: http://svn.apache.org/viewvc?rev=1331106&view=rev
Log:
[CXF-4270] Store bus-id with the endpoint name in WS-RM's RMTxStore to correctly recover two
endpoints with the same endpoint name

Modified:
    cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/AbstractEndpoint.java
    cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/ManagedRMManager.java
    cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMManager.java
    cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMUtils.java
    cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/ManagedRMManagerTest.java
    cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMManagerTest.java
    cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMUtilsTest.java
    cxf/trunk/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/ManagedEndpointsTest.java

Modified: cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/AbstractEndpoint.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/AbstractEndpoint.java?rev=1331106&r1=1331105&r2=1331106&view=diff
==============================================================================
--- cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/AbstractEndpoint.java (original)
+++ cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/AbstractEndpoint.java Thu Apr 26
21:33:20 2012
@@ -19,6 +19,7 @@
 
 package org.apache.cxf.ws.rm;
 
+import org.apache.cxf.Bus;
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.ws.rm.v200702.Identifier;
 
@@ -31,7 +32,7 @@ public class AbstractEndpoint {
     }
     
     public String getName() {
-        return RMUtils.getEndpointIdentifier(getEndpoint());
+        return RMUtils.getEndpointIdentifier(getEndpoint(), getBus());
     }
     
     /** 
@@ -63,4 +64,8 @@ public class AbstractEndpoint {
     public Identifier generateSequenceIdentifier() {
         return reliableEndpoint.getManager().getIdGenerator().generateSequenceIdentifier();
     }
+    
+    private Bus getBus() {
+        return reliableEndpoint.getManager().getBus();
+    }
 }

Modified: cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/ManagedRMManager.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/ManagedRMManager.java?rev=1331106&r1=1331105&r2=1331106&view=diff
==============================================================================
--- cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/ManagedRMManager.java (original)
+++ cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/ManagedRMManager.java Thu Apr 26
21:33:20 2012
@@ -62,7 +62,7 @@ public class ManagedRMManager implements
     public String[] getEndpointIdentifiers() {
         Set<String> identifiers = new HashSet<String>();
         for (Endpoint ep : manager.getReliableEndpointsMap().keySet()) {
-            identifiers.add(RMUtils.getEndpointIdentifier(ep));
+            identifiers.add(RMUtils.getEndpointIdentifier(ep, manager.getBus()));
         }
         return identifiers.toArray(new String[identifiers.size()]);
     }

Modified: cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMManager.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMManager.java?rev=1331106&r1=1331105&r2=1331106&view=diff
==============================================================================
--- cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMManager.java (original)
+++ cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMManager.java Thu Apr 26 21:33:20
2012
@@ -130,7 +130,7 @@ public class RMManager {
         if (null == store || null == retransmissionQueue) {
             return;
         }        
-        String id = RMUtils.getEndpointIdentifier(client.getEndpoint());
+        String id = RMUtils.getEndpointIdentifier(client.getEndpoint(), getBus());
         Collection<SourceSequence> sss = store.getSourceSequences(id);
         if (null == sss || 0 == sss.size()) {                        
             return;
@@ -507,7 +507,7 @@ public class RMManager {
             return;
         }        
         
-        String id = RMUtils.getEndpointIdentifier(endpoint);
+        String id = RMUtils.getEndpointIdentifier(endpoint, getBus());
         
         Collection<SourceSequence> sss = store.getSourceSequences(id);
         Collection<DestinationSequence> dss = store.getDestinationSequences(id);

Modified: cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMUtils.java?rev=1331106&r1=1331105&r2=1331106&view=diff
==============================================================================
--- cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMUtils.java (original)
+++ cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMUtils.java Thu Apr 26 21:33:20
2012
@@ -115,8 +115,20 @@ public final class RMUtils {
     }
     
     public static String getEndpointIdentifier(Endpoint endpoint) {
+        return getEndpointIdentifier(endpoint, null);
+    }
+
+    public static String getEndpointIdentifier(Endpoint endpoint, Bus bus) {
+        String busId = null;
+        if (bus != null) {
+            busId = bus.getId();
+        }
+        if (bus == null || busId.startsWith(Bus.DEFAULT_BUS_ID)) {
+            // no bus id or a generated anonymous id needs to be mapped to the default constant

+            busId = Bus.DEFAULT_BUS_ID;
+        }
         return endpoint.getEndpointInfo().getService().getName() + "."
-            + endpoint.getEndpointInfo().getName();
+            + endpoint.getEndpointInfo().getName() + "@" + busId;
     }
     
     public static WriteOnCloseOutputStream createCachedStream(Message message, OutputStream
os) {

Modified: cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/ManagedRMManagerTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/ManagedRMManagerTest.java?rev=1331106&r1=1331105&r2=1331106&view=diff
==============================================================================
--- cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/ManagedRMManagerTest.java (original)
+++ cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/ManagedRMManagerTest.java Thu Apr
26 21:33:20 2012
@@ -114,7 +114,7 @@ public class ManagedRMManagerTest extend
         o = mbs.invoke(managerName, "getEndpointIdentifiers", null, null);
         assertEquals("One Endpoint", 1, ((String[])o).length);
         assertEquals("Endpoint identifier must match", 
-                     RMUtils.getEndpointIdentifier(endpoint), ((String[])o)[0]);
+                     RMUtils.getEndpointIdentifier(endpoint, bus), ((String[])o)[0]);
 
         // test some endpoint methods
         o = mbs.getAttribute(endpointName, "Address");

Modified: cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMManagerTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMManagerTest.java?rev=1331106&r1=1331105&r2=1331106&view=diff
==============================================================================
--- cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMManagerTest.java (original)
+++ cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMManagerTest.java Thu Apr 26 21:33:20
2012
@@ -571,7 +571,7 @@ public class RMManagerTest extends Asser
         if (null != ss) {
             sss.add(ss);            
         }
-        EasyMock.expect(store.getSourceSequences("{S}s.{P}p"))
+        EasyMock.expect(store.getSourceSequences("{S}s.{P}p@cxf"))
             .andReturn(sss);
         if (null == ss) {
             return;
@@ -581,7 +581,7 @@ public class RMManagerTest extends Asser
         if (null != ds) {
             dss.add(ds);            
         }
-        EasyMock.expect(store.getDestinationSequences("{S}s.{P}p"))
+        EasyMock.expect(store.getDestinationSequences("{S}s.{P}p@cxf"))
             .andReturn(dss);
         if (null == ds) {
             return;

Modified: cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMUtilsTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMUtilsTest.java?rev=1331106&r1=1331105&r2=1331106&view=diff
==============================================================================
--- cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMUtilsTest.java (original)
+++ cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMUtilsTest.java Thu Apr 26 21:33:20
2012
@@ -21,6 +21,8 @@ package org.apache.cxf.ws.rm;
 
 import javax.xml.namespace.QName;
 
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.service.model.EndpointInfo;
 import org.apache.cxf.service.model.ServiceInfo;
@@ -50,6 +52,7 @@ public class RMUtilsTest extends Assert 
     
     @Test
     public void testGetName() {
+        // no bus given
         Endpoint e = control.createMock(Endpoint.class);
         EndpointInfo ei = control.createMock(EndpointInfo.class);
         EasyMock.expect(e.getEndpointInfo()).andReturn(ei).times(2);
@@ -60,6 +63,28 @@ public class RMUtilsTest extends Assert 
         QName sqn = new QName("ns1", "service");
         EasyMock.expect(si.getName()).andReturn(sqn);
         control.replay();
-        assertEquals("{ns1}service.{ns2}endpoint", RMUtils.getEndpointIdentifier(e));
+        assertEquals("{ns1}service.{ns2}endpoint@cxf", RMUtils.getEndpointIdentifier(e));
+
+        // a named bus
+        control.reset();
+        EasyMock.expect(e.getEndpointInfo()).andReturn(ei).times(2);
+        EasyMock.expect(ei.getName()).andReturn(eqn);
+        EasyMock.expect(ei.getService()).andReturn(si);
+        EasyMock.expect(si.getName()).andReturn(sqn);
+        Bus b = control.createMock(Bus.class);
+        EasyMock.expect(b.getId()).andReturn("mybus");
+        control.replay();
+        assertEquals("{ns1}service.{ns2}endpoint@mybus", RMUtils.getEndpointIdentifier(e,
b));
+
+        // this test makes sure that an automatically generated id will be
+        // mapped to the static default bus name "cxf".
+        control.reset();
+        EasyMock.expect(e.getEndpointInfo()).andReturn(ei).times(2);
+        EasyMock.expect(ei.getName()).andReturn(eqn);
+        EasyMock.expect(ei.getService()).andReturn(si);
+        EasyMock.expect(si.getName()).andReturn(sqn);
+        control.replay();
+        assertEquals("{ns1}service.{ns2}endpoint@cxf", 
+                     RMUtils.getEndpointIdentifier(e, BusFactory.getDefaultBus()));
     } 
 }

Modified: cxf/trunk/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/ManagedEndpointsTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/ManagedEndpointsTest.java?rev=1331106&r1=1331105&r2=1331106&view=diff
==============================================================================
--- cxf/trunk/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/ManagedEndpointsTest.java
(original)
+++ cxf/trunk/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/ManagedEndpointsTest.java
Thu Apr 26 21:33:20 2012
@@ -122,7 +122,7 @@ public class ManagedEndpointsTest extend
         LOG.fine("Created greeter client.");
 
         org.apache.cxf.endpoint.Endpoint ep = ClientProxy.getClient(greeter).getEndpoint();
-        String epId = RMUtils.getEndpointIdentifier(ep);
+        String epId = RMUtils.getEndpointIdentifier(ep, clientBus);
         
         greeter.greetMeOneWay("one"); // sent
 



Mime
View raw message