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/08 09:53:25 UTC

camel git commit: Polished couple of tests

Repository: camel
Updated Branches:
  refs/heads/master 422a72c31 -> fa04325a8


Polished couple of tests

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

Branch: refs/heads/master
Commit: fa04325a82b0ca79bddd3c899d3a00e012c16638
Parents: 422a72c
Author: Babak Vahdat <bv...@apache.org>
Authored: Sun May 8 11:53:16 2016 +0200
Committer: Babak Vahdat <bv...@apache.org>
Committed: Sun May 8 11:53:16 2016 +0200

----------------------------------------------------------------------
 ...tpEndpointOptionsNotChangeComponentTest.java |  8 +-
 .../HttpProducerWithSystemPropertiesTest.java   | 79 +-------------------
 .../http4/HttpReferenceParameterTest.java       |  5 +-
 3 files changed, 7 insertions(+), 85 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/fa04325a/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpEndpointOptionsNotChangeComponentTest.java
----------------------------------------------------------------------
diff --git a/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpEndpointOptionsNotChangeComponentTest.java b/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpEndpointOptionsNotChangeComponentTest.java
index 3af54f7..ef61f76 100644
--- a/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpEndpointOptionsNotChangeComponentTest.java
+++ b/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpEndpointOptionsNotChangeComponentTest.java
@@ -59,26 +59,24 @@ public class HttpEndpointOptionsNotChangeComponentTest extends CamelTestSupport
     public void testDoNotMessWithComponent() throws Exception {
         // get default
         HttpEndpoint end = context.getEndpoint("http4://www.google.com", HttpEndpoint.class);
-        assertIsInstanceOf(MyBinding.class, end.getBinding());
+        assertIsInstanceOf(MyBinding.class, end.getHttpBinding());
 
         // use a endpoint specific binding
         HttpEndpoint end2 = context.getEndpoint("http4://www.google.com?httpBinding=#other", HttpEndpoint.class);
-        assertIsInstanceOf(MyOtherBinding.class, end2.getBinding());
+        assertIsInstanceOf(MyOtherBinding.class, end2.getHttpBinding());
 
         // and the default option has not been messed with
         HttpEndpoint end3 = context.getEndpoint("http4://www.google.com", HttpEndpoint.class);
-        assertIsInstanceOf(MyBinding.class, end3.getBinding());
+        assertIsInstanceOf(MyBinding.class, end3.getHttpBinding());
         
         // test the headerFilterStrategy
         HttpEndpoint end4 = context.getEndpoint("http4://www.google.com?headerFilterStrategy=#myStrategy", HttpEndpoint.class);
         assertIsInstanceOf(MyHeaderFilterStrategy.class, end4.getHeaderFilterStrategy());
     }
 
-    @SuppressWarnings("deprecation")
     private static class MyBinding extends DefaultHttpBinding {
     }
 
-    @SuppressWarnings("deprecation")
     private static class MyOtherBinding extends DefaultHttpBinding {
     }
     

http://git-wip-us.apache.org/repos/asf/camel/blob/fa04325a/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpProducerWithSystemPropertiesTest.java
----------------------------------------------------------------------
diff --git a/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpProducerWithSystemPropertiesTest.java b/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpProducerWithSystemPropertiesTest.java
index fcd3d20..4433000 100644
--- a/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpProducerWithSystemPropertiesTest.java
+++ b/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpProducerWithSystemPropertiesTest.java
@@ -16,33 +16,14 @@
  */
 package org.apache.camel.component.http4;
 
-import java.io.IOException;
-import java.util.ArrayList;
 import java.util.HashMap;
-import java.util.List;
 import java.util.Map;
 
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.component.http4.handler.HeaderValidationHandler;
-import org.apache.commons.codec.BinaryDecoder;
-import org.apache.commons.codec.DecoderException;
-import org.apache.commons.codec.binary.Base64;
-import org.apache.http.Header;
-import org.apache.http.HttpException;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpRequestInterceptor;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpResponseInterceptor;
-import org.apache.http.HttpStatus;
-import org.apache.http.ProtocolException;
-import org.apache.http.auth.AUTH;
 import org.apache.http.impl.bootstrap.HttpServer;
 import org.apache.http.impl.bootstrap.ServerBootstrap;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.protocol.HttpProcessor;
