camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject [24/26] git commit: CAMEL-6555 Fixed UDPMulticastAsyncTest error and polish the test code
Date Tue, 22 Jul 2014 13:53:12 GMT
CAMEL-6555 Fixed UDPMulticastAsyncTest error and polish the test code


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/5bcdda6e
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/5bcdda6e
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/5bcdda6e

Branch: refs/heads/master
Commit: 5bcdda6efa9410f2d4fd64ba8703ae5717d9a89c
Parents: 706d1b4
Author: Willem Jiang <willem.jiang@gmail.com>
Authored: Tue Jul 22 21:24:46 2014 +0800
Committer: Willem Jiang <willem.jiang@gmail.com>
Committed: Tue Jul 22 21:25:20 2014 +0800

----------------------------------------------------------------------
 .../netty4/SingleUDPNettyServerBootstrapFactory.java         | 5 ++++-
 .../org/apache/camel/component/netty4/NettyUDPSyncTest.java  | 8 +++++---
 2 files changed, 9 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/5bcdda6e/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/SingleUDPNettyServerBootstrapFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/SingleUDPNettyServerBootstrapFactory.java
b/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/SingleUDPNettyServerBootstrapFactory.java
index c6b63a8..935b714 100644
--- a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/SingleUDPNettyServerBootstrapFactory.java
+++ b/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/SingleUDPNettyServerBootstrapFactory.java
@@ -163,7 +163,10 @@ public class SingleUDPNettyServerBootstrapFactory extends ServiceSupport
impleme
         SubnetUtils multicastSubnet = new SubnetUtils(MULTICAST_SUBNET);
 
         if (multicastSubnet.getInfo().isInRange(configuration.getHost())) {
-            datagramChannel = (DatagramChannel)bootstrap.bind(hostAddress);
+            ChannelFuture channelFuture = bootstrap.bind(hostAddress);
+            channelFuture.awaitUninterruptibly();
+            channel = channelFuture.channel();
+            DatagramChannel datagramChannel = (DatagramChannel) channel;
             String networkInterface = configuration.getNetworkInterface() == null ? LOOPBACK_INTERFACE
: configuration.getNetworkInterface();
             multicastNetworkInterface = NetworkInterface.getByName(networkInterface);
             ObjectHelper.notNull(multicastNetworkInterface, "No network interface found for
'" + networkInterface + "'.");

http://git-wip-us.apache.org/repos/asf/camel/blob/5bcdda6e/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyUDPSyncTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyUDPSyncTest.java
b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyUDPSyncTest.java
index b9ad248..3731732 100644
--- a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyUDPSyncTest.java
+++ b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyUDPSyncTest.java
@@ -22,14 +22,16 @@ import org.apache.camel.builder.RouteBuilder;
 import org.junit.Test;
 
 public class NettyUDPSyncTest extends BaseNettyTest {
+    private static final String RESPONSE = "Go tell the Spartans, thou that passest by, That
faithful to their precepts here we lie.";
+    private static final String REQUEST = "After the Battle of Thermopylae in 480 BC - Simonides
of Ceos (c. 556 BC-468 BC), Greek lyric poet wrote ";
 
     @Test
     public void testUDPStringInOutWithNettyConsumer() throws Exception {
         for (int i = 0; i < 5; i++) {
             String response = template.requestBody(
                 "netty4:udp://localhost:{{port}}?sync=true",
-                "After the Battle of Thermopylae in 480 BC - Simonides of Ceos (c. 556 BC-468
BC), Greek lyric poet wrote ?", String.class);        
-            assertEquals("Go tell the Spartans, thou that passest by, That faithful to their
precepts here we lie.", response);
+                REQUEST, String.class);        
+            assertEquals(RESPONSE, response);
         }
     }
     
@@ -41,7 +43,7 @@ public class NettyUDPSyncTest extends BaseNettyTest {
                 from("netty4:udp://localhost:{{port}}?sync=true")
                     .process(new Processor() {
                         public void process(Exchange exchange) throws Exception {
-                            exchange.getOut().setBody("Go tell the Spartans, thou that passest
by, That faithful to their precepts here we lie.");                           
+                            exchange.getOut().setBody(RESPONSE);                        
  
                         }
                     });
             }


Mime
View raw message