You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2013/08/07 15:45:52 UTC

[3/6] CAMEL-6555: camel-netty4 for Netty 4.x based component. Work in progress.

http://git-wip-us.apache.org/repos/asf/camel/blob/1bb756cd/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..00bfb09
--- /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("netty4:tcp://localhost:{{port}}?sync=false&textline=true")
+                        .to("mock:results");
+
+                from("file:src/test/data?noop=true&fileName=message1.txt").
+                        to("netty4:tcp://localhost:{{port}}?sync=false&textline=true");
+            }
+        };
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/1bb756cd/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..d774a28
--- /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("netty4: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("netty4: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/1bb756cd/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..9a794f0
--- /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("netty4:tcp://localhost:{{port}}?textline=true&sync=true")
+                    .log("after ${body}")
+                    .to("mock:result");
+
+                from("netty4:tcp://localhost:{{port}}?textline=true&sync=true")
+                    .transform(body().prepend("Bye "));
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/1bb756cd/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..e679d0f
--- /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("netty4:tcp://localhost:{{port}}", "Copenhagen");
+        assertEquals("Hello Claus", out);
+    }
+
+    @Test
+    public void testNoResponse() throws Exception {
+        try {
+            template.requestBody("netty4: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("netty4: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/1bb756cd/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..59d2ba6
--- /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("netty4: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("netty4", 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/1bb756cd/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..7308d20
--- /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("netty4: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/1bb756cd/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..8e6c921
--- /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("netty4: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("netty4: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/1bb756cd/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..8008beb
--- /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("netty4:tcp://localhost:{{port}}?textline=true&sync=true&producerPoolEnabled=false");
+
+                from("netty4: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/1bb756cd/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..fbbec0b
--- /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("netty4: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("netty4:tcp://localhost:%s?sync=true&textline=true", port1)
+                    .to("mock:before")
+                    .toF("netty4:tcp://localhost:%s?sync=true&textline=true", port2)
+                    .to("mock:after");
+
+                fromF("netty4: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/1bb756cd/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..24946fe
--- /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("netty4: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("netty4: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("netty4: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("netty4: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("netty4: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/1bb756cd/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..424fdf1
--- /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 = "netty4: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/1bb756cd/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..b588c62
--- /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("netty4: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(
+                "netty4: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/1bb756cd/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..5d4eb34
--- /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("netty4: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(
+                "netty4: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/1bb756cd/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..29b9630
--- /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("netty4: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(
+                "netty4: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/1bb756cd/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..c7bb923
--- /dev/null
+++ b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettySSLTest.java
@@ -0,0 +1,78 @@
+/**
+ * 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("netty4: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(
+                "netty4: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/1bb756cd/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..acb4833
--- /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("netty4:tcp://localhost:{{port}}?encoder=#encoder&sync=false");
+
+                from("netty4: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/1bb756cd/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..cd97937
--- /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("netty4:tcp://localhost:{{port}}?sync=false");
+        
+        mock.assertIsSatisfied();
+    }
+    
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("netty4:tcp://localhost:{{port}}?sync=false")
+                    .to("log:result")
+                    .to("mock:result");                
+            }
+        };
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/1bb756cd/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyTCPSyncNotLazyChannelTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyTCPSyncNotLazyChannelTest.java b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyTCPSyncNotLazyChannelTest.java
new file mode 100644
index 0000000..8d522d7
--- /dev/null
+++ b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyTCPSyncNotLazyChannelTest.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 org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.junit.Test;
+
+public class NettyTCPSyncNotLazyChannelTest extends BaseNettyTest {
+
+    @Test
+    public void testTCPStringInOutWithNettyConsumer() throws Exception {
+        String response = template.requestBody(
+            "netty4:tcp://localhost:{{port}}?sync=true&lazyChannelCreation=false",
+            "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);
+    }
+
+    @Test
+    public void testTCPObjectInOutWithNettyConsumer() throws Exception {
+        Poetry poetry = new Poetry();
+        Poetry response = (Poetry) template.requestBody("netty4:tcp://localhost:{{port}}?sync=true&lazyChannelCreation=false", poetry);
+        assertEquals("Dr. Sarojini Naidu", response.getPoet());
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("netty4:tcp://localhost:{{port}}?sync=true")
+                    .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/1bb756cd/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyTCPSyncTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyTCPSyncTest.java b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyTCPSyncTest.java
new file mode 100644
index 0000000..8671eb6
--- /dev/null
+++ b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyTCPSyncTest.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 org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.junit.Test;
+
+public class NettyTCPSyncTest extends BaseNettyTest {
+    
+    @Test
+    public void testTCPStringInOutWithNettyConsumer() throws Exception {
+        String response = template.requestBody(
+            "netty4:tcp://localhost:{{port}}?sync=true",
+            "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);
+    }
+
+    @Test
+    public void testTCPStringInOutWithNettyConsumer2Times() throws Exception {
+        String response = template.requestBody(
+            "netty4:tcp://localhost:{{port}}?sync=true",
+            "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);
+
+        response = template.requestBody(
+            "netty4:tcp://localhost:{{port}}?sync=true",
+            "Hello World", String.class);
+        assertEquals("When You Go Home, Tell Them Of Us And Say, For Your Tomorrow, We Gave Our Today.", response);
+    }
+
+    @Test
+    public void testTCPObjectInOutWithNettyConsumer() throws Exception {
+        Poetry poetry = new Poetry();
+        Poetry response = (Poetry) template.requestBody("netty4:tcp://localhost:{{port}}?sync=true", poetry);
+        assertEquals("Dr. Sarojini Naidu", response.getPoet());
+    }
+    
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("netty4:tcp://localhost:{{port}}?sync=true")
+                    .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/1bb756cd/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyTcpWithInOutUsingPlainSocketTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyTcpWithInOutUsingPlainSocketTest.java b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyTcpWithInOutUsingPlainSocketTest.java
new file mode 100644
index 0000000..17e22c1
--- /dev/null
+++ b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyTcpWithInOutUsingPlainSocketTest.java
@@ -0,0 +1,143 @@
+/**
+ * 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.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.InetSocketAddress;
+import java.net.Socket;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.junit.Test;
+
+/**
+ * @version 
+ */
+public class NettyTcpWithInOutUsingPlainSocketTest extends BaseNettyTest {
+
+    @Test
+    public void testSendAndReceiveOnce() throws Exception {
+        String response = sendAndReceive("World");
+
+        assertNotNull("Nothing received from Mina", response);
+        assertEquals("Hello World", response);
+    }
+
+    @Test
+    public void testSendAndReceiveTwice() throws Exception {
+        String london = sendAndReceive("London");
+        String paris = sendAndReceive("Paris");
+
+        assertNotNull("Nothing received from Mina", london);
+        assertNotNull("Nothing received from Mina", paris);
+        assertEquals("Hello London", london);
+        assertEquals("Hello Paris", paris);
+    }
+
+    @Test
+    public void testReceiveNoResponseSinceOutBodyIsNull() throws Exception {
+        String out = sendAndReceive("force-null-out-body");
+        assertNull("no data should be recieved", out);
+    }
+
+    @Test
+    public void testReceiveNoResponseSinceOutBodyIsNullTwice() throws Exception {
+        String out = sendAndReceive("force-null-out-body");
+        assertNull("no data should be recieved", out);
+
+        out = sendAndReceive("force-null-out-body");
+        assertNull("no data should be recieved", out);
+    }
+
+    @Test
+    public void testExchangeFailedOutShouldBeNull() throws Exception {
+        String out = sendAndReceive("force-exception");
+        assertTrue("out should not be the same as in when the exchange has failed", !"force-exception".equals(out));
+        assertEquals("should get the exception here", out, "java.lang.IllegalArgumentException: Forced exception");
+    }
+
+    private String sendAndReceive(String input) throws IOException {
+        byte buf[] = new byte[128];
+
+        Socket soc = new Socket();
+        soc.connect(new InetSocketAddress("localhost", getPort()));
+
+        // Send message using plain Socket to test if this works
+        OutputStream os = null;
+        InputStream is = null;
+        try {
+            os = soc.getOutputStream();
+            // must append the line delimiter
+            os.write((input + "\n").getBytes());
+
+            is = soc.getInputStream();
+            int len = is.read(buf);
+            if (len == -1) {
+                // no data received
+                return null;
+            }
+        } finally {
+            if (is != null) {
+                is.close();
+            }
+            if (os != null) {
+                os.close();
+            }
+            soc.close();
+        }
+
+        // convert the buffer to chars
+        StringBuilder sb = new StringBuilder();
+        for (byte b : buf) {
+            char ch = (char) b;
+            if (ch == '\n' || ch == 0) {
+                // newline denotes end of text (added in the end in the processor below)
+                break;
+            } else {
+                sb.append(ch);
+            }
+        }
+
+        return sb.toString();
+    }
+
+    protected RouteBuilder createRouteBuilder() {
+        return new RouteBuilder() {
+            public void configure() {
+                from("netty4:tcp://localhost:{{port}}?textline=true&sync=true").process(new Processor() {
+                    public void process(Exchange e) {
+                        String in = e.getIn().getBody(String.class);
+                        if ("force-null-out-body".equals(in)) {
+                            // forcing a null out body
+                            e.getOut().setBody(null);
+                        } else if ("force-exception".equals(in)) {
+                            // clear out before throwing exception
+                            e.getOut().setBody(null);
+                            throw new IllegalArgumentException("Forced exception");
+                        } else {
+                            e.getOut().setBody("Hello " + in);
+                        }
+                    }
+                });
+            }
+        };
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/1bb756cd/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyTextlineInOnlyNullDelimiterTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyTextlineInOnlyNullDelimiterTest.java b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyTextlineInOnlyNullDelimiterTest.java
new file mode 100644
index 0000000..16c45d1
--- /dev/null
+++ b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyTextlineInOnlyNullDelimiterTest.java
@@ -0,0 +1,48 @@
+/**
+ * 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 NettyTextlineInOnlyNullDelimiterTest extends BaseNettyTest {
+
+    @Test
+    public void testTextlineInOnlyNull() throws Exception {
+        getMockEndpoint("mock:result").expectedBodiesReceived("Hello World");
+
+        template.sendBody("netty4:tcp://localhost:{{port}}?textline=true&delimiter=NULL&sync=false", "Hello World\u0000");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("netty4:tcp://localhost:{{port}}?textline=true&delimiter=NULL&sync=false")
+                    // body should be a String when using textline codec
+                    .validate(body().isInstanceOf(String.class))
+                    .to("mock:result");
+            }
+        };
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/1bb756cd/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyTextlineInOnlyTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyTextlineInOnlyTest.java b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyTextlineInOnlyTest.java
new file mode 100644
index 0000000..29e37ca
--- /dev/null
+++ b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyTextlineInOnlyTest.java
@@ -0,0 +1,66 @@
+/**
+ * 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 NettyTextlineInOnlyTest extends BaseNettyTest {
+
+    @Test
+    public void testTextlineInOnlyDual() throws Exception {
+        getMockEndpoint("mock:result").expectedBodiesReceived("Hello World", "how are you?");
+
+        template.sendBody("netty4:tcp://localhost:{{port}}?textline=true&sync=false", "Hello World\nhow are you?\n");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Test
+    public void testTextlineInOnlyAutoAppend() throws Exception {
+        getMockEndpoint("mock:result").expectedBodiesReceived("Hello World");
+
+        template.sendBody("netty4:tcp://localhost:{{port}}?textline=true&sync=false", "Hello World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Test
+    public void testTextlineInOnly() throws Exception {
+        getMockEndpoint("mock:result").expectedBodiesReceived("Hello World");
+
+        template.sendBody("netty4:tcp://localhost:{{port}}?textline=true&sync=false", "Hello World\n");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("netty4:tcp://localhost:{{port}}?textline=true&sync=false")
+                    // body should be a String when using textline codec
+                    .validate(body().isInstanceOf(String.class))
+                    .to("mock:result");
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/1bb756cd/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyTextlineInOutNonBlockingTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyTextlineInOutNonBlockingTest.java b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyTextlineInOutNonBlockingTest.java
new file mode 100644
index 0000000..54696e7
--- /dev/null
+++ b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyTextlineInOutNonBlockingTest.java
@@ -0,0 +1,87 @@
+/**
+ * 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 NettyTextlineInOutNonBlockingTest extends BaseNettyTest {
+
+    private static String beforeThreadName;
+    private static String afterThreadName;
+    private static String beforeThreadName2;
+    private static String afterThreadName2;
+
+    @Test
+    public void testNonBlocking() throws Exception {
+        getMockEndpoint("mock:result").expectedBodiesReceived("Bye World");
+
+        String reply = template.requestBody("direct:start", "Hello World", String.class);
+        assertEquals("Bye World", reply);
+
+        assertMockEndpointsSatisfied();
+
+        assertFalse("Should not same threads", beforeThreadName.equalsIgnoreCase(afterThreadName));
+        assertFalse("Should not same threads", beforeThreadName2.equalsIgnoreCase(afterThreadName2));
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start")
+                    .to("log:before")
+                    .process(new Processor() {
+                        public void process(Exchange exchange) throws Exception {
+                            beforeThreadName = Thread.currentThread().getName();
+                        }
+                    })
+                    .to("netty4: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:result");
+
+                from("netty4:tcp://localhost:{{port}}?textline=true&sync=true")
+                    .process(new Processor() {
+                        public void process(Exchange exchange) throws Exception {
+                            beforeThreadName2 = Thread.currentThread().getName();
+                        }
+                    })
+                    // body should be a String when using textline codec
+                    .validate(body().isInstanceOf(String.class))
+                    // async delayed is non blocking
+                    .delay(100).asyncDelayed()
+                    .process(new Processor() {
+                        public void process(Exchange exchange) throws Exception {
+                            afterThreadName2 = Thread.currentThread().getName();
+                        }
+                    })
+                    .transform(body().regexReplaceAll("Hello", "Bye"));
+            }
+        };
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/1bb756cd/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyTextlineInOutSynchronousFalseTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyTextlineInOutSynchronousFalseTest.java b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyTextlineInOutSynchronousFalseTest.java
new file mode 100644
index 0000000..ab31fe9
--- /dev/null
+++ b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyTextlineInOutSynchronousFalseTest.java
@@ -0,0 +1,72 @@
+/**
+ * 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 NettyTextlineInOutSynchronousFalseTest extends BaseNettyTest {
+
+    private static String beforeThreadName;
+    private static String afterThreadName;
+
+    @Test
+    public void testSynchronous() throws Exception {
+        getMockEndpoint("mock:result").expectedBodiesReceived("Bye World");
+
+        String reply = template.requestBody("direct:start", "Hello World", String.class);
+        assertEquals("Bye World", reply);
+
+        assertMockEndpointsSatisfied();
+
+        assertFalse("Should not same threads", beforeThreadName.equalsIgnoreCase(afterThreadName));
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start")
+                    .to("log:before")
+                    .process(new Processor() {
+                        public void process(Exchange exchange) throws Exception {
+                            beforeThreadName = Thread.currentThread().getName();
+                        }
+                    })
+                    .to("netty4:tcp://localhost:{{port}}?textline=true&sync=true&synchronous=false")
+                    .process(new Processor() {
+                        public void process(Exchange exchange) throws Exception {
+                            afterThreadName = Thread.currentThread().getName();
+                        }
+                    })
+                    .to("log:after")
+                    .to("mock:result");
+
+                from("netty4:tcp://localhost:{{port}}?textline=true&sync=true&synchronous=false")
+                    // 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/1bb756cd/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyTextlineInOutSynchronousTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyTextlineInOutSynchronousTest.java b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyTextlineInOutSynchronousTest.java
new file mode 100644
index 0000000..8f97db5
--- /dev/null
+++ b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyTextlineInOutSynchronousTest.java
@@ -0,0 +1,72 @@
+/**
+ * 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 NettyTextlineInOutSynchronousTest extends BaseNettyTest {
+
+    private static String beforeThreadName;
+    private static String afterThreadName;
+
+    @Test
+    public void testSynchronous() throws Exception {
+        getMockEndpoint("mock:result").expectedBodiesReceived("Bye World");
+
+        String reply = template.requestBody("direct:start", "Hello World", String.class);
+        assertEquals("Bye World", reply);
+
+        assertMockEndpointsSatisfied();
+
+        assertTrue("Should use same threads", beforeThreadName.equalsIgnoreCase(afterThreadName));
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start")
+                    .to("log:before")
+                    .process(new Processor() {
+                        public void process(Exchange exchange) throws Exception {
+                            beforeThreadName = Thread.currentThread().getName();
+                        }
+                    })
+                    .to("netty4:tcp://localhost:{{port}}?textline=true&sync=true&synchronous=true")
+                    .process(new Processor() {
+                        public void process(Exchange exchange) throws Exception {
+                            afterThreadName = Thread.currentThread().getName();
+                        }
+                    })
+                    .to("log:after")
+                    .to("mock:result");
+
+                from("netty4:tcp://localhost:{{port}}?textline=true&sync=true&synchronous=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/1bb756cd/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyTextlineInOutTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyTextlineInOutTest.java b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyTextlineInOutTest.java
new file mode 100644
index 0000000..0020a99
--- /dev/null
+++ b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyTextlineInOutTest.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 NettyTextlineInOutTest extends BaseNettyTest {
+
+    @Test
+    public void testTextlineInOut() throws Exception {
+        getMockEndpoint("mock:result").expectedBodiesReceived("Hello World");
+
+        String reply = template.requestBody("netty4:tcp://localhost:{{port}}?textline=true&sync=true", "Hello World", String.class);
+        assertEquals("Bye World", reply);
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("netty4:tcp://localhost:{{port}}?textline=true&sync=true")
+                    // body should be a String when using textline codec
+                    .validate(body().isInstanceOf(String.class))
+                    .to("mock:result")
+                    .transform(body().regexReplaceAll("Hello", "Bye"));
+            }
+        };
+    }
+}
\ No newline at end of file