camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r1103984 - in /camel/trunk/components/camel-http4/src: main/java/org/apache/camel/component/http4/ test/java/org/apache/camel/component/http4/
Date Tue, 17 May 2011 02:12:08 GMT
Author: ningjiang
Date: Tue May 17 02:12:08 2011
New Revision: 1103984

URL: http://svn.apache.org/viewvc?rev=1103984&view=rev
Log:
CAMEL-3780 camel-http4 should use same option names as camel-http

Modified:
    camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpComponent.java
    camel/trunk/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpAuthenticationTest.java
    camel/trunk/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpProxyServerTest.java
    camel/trunk/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpsAuthenticationTest.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=1103984&r1=1103983&r2=1103984&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
Tue May 17 02:12:08 2011
@@ -110,37 +110,34 @@ public class HttpComponent extends Heade
     }
 
     private HttpClientConfigurer configureBasicAuthentication(Map<String, Object> parameters,
HttpClientConfigurer configurer) {
-        String username = getAndRemoveParameter(parameters, "username", String.class);
-        String password = getAndRemoveParameter(parameters, "password", String.class);
+        String authUsername = getAndRemoveParameter(parameters, "authUsername", String.class);
+        String authPassword = getAndRemoveParameter(parameters, "authPassword", String.class);
 
-        if (username != null && password != null) {
-            String domain = getAndRemoveParameter(parameters, "domain", String.class);
-            String host = getAndRemoveParameter(parameters, "host", String.class);
+        if (authUsername != null && authPassword != null) {
+            String authDomain = getAndRemoveParameter(parameters, "authDomain", String.class);
+            String authHost = getAndRemoveParameter(parameters, "authHost", String.class);
             
-            return CompositeHttpConfigurer.combineConfigurers(
-                    configurer,
-                    new BasicAuthenticationHttpClientConfigurer(username, password, domain,
host));
+            return CompositeHttpConfigurer.combineConfigurers(configurer, new BasicAuthenticationHttpClientConfigurer(authUsername,
authPassword, authDomain, authHost));
         }
         
         return configurer;
     }
 
     private HttpClientConfigurer configureHttpProxy(Map<String, Object> parameters,
HttpClientConfigurer configurer) {
-        String proxyHost = getAndRemoveParameter(parameters, "proxyHost", String.class);
-        Integer proxyPort = getAndRemoveParameter(parameters, "proxyPort", Integer.class);
+        String proxyAuthHost = getAndRemoveParameter(parameters, "proxyAuthHost", String.class);
+        Integer proxyAuthPort = getAndRemoveParameter(parameters, "proxyAuthPort", Integer.class);
         
-        if (proxyHost != null && proxyPort != null) {
-            String proxyUsername = getAndRemoveParameter(parameters, "proxyUsername", String.class);
-            String proxyPassword = getAndRemoveParameter(parameters, "proxyPassword", String.class);
-            String proxyDomain = getAndRemoveParameter(parameters, "proxyDomain", String.class);
-            String proxyNtHost = getAndRemoveParameter(parameters, "proxyNtHost", String.class);
+        if (proxyAuthHost != null && proxyAuthPort != null) {
+            String proxyAuthUsername = getAndRemoveParameter(parameters, "proxyAuthUsername",
String.class);
+            String proxyAuthPassword = getAndRemoveParameter(parameters, "proxyAuthPassword",
String.class);
+            String proxyAuthDomain = getAndRemoveParameter(parameters, "proxyAuthDomain",
String.class);
+            String proxyAuthNtHost = getAndRemoveParameter(parameters, "proxyAuthNtHost",
String.class);
             
-            if (proxyUsername != null && proxyPassword != null) {
+            if (proxyAuthUsername != null && proxyAuthPassword != null) {
                 return CompositeHttpConfigurer.combineConfigurers(
-                        configurer, new ProxyHttpClientConfigurer(proxyHost, proxyPort, proxyUsername,
proxyPassword, proxyDomain, proxyNtHost));
+                    configurer, new ProxyHttpClientConfigurer(proxyAuthHost, proxyAuthPort,
proxyAuthUsername, proxyAuthPassword, proxyAuthDomain, proxyAuthNtHost));
             } else {
-                return CompositeHttpConfigurer.combineConfigurers(
-                        configurer, new ProxyHttpClientConfigurer(proxyHost, proxyPort));
+                return CompositeHttpConfigurer.combineConfigurers(configurer, new ProxyHttpClientConfigurer(proxyAuthHost,
proxyAuthPort));
             }
         }
         

Modified: camel/trunk/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpAuthenticationTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpAuthenticationTest.java?rev=1103984&r1=1103983&r2=1103984&view=diff
==============================================================================
--- camel/trunk/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpAuthenticationTest.java
(original)
+++ camel/trunk/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpAuthenticationTest.java
Tue May 17 02:12:08 2011
@@ -41,7 +41,7 @@ public class HttpAuthenticationTest exte
 
     @Test
     public void basicAuthenticationShouldSuccess() throws Exception {
-        Exchange exchange = template.request("http4://" + getHostName() + ":" + getPort()
+ "/search?username=" + user + "&password=" + password, new Processor() {
+        Exchange exchange = template.request("http4://" + getHostName() + ":" + getPort()
+ "/search?authUsername=" + user + "&authPassword=" + password, new Processor() {
             public void process(Exchange exchange) throws Exception {
             }
         });
@@ -61,7 +61,7 @@ public class HttpAuthenticationTest exte
 
     @Test
     public void basicAuthenticationShouldFailWithWrongCreds() throws Exception {
-        Exchange exchange = template.request("http4://" + getHostName() + ":" + getPort()
+ "/search?throwExceptionOnFailure=false&username=camel&password=wrong", new Processor()
{
+        Exchange exchange = template.request("http4://" + getHostName() + ":" + getPort()
+ "/search?throwExceptionOnFailure=false&authUsername=camel&authPassword=wrong", new
Processor() {
             public void process(Exchange exchange) throws Exception {
             }
         });

Modified: camel/trunk/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpProxyServerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpProxyServerTest.java?rev=1103984&r1=1103983&r2=1103984&view=diff
==============================================================================
--- camel/trunk/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpProxyServerTest.java
(original)
+++ camel/trunk/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpProxyServerTest.java
Tue May 17 02:12:08 2011
@@ -85,8 +85,8 @@ public class HttpProxyServerTest extends
     
     @Test
     public void testDifferentHttpProxyConfigured() throws Exception {
-        HttpEndpoint http1 = context.getEndpoint("http4://www.google.com?proxyHost=myproxy&proxyPort=1234",
HttpEndpoint.class);
-        HttpEndpoint http2 = context.getEndpoint("http4://www.google.com?test=parameter&proxyHost=myotherproxy&proxyPort=2345",
HttpEndpoint.class);
+        HttpEndpoint http1 = context.getEndpoint("http4://www.google.com?proxyAuthHost=myproxy&proxyAuthPort=1234",
HttpEndpoint.class);
+        HttpEndpoint http2 = context.getEndpoint("http4://www.google.com?test=parameter&proxyAuthHost=myotherproxy&proxyAuthPort=2345",
HttpEndpoint.class);
 
         
         HttpClient client1 = http1.createHttpClient();
@@ -100,8 +100,8 @@ public class HttpProxyServerTest extends
         assertEquals(2345, proxy2.getPort());
         
       //As the endpointUri is recreated, so the parameter could be in different place, so
we use the URISupport.normalizeUri
-        assertEquals("Get a wrong endpoint uri of http1", "http4://www.google.com?proxyHost=myproxy&proxyPort=1234",
URISupport.normalizeUri(http1.getEndpointUri()));
-        assertEquals("Get a wrong endpoint uri of http2", "http4://www.google.com?proxyHost=myotherproxy&proxyPort=2345&test=parameter",
URISupport.normalizeUri(http2.getEndpointUri()));
+        assertEquals("Get a wrong endpoint uri of http1", "http4://www.google.com?proxyAuthHost=myproxy&proxyAuthPort=1234",
URISupport.normalizeUri(http1.getEndpointUri()));
+        assertEquals("Get a wrong endpoint uri of http2", "http4://www.google.com?proxyAuthHost=myotherproxy&proxyAuthPort=2345&test=parameter",
URISupport.normalizeUri(http2.getEndpointUri()));
 
         assertEquals("Should get the same EndpointKey", http1.getEndpointKey(), http2.getEndpointKey());
     }
@@ -113,7 +113,7 @@ public class HttpProxyServerTest extends
         expectedHeaders.put("Proxy-Connection", "Keep-Alive");
         proxy.register("*", new HeaderValidationHandler("GET", null, null, getExpectedContent(),
expectedHeaders));
 
-        Exchange exchange = template.request("http4://" + getHostName() + ":" + getPort()
+ "?proxyHost=" + getProxyHost() + "&proxyPort=" + getProxyPort(), new Processor() {
+        Exchange exchange = template.request("http4://" + getHostName() + ":" + getPort()
+ "?proxyAuthHost=" + getProxyHost() + "&proxyAuthPort=" + getProxyPort(), new Processor()
{
             public void process(Exchange exchange) throws Exception {
             }
         });
@@ -157,8 +157,8 @@ public class HttpProxyServerTest extends
         try {
             proxy.register("*", new HeaderValidationHandler("GET", null, null, getExpectedContent(),
expectedHeaders));
 
-            Exchange exchange = template.request("http4://" + getHostName() + ":" + getPort()
+ "?proxyHost="
-                    + getProxyHost() + "&proxyPort=" + getProxyPort(), new Processor()
{
+            Exchange exchange = template.request("http4://" + getHostName() + ":" + getPort()
+ "?proxyAuthHost="
+                    + getProxyHost() + "&proxyAuthPort=" + getProxyPort(), new Processor()
{
                         public void process(Exchange exchange) throws Exception {
                         }
                     });
@@ -174,8 +174,8 @@ public class HttpProxyServerTest extends
     public void httpGetWithProxyAndWithUser() throws Exception {
         proxy.register("*", new ProxyAuthenticationValidationHandler("GET", null, null, getExpectedContent(),
user, password));
 
-        Exchange exchange = template.request("http4://" + getHostName() + ":" + getPort()
+ "?proxyHost="
-                + getProxyHost() + "&proxyPort=" + getProxyPort() + "&proxyUsername=camel&proxyPassword=password",
new Processor() {
+        Exchange exchange = template.request("http4://" + getHostName() + ":" + getPort()
+ "?proxyAuthHost="
+                + getProxyHost() + "&proxyAuthPort=" + getProxyPort() + "&proxyAuthUsername=camel&proxyAuthPassword=password",
new Processor() {
                     public void process(Exchange exchange) throws Exception {
                     }
                 });

Modified: camel/trunk/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpsAuthenticationTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpsAuthenticationTest.java?rev=1103984&r1=1103983&r2=1103984&view=diff
==============================================================================
--- camel/trunk/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpsAuthenticationTest.java
(original)
+++ camel/trunk/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpsAuthenticationTest.java
Tue May 17 02:12:08 2011
@@ -48,7 +48,7 @@ public class HttpsAuthenticationTest ext
     public void httpsGetWithAuthentication() throws Exception {
         localServer.register("/", new AuthenticationValidationHandler("GET", null, null,
getExpectedContent(), user, password));
 
-        Exchange exchange = template.request("https4://127.0.0.1:" + getPort() + "/?username=camel&password=password&x509HostnameVerifier=x509HostnameVerifier",
new Processor() {
+        Exchange exchange = template.request("https4://127.0.0.1:" + getPort() + "/?authUsername=camel&authPassword=password&x509HostnameVerifier=x509HostnameVerifier",
new Processor() {
             public void process(Exchange exchange) throws Exception {
             }
         });



Mime
View raw message