camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject [09/12] git commit: CAMEL-6555 fixed the compile errors in camel-netty4 test
Date Fri, 18 Jul 2014 15:15:36 GMT
CAMEL-6555 fixed the compile errors in camel-netty4 test


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

Branch: refs/heads/CAMEL-6555
Commit: 2e85d5a13b17aba2fcc7edf89e2895c6dc65f1d9
Parents: ace57e9
Author: Willem Jiang <willem.jiang@gmail.com>
Authored: Fri Jul 18 15:50:42 2014 +0800
Committer: Willem Jiang <willem.jiang@gmail.com>
Committed: Fri Jul 18 16:37:10 2014 +0800

----------------------------------------------------------------------
 .../component/netty4/MultipleCodecsTest.java    |  9 ++---
 .../component/netty4/NettyConverterTest.java    |  8 ++---
 .../NettyCustomPipelineFactoryAsynchTest.java   | 32 +++++++----------
 .../NettyCustomPipelineFactorySynchTest.java    | 37 +++++++++-----------
 .../netty4/NettyManualEndpointTest.java         |  5 +--
 .../netty4/NettyRequestTimeoutTest.java         |  2 +-
 .../component/netty4/NettySingleCodecTest.java  |  5 +--
 ...UseSharedWorkerThreadPoolManyRoutesTest.java | 19 +++++-----
 .../NettyUseSharedWorkerThreadPoolTest.java     | 18 +++++-----
 9 files changed, 63 insertions(+), 72 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/2e85d5a1/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/MultipleCodecsTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/MultipleCodecsTest.java
b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/MultipleCodecsTest.java
index 4a9f86a..c067d93 100644
--- a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/MultipleCodecsTest.java
+++ b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/MultipleCodecsTest.java
@@ -20,13 +20,14 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.TimeUnit;
 
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.impl.JndiRegistry;
 import io.netty.channel.ChannelHandler;
