Repository: camel
Updated Branches:
  refs/heads/master 07043c1fd -> 74de98f56


Added an unit test for verify the http4 component port issue


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

Branch: refs/heads/master
Commit: 74de98f568cd0dce52f50ef82f1b2a3945975295
Parents: 07043c1
Author: Willem Jiang <willem.ji...@gmail.com>
Authored: Thu Jul 3 15:08:11 2014 +0800
Committer: Willem Jiang <willem.ji...@gmail.com>
Committed: Thu Jul 3 15:08:31 2014 +0800

----------------------------------------------------------------------
 .../apache/camel/itest/http/Http4RouteTest.java | 37 +++++++++++++++++---
 1 file changed, 32 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/74de98f5/tests/camel-itest/src/test/java/org/apache/camel/itest/http/Http4RouteTest.java
----------------------------------------------------------------------
diff --git 
a/tests/camel-itest/src/test/java/org/apache/camel/itest/http/Http4RouteTest.java
 
b/tests/camel-itest/src/test/java/org/apache/camel/itest/http/Http4RouteTest.java
index e6d35a4..713e57b 100644
--- 
a/tests/camel-itest/src/test/java/org/apache/camel/itest/http/Http4RouteTest.java
+++ 
b/tests/camel-itest/src/test/java/org/apache/camel/itest/http/Http4RouteTest.java
@@ -25,24 +25,33 @@ import org.apache.camel.test.junit4.CamelTestSupport;
 import org.junit.Test;
 
 public class Http4RouteTest extends CamelTestSupport {
-    private int port;
+    private int port1;
+    private int port2;
     
     @Test
     public void sendHttpGetRequestTest() {
-        String response = template.requestBody("http4://localhost:" + port 
+        String response = template.requestBody("http4://localhost:" + port1 
                          + 
"/test?aa=bb&httpClient.socketTimeout=10000&httpClient.connectTimeout=10000"
                          + 
"&bridgeEndpoint=true&throwExceptionOnFailure=false" , null, String.class);
-        assertEquals("aa=bb", response);
+        assertEquals("Get a wrong response", "aa=bb", response);
+        
+        response = template.requestBodyAndHeader("direct:start1", null, 
Exchange.HTTP_QUERY, "aa=bb", String.class);
+        
+        assertEquals("Get a wrong response", "aa=bb", response);
+        
+        response = template.requestBodyAndHeader("direct:start2", null, 
Exchange.HTTP_QUERY, "aa=bb", String.class);
+        assertEquals("Get a wrong response", "aa=bb&2", response);
     }
     
     @Override
     protected RouteBuilder createRouteBuilder() throws Exception {
-        port = AvailablePortFinder.getNextAvailable(8000);
+        port1 = AvailablePortFinder.getNextAvailable(8000);
+        port2 = AvailablePortFinder.getNextAvailable(9000);
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
                 
-                from("jetty:http://localhost:"; + port + "/test").process(new 
Processor() {
+                from("jetty:http://localhost:"; + port1 + "/test").process(new 
Processor() {
 
                     @Override
                     public void process(Exchange exchange) throws Exception {
@@ -54,6 +63,24 @@ public class Http4RouteTest extends CamelTestSupport {
                     }
                     
                 });
+                
+                from("jetty:http://localhost:"; + port2 + "/test").process(new 
Processor() {
+
+                    @Override
+                    public void process(Exchange exchange) throws Exception {
+                        HttpMessage message = (HttpMessage)exchange.getIn();
+                        assertNotNull(message.getRequest());
+                        assertEquals("GET", message.getRequest().getMethod());
+                        
exchange.getOut().setBody(message.getRequest().getQueryString() + "&2");
+                    }
+                    
+                });
+                
+                from("direct:start1").to("http4://localhost:" + port1 + 
"/test");
+                
+                from("direct:start2").to("http4://localhost:" + port2 + 
"/test");
+                
+                
                    
             }
         };

Reply via email to