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/01 19:43:59 UTC

[1/3] git commit: camel-netty-http: Allow to configure chunked max content length on the netty http server.

Updated Branches:
  refs/heads/master 526222842 -> 6bc5a693c


camel-netty-http: Allow to configure chunked max content length on the netty http server.


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

Branch: refs/heads/master
Commit: 87ccdd3f047203fa7cb1531b333e75a8ee77807b
Parents: 5262228
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Aug 1 15:14:04 2013 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Aug 1 15:14:04 2013 +0200

----------------------------------------------------------------------
 .../netty/http/HttpServerSharedPipelineFactory.java         | 2 +-
 .../http/NettySharedHttpServerBootstrapConfiguration.java   | 9 +++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/87ccdd3f/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerSharedPipelineFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerSharedPipelineFactory.java b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerSharedPipelineFactory.java
index daa896a..ea24704 100644
--- a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerSharedPipelineFactory.java
+++ b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerSharedPipelineFactory.java
@@ -82,7 +82,7 @@ public class HttpServerSharedPipelineFactory extends HttpServerPipelineFactory {
 
         pipeline.addLast("decoder", new HttpRequestDecoder());
         if (configuration.isChunked()) {
-            pipeline.addLast("aggregator", new HttpChunkAggregator(1048576));
+            pipeline.addLast("aggregator", new HttpChunkAggregator(configuration.getChunkedMaxContentLength()));
         }
         pipeline.addLast("encoder", new HttpResponseEncoder());
         if (configuration.isCompression()) {

http://git-wip-us.apache.org/repos/asf/camel/blob/87ccdd3f/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettySharedHttpServerBootstrapConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettySharedHttpServerBootstrapConfiguration.java b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettySharedHttpServerBootstrapConfiguration.java
index 0e99996..cf785c4 100644
--- a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettySharedHttpServerBootstrapConfiguration.java
+++ b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettySharedHttpServerBootstrapConfiguration.java
@@ -20,6 +20,7 @@ import org.apache.camel.component.netty.NettyServerBootstrapConfiguration;
 
 public class NettySharedHttpServerBootstrapConfiguration extends NettyServerBootstrapConfiguration {
 
+    private int chunkedMaxContentLength = 1024 * 1024;
     private boolean chunked = true;
     private boolean compression;
 
@@ -31,6 +32,14 @@ public class NettySharedHttpServerBootstrapConfiguration extends NettyServerBoot
         this.chunked = chunked;
     }
 
+    public int getChunkedMaxContentLength() {
+        return chunkedMaxContentLength;
+    }
+
+    public void setChunkedMaxContentLength(int chunkedMaxContentLength) {
+        this.chunkedMaxContentLength = chunkedMaxContentLength;
+    }
+
     public boolean isCompression() {
         return compression;
     }


[2/3] git commit: Added camel-netty-http SSL unit test using XML DSL

Posted by da...@apache.org.
Added camel-netty-http SSL unit test using XML DSL


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

Branch: refs/heads/master
Commit: 337c27181a80097616e0b4bccd96b2f122137988
Parents: 87ccdd3
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Aug 1 19:01:41 2013 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Aug 1 19:01:41 2013 +0200

----------------------------------------------------------------------
 .../netty/http/SpringNettyHttpSSLTest.java      | 79 ++++++++++++++++++++
 .../netty/http/SpringNettyHttpSSLTest.xml       | 62 +++++++++++++++
 2 files changed, 141 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/337c2718/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/SpringNettyHttpSSLTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/SpringNettyHttpSSLTest.java b/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/SpringNettyHttpSSLTest.java
new file mode 100644
index 0000000..39ff57a
--- /dev/null
+++ b/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/SpringNettyHttpSSLTest.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.netty.http;
+
+import java.net.URL;
+import javax.annotation.Resource;
+
+import junit.framework.TestCase;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.Produce;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(locations = {"/org/apache/camel/component/netty/http/SpringNettyHttpSSLTest.xml"})
+public class SpringNettyHttpSSLTest extends TestCase {
+
+    @Produce
+    private ProducerTemplate template;
+
+    @EndpointInject(uri = "mock:input")
+    private MockEndpoint mockEndpoint;
+
+    private Integer port;
+
+    public Integer getPort() {
+        return port;
+    }
+
+    @Resource(name = "dynaPort")
+    public void setPort(Integer port) {
+        this.port = port;
+    }
+
+    @BeforeClass
+    public static void setUpJaas() throws Exception {
+        // ensure jsse clients can validate the self signed dummy localhost cert,
+        // use the server keystore as the trust store for these tests
+        URL trustStoreUrl = NettyHttpSSLTest.class.getClassLoader().getResource("jsse/localhost.ks");
+        System.setProperty("javax.net.ssl.trustStore", trustStoreUrl.toURI().getPath());
+    }
+
+    @AfterClass
+    public static void tearDownJaas() throws Exception {
+        System.clearProperty("java.security.auth.login.config");
+    }
+
+    @Test
+    public void testSSLInOutWithNettyConsumer() throws Exception {
+        mockEndpoint.expectedBodiesReceived("Hello World");
+
+        String out = template.requestBody("https://localhost:" + getPort(), "Hello World", String.class);
+        assertEquals("Bye World", out);
+
+        mockEndpoint.assertIsSatisfied();
+    }
+
+}
+

http://git-wip-us.apache.org/repos/asf/camel/blob/337c2718/components/camel-netty-http/src/test/resources/org/apache/camel/component/netty/http/SpringNettyHttpSSLTest.xml
----------------------------------------------------------------------
diff --git a/components/camel-netty-http/src/test/resources/org/apache/camel/component/netty/http/SpringNettyHttpSSLTest.xml b/components/camel-netty-http/src/test/resources/org/apache/camel/component/netty/http/SpringNettyHttpSSLTest.xml
new file mode 100644
index 0000000..152b397
--- /dev/null
+++ b/components/camel-netty-http/src/test/resources/org/apache/camel/component/netty/http/SpringNettyHttpSSLTest.xml
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:camel="http://camel.apache.org/schema/spring"
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+    ">
+
+  <bean id="dynaPort" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
+    <property name="targetClass">
+      <value>org.apache.camel.test.AvailablePortFinder</value>
+    </property>
+    <property name="targetMethod">
+      <value>getNextAvailable</value>
+    </property>
+    <property name="arguments">
+      <list>
+        <value>9000</value>
+      </list>
+    </property>
+  </bean>
+
+  <camel:sslContextParameters id="mySsl">
+    <camel:keyManagers keyPassword="changeit">
+      <camel:keyStore resource="jsse/localhost.ks" password="changeit"/>
+    </camel:keyManagers>
+    <camel:trustManagers>
+      <camel:keyStore resource="jsse/localhost.ks" password="changeit"/>
+    </camel:trustManagers>
+  </camel:sslContextParameters>
+
+  <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
+    <endpoint id="input1" uri="netty-http:https://0.0.0.0:#{dynaPort}?ssl=true&amp;sslContextParameters=#mySsl"/>
+
+    <route>
+      <from ref="input1"/>
+      <to uri="mock:input"/>
+      <transform>
+        <simple>Bye World</simple>
+      </transform>
+    </route>
+
+  </camelContext>
+
+</beans>


[3/3] git commit: camel-netty-http: Fixed problem if message body is null. And an unit test.

Posted by da...@apache.org.
camel-netty-http: Fixed problem if message body is null. And an unit test.


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

Branch: refs/heads/master
Commit: 6bc5a693cb7c117a01d12e05e81e4b7d720e536e
Parents: 337c271
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Aug 1 19:43:47 2013 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Aug 1 19:43:47 2013 +0200

----------------------------------------------------------------------
 .../netty/http/DefaultNettyHttpBinding.java     | 107 ++++++++++---------
 .../http/handlers/HttpClientChannelHandler.java |  12 ++-
 .../http/handlers/HttpServerChannelHandler.java |   4 +
 .../http/NettyHttpRedirectNoLocationTest.java   |   8 +-
 4 files changed, 75 insertions(+), 56 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/6bc5a693/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/DefaultNettyHttpBinding.java
----------------------------------------------------------------------
diff --git a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/DefaultNettyHttpBinding.java b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/DefaultNettyHttpBinding.java
index e464f0b..f739f81 100644
--- a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/DefaultNettyHttpBinding.java
+++ b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/DefaultNettyHttpBinding.java
@@ -290,64 +290,67 @@ public class DefaultNettyHttpBinding implements NettyHttpBinding {
 
         Object body = message.getBody();
         Exception cause = message.getExchange().getException();
-        if (body != null || cause != null) {
-            // support bodies as native Netty
-            ChannelBuffer buffer;
-
-            // if there was an exception then use that as body
-            if (cause != null) {
-                if (configuration.isTransferException()) {
-                    // we failed due an exception, and transfer it as java serialized object
-                    ByteArrayOutputStream bos = new ByteArrayOutputStream();
-                    ObjectOutputStream oos = new ObjectOutputStream(bos);
-                    oos.writeObject(cause);
-                    oos.flush();
-                    IOHelper.close(oos, bos);
-
-                    // the body should be the serialized java object of the exception
-                    body = ChannelBuffers.copiedBuffer(bos.toByteArray());
-                    // force content type to be serialized java object
-                    message.setHeader(Exchange.CONTENT_TYPE, NettyHttpConstants.CONTENT_TYPE_JAVA_SERIALIZED_OBJECT);
-                } else {
-                    // we failed due an exception so print it as plain text
-                    StringWriter sw = new StringWriter();
-                    PrintWriter pw = new PrintWriter(sw);
-                    cause.printStackTrace(pw);
-
-                    // the body should then be the stacktrace
-                    body = ChannelBuffers.copiedBuffer(sw.toString().getBytes());
-                    // force content type to be text/plain as that is what the stacktrace is
-                    message.setHeader(Exchange.CONTENT_TYPE, "text/plain");
-                }
-
-                // and mark the exception as failure handled, as we handled it by returning it as the response
-                ExchangeHelper.setFailureHandled(message.getExchange());
+        // support bodies as native Netty
+        ChannelBuffer buffer;
+
+        // if there was an exception then use that as body
+        if (cause != null) {
+            if (configuration.isTransferException()) {
+                // we failed due an exception, and transfer it as java serialized object
+                ByteArrayOutputStream bos = new ByteArrayOutputStream();
+                ObjectOutputStream oos = new ObjectOutputStream(bos);
+                oos.writeObject(cause);
+                oos.flush();
+                IOHelper.close(oos, bos);
+
+                // the body should be the serialized java object of the exception
+                body = ChannelBuffers.copiedBuffer(bos.toByteArray());
+                // force content type to be serialized java object
+                message.setHeader(Exchange.CONTENT_TYPE, NettyHttpConstants.CONTENT_TYPE_JAVA_SERIALIZED_OBJECT);
+            } else {
+                // we failed due an exception so print it as plain text
+                StringWriter sw = new StringWriter();
+                PrintWriter pw = new PrintWriter(sw);
+                cause.printStackTrace(pw);
+
+                // the body should then be the stacktrace
+                body = ChannelBuffers.copiedBuffer(sw.toString().getBytes());
+                // force content type to be text/plain as that is what the stacktrace is
+                message.setHeader(Exchange.CONTENT_TYPE, "text/plain");
             }
 
-            if (body instanceof ChannelBuffer) {
-                buffer = (ChannelBuffer) body;
-            } else {
-                // try to convert to buffer first
-                buffer = message.getBody(ChannelBuffer.class);
-                if (buffer == null) {
-                    // fallback to byte array as last resort
-                    byte[] data = message.getBody(byte[].class);
-                    if (data != null) {
-                        buffer = ChannelBuffers.copiedBuffer(data);
+            // and mark the exception as failure handled, as we handled it by returning it as the response
+            ExchangeHelper.setFailureHandled(message.getExchange());
+        }
+
+        if (body instanceof ChannelBuffer) {
+            buffer = (ChannelBuffer) body;
+        } else {
+            // try to convert to buffer first
+            buffer = message.getBody(ChannelBuffer.class);
+            if (buffer == null) {
+                // fallback to byte array as last resort
+                byte[] data = message.getBody(byte[].class);
+                if (data != null) {
+                    buffer = ChannelBuffers.copiedBuffer(data);
+                } else {
+                    // and if byte array fails then try String
+                    String str;
+                    if (body != null) {
+                        str = message.getMandatoryBody(String.class);
                     } else {
-                        // and if byte array fails then try String
-                        String str = message.getMandatoryBody(String.class);
-                        buffer = ChannelBuffers.copiedBuffer(str.getBytes());
+                        str = "";
                     }
+                    buffer = ChannelBuffers.copiedBuffer(str.getBytes());
                 }
             }
-            if (buffer != null) {
-                response.setContent(buffer);
-                int len = buffer.readableBytes();
-                // set content-length
-                response.setHeader(HttpHeaders.Names.CONTENT_LENGTH, len);
-                LOG.trace("Content-Length: {}", len);
-            }
+        }
+        if (buffer != null) {
+            response.setContent(buffer);
+            int len = buffer.readableBytes();
+            // set content-length
+            response.setHeader(HttpHeaders.Names.CONTENT_LENGTH, len);
+            LOG.trace("Content-Length: {}", len);
         }
 
         // set the content type in the response.

http://git-wip-us.apache.org/repos/asf/camel/blob/6bc5a693/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/handlers/HttpClientChannelHandler.java
----------------------------------------------------------------------
diff --git a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/handlers/HttpClientChannelHandler.java b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/handlers/HttpClientChannelHandler.java
index e2cccf1..cdee347 100644
--- a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/handlers/HttpClientChannelHandler.java
+++ b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/handlers/HttpClientChannelHandler.java
@@ -46,9 +46,17 @@ public class HttpClientChannelHandler extends ClientChannelHandler {
     @Override
     public void messageReceived(ChannelHandlerContext ctx, MessageEvent messageEvent) throws Exception {
         // store response, as this channel handler is created per pipeline
-        response = (HttpResponse) messageEvent.getMessage();
+        Object msg = messageEvent.getMessage();
+        if (msg instanceof HttpResponse) {
+            response = (HttpResponse) msg;
+            super.messageReceived(ctx, messageEvent);
+        } else {
+            // ignore not supported message
+            if (msg != null) {
+                LOG.trace("Ignoring non HttpResponse message of type {} -> {}", msg.getClass(), msg);
+            }
+        }
 
-        super.messageReceived(ctx, messageEvent);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/camel/blob/6bc5a693/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/handlers/HttpServerChannelHandler.java
----------------------------------------------------------------------
diff --git a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/handlers/HttpServerChannelHandler.java b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/handlers/HttpServerChannelHandler.java
index 12c1083..0ae157b 100644
--- a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/handlers/HttpServerChannelHandler.java
+++ b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/handlers/HttpServerChannelHandler.java
@@ -92,6 +92,7 @@ public class HttpServerChannelHandler extends ServerChannelHandler {
             // are we suspended?
             LOG.debug("Consumer suspended, cannot service request {}", request);
             HttpResponse response = new DefaultHttpResponse(HTTP_1_1, SERVICE_UNAVAILABLE);
+            response.setChunked(false);
             response.setHeader(Exchange.CONTENT_TYPE, "text/plain");
             response.setHeader(Exchange.CONTENT_LENGTH, 0);
             response.setContent(ChannelBuffers.copiedBuffer(new byte[]{}));
@@ -101,6 +102,7 @@ public class HttpServerChannelHandler extends ServerChannelHandler {
         if (consumer.getEndpoint().getHttpMethodRestrict() != null
                 && !consumer.getEndpoint().getHttpMethodRestrict().contains(request.getMethod().getName())) {
             HttpResponse response = new DefaultHttpResponse(HTTP_1_1, METHOD_NOT_ALLOWED);
+            response.setChunked(false);
             response.setHeader(Exchange.CONTENT_TYPE, "text/plain");
             response.setHeader(Exchange.CONTENT_LENGTH, 0);
             response.setContent(ChannelBuffers.copiedBuffer(new byte[]{}));
@@ -109,6 +111,7 @@ public class HttpServerChannelHandler extends ServerChannelHandler {
         }
         if ("TRACE".equals(request.getMethod().getName()) && !consumer.getEndpoint().isTraceEnabled()) {
             HttpResponse response = new DefaultHttpResponse(HTTP_1_1, METHOD_NOT_ALLOWED);
+            response.setChunked(false);
             response.setHeader(Exchange.CONTENT_TYPE, "text/plain");
             response.setHeader(Exchange.CONTENT_LENGTH, 0);
             response.setContent(ChannelBuffers.copiedBuffer(new byte[]{}));
@@ -118,6 +121,7 @@ public class HttpServerChannelHandler extends ServerChannelHandler {
         // must include HOST header as required by HTTP 1.1
         if (!request.getHeaderNames().contains(HttpHeaders.Names.HOST)) {
             HttpResponse response = new DefaultHttpResponse(HTTP_1_1, BAD_REQUEST);
+            response.setChunked(false);
             response.setHeader(Exchange.CONTENT_TYPE, "text/plain");
             response.setHeader(Exchange.CONTENT_LENGTH, 0);
             response.setContent(ChannelBuffers.copiedBuffer(new byte[]{}));

http://git-wip-us.apache.org/repos/asf/camel/blob/6bc5a693/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpRedirectNoLocationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpRedirectNoLocationTest.java b/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpRedirectNoLocationTest.java
index 0005673..0762bba 100644
--- a/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpRedirectNoLocationTest.java
+++ b/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpRedirectNoLocationTest.java
@@ -24,10 +24,12 @@ import org.junit.Test;
 
 public class NettyHttpRedirectNoLocationTest extends BaseNettyTest {
 
+    private int nextPort;
+
     @Test
     public void testHttpRedirectNoLocation() throws Exception {
         try {
-            template.requestBody("netty-http:http://localhost:{{port}}/test", "Hello World", String.class);
+            template.requestBody("netty-http:http://localhost:" + nextPort + "/test", "Hello World", String.class);
             fail("Should have thrown an exception");
         } catch (RuntimeCamelException e) {
             NettyHttpOperationFailedException cause = assertIsInstanceOf(NettyHttpOperationFailedException.class, e.getCause());
@@ -43,7 +45,9 @@ public class NettyHttpRedirectNoLocationTest extends BaseNettyTest {
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                from("netty-http:http://localhost:{{port}}/test")
+                nextPort = getNextPort();
+
+                from("netty-http:http://localhost:" + nextPort + "/test")
                         .process(new Processor() {
                             public void process(Exchange exchange) throws Exception {
                                 exchange.getOut().setHeader(Exchange.HTTP_RESPONSE_CODE, 302);