-import io.netty.handler.codec.frame.LengthFieldPrepender;
+import io.netty.handler.codec.LengthFieldPrepender;
 import io.netty.handler.codec.string.StringDecoder;
 import io.netty.handler.codec.string.StringEncoder;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.impl.JndiRegistry;
 import org.junit.Test;
 
 public class MultipleCodecsTest extends BaseNettyTest {

http://git-wip-us.apache.org/repos/asf/camel/blob/2e85d5a1/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyConverterTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyConverterTest.java
b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyConverterTest.java
index 8878862..6d9f8ec 100644
--- a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyConverterTest.java
+++ b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyConverterTest.java
@@ -16,10 +16,10 @@
  */
 package org.apache.camel.component.netty4;
 
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.ByteBufAllocator;
 import org.apache.camel.impl.DefaultExchange;
 import org.apache.camel.test.junit4.CamelTestSupport;
-import io.netty.buffer.ChannelBuffer;
-import io.netty.buffer.DynamicChannelBuffer;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -33,12 +33,12 @@ public class NettyConverterTest extends CamelTestSupport {
      */
     private  static final String PAYLOAD = "Test Message";
 
-    private ChannelBuffer buf;
+    private ByteBuf buf;
 
     @Before
     public void startUp() {
         byte[] bytes = PAYLOAD.getBytes();
-        buf = new DynamicChannelBuffer(bytes.length);
+        buf = ByteBufAllocator.DEFAULT.buffer(bytes.length);
         buf.writeBytes(bytes);
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/2e85d5a1/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyCustomPipelineFactoryAsynchTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyCustomPipelineFactoryAsynchTest.java
b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyCustomPipelineFactoryAsynchTest.java
index 009c6f9..ba73be7 100644
--- a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyCustomPipelineFactoryAsynchTest.java
+++ b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyCustomPipelineFactoryAsynchTest.java
@@ -16,19 +16,19 @@
  */
 package org.apache.camel.component.netty4;
 
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelPipeline;
+import io.netty.handler.codec.DelimiterBasedFrameDecoder;
+import io.netty.handler.codec.Delimiters;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
+import io.netty.util.CharsetUtil;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.netty4.handlers.ClientChannelHandler;
 import org.apache.camel.component.netty4.handlers.ServerChannelHandler;
 import org.apache.camel.impl.JndiRegistry;
-import io.netty.channel.ChannelPipeline;
-import io.netty.channel.Channels;
-import io.netty.handler.codec.frame.DelimiterBasedFrameDecoder;
-import io.netty.handler.codec.frame.Delimiters;
-import io.netty.handler.codec.string.StringDecoder;
-import io.netty.handler.codec.string.StringEncoder;
-import io.netty.util.CharsetUtil;
 import org.junit.Test;
 
 public class NettyCustomPipelineFactoryAsynchTest extends BaseNettyTest {
@@ -79,17 +79,14 @@ public class NettyCustomPipelineFactoryAsynchTest extends BaseNettyTest
{
         }
 
         @Override
-        public ChannelPipeline getPipeline() throws Exception {
+        protected void initChannel(Channel ch) throws Exception {
+            
+            ChannelPipeline channelPipeline = ch.pipeline();
             clientInvoked = true;
-
-            ChannelPipeline channelPipeline = Channels.pipeline();
-
             channelPipeline.addLast("decoder-DELIM", new DelimiterBasedFrameDecoder(maxLineSize,
true, Delimiters.lineDelimiter()));
             channelPipeline.addLast("decoder-SD", new StringDecoder(CharsetUtil.UTF_8));
             channelPipeline.addLast("encoder-SD", new StringEncoder(CharsetUtil.UTF_8));
             channelPipeline.addLast("handler", new ClientChannelHandler(producer));
-
-            return channelPipeline;
         }
 
         @Override
@@ -106,18 +103,13 @@ public class NettyCustomPipelineFactoryAsynchTest extends BaseNettyTest
{
             this.consumer = consumer;
         }
 
-        @Override
-        public ChannelPipeline getPipeline() throws Exception {
+        protected void initChannel(Channel ch) throws Exception {
+            ChannelPipeline channelPipeline = ch.pipeline();
             serverInvoked = true;
-
-            ChannelPipeline channelPipeline = Channels.pipeline();
-
             channelPipeline.addLast("encoder-SD", new StringEncoder(CharsetUtil.UTF_8));
             channelPipeline.addLast("decoder-DELIM", new DelimiterBasedFrameDecoder(maxLineSize,
true, Delimiters.lineDelimiter()));
             channelPipeline.addLast("decoder-SD", new StringDecoder(CharsetUtil.UTF_8));
             channelPipeline.addLast("handler", new ServerChannelHandler(consumer));
-
-            return channelPipeline;
         }
 
         @Override

http://git-wip-us.apache.org/repos/asf/camel/blob/2e85d5a1/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyCustomPipelineFactorySynchTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyCustomPipelineFactorySynchTest.java
b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyCustomPipelineFactorySynchTest.java
index 745ca17..dd85166 100644
--- a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyCustomPipelineFactorySynchTest.java
+++ b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyCustomPipelineFactorySynchTest.java
@@ -16,19 +16,21 @@
  */
 package org.apache.camel.component.netty4;
 
+import java.nio.channels.Channels;
+
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelPipeline;
+import io.netty.handler.codec.DelimiterBasedFrameDecoder;
+import io.netty.handler.codec.Delimiters;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
+import io.netty.util.CharsetUtil;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.netty4.handlers.ClientChannelHandler;
 import org.apache.camel.component.netty4.handlers.ServerChannelHandler;
 import org.apache.camel.impl.JndiRegistry;
-import io.netty.channel.ChannelPipeline;
-import io.netty.channel.Channels;
-import io.netty.handler.codec.frame.DelimiterBasedFrameDecoder;
-import io.netty.handler.codec.frame.Delimiters;
-import io.netty.handler.codec.string.StringDecoder;
-import io.netty.handler.codec.string.StringEncoder;
-import io.netty.util.CharsetUtil;
 import org.junit.Test;
 
 public class NettyCustomPipelineFactorySynchTest extends BaseNettyTest {
@@ -79,17 +81,15 @@ public class NettyCustomPipelineFactorySynchTest extends BaseNettyTest
{
         }
 
         @Override
-        public ChannelPipeline getPipeline() throws Exception {
+        protected void initChannel(Channel ch) throws Exception {
+            
+            ChannelPipeline channelPipeline = ch.pipeline();
             clientInvoked = true;
-
-            ChannelPipeline channelPipeline = Channels.pipeline();
-
             channelPipeline.addLast("decoder-DELIM", new DelimiterBasedFrameDecoder(maxLineSize,
true, Delimiters.lineDelimiter()));
             channelPipeline.addLast("decoder-SD", new StringDecoder(CharsetUtil.UTF_8));
             channelPipeline.addLast("encoder-SD", new StringEncoder(CharsetUtil.UTF_8));
             channelPipeline.addLast("handler", new ClientChannelHandler(producer));
-
-            return channelPipeline;
+           
         }
 
         @Override
@@ -107,17 +107,14 @@ public class NettyCustomPipelineFactorySynchTest extends BaseNettyTest
{
         }
 
         @Override
-        public ChannelPipeline getPipeline() throws Exception {
+        protected void initChannel(Channel ch) throws Exception {
+            
+            ChannelPipeline channelPipeline = ch.pipeline();
             serverInvoked = true;
-
-            ChannelPipeline channelPipeline = Channels.pipeline();
-
             channelPipeline.addLast("encoder-SD", new StringEncoder(CharsetUtil.UTF_8));
             channelPipeline.addLast("decoder-DELIM", new DelimiterBasedFrameDecoder(maxLineSize,
true, Delimiters.lineDelimiter()));
             channelPipeline.addLast("decoder-SD", new StringDecoder(CharsetUtil.UTF_8));
-            channelPipeline.addLast("handler", new ServerChannelHandler(consumer));
-
-            return channelPipeline;
+            channelPipeline.addLast("handler", new ServerChannelHandler(consumer));     
    
         }
 
         @Override

http://git-wip-us.apache.org/repos/asf/camel/blob/2e85d5a1/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyManualEndpointTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyManualEndpointTest.java
b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyManualEndpointTest.java
index 1ad1da8..58a279e 100644
--- a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyManualEndpointTest.java
+++ b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyManualEndpointTest.java
@@ -19,10 +19,11 @@ package org.apache.camel.component.netty4;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.camel.builder.RouteBuilder;
 import io.netty.channel.ChannelHandler;
-import io.netty.handler.codec.frame.Delimiters;
+import io.netty.handler.codec.Delimiters;
 import io.netty.util.CharsetUtil;
+
+import org.apache.camel.builder.RouteBuilder;
 import org.junit.Test;
 
 public class NettyManualEndpointTest extends BaseNettyTest {

http://git-wip-us.apache.org/repos/asf/camel/blob/2e85d5a1/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyRequestTimeoutTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyRequestTimeoutTest.java
b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyRequestTimeoutTest.java
index c674d24..a3de7b7 100644
--- a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyRequestTimeoutTest.java
+++ b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyRequestTimeoutTest.java
@@ -16,11 +16,11 @@
  */
 package org.apache.camel.component.netty4;
 
+import io.netty.handler.timeout.ReadTimeoutException;
 import org.apache.camel.CamelExecutionException;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
-import io.netty.handler.timeout.ReadTimeoutException;
 import org.junit.Test;
 
 /**

http://git-wip-us.apache.org/repos/asf/camel/blob/2e85d5a1/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettySingleCodecTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettySingleCodecTest.java
b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettySingleCodecTest.java
index 18f245d..19b0dea 100644
--- a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettySingleCodecTest.java
+++ b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettySingleCodecTest.java
@@ -18,11 +18,12 @@ package org.apache.camel.component.netty4;
 
 import java.util.concurrent.TimeUnit;
 
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
+
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.impl.JndiRegistry;
-import io.netty.handler.codec.string.StringDecoder;
-import io.netty.handler.codec.string.StringEncoder;
 import org.junit.Test;
 
 public class NettySingleCodecTest extends BaseNettyTest {

http://git-wip-us.apache.org/repos/asf/camel/blob/2e85d5a1/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyUseSharedWorkerThreadPoolManyRoutesTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyUseSharedWorkerThreadPoolManyRoutesTest.java
b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyUseSharedWorkerThreadPoolManyRoutesTest.java
index d1d6e81..58ae4c2 100644
--- a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyUseSharedWorkerThreadPoolManyRoutesTest.java
+++ b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyUseSharedWorkerThreadPoolManyRoutesTest.java
@@ -16,10 +16,9 @@
  */
 package org.apache.camel.component.netty4;
 
+import io.netty.channel.EventLoopGroup;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.impl.JndiRegistry;
-import io.netty.channel.socket.nio.BossPool;
-import io.netty.channel.socket.nio.WorkerPool;
 import org.junit.Test;
 
 /**
@@ -28,8 +27,8 @@ import org.junit.Test;
 public class NettyUseSharedWorkerThreadPoolManyRoutesTest extends BaseNettyTest {
 
     private JndiRegistry jndi;
-    private BossPool sharedBoos;
-    private WorkerPool sharedWorker;
+    private EventLoopGroup sharedBoosGroup;
+    private EventLoopGroup sharedWorkerGroup;
     private int before;
 
     @Override
@@ -56,8 +55,8 @@ public class NettyUseSharedWorkerThreadPoolManyRoutesTest extends BaseNettyTest
         log.info("Created threads {}", delta);
         assertTrue("There should not be created so many threads: " + delta, delta < 50);
 
-        sharedWorker.shutdown();
-        sharedBoos.shutdown();
+        sharedBoosGroup.shutdownGracefully().sync().await();
+        sharedWorkerGroup.shutdownGracefully().sync().await();
     }
 
     @Override
@@ -65,10 +64,10 @@ public class NettyUseSharedWorkerThreadPoolManyRoutesTest extends BaseNettyTest
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                sharedWorker = new NettyWorkerPoolBuilder().withWorkerCount(10).build();
-                jndi.bind("sharedWorker", sharedWorker);
-                sharedBoos = new NettyServerBossPoolBuilder().withBossCount(20).build();
-                jndi.bind("sharedBoss", sharedBoos);
+                sharedWorkerGroup = new NettyWorkerPoolBuilder().withWorkerCount(10).build();
+                jndi.bind("sharedWorker", sharedWorkerGroup);
+                sharedBoosGroup = new NettyServerBossPoolBuilder().withBossCount(20).build();
+                jndi.bind("sharedBoss", sharedBoosGroup);
 
                 for (int i = 0; i < 100; i++) {
                     from("netty:tcp://localhost:" + getNextPort() + "?textline=true&sync=true&orderedThreadPoolExecutor=false"

http://git-wip-us.apache.org/repos/asf/camel/blob/2e85d5a1/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyUseSharedWorkerThreadPoolTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyUseSharedWorkerThreadPoolTest.java
b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyUseSharedWorkerThreadPoolTest.java
index 841f3cd..b80dd0d 100644
--- a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyUseSharedWorkerThreadPoolTest.java
+++ b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyUseSharedWorkerThreadPoolTest.java
@@ -16,9 +16,9 @@
  */
 package org.apache.camel.component.netty4;
 
+import io.netty.channel.EventLoopGroup;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.impl.JndiRegistry;
-import io.netty.channel.socket.nio.WorkerPool;
 import org.junit.Test;
 
 /**
@@ -27,8 +27,8 @@ import org.junit.Test;
 public class NettyUseSharedWorkerThreadPoolTest extends BaseNettyTest {
 
     private JndiRegistry jndi;
-    private WorkerPool sharedServer;
-    private WorkerPool sharedClient;
+    private EventLoopGroup sharedWorkerServerGroup;
+    private EventLoopGroup sharedWorkerClientGroup;
     private int port;
     private int port2;
     private int port3;
@@ -61,8 +61,8 @@ public class NettyUseSharedWorkerThreadPoolTest extends BaseNettyTest {
 
         assertMockEndpointsSatisfied();
 
-        sharedServer.shutdown();
-        sharedClient.shutdown();
+        sharedWorkerServerGroup.shutdownGracefully().sync().await();
+        sharedWorkerClientGroup.shutdownGracefully().sync().await();
     }
 
     @Override
@@ -71,10 +71,10 @@ public class NettyUseSharedWorkerThreadPoolTest extends BaseNettyTest
{
             @Override
             public void configure() throws Exception {
                 // we have 3 routes, but lets try to have only 2 threads in the pool
-                sharedServer = new NettyWorkerPoolBuilder().withWorkerCount(2).withName("NettyServer").build();
-                jndi.bind("sharedServerPool", sharedServer);
-                sharedClient = new NettyWorkerPoolBuilder().withWorkerCount(3).withName("NettyClient").build();
-                jndi.bind("sharedClientPool", sharedClient);
+                sharedWorkerServerGroup = new NettyWorkerPoolBuilder().withWorkerCount(2).withName("NettyServer").build();
+                jndi.bind("sharedServerPool", sharedWorkerServerGroup);
+                sharedWorkerClientGroup = new NettyWorkerPoolBuilder().withWorkerCount(3).withName("NettyClient").build();
+                jndi.bind("sharedClientPool", sharedWorkerClientGroup);
 
                 port = getPort();
                 port2 = getNextPort();


Mime
View raw message