servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ge...@apache.org
Subject svn commit: r1085580 - in /servicemix/smx4/nmr/trunk/nmr/core/src: main/java/org/apache/servicemix/nmr/core/EndpointRegistryImpl.java test/java/org/apache/servicemix/nmr/core/EndpointRegistryImplTest.java
Date Fri, 25 Mar 2011 22:06:30 GMT
Author: gertv
Date: Fri Mar 25 22:06:30 2011
New Revision: 1085580

URL: http://svn.apache.org/viewvc?rev=1085580&view=rev
Log:
SMX4NMR-262: Endpoint.CHANNEL_SYNC_DELIVERY property doesn't work when passed as string
Thanks to Jonathan Anstey for providing the patch!

Modified:
    servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/EndpointRegistryImpl.java
    servicemix/smx4/nmr/trunk/nmr/core/src/test/java/org/apache/servicemix/nmr/core/EndpointRegistryImplTest.java

Modified: servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/EndpointRegistryImpl.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/EndpointRegistryImpl.java?rev=1085580&r1=1085579&r2=1085580&view=diff
==============================================================================
--- servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/EndpointRegistryImpl.java
(original)
+++ servicemix/smx4/nmr/trunk/nmr/core/src/main/java/org/apache/servicemix/nmr/core/EndpointRegistryImpl.java
Fri Mar 25 22:06:30 2011
@@ -144,7 +144,7 @@ public class EndpointRegistryImpl implem
      * Should the Channel use sync delivery?
      */
     private boolean isChannelSyncDelivery(Map<String, ?> properties) {
-        return Boolean.TRUE.equals(properties.get(Endpoint.CHANNEL_SYNC_DELIVERY));
+        return getBoolean(properties.get(Endpoint.CHANNEL_SYNC_DELIVERY));
     }
 
     /**
@@ -310,4 +310,14 @@ public class EndpointRegistryImpl implem
         }
         return endpoints;
     }
+
+    private static boolean getBoolean(Object o) {
+        if (o instanceof String) {
+            return Boolean.valueOf(o.toString());
+        } else if (o instanceof Boolean) {
+            return (Boolean) o;
+        } else {
+            return false;
+        }
+    }
 }

Modified: servicemix/smx4/nmr/trunk/nmr/core/src/test/java/org/apache/servicemix/nmr/core/EndpointRegistryImplTest.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/nmr/core/src/test/java/org/apache/servicemix/nmr/core/EndpointRegistryImplTest.java?rev=1085580&r1=1085579&r2=1085580&view=diff
==============================================================================
--- servicemix/smx4/nmr/trunk/nmr/core/src/test/java/org/apache/servicemix/nmr/core/EndpointRegistryImplTest.java
(original)
+++ servicemix/smx4/nmr/trunk/nmr/core/src/test/java/org/apache/servicemix/nmr/core/EndpointRegistryImplTest.java
Fri Mar 25 22:06:30 2011
@@ -79,6 +79,16 @@ public class EndpointRegistryImplTest ex
         assertNotNull(r.choose(registry));
         assertFalse(r.choose(registry).iterator().hasNext());
     }
+
+    public void testRegisterWithoutSyncChannel() throws Exception {
+        DummyEndpoint endpoint = new DummyEndpoint();
+
+        Map<String, Object> properties = ServiceHelper.createMap(Endpoint.NAME, "endpoint-id");
+
+        registry.register(endpoint, properties);
+        assertFalse("Injected channel should not have shouldRunSynchronously enabled",
+                    endpoint.channel.isShouldRunSynchronously());
+    }
     
     public void testRegisterWithSyncChannel() throws Exception {
         DummyEndpoint endpoint = new DummyEndpoint();
@@ -91,6 +101,20 @@ public class EndpointRegistryImplTest ex
                    endpoint.channel.isShouldRunSynchronously());
     }
 
+    /*
+     * Test to ensure that the CHANNEL_SYNC_DELIVERY flag can also be set with a String instead
of Boolean value
+     */
+    public void testStringChannelSyncDeliveryProperty() throws Exception {
+        DummyEndpoint endpoint = new DummyEndpoint();
+
+        Map<String, Object> properties = ServiceHelper.createMap(Endpoint.NAME, "endpoint-id");
+        properties.put(Endpoint.CHANNEL_SYNC_DELIVERY, "true");
+
+        registry.register(endpoint, properties);
+        assertTrue("Injected channel should have shouldRunSynchronously enabled",
+                   endpoint.channel.isShouldRunSynchronously());
+    }
+
     public void testLdapFilter() throws Exception {
         System.setProperty("org.osgi.vendor.framework", "org.apache.servicemix.nmr.core");
 



Mime
View raw message