camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject [03/12] CAMEL-6555 Created camel-netty4 module based on latest camel-netty code
Date Fri, 18 Jul 2014 15:15:30 GMT
http://git-wip-us.apache.org/repos/asf/camel/blob/7b054480/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
new file mode 100644
index 0000000..a9770db
--- /dev/null
+++ b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyConverterTest.java
@@ -0,0 +1,60 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.netty4;
+
+import org.apache.camel.impl.DefaultExchange;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.DynamicChannelBuffer;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Utility test to verify netty type converter.
+ */
+public class NettyConverterTest extends CamelTestSupport {
+
+    /**
+     * Test payload to send.
+     */
+    private  static final String PAYLOAD = "Test Message";
+
+    private ChannelBuffer buf;
+
+    @Before
+    public void startUp() {
+        byte[] bytes = PAYLOAD.getBytes();
+        buf = new DynamicChannelBuffer(bytes.length);
+        buf.writeBytes(bytes);
+    }
+
+    @Test
+    public void testConversionWithExchange() {
+        String result = context.getTypeConverter().convertTo(String.class, new DefaultExchange(context), buf);
+        assertNotNull(result);
+        assertEquals(PAYLOAD, result);
+    }
+
+
+    @Test
+    public void testConversionWithoutExchange() {
+        String result = context.getTypeConverter().convertTo(String.class, buf);
+        assertNotNull(result);
+        assertEquals(PAYLOAD, result);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/7b054480/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyCustomCodecTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyCustomCodecTest.java b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyCustomCodecTest.java
new file mode 100644
index 0000000..353c60a
--- /dev/null
+++ b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyCustomCodecTest.java
@@ -0,0 +1,64 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.netty4;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.impl.JndiRegistry;
+import org.apache.camel.util.ObjectHelper;
+import org.junit.Test;
+
+public class NettyCustomCodecTest extends BaseNettyTest {
+
+    private String uri = "netty:tcp://localhost:{{port}}?disconnect=true&sync=false"
+        + "&allowDefaultCodec=false&decoders=#myCustomDecoder,#myCustomDecoder2&encoder=#myCustomEncoder";
+
+    // use reaadble bytes
+    private byte[] data = new byte[]{65, 66, 67, 68, 69, 70, 71, 72, 73, 0, 0};
+
+    @Override
+    protected JndiRegistry createRegistry() throws Exception {
+        JndiRegistry jndi = super.createRegistry();
+        jndi.bind("myCustomDecoder", MyCustomCodec.createMyCustomDecoder());
+        jndi.bind("myCustomDecoder2", MyCustomCodec.createMyCustomDecoder2());
+        jndi.bind("myCustomEncoder", MyCustomCodec.createMyCustomEncoder());
+        return jndi;
+    }
+
+    @Test
+    public void testCustomCodec() throws Exception {
+        getMockEndpoint("mock:input").expectedMessageCount(1);
+
+        template.sendBody(uri, data);
+
+        assertMockEndpointsSatisfied();
+
+        byte[] mockData = getMockEndpoint("mock:input").getReceivedExchanges().get(0).getIn().getBody(byte[].class);
+        ObjectHelper.equalByteArray(data, mockData);
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from(uri)
+                    .to("log:input")
+                    .to("mock:input");
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/7b054480/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
new file mode 100644
index 0000000..66712dd
--- /dev/null
+++ b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyCustomPipelineFactoryAsynchTest.java
@@ -0,0 +1,128 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.netty4;
+
+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 org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.channel.Channels;
+import org.jboss.netty.handler.codec.frame.DelimiterBasedFrameDecoder;
+import org.jboss.netty.handler.codec.frame.Delimiters;
+import org.jboss.netty.handler.codec.string.StringDecoder;
+import org.jboss.netty.handler.codec.string.StringEncoder;
+import org.jboss.netty.util.CharsetUtil;
+import org.junit.Test;
+
+public class NettyCustomPipelineFactoryAsynchTest extends BaseNettyTest {
+
+    private volatile boolean clientInvoked;
+    private volatile boolean serverInvoked;
+
+    @Override
+    protected JndiRegistry createRegistry() throws Exception {
+        JndiRegistry registry = super.createRegistry();
+        registry.bind("cpf", new TestClientChannelPipelineFactory(null));
+        registry.bind("spf", new TestServerChannelPipelineFactory(null));
+        return registry;
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("netty:tcp://localhost:{{port}}?serverPipelineFactory=#spf&textline=true")
+                        .process(new Processor() {
+                            public void process(Exchange exchange) throws Exception {
+                                exchange.getOut().setBody("Forrest Gump: We was always taking long walks, and we was always looking for a guy named 'Charlie'");
+                            }
+                        });
+            }
+        };
+    }
+
+    @Test
+    public void testCustomClientPipelineFactory() throws Exception {
+        String response = (String) template.requestBody(
+                "netty:tcp://localhost:{{port}}?clientPipelineFactory=#cpf&textline=true",
+                "Forest Gump describing Vietnam...");
+
+        assertEquals("Forrest Gump: We was always taking long walks, and we was always looking for a guy named 'Charlie'", response);
+        assertEquals(true, clientInvoked);
+        assertEquals(true, serverInvoked);
+    }
+
+    public class TestClientChannelPipelineFactory extends ClientPipelineFactory {
+        private int maxLineSize = 1024;
+        private NettyProducer producer;
+
+        public TestClientChannelPipelineFactory(NettyProducer producer) {
+            this.producer = producer;
+        }
+
+        @Override
+        public ChannelPipeline getPipeline() throws Exception {
+            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
+        public ClientPipelineFactory createPipelineFactory(NettyProducer producer) {
+            return new TestClientChannelPipelineFactory(producer);
+        }
+    }
+
+    public class TestServerChannelPipelineFactory extends ServerPipelineFactory {
+        private int maxLineSize = 1024;
+        private NettyConsumer consumer;
+
+        public TestServerChannelPipelineFactory(NettyConsumer consumer) {
+            this.consumer = consumer;
+        }
+
+        @Override
+        public ChannelPipeline getPipeline() throws Exception {
+            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
+        public ServerPipelineFactory createPipelineFactory(NettyConsumer consumer) {
+            return new TestServerChannelPipelineFactory(consumer);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/7b054480/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
new file mode 100644
index 0000000..4f39e88
--- /dev/null
+++ b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyCustomPipelineFactorySynchTest.java
@@ -0,0 +1,130 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.netty4;
+
+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 org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.channel.Channels;
+import org.jboss.netty.handler.codec.frame.DelimiterBasedFrameDecoder;
+import org.jboss.netty.handler.codec.frame.Delimiters;
+import org.jboss.netty.handler.codec.string.StringDecoder;
+import org.jboss.netty.handler.codec.string.StringEncoder;
+import org.jboss.netty.util.CharsetUtil;
+import org.junit.Test;
+
+public class NettyCustomPipelineFactorySynchTest extends BaseNettyTest {
+
+    private volatile boolean clientInvoked;
+    private volatile boolean serverInvoked;
+
+    @Override
+    protected JndiRegistry createRegistry() throws Exception {
+        JndiRegistry registry = super.createRegistry();
+        registry.bind("cpf", new TestClientChannelPipelineFactory(null));
+        registry.bind("spf", new TestServerChannelPipelineFactory(null));
+        return registry;
+    }
+    
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("netty:tcp://localhost:{{port}}?serverPipelineFactory=#spf&sync=true&textline=true")
+                        .process(new Processor() {
+                            public void process(Exchange exchange) throws Exception {
+                                exchange.getOut().setBody("Forrest Gump: We was always taking long walks, and we was always looking for a guy named 'Charlie'");
+                            }
+                        });
+            }
+        };
+    }
+
+    @Test
+    public void testCustomClientPipelineFactory() throws Exception {
+        String response = (String) template.requestBody(
+                "netty:tcp://localhost:{{port}}?clientPipelineFactory=#cpf&sync=true&textline=true",
+                "Forest Gump describing Vietnam...");
+
+        assertEquals("Forrest Gump: We was always taking long walks, and we was always looking for a guy named 'Charlie'", response);
+        assertEquals(true, clientInvoked);
+        assertEquals(true, serverInvoked);
+    }
+
+    public class TestClientChannelPipelineFactory extends ClientPipelineFactory {
+        private int maxLineSize = 1024;
+        private NettyProducer producer;
+
+        public TestClientChannelPipelineFactory(NettyProducer producer) {
+            this.producer = producer;
+        }
+
+        @Override
+        public ChannelPipeline getPipeline() throws Exception {
+            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
+        public ClientPipelineFactory createPipelineFactory(NettyProducer producer) {
+            return new TestClientChannelPipelineFactory(producer);
+        }
+    }
+
+    public class TestServerChannelPipelineFactory extends ServerPipelineFactory {
+        private int maxLineSize = 1024;
+        private NettyConsumer consumer;
+
+        public TestServerChannelPipelineFactory(NettyConsumer consumer) {
+            this.consumer = consumer;
+        }
+
+        @Override
+        public ChannelPipeline getPipeline() throws Exception {
+            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
+        public ServerPipelineFactory createPipelineFactory(NettyConsumer consumer) {
+            return new TestServerChannelPipelineFactory(consumer);
+        }
+    }
+
+}
+

http://git-wip-us.apache.org/repos/asf/camel/blob/7b054480/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyDisconnectTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyDisconnectTest.java b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyDisconnectTest.java
new file mode 100644
index 0000000..1bbf636
--- /dev/null
+++ b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyDisconnectTest.java
@@ -0,0 +1,49 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.netty4;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.junit.Test;
+
+/**
+ * @version 
+ */
+public class NettyDisconnectTest extends BaseNettyTest {
+
+    @Test
+    public void testCloseSessionWhenComplete() throws Exception {
+        Object out = template.requestBody("netty:tcp://localhost:{{port}}?sync=true&disconnect=true", "Claus");
+        assertEquals("Bye Claus", out);
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() throws Exception {
+                from("netty:tcp://localhost:{{port}}?sync=true&disconnect=true").process(new Processor() {
+                    public void process(Exchange exchange) throws Exception {
+                        String body = exchange.getIn().getBody(String.class);
+                        exchange.getOut().setBody("Bye " + body);
+                    }
+                });
+            }
+        };
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/7b054480/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyFileTcpTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyFileTcpTest.java b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyFileTcpTest.java
new file mode 100644
index 0000000..8376a72
--- /dev/null
+++ b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyFileTcpTest.java
@@ -0,0 +1,50 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.netty4;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.Test;
+
+/**
+ * @version 
+ */
+public class NettyFileTcpTest extends BaseNettyTest {
+
+    @Test
+    public void testMinaRoute() throws Exception {
+        MockEndpoint endpoint = getMockEndpoint("mock:results");
+        endpoint.expectedMessageCount(1);
+        endpoint.message(0).body().startsWith("Hello World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    protected RouteBuilder createRouteBuilder() {
+        return new RouteBuilder() {
+            public void configure() {
+                // lets setup a server
+                from("netty:tcp://localhost:{{port}}?sync=false&textline=true")
+                        .to("mock:results");
+
+                from("file:src/test/data?noop=true&fileName=message1.txt").
+                        to("netty:tcp://localhost:{{port}}?sync=false&textline=true");
+            }
+        };
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/7b054480/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyInOutCloseChannelWhenCompleteTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyInOutCloseChannelWhenCompleteTest.java b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyInOutCloseChannelWhenCompleteTest.java
new file mode 100644
index 0000000..0f650f1
--- /dev/null
+++ b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyInOutCloseChannelWhenCompleteTest.java
@@ -0,0 +1,50 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.netty4;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.junit.Test;
+
+/**
+ * @version 
+ */
+public class NettyInOutCloseChannelWhenCompleteTest extends BaseNettyTest {
+
+    @Test
+    public void testCloseSessionWhenComplete() throws Exception {
+        Object out = template.requestBody("netty:tcp://localhost:{{port}}?sync=true", "Claus");
+        assertEquals("Bye Claus", out);
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() throws Exception {
+                from("netty:tcp://localhost:{{port}}?sync=true").process(new Processor() {
+                    public void process(Exchange exchange) throws Exception {
+                        String body = exchange.getIn().getBody(String.class);
+                        exchange.getOut().setBody("Bye " + body);
+                        exchange.getOut().setHeader(NettyConstants.NETTY_CLOSE_CHANNEL_WHEN_COMPLETE, true);
+                    }
+                });
+            }
+        };
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/7b054480/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyInOutFromSedaTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyInOutFromSedaTest.java b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyInOutFromSedaTest.java
new file mode 100644
index 0000000..a8a04fa
--- /dev/null
+++ b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyInOutFromSedaTest.java
@@ -0,0 +1,56 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.netty4;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.Test;
+
+/**
+ * @version 
+ */
+public class NettyInOutFromSedaTest extends BaseNettyTest {
+
+    @Test
+    public void testInOutIssue() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedBodiesReceivedInAnyOrder("Bye A", "Bye B", "Bye C");
+
+        template.sendBody("seda:start", "A");
+        template.sendBody("seda:start", "B");
+        template.sendBody("seda:start", "C");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("seda:start")
+                    .log("before ${body}")
+                    .to("netty:tcp://localhost:{{port}}?textline=true&sync=true")
+                    .log("after ${body}")
+                    .to("mock:result");
+
+                from("netty:tcp://localhost:{{port}}?textline=true&sync=true")
+                    .transform(body().prepend("Bye "));
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/7b054480/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyInOutWithForcedNoResponseTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyInOutWithForcedNoResponseTest.java b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyInOutWithForcedNoResponseTest.java
new file mode 100644
index 0000000..5d875a3
--- /dev/null
+++ b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyInOutWithForcedNoResponseTest.java
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.netty4;
+
+import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.builder.RouteBuilder;
+import org.junit.Test;
+
+/**
+ * @version 
+ */
+public class NettyInOutWithForcedNoResponseTest extends BaseNettyTest {
+
+    @Test
+    public void testResponse() throws Exception {
+        Object out = template.requestBody("netty:tcp://localhost:{{port}}", "Copenhagen");
+        assertEquals("Hello Claus", out);
+    }
+
+    @Test
+    public void testNoResponse() throws Exception {
+        try {
+            template.requestBody("netty:tcp://localhost:{{port}}", "London");
+            fail("Should throw an exception");
+        } catch (RuntimeCamelException e) {
+            assertTrue(e.getCause().getMessage().startsWith("No response"));
+        }
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() throws Exception {
+                from("netty:tcp://localhost:{{port}}")
+                    .choice()
+                        .when(body().isEqualTo("Copenhagen")).transform(constant("Hello Claus"))
+                        .otherwise().transform(constant(null));
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/7b054480/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
new file mode 100644
index 0000000..f658db8
--- /dev/null
+++ b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyManualEndpointTest.java
@@ -0,0 +1,79 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.netty4;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.jboss.netty.channel.ChannelHandler;
+import org.jboss.netty.handler.codec.frame.Delimiters;
+import org.jboss.netty.util.CharsetUtil;
+import org.junit.Test;
+
+public class NettyManualEndpointTest extends BaseNettyTest {
+
+    private NettyEndpoint endpoint;
+
+    @Test
+    public void testNettyManaul() throws Exception {
+        assertNotNull(endpoint);
+
+        getMockEndpoint("mock:result").expectedMessageCount(1);
+
+        template.sendBody(endpoint, "Hello World\n");
+
+        assertMockEndpointsSatisfied();
+
+        assertEquals("netty:tcp://localhost:" + getPort(), endpoint.getEndpointUri());
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                NettyConfiguration nettyConfig = new NettyConfiguration();
+                nettyConfig.setProtocol("tcp");
+                nettyConfig.setHost("localhost");
+                nettyConfig.setPort(getPort());
+                nettyConfig.setSync(false);
+
+                // need to add encoders and decoders manually
+                nettyConfig.setEncoder(ChannelHandlerFactories.newStringEncoder(CharsetUtil.UTF_8));
+                List<ChannelHandler> decoders = new ArrayList<ChannelHandler>();
+                decoders.add(ChannelHandlerFactories.newDelimiterBasedFrameDecoder(1000, Delimiters.lineDelimiter()));
+                decoders.add(ChannelHandlerFactories.newStringDecoder(CharsetUtil.UTF_8));
+                nettyConfig.setDecoders(decoders);
+
+                // create and start component
+                NettyComponent component = new NettyComponent(getContext());
+                component.setConfiguration(nettyConfig);
+                getContext().addComponent("netty", component);
+                component.start();
+
+                // create and start endpoint, pass in null as endpoint uri
+                // as we create this endpoint manually
+                endpoint = new NettyEndpoint(null, component, nettyConfig);
+                endpoint.setTimer(NettyComponent.getTimer());
+                endpoint.start();
+
+                from(endpoint).to("mock:result");
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/7b054480/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyMultipleSimultaneousClientsTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyMultipleSimultaneousClientsTest.java b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyMultipleSimultaneousClientsTest.java
new file mode 100644
index 0000000..9634c84
--- /dev/null
+++ b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyMultipleSimultaneousClientsTest.java
@@ -0,0 +1,95 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.netty4;
+
+import java.util.Arrays;
+import java.util.concurrent.Callable;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.junit.Test;
+
+/**
+ *
+ */
+public class NettyMultipleSimultaneousClientsTest extends BaseNettyTest {
+
+    private String uri = "netty:tcp://localhost:{{port}}?sync=true&reuseAddress=true&synchronous=false";
+    private int clientCount = 20;
+    private CountDownLatch startLatch = new CountDownLatch(1);
+    private CountDownLatch finishLatch = new CountDownLatch(clientCount);
+
+    @Test
+    public void testSimultaneousClients() throws Exception {
+        ExecutorService executorService = Executors.newFixedThreadPool(clientCount);
+        Future<?>[] replies = new Future[clientCount];
+
+        for (int i = 0; i < clientCount; i++) {
+            replies[i] = executorService.submit(new Callable<Object>() {
+                @Override
+                public Object call() throws Exception {
+                    // wait until we're allowed to start
+                    startLatch.await();
+
+                    Object reply = template.requestBody(uri, "World");
+
+                    // signal that we're done now
+                    finishLatch.countDown();
+
+                    return reply;
+                }
+            });
+        }
+
+        Object[] expectedReplies = new Object[clientCount];
+        Arrays.fill(expectedReplies, "Bye World");
+
+        getMockEndpoint("mock:result").expectedMessageCount(clientCount);
+        getMockEndpoint("mock:result").expectedBodiesReceived(expectedReplies);
+
+        // fire the simultaneous client calls
+        startLatch.countDown();
+
+        // and wait long enough until they're all done
+        assertTrue("Waiting on the latch ended up with a timeout!", finishLatch.await(5, TimeUnit.SECONDS));
+
+        executorService.shutdown();
+
+        // assert on what we expect to receive
+        for (int i = 0; i < clientCount; i++) {
+            assertEquals("Bye World", replies[i].get());
+        }
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from(uri)
+                    .log("${body}")
+                    .transform(body().prepend("Bye "))
+                    .to("mock:result");
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/7b054480/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyOptionTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyOptionTest.java b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyOptionTest.java
new file mode 100644
index 0000000..ab49d3b
--- /dev/null
+++ b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyOptionTest.java
@@ -0,0 +1,46 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.netty4;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+
+public class NettyOptionTest extends NettyTCPSyncTest {
+    
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("netty:tcp://localhost:{{port}}?sync=true&option.child.keepAlive=false")
+                    .process(new Processor() {
+                        public void process(Exchange exchange) throws Exception {
+                            if (exchange.getIn().getBody() instanceof Poetry) {
+                                Poetry poetry = (Poetry) exchange.getIn().getBody();
+                                poetry.setPoet("Dr. Sarojini Naidu");
+                                exchange.getOut().setBody(poetry);
+                                return;
+                            }
+                            exchange.getOut().setBody("When You Go Home, Tell Them Of Us And Say, For Your Tomorrow, We Gave Our Today.");                           
+                        }
+                    });                
+            }
+        };
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/7b054480/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyProducerAsyncEndpointTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyProducerAsyncEndpointTest.java b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyProducerAsyncEndpointTest.java
new file mode 100644
index 0000000..6c2e8ac
--- /dev/null
+++ b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyProducerAsyncEndpointTest.java
@@ -0,0 +1,76 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.netty4;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.junit.Test;
+
+/**
+ * @version 
+ */
+public class NettyProducerAsyncEndpointTest extends BaseNettyTest {
+
+    private static String beforeThreadName;
+    private static String afterThreadName;
+
+    @Test
+    public void testAsyncEndpoint() throws Exception {
+        getMockEndpoint("mock:before").expectedBodiesReceived("Hello Camel");
+        getMockEndpoint("mock:after").expectedBodiesReceived("Bye Camel");
+        getMockEndpoint("mock:result").expectedBodiesReceived("Bye Camel");
+
+        String reply = template.requestBody("direct:start", "Hello Camel", String.class);
+        assertEquals("Bye Camel", reply);
+
+        assertMockEndpointsSatisfied();
+
+        assertFalse("Should use different threads", beforeThreadName.equalsIgnoreCase(afterThreadName));
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start")
+                        .to("mock:before")
+                        .to("log:before")
+                        .process(new Processor() {
+                            public void process(Exchange exchange) throws Exception {
+                                beforeThreadName = Thread.currentThread().getName();
+                            }
+                        })
+                        .to("netty:tcp://localhost:{{port}}?textline=true&sync=true")
+                        .process(new Processor() {
+                            public void process(Exchange exchange) throws Exception {
+                                afterThreadName = Thread.currentThread().getName();
+                            }
+                        })
+                        .to("log:after")
+                        .to("mock:after")
+                        .to("mock:result");
+
+                from("netty:tcp://localhost:{{port}}?textline=true&sync=true")
+                    .delay(1000)
+                    .validate(body().isInstanceOf(String.class))
+                    .transform(body().regexReplaceAll("Hello", "Bye"));
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/7b054480/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyProducerPoolDisabledTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyProducerPoolDisabledTest.java b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyProducerPoolDisabledTest.java
new file mode 100644
index 0000000..138f88f
--- /dev/null
+++ b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyProducerPoolDisabledTest.java
@@ -0,0 +1,50 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.netty4;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.junit.Test;
+
+/**
+ * @version 
+ */
+public class NettyProducerPoolDisabledTest extends BaseNettyTest {
+
+    @Test
+    public void testProducerPoolDisabled() throws Exception {
+        for (int i = 0; i < 10; i++) {
+            String reply = template.requestBody("direct:start", "Hello " + i, String.class);
+            assertEquals("Bye " + i, reply);
+        }
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start")
+                    .to("netty:tcp://localhost:{{port}}?textline=true&sync=true&producerPoolEnabled=false");
+
+                from("netty:tcp://localhost:{{port}}?textline=true&sync=true")
+                    // body should be a String when using textline codec
+                    .validate(body().isInstanceOf(String.class))
+                    .transform(body().regexReplaceAll("Hello", "Bye"));
+            }
+        };
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/7b054480/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyProxyTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyProxyTest.java b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyProxyTest.java
new file mode 100644
index 0000000..e8e42a5
--- /dev/null
+++ b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyProxyTest.java
@@ -0,0 +1,61 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.netty4;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.junit.Test;
+
+/**
+ *
+ */
+public class NettyProxyTest extends BaseNettyTest {
+
+    private int port1;
+    private int port2;
+
+    @Test
+    public void testNettyProxy() throws Exception {
+        getMockEndpoint("mock:before").expectedBodiesReceived("Camel");
+        getMockEndpoint("mock:proxy").expectedBodiesReceived("Camel");
+        getMockEndpoint("mock:after").expectedBodiesReceived("Bye Camel");
+
+        Object body = template.requestBody("netty:tcp://localhost:" + port1 + "?sync=true&textline=true", "Camel\n");
+        assertEquals("Bye Camel", body);
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                port1 = getPort();
+                port2 = getNextPort();
+
+                fromF("netty:tcp://localhost:%s?sync=true&textline=true", port1)
+                    .to("mock:before")
+                    .toF("netty:tcp://localhost:%s?sync=true&textline=true", port2)
+                    .to("mock:after");
+
+                fromF("netty:tcp://localhost:%s?sync=true&textline=true", port2)
+                    .to("mock:proxy")
+                    .transform().simple("Bye ${body}\n");
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/7b054480/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyRequestTimeoutIssueTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyRequestTimeoutIssueTest.java b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyRequestTimeoutIssueTest.java
new file mode 100644
index 0000000..31c0ac4
--- /dev/null
+++ b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyRequestTimeoutIssueTest.java
@@ -0,0 +1,50 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.netty4;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Assert;
+import org.junit.Ignore;
+import org.junit.Test;
+
+@Ignore("This test can be run manually")
+public class NettyRequestTimeoutIssueTest extends CamelTestSupport {
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:out")
+                        .to("netty:tcp://localhost:8080?requestTimeout=5000");
+
+                from("netty:tcp://localhost:8080")
+                        .to("log:nettyCase?showAll=true&multiline=true");
+            }
+        };
+    }
+
+    @Test
+    public void test() throws Exception {
+        String result = template.requestBody("direct:out", "hello", String.class);
+        Assert.assertEquals("hello", result);
+
+        log.info("Sleeping for 20 seconds, and no Netty exception should occur");
+        Thread.sleep(20000);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/7b054480/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
new file mode 100644
index 0000000..2c08d35
--- /dev/null
+++ b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyRequestTimeoutTest.java
@@ -0,0 +1,84 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.netty4;
+
+import org.apache.camel.CamelExecutionException;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.jboss.netty.handler.timeout.ReadTimeoutException;
+import org.junit.Test;
+
+/**
+ * @version 
+ */
+public class NettyRequestTimeoutTest extends BaseNettyTest {
+
+    @Test
+    public void testRequestTimeoutOK() throws Exception {
+        String out = template.requestBody("netty:tcp://localhost:{{port}}?textline=true&sync=true&requestTimeout=5000", "Hello Camel", String.class);
+        assertEquals("Bye World", out);
+    }
+
+    @Test
+    public void testRequestTimeout() throws Exception {
+        try {
+            template.requestBody("netty:tcp://localhost:{{port}}?textline=true&sync=true&requestTimeout=1000", "Hello Camel", String.class);
+            fail("Should have thrown exception");
+        } catch (CamelExecutionException e) {
+            ReadTimeoutException cause = assertIsInstanceOf(ReadTimeoutException.class, e.getCause());
+            assertNotNull(cause);
+        }
+    }
+
+    @Test
+    public void testRequestTimeoutAndOk() throws Exception {
+        try {
+            template.requestBody("netty:tcp://localhost:{{port}}?textline=true&sync=true&requestTimeout=1000", "Hello Camel", String.class);
+            fail("Should have thrown exception");
+        } catch (CamelExecutionException e) {
+            ReadTimeoutException cause = assertIsInstanceOf(ReadTimeoutException.class, e.getCause());
+            assertNotNull(cause);
+        }
+
+        // now we try again but this time the is no delay on server and thus faster
+        String out = template.requestBody("netty:tcp://localhost:{{port}}?textline=true&sync=true&requestTimeout=1000", "Hello World", String.class);
+        assertEquals("Bye World", out);
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("netty:tcp://localhost:{{port}}?textline=true&sync=true")
+                    .process(new Processor() {
+                        @Override
+                        public void process(Exchange exchange) throws Exception {
+                            String body = exchange.getIn().getBody(String.class);
+
+                            if (body.contains("Camel")) {
+                                Thread.sleep(3000);
+                            }
+                        }
+                    })
+                    .transform().constant("Bye World");
+
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/7b054480/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyReuseConnectionTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyReuseConnectionTest.java b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyReuseConnectionTest.java
new file mode 100644
index 0000000..e1252ab
--- /dev/null
+++ b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyReuseConnectionTest.java
@@ -0,0 +1,46 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.netty4;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.junit.Test;
+
+/**
+ *
+ */
+public class NettyReuseConnectionTest extends BaseNettyTest {
+
+    private String uri = "netty:tcp://localhost:{{port}}?sync=true&disconnect=false";
+
+    @Test
+    public void testReuseConnection() throws Exception {
+        for (int i = 0; i < 20; i++) {
+            String out = template.requestBody(uri, "" + i, String.class);
+            assertEquals("Reply " + i, out);
+        }
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from(uri).transform().simple("Reply ${body}");
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/7b054480/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettySSLClasspathTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettySSLClasspathTest.java b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettySSLClasspathTest.java
new file mode 100644
index 0000000..6816074
--- /dev/null
+++ b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettySSLClasspathTest.java
@@ -0,0 +1,57 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.camel.component.netty4;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.junit.Test;
+
+public class NettySSLClasspathTest extends BaseNettyTest {
+
+    @Override
+    public boolean isUseRouteBuilder() {
+        return false;
+    }
+
+    @Test
+    public void testSSLInOutWithNettyConsumer() throws Exception {
+        // ibm jdks dont have sun security algorithms
+        if (isJavaVendor("ibm")) {
+            return;
+        }
+
+        context.addRoutes(new RouteBuilder() {
+            public void configure() {
+                from("netty:tcp://localhost:{{port}}?sync=true&ssl=true&passphrase=changeit&keyStoreResource=classpath:keystore.jks&trustStoreResource=classpath:keystore.jks")
+                    .process(new Processor() {
+                        public void process(Exchange exchange) throws Exception {
+                            exchange.getOut().setBody("When You Go Home, Tell Them Of Us And Say, For Your Tomorrow, We Gave Our Today.");                           
+                        }
+                    });
+            }
+        });
+        context.start();
+
+        String response = template.requestBody(
+                "netty:tcp://localhost:{{port}}?sync=true&ssl=true&passphrase=changeit&keyStoreResource=classpath:keystore.jks&trustStoreResource=classpath:keystore.jks",
+                "Epitaph in Kohima, India marking the WWII Battle of Kohima and Imphal, Burma Campaign - Attributed to John Maxwell Edmonds", String.class);
+        assertEquals("When You Go Home, Tell Them Of Us And Say, For Your Tomorrow, We Gave Our Today.", response);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/7b054480/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettySSLClientCertHeadersTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettySSLClientCertHeadersTest.java b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettySSLClientCertHeadersTest.java
new file mode 100644
index 0000000..56345c9
--- /dev/null
+++ b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettySSLClientCertHeadersTest.java
@@ -0,0 +1,74 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.netty4;
+
+import java.io.File;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.impl.JndiRegistry;
+import org.junit.Test;
+
+public class NettySSLClientCertHeadersTest extends BaseNettyTest {
+
+    @Override
+    protected JndiRegistry createRegistry() throws Exception {
+        JndiRegistry registry = super.createRegistry();
+        registry.bind("ksf", new File("src/test/resources/keystore.jks"));
+        registry.bind("tsf", new File("src/test/resources/keystore.jks"));
+        return registry;
+    }
+    
+    @Override
+    public boolean isUseRouteBuilder() {
+        return false;
+    }
+
+    @Test
+    public void testSSLInOutWithNettyConsumer() throws Exception {
+        // ibm jdks dont have sun security algorithms
+        if (isJavaVendor("ibm")) {
+            return;
+        }
+
+        getMockEndpoint("mock:input").expectedMessageCount(1);
+
+        getMockEndpoint("mock:input").expectedHeaderReceived(NettyConstants.NETTY_SSL_CLIENT_CERT_SUBJECT_NAME,
+                "CN=arlu15, OU=Sun Java System Application Server, O=Sun Microsystems, L=Santa Clara, ST=California, C=US");
+        getMockEndpoint("mock:input").expectedHeaderReceived(NettyConstants.NETTY_SSL_CLIENT_CERT_ISSUER_NAME,
+                "CN=arlu15, OU=Sun Java System Application Server, O=Sun Microsystems, L=Santa Clara, ST=California, C=US");
+        getMockEndpoint("mock:input").expectedHeaderReceived(NettyConstants.NETTY_SSL_CLIENT_CERT_SERIAL_NO, "1210701502");
+
+        context.addRoutes(new RouteBuilder() {
+            public void configure() {
+                // needClientAuth=true so we can get the client certificate details
+                from("netty:tcp://localhost:{{port}}?sync=true&ssl=true&passphrase=changeit&keyStoreFile=#ksf&trustStoreFile=#tsf"
+                        + "&needClientAuth=true&sslClientCertHeaders=true")
+                    .to("mock:input")
+                    .transform().constant("Bye World");
+            }
+        });
+        context.start();
+
+        String response = template.requestBody(
+                "netty:tcp://localhost:{{port}}?sync=true&ssl=true&passphrase=changeit&keyStoreFile=#ksf&trustStoreFile=#tsf",
+                "Hello World", String.class);
+        assertEquals("Bye World", response);
+
+        assertMockEndpointsSatisfied();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/7b054480/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettySSLContextParametersTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettySSLContextParametersTest.java b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettySSLContextParametersTest.java
new file mode 100644
index 0000000..0ef1406
--- /dev/null
+++ b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettySSLContextParametersTest.java
@@ -0,0 +1,92 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.netty4;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.impl.JndiRegistry;
+import org.apache.camel.util.jsse.ClientAuthentication;
+import org.apache.camel.util.jsse.KeyManagersParameters;
+import org.apache.camel.util.jsse.KeyStoreParameters;
+import org.apache.camel.util.jsse.SSLContextParameters;
+import org.apache.camel.util.jsse.SSLContextServerParameters;
+import org.apache.camel.util.jsse.TrustManagersParameters;
+import org.junit.Test;
+
+public class NettySSLContextParametersTest extends BaseNettyTest {
+
+    @Override
+    protected JndiRegistry createRegistry() throws Exception {
+        
+        KeyStoreParameters ksp = new KeyStoreParameters();
+        ksp.setResource(this.getClass().getClassLoader().getResource("keystore.jks").toString());
+        ksp.setPassword("changeit");
+        
+        KeyManagersParameters kmp = new KeyManagersParameters();
+        kmp.setKeyPassword("changeit");
+        kmp.setKeyStore(ksp);
+        
+        TrustManagersParameters tmp = new TrustManagersParameters();
+        tmp.setKeyStore(ksp);
+
+        // NOTE: Needed since the client uses a loose trust configuration when no ssl context
+        // is provided.  We turn on WANT client-auth to prefer using authentication
+        SSLContextServerParameters scsp = new SSLContextServerParameters();
+        scsp.setClientAuthentication(ClientAuthentication.WANT.name());
+
+        SSLContextParameters sslContextParameters = new SSLContextParameters();
+        sslContextParameters.setKeyManagers(kmp);
+        sslContextParameters.setTrustManagers(tmp);
+        sslContextParameters.setServerParameters(scsp);
+
+        JndiRegistry registry = super.createRegistry();
+        registry.bind("sslContextParameters", sslContextParameters);
+        return registry;
+    }
+    
+    @Override
+    public boolean isUseRouteBuilder() {
+        return false;
+    }
+
+    @Test
+    public void testSSLInOutWithNettyConsumer() throws Exception {
+        // ibm jdks dont have sun security algorithms
+        if (isJavaVendor("ibm")) {
+            return;
+        }
+
+        context.addRoutes(new RouteBuilder() {
+            public void configure() {
+                from("netty:tcp://localhost:{{port}}?sync=true&ssl=true&sslContextParameters=#sslContextParameters")
+                    .process(new Processor() {
+                        public void process(Exchange exchange) throws Exception {
+                            exchange.getOut().setBody("When You Go Home, Tell Them Of Us And Say, For Your Tomorrow, We Gave Our Today.");                           
+                        }
+                    });
+            }
+        });
+        context.start();
+
+        String response = template.requestBody(
+                "netty:tcp://localhost:{{port}}?sync=true&ssl=true&sslContextParameters=#sslContextParameters",
+                "Epitaph in Kohima, India marking the WWII Battle of Kohima and Imphal, Burma Campaign - Attributed to John Maxwell Edmonds", String.class);
+        assertEquals("When You Go Home, Tell Them Of Us And Say, For Your Tomorrow, We Gave Our Today.", response);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/7b054480/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettySSLPassphaseBeanTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettySSLPassphaseBeanTest.java b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettySSLPassphaseBeanTest.java
new file mode 100644
index 0000000..b5843ff
--- /dev/null
+++ b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettySSLPassphaseBeanTest.java
@@ -0,0 +1,65 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.camel.component.netty4;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.impl.JndiRegistry;
+import org.junit.Test;
+
+public class NettySSLPassphaseBeanTest extends BaseNettyTest {
+
+    @Override
+    protected JndiRegistry createRegistry() throws Exception {
+        JndiRegistry jndi = super.createRegistry();
+        jndi.bind("myBean", "changeit");
+        return jndi;
+    }
+
+    @Override
+    public boolean isUseRouteBuilder() {
+        return false;
+    }
+
+    @Test
+    public void testPassphaseBean() throws Exception {
+        // ibm jdks dont have sun security algorithms
+        if (isJavaVendor("ibm")) {
+            return;
+        }
+
+        context.addRoutes(new RouteBuilder() {
+            public void configure() {
+                from("netty:tcp://localhost:{{port}}?sync=true&ssl=true&passphrase=#myBean&keyStoreResource=classpath:keystore.jks&trustStoreResource=classpath:keystore.jks")
+                    .process(new Processor() {
+                        public void process(Exchange exchange) throws Exception {
+                            exchange.getOut().setBody("When You Go Home, Tell Them Of Us And Say, For Your Tomorrow, We Gave Our Today.");                           
+                        }
+                    });
+            }
+        });
+        context.start();
+
+        String response = template.requestBody(
+                "netty:tcp://localhost:{{port}}?sync=true&ssl=true&passphrase=#myBean&keyStoreResource=classpath:keystore.jks&trustStoreResource=classpath:keystore.jks",
+                "Epitaph in Kohima, India marking the WWII Battle of Kohima and Imphal, Burma Campaign - Attributed to John Maxwell Edmonds", String.class);
+        assertEquals("When You Go Home, Tell Them Of Us And Say, For Your Tomorrow, We Gave Our Today.", response);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/7b054480/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettySSLTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettySSLTest.java b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettySSLTest.java
new file mode 100644
index 0000000..dcc4fce
--- /dev/null
+++ b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettySSLTest.java
@@ -0,0 +1,79 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.netty4;
+
+import java.io.File;
+import java.security.Principal;
+
+import javax.net.ssl.SSLSession;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.impl.JndiRegistry;
+import org.junit.Test;
+
+public class NettySSLTest extends BaseNettyTest {
+
+    @Override
+    protected JndiRegistry createRegistry() throws Exception {
+        JndiRegistry registry = super.createRegistry();
+        registry.bind("ksf", new File("src/test/resources/keystore.jks"));
+        registry.bind("tsf", new File("src/test/resources/keystore.jks"));
+        return registry;
+    }
+    
+    @Override
+    public boolean isUseRouteBuilder() {
+        return false;
+    }
+
+    @Test
+    public void testSSLInOutWithNettyConsumer() throws Exception {
+        // ibm jdks dont have sun security algorithms
+        if (isJavaVendor("ibm")) {
+            return;
+        }
+
+        context.addRoutes(new RouteBuilder() {
+            public void configure() {
+                // needClientAuth=true so we can get the client certificate details
+                from("netty:tcp://localhost:{{port}}?sync=true&ssl=true&passphrase=changeit&keyStoreFile=#ksf&trustStoreFile=#tsf&needClientAuth=true")
+                    .process(new Processor() {
+                        public void process(Exchange exchange) throws Exception {
+                            SSLSession session = exchange.getIn().getHeader(NettyConstants.NETTY_SSL_SESSION, SSLSession.class);
+                            if (session != null) {
+                                javax.security.cert.X509Certificate cert = session.getPeerCertificateChain()[0];
+                                Principal principal = cert.getSubjectDN();
+                                log.info("Client Cert SubjectDN: {}", principal.getName());
+                                exchange.getOut().setBody("When You Go Home, Tell Them Of Us And Say, For Your Tomorrow, We Gave Our Today.");
+                            } else {
+                                exchange.getOut().setBody("Cannot start conversion without SSLSession");
+                            }
+                        }
+                    });
+            }
+        });
+        context.start();
+
+        String response = template.requestBody(
+                "netty:tcp://localhost:{{port}}?sync=true&ssl=true&passphrase=changeit&keyStoreFile=#ksf&trustStoreFile=#tsf",
+                "Epitaph in Kohima, India marking the WWII Battle of Kohima and Imphal, Burma Campaign - Attributed to John Maxwell Edmonds", String.class);
+        assertEquals("When You Go Home, Tell Them Of Us And Say, For Your Tomorrow, We Gave Our Today.", response);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/7b054480/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
new file mode 100644
index 0000000..26181bc
--- /dev/null
+++ b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettySingleCodecTest.java
@@ -0,0 +1,62 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.netty4;
+
+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 org.jboss.netty.handler.codec.string.StringDecoder;
+import org.jboss.netty.handler.codec.string.StringEncoder;
+import org.junit.Test;
+
+public class NettySingleCodecTest extends BaseNettyTest {
+
+    @Override
+    protected JndiRegistry createRegistry() throws Exception {
+        JndiRegistry registry = super.createRegistry();
+        StringEncoder stringEncoder = new StringEncoder();
+
+        StringDecoder stringDecoder = new StringDecoder();
+
+        registry.bind("encoder", stringEncoder);
+        registry.bind("decoder", stringDecoder);
+        return registry;
+    }
+
+    @Test
+    public void canSupplySingleCodecToEndpointPipeline() throws Exception {
+        String poem = new Poetry().getPoem();
+        MockEndpoint mock = getMockEndpoint("mock:single-codec");
+        mock.expectedBodiesReceived(poem);
+        sendBody("direct:single-codec", poem);
+        mock.await(1, TimeUnit.SECONDS);
+        mock.assertIsSatisfied();
+
+    }
+
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() throws Exception {
+                from("direct:single-codec").to("netty:tcp://localhost:{{port}}?encoder=#encoder&sync=false");
+
+                from("netty:tcp://localhost:{{port}}?decoder=#decoder&sync=false").to("mock:single-codec");
+            }
+        };
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/7b054480/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettySuspendResumeTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettySuspendResumeTest.java b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettySuspendResumeTest.java
new file mode 100644
index 0000000..514f9a1
--- /dev/null
+++ b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettySuspendResumeTest.java
@@ -0,0 +1,61 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.netty4;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.junit.Test;
+
+public class NettySuspendResumeTest extends BaseNettyTest {
+    
+    @Test
+    public void testSuspendResume() throws Exception {
+        getMockEndpoint("mock:result").expectedBodiesReceived("Camel", "Again");
+
+        String out = template.requestBody("netty:tcp://localhost:{{port}}?sync=true&disconnect=true", "Camel", String.class);
+        assertEquals("Bye Camel", out);
+
+        context.suspendRoute("foo");
+
+        try {
+            template.requestBody("netty:tcp://localhost:{{port}}?sync=true&disconnect=true", "World", String.class);
+            fail("Should not allow connecting as its suspended");
+        } catch (Exception e) {
+            // expected
+        }
+
+        context.resumeRoute("foo");
+
+        out = template.requestBody("netty:tcp://localhost:{{port}}?sync=true&disconnect=true", "Again", String.class);
+        assertEquals("Bye Again", out);
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("netty:tcp://localhost:{{port}}?sync=true").routeId("foo")
+                    .to("log:result")
+                    .to("mock:result")
+                    .transform(body().prepend("Bye "));
+            }
+        };
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/7b054480/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyTCPAsyncTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyTCPAsyncTest.java b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyTCPAsyncTest.java
new file mode 100644
index 0000000..92ba8d5
--- /dev/null
+++ b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyTCPAsyncTest.java
@@ -0,0 +1,75 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.netty4;
+
+import java.io.FileInputStream;
+import java.io.InputStream;
+
+import org.apache.camel.EndpointInject;
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.converter.IOConverter;
+import org.apache.camel.util.IOHelper;
+
+import org.junit.Test;
+
+public class NettyTCPAsyncTest extends BaseNettyTest {
+    @EndpointInject(uri = "mock:result")
+    protected MockEndpoint resultEndpoint;
+
+    private void sendFile(String uri) throws Exception {
+        template.send(uri, new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                // Read from an input stream
+                InputStream is = IOHelper.buffered(new FileInputStream("src/test/resources/test.txt"));
+
+                byte buffer[] = IOConverter.toBytes(is);
+                is.close();
+
+                // Set the property of the charset encoding
+                exchange.setProperty(Exchange.CHARSET_NAME, "UTF-8");
+                Message in = exchange.getIn();
+                in.setBody(buffer);
+            }
+        });
+    }
+
+    @Test
+    public void testTCPInOnlyWithNettyConsumer() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(1);
+        sendFile("netty:tcp://localhost:{{port}}?sync=false");
+        
+        mock.assertIsSatisfied();
+    }
+    
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("netty:tcp://localhost:{{port}}?sync=false")
+                    .to("log:result")
+                    .to("mock:result");                
+            }
+        };
+    }
+
+}


Mime
View raw message