You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2010/07/16 06:39:25 UTC

svn commit: r964672 - /camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProxyTest.java

Author: ningjiang
Date: Fri Jul 16 04:39:25 2010
New Revision: 964672

URL: http://svn.apache.org/viewvc?rev=964672&view=rev
Log:
CAMEL-2945 Try to fix the HttpProxyTest error on other platform

Modified:
    camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProxyTest.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=964672&r1=964671&r2=964672&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 04:39:25 2010
@@ -37,7 +37,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?test=parameter&proxyHost=myotherproxy&proxyPort=2345", 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);
         
         HttpClient client1 = http1.createHttpClient();
         assertEquals("myproxy", client1.getHostConfiguration().getProxyHost());
@@ -47,8 +48,10 @@ public class HttpProxyTest extends Camel
         assertEquals("myotherproxy", client2.getHostConfiguration().getProxyHost());
         assertEquals(2345, client2.getHostConfiguration().getProxyPort());
 
-        assertEquals("Get a wrong endpoint uri", "http://www.google.com?proxyHost=myproxy&proxyPort=1234", http1.getEndpointUri());
-        assertEquals("Get a wrong endpoint uri", "http://www.google.com?test=parameter&proxyHost=myotherproxy&proxyPort=2345", 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", "http://www.google.com?test=parameter", http3.getEndpointUri());
        
         assertEquals("Should get the same EndpointKey", http1.getEndpointKey(), http2.getEndpointKey());
     }



Re: svn commit: r964672 - /camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProxyTest.java

Posted by Claus Ibsen <cl...@gmail.com>.
Hi Willem

You can use the URISupport.normalizeUri method to have the URI
returned in an ordered way. This ensures that the URI is returned the
same regardless how people re-order parameters.

http://foo.com?a=1&b=2
http://foo.com?b=2&a=1

Will have it return both the same way (parameters being sorted)
http://foo.com?a=1&b=2

Camel itself uses this when registering endpoints in its internal
registry/cache to ensure it can lookup endpoints.


On Fri, Jul 16, 2010 at 6:39 AM,  <ni...@apache.org> wrote:
> Author: ningjiang
> Date: Fri Jul 16 04:39:25 2010
> New Revision: 964672
>
> URL: http://svn.apache.org/viewvc?rev=964672&view=rev
> Log:
> CAMEL-2945 Try to fix the HttpProxyTest error on other platform
>
> Modified:
>    camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProxyTest.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=964672&r1=964671&r2=964672&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 04:39:25 2010
> @@ -37,7 +37,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?test=parameter&proxyHost=myotherproxy&proxyPort=2345", 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);
>
>         HttpClient client1 = http1.createHttpClient();
>         assertEquals("myproxy", client1.getHostConfiguration().getProxyHost());
> @@ -47,8 +48,10 @@ public class HttpProxyTest extends Camel
>         assertEquals("myotherproxy", client2.getHostConfiguration().getProxyHost());
>         assertEquals(2345, client2.getHostConfiguration().getProxyPort());
>
> -        assertEquals("Get a wrong endpoint uri", "http://www.google.com?proxyHost=myproxy&proxyPort=1234", http1.getEndpointUri());
> -        assertEquals("Get a wrong endpoint uri", "http://www.google.com?test=parameter&proxyHost=myotherproxy&proxyPort=2345", 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", "http://www.google.com?test=parameter", http3.getEndpointUri());
>
>         assertEquals("Should get the same EndpointKey", http1.getEndpointKey(), http2.getEndpointKey());
>     }
>
>
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus