Author: ningjiang
Date: Fri Jul 16 06:52:16 2010
New Revision: 964694
URL: http://svn.apache.org/viewvc?rev=964694&view=rev
Log:
CAMEL-2945 Using URISupport.normalizeUri by the suggestion of Claus
Modified:
camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProxyTest.java
camel/trunk/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpProxyServerTest.java
Modified:
camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProxyTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProxyTest.java?rev=964694&r1=964693&r2=964694&view=diff
==============================================================================
---
camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProxyTest.java
(original)
+++
camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProxyTest.java
Fri Jul 16 06:52:16 2010
@@ -17,6 +17,7 @@
package org.apache.camel.component.http;
import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.camel.util.URISupport;
import org.apache.commons.httpclient.HttpClient;
import org.junit.Test;
@@ -37,8 +38,8 @@ public class HttpProxyTest extends Camel
@Test
public void testDifferentHttpProxyConfigured() throws Exception {
HttpEndpoint http1 =
context.getEndpoint("http://www.google.com?proxyHost=myproxy&proxyPort=1234",
HttpEndpoint.class);
- HttpEndpoint http2 =
context.getEndpoint("http://www.google.com?proxyHost=myotherproxy&proxyPort=2345",
HttpEndpoint.class);
- HttpEndpoint http3 =
context.getEndpoint("http://www.google.com?test=parameter", HttpEndpoint.class);
+ HttpEndpoint http2 =
context.getEndpoint("http://www.google.com?test=parameter&proxyHost=myotherproxy&proxyPort=2345",
HttpEndpoint.class);
+
HttpClient client1 = http1.createHttpClient();
assertEquals("myproxy", client1.getHostConfiguration().getProxyHost());
@@ -48,10 +49,9 @@ public class HttpProxyTest extends Camel
assertEquals("myotherproxy",
client2.getHostConfiguration().getProxyHost());
assertEquals(2345, client2.getHostConfiguration().getProxyPort());
- //As the endpointUri is recreated, so the parameter could be in
different place
- assertTrue("Get a wrong endpoint uri of http1",
http1.getEndpointUri().indexOf("proxyPort=1234") > 0);
- assertTrue("Get a wrong endpoint uri of http2",
http2.getEndpointUri().indexOf("proxyHost=myotherproxy") > 0);
- assertEquals("Get a wrong endpoint uri",
"http://www.google.com?test=parameter", http3.getEndpointUri());
+ //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",
"http://www.google.com?proxyHost=myproxy&proxyPort=1234",
URISupport.normalizeUri(http1.getEndpointUri()));
+ assertEquals("Get a wrong endpoint uri of http2",
"http://www.google.com?proxyHost=myotherproxy&proxyPort=2345&test=parameter",
URISupport.normalizeUri(http2.getEndpointUri()));
assertEquals("Should get the same EndpointKey",
http1.getEndpointKey(), http2.getEndpointKey());
}
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=964694&r1=964693&r2=964694&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
Fri Jul 16 06:52:16 2010
@@ -24,6 +24,7 @@ import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.component.http4.handler.HeaderValidationHandler;
import
org.apache.camel.component.http4.handler.ProxyAuthenticationValidationHandler;
+import org.apache.camel.util.URISupport;
import org.apache.commons.codec.BinaryDecoder;
import org.apache.commons.codec.DecoderException;
import org.apache.commons.codec.binary.Base64;
@@ -85,8 +86,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?proxyHost=myotherproxy&proxyPort=2345",
HttpEndpoint.class);
- HttpEndpoint http3 =
context.getEndpoint("http4://www.google.com?test=parameter",
HttpEndpoint.class);
+ HttpEndpoint http2 =
context.getEndpoint("http4://www.google.com?test=parameter&proxyHost=myotherproxy&proxyPort=2345",
HttpEndpoint.class);
+
HttpClient client1 = http1.createHttpClient();
HttpHost proxy1 =
(HttpHost)client1.getParams().getParameter(ConnRoutePNames.DEFAULT_PROXY);
@@ -97,12 +98,11 @@ public class HttpProxyServerTest extends
HttpHost proxy2 =
(HttpHost)client2.getParams().getParameter(ConnRoutePNames.DEFAULT_PROXY);
assertEquals("myotherproxy", proxy2.getHostName());
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()));
- //As the endpointUri is recreated, so the parameter could be in
different place
- assertTrue("Get a wrong endpoint uri of http1",
http1.getEndpointUri().indexOf("proxyPort=1234") > 0);
- assertTrue("Get a wrong endpoint uri of http2",
http2.getEndpointUri().indexOf("proxyHost=myotherproxy") > 0);
- assertEquals("Get a wrong endpoint uri",
"http4://www.google.com?test=parameter", http3.getEndpointUri());
-
assertEquals("Should get the same EndpointKey",
http1.getEndpointKey(), http2.getEndpointKey());
}