-import org.apache.http.protocol.ImmutableHttpProcessor;
-import org.apache.http.protocol.ResponseContent;
 import org.junit.After;
 import org.junit.AfterClass;
 import org.junit.Before;
@@ -59,13 +40,13 @@ public class HttpProducerWithSystemPropertiesTest extends BaseHttpTest {
     private HttpServer localServer;
 
     @BeforeClass
-    public static void setUpSystemProperties() throws Exception {
+    public static void setUpHttpAgentSystemProperty() throws Exception {
         // the 'http.agent' java system-property corresponds to the http 'User-Agent' header
         defaultSystemHttpAgent = System.getProperties().setProperty("http.agent", "myCoolCamelCaseAgent");
     }
 
     @AfterClass
-    public static void resetSystemProperties() throws Exception {
+    public static void resetHttpAgentSystemProperty() throws Exception {
         if (defaultSystemHttpAgent != null) {
             System.getProperties().setProperty("http.agent", String.valueOf(defaultSystemHttpAgent));
         } else {
@@ -101,17 +82,6 @@ public class HttpProducerWithSystemPropertiesTest extends BaseHttpTest {
         }
     }
 
-    @Override
-    protected HttpProcessor getBasicHttpProcessor() {
-        List<HttpRequestInterceptor> requestInterceptors = new ArrayList<HttpRequestInterceptor>();
-        requestInterceptors.add(new RequestProxyBasicAuth());
-        List<HttpResponseInterceptor> responseInterceptors = new ArrayList<HttpResponseInterceptor>();
-        responseInterceptors.add(new ResponseContent());
-        responseInterceptors.add(new ResponseProxyBasicUnauthorized());
-        ImmutableHttpProcessor httpproc = new ImmutableHttpProcessor(requestInterceptors, responseInterceptors);
-        return httpproc;
-    }
-
     @Test
     public void httpGetWithProxyFromSystemProperties() throws Exception {
 
@@ -123,49 +93,4 @@ public class HttpProducerWithSystemPropertiesTest extends BaseHttpTest {
         assertExchange(exchange);
     }
 
-    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")) {
-                throw new HttpException("Get a wrong proxy GET url");
-            }
-            Header h = request.getFirstHeader(AUTH.PROXY_AUTH_RESP);
-            if (h != null) {
-                String s = h.getValue();
-                if (s != null) {
-                    auth = s.trim();
-                }
-            }
-
-            if (auth != null) {
-                int i = auth.indexOf(' ');
-                if (i == -1) {
-                    throw new ProtocolException("Invalid Authorization header: " + auth);
-                }
-                String authscheme = auth.substring(0, i);
-                if (authscheme.equalsIgnoreCase("basic")) {
-                    String s = auth.substring(i + 1).trim();
-                    byte[] credsRaw = s.getBytes("ASCII");
-                    BinaryDecoder codec = new Base64();
-                    try {
-                        String creds = new String(codec.decode(credsRaw), "ASCII");
-                        context.setAttribute("proxy-creds", creds);
-                    } catch (DecoderException ex) {
-                        throw new ProtocolException("Malformed BASIC credentials");
-                    }
-                }
-            }
-        }
-    }
-
-    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\"");
-            }
-        }
-    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/fa04325a/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpReferenceParameterTest.java
----------------------------------------------------------------------
diff --git a/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpReferenceParameterTest.java b/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpReferenceParameterTest.java
index ff2599f..f35a5fc 100644
--- a/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpReferenceParameterTest.java
+++ b/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpReferenceParameterTest.java
@@ -54,8 +54,8 @@ public class HttpReferenceParameterTest extends CamelTestSupport {
 
     @Test
     public void testHttpBinding() {
-        assertSame(testBinding, endpoint1.getBinding());
-        assertSame(testBinding, endpoint2.getBinding());
+        assertSame(testBinding, endpoint1.getHttpBinding());
+        assertSame(testBinding, endpoint2.getHttpBinding());
     }
 
     @Test
@@ -89,7 +89,6 @@ public class HttpReferenceParameterTest extends CamelTestSupport {
         };
     }
 
-    @SuppressWarnings("deprecation")
     private static class TestHttpBinding extends DefaultHttpBinding {
     }