cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject svn commit: r1338763 - in /cxf/branches/2.5.x-fixes: ./ rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMUtils.java rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMUtilsTest.java
Date Tue, 15 May 2012 15:52:31 GMT
Author: ay
Date: Tue May 15 15:52:31 2012
New Revision: 1338763

URL: http://svn.apache.org/viewvc?rev=1338763&view=rev
Log:
Merged revisions 1338752 via  svn merge from
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1338752 | ay | 2012-05-15 17:29:58 +0200 (Tue, 15 May 2012) | 1 line
  
  fix for extracting the bus id on osgi for CXF-4270
........

Modified:
    cxf/branches/2.5.x-fixes/   (props changed)
    cxf/branches/2.5.x-fixes/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMUtils.java
    cxf/branches/2.5.x-fixes/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMUtilsTest.java

Propchange: cxf/branches/2.5.x-fixes/
            ('svn:mergeinfo' removed)

Propchange: cxf/branches/2.5.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.5.x-fixes/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMUtils.java?rev=1338763&r1=1338762&r2=1338763&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMUtils.java (original)
+++ cxf/branches/2.5.x-fixes/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMUtils.java Tue
May 15 15:52:31 2012
@@ -20,6 +20,8 @@
 package org.apache.cxf.ws.rm;
 
 import java.io.OutputStream;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 import javax.management.JMException;
 import javax.management.ObjectName;
@@ -37,7 +39,8 @@ public final class RMUtils {
     private static final org.apache.cxf.ws.rm.v200702.ObjectFactory WSRM_FACTORY;
     private static final org.apache.cxf.ws.rm.v200502.ObjectFactory WSRM200502_FACTORY;
     private static final org.apache.cxf.ws.rm.v200502wsa15.ObjectFactory WSRM200502_WSA200508_FACTORY;
-    private static final AddressingConstants WSA_CONSTANTS; 
+    private static final AddressingConstants WSA_CONSTANTS;
+    private static final Pattern GENERATED_BUS_ID_PATTERN = Pattern.compile(Bus.DEFAULT_BUS_ID
+ "\\d+$");
     
     static {
         WSRM_FACTORY = new org.apache.cxf.ws.rm.v200702.ObjectFactory();        
@@ -120,12 +123,15 @@ public final class RMUtils {
 
     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

+        if (bus == null) {
             busId = Bus.DEFAULT_BUS_ID;
+        } else {
+            busId = bus.getId();
+            // bus-ids of form cxfnnn or artifactid-cxfnnn must drop the variable part nnn
+            Matcher m = GENERATED_BUS_ID_PATTERN.matcher(busId);
+            if (m.find()) {
+                busId = busId.substring(0, m.start() + Bus.DEFAULT_BUS_ID.length());
+            }
         }
         return endpoint.getEndpointInfo().getService().getName() + "."
             + endpoint.getEndpointInfo().getName() + "@" + busId;

Modified: cxf/branches/2.5.x-fixes/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMUtilsTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMUtilsTest.java?rev=1338763&r1=1338762&r2=1338763&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMUtilsTest.java
(original)
+++ cxf/branches/2.5.x-fixes/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMUtilsTest.java
Tue May 15 15:52:31 2012
@@ -63,7 +63,8 @@ public class RMUtilsTest extends Assert 
         QName sqn = new QName("ns1", "service");
         EasyMock.expect(si.getName()).andReturn(sqn);
         control.replay();
-        assertEquals("{ns1}service.{ns2}endpoint@cxf", RMUtils.getEndpointIdentifier(e));
+        assertEquals("{ns1}service.{ns2}endpoint@" + Bus.DEFAULT_BUS_ID, 
+                     RMUtils.getEndpointIdentifier(e));
 
         // a named bus
         control.reset();
@@ -84,7 +85,30 @@ public class RMUtilsTest extends Assert 
         EasyMock.expect(ei.getService()).andReturn(si);
         EasyMock.expect(si.getName()).andReturn(sqn);
         control.replay();
-        assertEquals("{ns1}service.{ns2}endpoint@cxf", 
+        assertEquals("{ns1}service.{ns2}endpoint@" + Bus.DEFAULT_BUS_ID, 
                      RMUtils.getEndpointIdentifier(e, BusFactory.getDefaultBus()));
+
+        // a generated bundle artifact 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);
+        EasyMock.expect(b.getId()).andReturn("mybus-" + Bus.DEFAULT_BUS_ID + "12345");
+        control.replay();
+        assertEquals("{ns1}service.{ns2}endpoint@mybus-" + Bus.DEFAULT_BUS_ID, 
+                     RMUtils.getEndpointIdentifier(e, b));
+
+        // look like a generated bundle artifact bus but not
+        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);
+        EasyMock.expect(b.getId()).andReturn("mybus." + Bus.DEFAULT_BUS_ID + ".foo");
+        control.replay();
+        assertEquals("{ns1}service.{ns2}endpoint@mybus." + Bus.DEFAULT_BUS_ID + ".foo", 
+                     RMUtils.getEndpointIdentifier(e, b));
+        
     } 
 }



Mime
View raw message