Author: ningjiang
Date: Mon Dec 12 12:56:31 2011
New Revision: 1213219

URL: http://svn.apache.org/viewvc?rev=1213219&view=rev
Log:
CAMEL-4768 Fix the issue that camel-http4 component send the endpoint parameters

Modified:
    
camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpComponent.java
    
camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpEndpoint.java
    
camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/http/Http4RouteTest.java

Modified: 
camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpComponent.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpComponent.java?rev=1213219&r1=1213218&r2=1213219&view=diff
==============================================================================
--- 
camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpComponent.java
 (original)
+++ 
camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpComponent.java
 Mon Dec 12 12:56:31 2011
@@ -17,6 +17,7 @@
 package org.apache.camel.component.http4;
 
 import java.net.URI;
+import java.net.URISyntaxException;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -193,7 +194,10 @@ public class HttpComponent extends Heade
         // create the configurer to use for this endpoint
         HttpClientConfigurer configurer = 
createHttpClientConfigurer(parameters, secure);
         URI endpointUri = URISupport.createRemainingURI(new URI(addressUri), 
CastUtils.cast(httpClientParameters));
-        // restructure uri to be based on the parameters left as we dont want 
to include the Camel internal options
+        // create the endpoint and set the http uri to be null
+        HttpEndpoint endpoint = new HttpEndpoint(endpointUri.toString(), this, 
clientParams, clientConnectionManager, configurer);
+        // configure the endpoint
+        setProperties(endpoint, parameters);
         // The httpUri should be start with http or https
         String httpUriAddress = addressUri;
         if (addressUri.startsWith("http4")) {
@@ -202,6 +206,8 @@ public class HttpComponent extends Heade
         if (addressUri.startsWith("https4")) {
             httpUriAddress = "https" + addressUri.substring(6);
         }
+        // restructure uri to be based on the parameters left as we dont want 
to include the Camel internal options
+        // build up the http uri
         URI httpUri = URISupport.createRemainingURI(new URI(httpUriAddress), 
CastUtils.cast(parameters));
 
         // validate http uri that end-user did not duplicate the http part 
that can be a common error
@@ -213,14 +219,7 @@ public class HttpComponent extends Heade
                         "The uri part is not configured correctly. You have 
duplicated the http(s) protocol.");
             }
         }
-
-        // register port on schema registry
-        int port = getPort(httpUri);
-        registerPort(secure, x509HostnameVerifier, port, sslContextParameters);
-
-        // create the endpoint
-        HttpEndpoint endpoint = new HttpEndpoint(endpointUri.toString(), this, 
httpUri, clientParams, clientConnectionManager, configurer);
-        setProperties(endpoint, parameters);
+        endpoint.setHttpUri(httpUri);
         setEndpointHeaderFilterStrategy(endpoint);
         endpoint.setBinding(getHttpBinding());
         if (httpBinding != null) {
@@ -229,10 +228,13 @@ public class HttpComponent extends Heade
         if (httpClientConfigurer != null) {
             endpoint.setHttpClientConfigurer(httpClientConfigurer);
         }
+        // register port on schema registry
+        int port = getPort(httpUri);
+        registerPort(secure, x509HostnameVerifier, port, sslContextParameters);
 
         return endpoint;
     }
-
+   
     private static int getPort(URI uri) {
         int port = uri.getPort();
         if (port < 0) {

Modified: 
camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpEndpoint.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpEndpoint.java?rev=1213219&r1=1213218&r2=1213219&view=diff
==============================================================================
--- 
camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpEndpoint.java
 (original)
+++ 
camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpEndpoint.java
 Mon Dec 12 12:56:31 2011
@@ -69,6 +69,11 @@ public class HttpEndpoint extends Defaul
     public HttpEndpoint(String endPointURI, HttpComponent component, URI 
httpURI, ClientConnectionManager clientConnectionManager) throws 
URISyntaxException {
         this(endPointURI, component, httpURI, new BasicHttpParams(), 
clientConnectionManager, null);
     }
+    
+    public HttpEndpoint(String endPointURI, HttpComponent component, 
HttpParams clientParams,
+                        ClientConnectionManager clientConnectionManager, 
HttpClientConfigurer clientConfigurer) throws URISyntaxException {
+        this(endPointURI, component, null, clientParams, 
clientConnectionManager, clientConfigurer);
+    }
 
     public HttpEndpoint(String endPointURI, HttpComponent component, URI 
httpURI, HttpParams clientParams,
                         ClientConnectionManager clientConnectionManager, 
HttpClientConfigurer clientConfigurer) throws URISyntaxException {

Modified: 
camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/http/Http4RouteTest.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/http/Http4RouteTest.java?rev=1213219&r1=1213218&r2=1213219&view=diff
==============================================================================
--- 
camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/http/Http4RouteTest.java
 (original)
+++ 
camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/http/Http4RouteTest.java
 Mon Dec 12 12:56:31 2011
@@ -32,7 +32,8 @@ public class Http4RouteTest extends Came
     @Test
     public void sendHttpGetRequestTest() {
         String response = template.requestBody("http4://localhost:" + port 
-                         + 
"/test?aa=bb&httpClient.soTimeout=10000&httpClient.connectionTimeout=10000" , 
null, String.class);
+                         + 
"/test?aa=bb&httpClient.soTimeout=10000&httpClient.connectionTimeout=10000"
+                         + 
"&bridgeEndpoint=true&throwExceptionOnFailure=false" , null, String.class);
         assertEquals("aa=bb", response);
     }
     


Reply via email to