You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by bv...@apache.org on 2016/05/07 20:31:31 UTC

camel git commit: Polished another test

Repository: camel
Updated Branches:
  refs/heads/master 61cd48af7 -> 2820ca76b


Polished another test

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

Branch: refs/heads/master
Commit: 2820ca76b4063248277eb4669b507a41499702f6
Parents: 61cd48a
Author: Babak Vahdat <bv...@apache.org>
Authored: Sat May 7 22:31:13 2016 +0200
Committer: Babak Vahdat <bv...@apache.org>
Committed: Sat May 7 22:31:13 2016 +0200

----------------------------------------------------------------------
 .../component/http4/HttpProxyServerTest.java    | 32 +++++++++-----------
 1 file changed, 15 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/2820ca76/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpProxyServerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpProxyServerTest.java b/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpProxyServerTest.java
index 7914b71..90c26ca 100644
--- a/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpProxyServerTest.java
+++ b/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpProxyServerTest.java
@@ -53,13 +53,13 @@ import org.junit.Test;
  * @version 
  */
 public class HttpProxyServerTest extends BaseHttpTest {
-    
+
     private HttpServer proxy;
-    
+
     @Before
     @Override
     public void setUp() throws Exception {
-        Map<String, String> expectedHeaders = new HashMap<String, String>();
+        Map<String, String> expectedHeaders = new HashMap<>();
         expectedHeaders.put("Proxy-Connection", "Keep-Alive");
         proxy = ServerBootstrap.bootstrap().
                 setHttpProcessor(getBasicHttpProcessor()).
@@ -82,7 +82,7 @@ public class HttpProxyServerTest extends BaseHttpTest {
             proxy.stop();
         }
     }
-    
+
     @Override
     protected HttpProcessor getBasicHttpProcessor() {
         List<HttpRequestInterceptor> requestInterceptors = new ArrayList<HttpRequestInterceptor>();
@@ -94,20 +94,18 @@ public class HttpProxyServerTest extends BaseHttpTest {
         return httpproc;
     }
 
-    
     @Test
     public void testDifferentHttpProxyConfigured() throws Exception {
-        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);
+        HttpEndpoint http1 = context.getEndpoint("http4://www.google.com?proxyAuthHost=www.myproxy.com&proxyAuthPort=1234", HttpEndpoint.class);
+        HttpEndpoint http2 = context.getEndpoint("http4://www.google.com?test=parameter&proxyAuthHost=www.myotherproxy.com&proxyAuthPort=2345", HttpEndpoint.class);
         // HttpClientBuilder doesn't support get the configuration here
         
         //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?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("Get a wrong endpoint uri of http1", "http4://www.google.com?proxyAuthHost=www.myproxy.com&proxyAuthPort=1234", URISupport.normalizeUri(http1.getEndpointUri()));
+        assertEquals("Get a wrong endpoint uri of http2", "http4://www.google.com?proxyAuthHost=www.myotherproxy.com&proxyAuthPort=2345&test=parameter", URISupport.normalizeUri(http2.getEndpointUri()));
 
         assertEquals("Should get the same EndpointKey", http1.getEndpointKey(), http2.getEndpointKey());
     }
-    
 
     @Test
     public void httpGetWithProxyAndWithoutUser() throws Exception {
@@ -124,14 +122,14 @@ public class HttpProxyServerTest extends BaseHttpTest {
         return proxy.getInetAddress().getHostName();
     }
 
-    private int getProxyPort() {
-        return proxy.getLocalPort();
+    private String getProxyPort() {
+        return "" + proxy.getLocalPort();
     }
-    
-    class RequestProxyBasicAuth implements HttpRequestInterceptor {
+
+    private static class RequestProxyBasicAuth implements HttpRequestInterceptor {
         public void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException {
             String auth = null;
-            
+
             String requestLine = request.getRequestLine().toString();
             // assert we set a write GET URI
             if (requestLine.contains("http4://localhost")) {
@@ -166,11 +164,11 @@ public class HttpProxyServerTest extends BaseHttpTest {
         }
     }
 
-    class ResponseProxyBasicUnauthorized implements HttpResponseInterceptor {
+    private static class ResponseProxyBasicUnauthorized implements HttpResponseInterceptor {
         public void process(final HttpResponse response, final HttpContext context) throws HttpException, IOException {
             if (response.getStatusLine().getStatusCode() == HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED) {
                 response.addHeader(AUTH.PROXY_AUTH, "Basic realm=\"test realm\"");
             }
         }
     }
-}
\ No newline at end of file
+}