You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by dv...@apache.org on 2011/07/28 15:52:58 UTC

svn commit: r1151849 - in /camel/trunk: camel-core/src/main/java/org/apache/camel/util/ camel-core/src/test/java/org/apache/camel/util/ components/camel-ahc/src/main/java/org/apache/camel/component/ahc/ components/camel-ahc/src/test/java/org/apache/cam...

Author: dvaleri
Date: Thu Jul 28 13:52:55 2011
New Revision: 1151849

URL: http://svn.apache.org/viewvc?rev=1151849&view=rev
Log:
[CAMEL-4060] [CAMEL-4049] Added support for JSSE Config Utility and upgraded to AHC 1.6.4 with clientConfig. style configuration in AHC component URI.

Added:
    camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcComponentClientConfigSslContextParametersTest.java   (with props)
    camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcComponentClientConfigWithClientConfigUriParametersTest.java   (with props)
    camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceClientConfigWithClientConfigUriParametersTest.java   (with props)
    camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceSSLContextParametersGetTest.java   (with props)
    camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceWithClientConfigUriParametersTest.java   (with props)
    camel/trunk/components/camel-ahc/src/test/resources/jsse/
    camel/trunk/components/camel-ahc/src/test/resources/jsse/localhost.ks   (with props)
Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/util/IntrospectionSupport.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/util/IntrospectionSupportTest.java
    camel/trunk/components/camel-ahc/src/main/java/org/apache/camel/component/ahc/AhcComponent.java
    camel/trunk/components/camel-ahc/src/main/java/org/apache/camel/component/ahc/AhcEndpoint.java
    camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcComponentClientConfigTest.java
    camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduce500Test.java
    camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceClientConfigTest.java
    camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceGetHeadersTest.java
    camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceGetNoSlashInUriTest.java
    camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceGetTest.java
    camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceNoThrowExceptionOnFailureTest.java
    camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProducePostHeadersTest.java
    camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProducePostTest.java
    camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceTransferExceptionTest.java
    camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProducerTwoParametersWithSameKeyTest.java
    camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/BaseAhcTest.java
    camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/MyOrderException.java
    camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/javabody/AhcProduceJavaBodyTest.java
    camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/javabody/MyCoolBean.java
    camel/trunk/parent/pom.xml

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/util/IntrospectionSupport.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/util/IntrospectionSupport.java?rev=1151849&r1=1151848&r2=1151849&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/util/IntrospectionSupport.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/util/IntrospectionSupport.java Thu Jul 28 13:52:55 2011
@@ -111,7 +111,7 @@ public final class IntrospectionSupport 
         return name;
     }
 
-    public static boolean isSetter(Method method) {
+    public static boolean isSetter(Method method, boolean allowBuilderPattern) {
         String name = method.getName();
         Class<?> type = method.getReturnType();
         Class<?> params[] = method.getParameterTypes();
@@ -120,7 +120,11 @@ public final class IntrospectionSupport 
             return false;
         }
 
-        return params.length == 1 && type.equals(Void.TYPE);
+        return params.length == 1 && (type.equals(Void.TYPE) || (allowBuilderPattern && method.getDeclaringClass().isAssignableFrom(type)));
+    }
+    
+    public static boolean isSetter(Method method) {
+        return isSetter(method, false);
     }
 
     /**
@@ -240,8 +244,8 @@ public final class IntrospectionSupport 
         }
         return false;
     }
-
-    public static boolean setProperties(Object target, Map<String, Object> properties, String optionPrefix) throws Exception {
+    
+    public static boolean setProperties(Object target, Map<String, Object> properties, String optionPrefix, boolean allowBuilderPattern) throws Exception {
         ObjectHelper.notNull(target, "target");
         ObjectHelper.notNull(properties, "properties");
         boolean rc = false;
@@ -252,16 +256,20 @@ public final class IntrospectionSupport 
             if (name.startsWith(optionPrefix)) {
                 Object value = properties.get(name);
                 name = name.substring(optionPrefix.length());
-                if (setProperty(target, name, value)) {
+                if (setProperty(target, name, value, allowBuilderPattern)) {
                     it.remove();
                     rc = true;
                 }
             }
         }
-
+        
         return rc;
     }
 
+    public static boolean setProperties(Object target, Map<String, Object> properties, String optionPrefix) throws Exception {
+        return setProperties(target, properties, optionPrefix, false);
+    }
+
     public static Map<String, Object> extractProperties(Map<String, Object> properties, String optionPrefix) {
         ObjectHelper.notNull(properties, "properties");
 
@@ -301,11 +309,11 @@ public final class IntrospectionSupport 
         return setProperties(null, target, properties);
     }
 
-    public static boolean setProperty(TypeConverter typeConverter, Object target, String name, Object value) throws Exception {
+    public static boolean setProperty(TypeConverter typeConverter, Object target, String name, Object value, boolean allowBuilderPattern) throws Exception {
         try {
             Class<?> clazz = target.getClass();
             // find candidates of setter methods as there can be overloaded setters
-            Set<Method> setters = findSetterMethods(typeConverter, clazz, name, value);
+            Set<Method> setters = findSetterMethods(typeConverter, clazz, name, value, allowBuilderPattern);
             if (setters.isEmpty()) {
                 return false;
             }
@@ -356,9 +364,17 @@ public final class IntrospectionSupport 
             }
         }
     }
+    
+    public static boolean setProperty(TypeConverter typeConverter, Object target, String name, Object value) throws Exception {
+        return setProperty(typeConverter, target, name, value, false);
+    }
+    
+    public static boolean setProperty(Object target, String name, Object value, boolean allowBuilderPattern) throws Exception {
+        return setProperty(null, target, name, value, allowBuilderPattern);
+    }
 
     public static boolean setProperty(Object target, String name, Object value) throws Exception {
-        return setProperty(null, target, name, value);
+        return setProperty(target, name, value, false);
     }
 
     @SuppressWarnings("unchecked")
@@ -377,8 +393,8 @@ public final class IntrospectionSupport 
         }
         return null;
     }
-
-    private static Set<Method> findSetterMethods(TypeConverter typeConverter, Class<?> clazz, String name, Object value) {
+    
+    private static Set<Method> findSetterMethods(TypeConverter typeConverter, Class<?> clazz, String name, Object value, boolean allowBuilderPattern) {
         Set<Method> candidates = new LinkedHashSet<Method>();
 
         // Build the method name.
@@ -394,7 +410,7 @@ public final class IntrospectionSupport 
                     Class<?> paramType = params[0];
                     if (paramType.equals(Object.class)) {                        
                         objectSetMethod = method;
-                    } else if (typeConverter != null || isSetter(method) || paramType.isInstance(value)) {
+                    } else if (typeConverter != null || isSetter(method, allowBuilderPattern) || paramType.isInstance(value)) {
                         candidates.add(method);
                     }
                 }
@@ -427,5 +443,8 @@ public final class IntrospectionSupport 
             return candidates;
         }
     }
-
+    
+    private static Set<Method> findSetterMethods(TypeConverter typeConverter, Class<?> clazz, String name, Object value) {
+        return findSetterMethods(typeConverter, clazz, name, value, false);
+    }
 }

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/util/IntrospectionSupportTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/util/IntrospectionSupportTest.java?rev=1151849&r1=1151848&r2=1151849&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/util/IntrospectionSupportTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/util/IntrospectionSupportTest.java Thu Jul 28 13:52:55 2011
@@ -71,6 +71,46 @@ public class IntrospectionSupportTest ex
             return bean.getName();
         }
     }
+    
+    public class MyBuilderBean {
+        private String name;
+        
+        public String getName() {
+            return name;
+        }
+
+        public MyBuilderBean setName(String name) {
+            this.name = name;
+            
+            return this;
+        }
+    }
+    
+    public class MyOtherBuilderBean extends MyBuilderBean {    
+    }
+    
+    public class MyOtherOtherBuilderBean extends MyOtherBuilderBean {
+        
+        public MyOtherOtherBuilderBean setName(String name) {
+            super.setName(name);
+            return this;
+        }
+    }
+    
+    public void testIsSetterBuilderPatternSupport() throws Exception {
+        Method setter = MyBuilderBean.class.getMethod("setName", String.class);
+        Method setter2 = MyOtherBuilderBean.class.getMethod("setName", String.class);
+        Method setter3 = MyOtherOtherBuilderBean.class.getMethod("setName", String.class);
+        
+        assertFalse(IntrospectionSupport.isSetter(setter, false));
+        assertTrue(IntrospectionSupport.isSetter(setter, true));
+        
+        assertFalse(IntrospectionSupport.isSetter(setter2, false));
+        assertTrue(IntrospectionSupport.isSetter(setter2, true));
+        
+        assertFalse(IntrospectionSupport.isSetter(setter3, false));
+        assertTrue(IntrospectionSupport.isSetter(setter3, true));
+    }
 
     public void testHasProperties() throws Exception {
         Map<String, Object> empty = CastUtils.cast(Collections.emptyMap());

Modified: camel/trunk/components/camel-ahc/src/main/java/org/apache/camel/component/ahc/AhcComponent.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ahc/src/main/java/org/apache/camel/component/ahc/AhcComponent.java?rev=1151849&r1=1151848&r2=1151849&view=diff
==============================================================================
--- camel/trunk/components/camel-ahc/src/main/java/org/apache/camel/component/ahc/AhcComponent.java (original)
+++ camel/trunk/components/camel-ahc/src/main/java/org/apache/camel/component/ahc/AhcComponent.java Thu Jul 28 13:52:55 2011
@@ -21,33 +21,78 @@ import java.util.Map;
 
 import com.ning.http.client.AsyncHttpClient;
 import com.ning.http.client.AsyncHttpClientConfig;
+import com.ning.http.client.filter.IOExceptionFilter;
+import com.ning.http.client.filter.RequestFilter;
+import com.ning.http.client.filter.ResponseFilter;
+
 import org.apache.camel.Endpoint;
 import org.apache.camel.impl.HeaderFilterStrategyComponent;
 import org.apache.camel.util.CastUtils;
+import org.apache.camel.util.IntrospectionSupport;
 import org.apache.camel.util.URISupport;
+import org.apache.camel.util.jsse.SSLContextParameters;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  *  Defines the <a href="http://camel.apache.org/ahc.html">Async HTTP Client Component</a>
  */
 public class AhcComponent extends HeaderFilterStrategyComponent {
+    
+    private static final transient Logger LOG = LoggerFactory.getLogger(AhcComponent.class);
+    
+    private static final String CLIENT_CONFIG_PREFIX = "clientConfig.";
 
     private AsyncHttpClient client;
     private AsyncHttpClientConfig clientConfig;
     private AhcBinding binding;
+    private SSLContextParameters sslContextParameters;
 
     @Override
     protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
         String addressUri = remaining;
 
-        // restructure uri to be based on the parameters left as we dont want to include the Camel internal options
-        URI httpUri = URISupport.createRemainingURI(new URI(addressUri), CastUtils.cast(parameters));
-
-        AhcEndpoint endpoint = new AhcEndpoint(uri, this, httpUri);
+        // Do not set the HTTP URI because we still have all of the Camel internal
+        // parameters in the URI at this point.
+        AhcEndpoint endpoint = new AhcEndpoint(uri, this, null);
         setEndpointHeaderFilterStrategy(endpoint);
         endpoint.setClient(getClient());
         endpoint.setClientConfig(getClientConfig());
         endpoint.setBinding(getBinding());
+        endpoint.setSslContextParameters(getSslContextParameters());
+        
         setProperties(endpoint, parameters);
+        
+        if (IntrospectionSupport.hasProperties(parameters, CLIENT_CONFIG_PREFIX)) {
+            AsyncHttpClientConfig.Builder builder = endpoint.getClientConfig() == null 
+                    ? new AsyncHttpClientConfig.Builder() : AhcComponent.cloneConfig(endpoint.getClientConfig());
+            
+            if (endpoint.getClient() != null) {
+                LOG.warn("The user explicitly set an AsyncHttpClient instance on the component or "
+                         + "endpoint, but this endpoint URI contains client configuration parameters.  "
+                         + "Are you sure that this is what was intended?  The AsyncHttpClient will be used"
+                         + " and the URI parameters will be ignored.");
+            } else if (endpoint.getClientConfig() != null) {
+                LOG.warn("The user explicitly set an AsyncHttpClientConfig instance on the component or "
+                         + "endpoint, but this endpoint URI contains client configuration parameters.  "
+                         + "Are you sure that this is what was intended?  The URI parameters will be applied"
+                         + " to a clone of the supplied AsyncHttpClientConfig in order to prevent unintended modification"
+                         + " of the explicitly configured AsyncHttpClientConfig.  That is, the URI parameters override the"
+                         + " settings on the explicitly configured AsyncHttpClientConfig for this endpoint.");
+            }
+            
+            // set and validate additional parameters on client config
+            IntrospectionSupport.setProperties(builder, parameters, CLIENT_CONFIG_PREFIX, true);
+            validateParameters(uri, parameters, CLIENT_CONFIG_PREFIX);
+            
+            endpoint.setClientConfig(builder.build());
+        }
+        
+        // restructure uri to be based on the parameters left as we don't want to include the Camel internal options
+        URI httpUri = URISupport.createRemainingURI(new URI(addressUri), CastUtils.cast(parameters));
+        endpoint.setHttpUri(httpUri);
+        
         return endpoint;
     }
 
@@ -77,4 +122,66 @@ public class AhcComponent extends Header
     public void setClientConfig(AsyncHttpClientConfig clientConfig) {
         this.clientConfig = clientConfig;
     }
+
+    public SSLContextParameters getSslContextParameters() {
+        return sslContextParameters;
+    }
+
+    public void setSslContextParameters(SSLContextParameters sslContextParameters) {
+        this.sslContextParameters = sslContextParameters;
+    }
+    
+    /**
+     * Creates a new client configuration builder using {@code clientConfig} as a template for
+     * the builder.
+     *
+     * @param clientConfig the instance to serve as a template for the builder
+     *
+     * @return a builder configured with the same options as the supplied config
+     */
+    static AsyncHttpClientConfig.Builder cloneConfig(AsyncHttpClientConfig clientConfig) {
+        
+        // TODO - Replace with copy based constructor and remove duplicate copy code below when AHC 1.7 is released (CAMEL-4081).
+        AsyncHttpClientConfig.Builder builder =
+            new AsyncHttpClientConfig.Builder();
+        
+        builder.setAllowPoolingConnection(clientConfig.getAllowPoolingConnection());
+        builder.setAsyncHttpClientProviderConfig(clientConfig.getAsyncHttpProviderConfig());
+        builder.setConnectionsPool(clientConfig.getConnectionsPool());
+        builder.setConnectionTimeoutInMs(clientConfig.getConnectionTimeoutInMs());
+        builder.setIdleConnectionInPoolTimeoutInMs(clientConfig.getIdleConnectionInPoolTimeoutInMs());
+        builder.setMaximumConnectionsPerHost(clientConfig.getMaxConnectionPerHost());
+        builder.setMaximumNumberOfRedirects(clientConfig.getMaxRedirects());
+        builder.setMaximumConnectionsTotal(clientConfig.getMaxTotalConnections());
+        builder.setProxyServer(clientConfig.getProxyServer());
+        builder.setRealm(clientConfig.getRealm());
+        builder.setRequestTimeoutInMs(clientConfig.getRequestTimeoutInMs());
+        builder.setSSLContext(clientConfig.getSSLContext());
+        builder.setSSLEngineFactory(clientConfig.getSSLEngineFactory());
+        builder.setUserAgent(clientConfig.getUserAgent());
+        builder.setFollowRedirects(clientConfig.isRedirectEnabled());
+        builder.setCompressionEnabled(clientConfig.isCompressionEnabled());
+        builder.setScheduledExecutorService(clientConfig.reaper());
+        builder.setExecutorService(clientConfig.executorService());
+
+        for (RequestFilter filter : clientConfig.getRequestFilters()) {
+            builder.addRequestFilter(filter);
+        }
+        
+        for (ResponseFilter filter : clientConfig.getResponseFilters()) {
+            builder.addResponseFilter(filter);
+        }
+
+        for (IOExceptionFilter filter : clientConfig.getIOExceptionFilters()) {
+            builder.addIOExceptionFilter(filter);
+        }
+        
+        builder.setRequestCompressionLevel(clientConfig.getRequestCompressionLevel());
+        builder.setUseRawUrl(clientConfig.isUseRawUrl());
+        builder.setMaxRequestRetry(clientConfig.getMaxRequestRetry());
+        builder.setAllowSslConnectionPool(clientConfig.getAllowPoolingConnection());
+        // End of duplicate code to remove.
+        
+        return builder;
+    }
 }

Modified: camel/trunk/components/camel-ahc/src/main/java/org/apache/camel/component/ahc/AhcEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ahc/src/main/java/org/apache/camel/component/ahc/AhcEndpoint.java?rev=1151849&r1=1151848&r2=1151849&view=diff
==============================================================================
--- camel/trunk/components/camel-ahc/src/main/java/org/apache/camel/component/ahc/AhcEndpoint.java (original)
+++ camel/trunk/components/camel-ahc/src/main/java/org/apache/camel/component/ahc/AhcEndpoint.java Thu Jul 28 13:52:55 2011
@@ -27,6 +27,7 @@ import org.apache.camel.impl.DefaultEndp
 import org.apache.camel.spi.HeaderFilterStrategy;
 import org.apache.camel.spi.HeaderFilterStrategyAware;
 import org.apache.camel.util.ObjectHelper;
+import org.apache.camel.util.jsse.SSLContextParameters;
 
 /**
  *
@@ -41,6 +42,7 @@ public class AhcEndpoint extends Default
     private boolean bridgeEndpoint;
     private boolean throwExceptionOnFailure = true;
     private boolean transferException;
+    private SSLContextParameters sslContextParameters;
 
     public AhcEndpoint(String endpointUri, AhcComponent component, URI httpUri) {
         super(endpointUri, component);
@@ -139,15 +141,44 @@ public class AhcEndpoint extends Default
     public void setTransferException(boolean transferException) {
         this.transferException = transferException;
     }
+    
+    public SSLContextParameters getSslContextParameters() {
+        return sslContextParameters;
+    }
+
+    public void setSslContextParameters(SSLContextParameters sslContextParameters) {
+        this.sslContextParameters = sslContextParameters;
+    }
 
     @Override
     protected void doStart() throws Exception {
         super.doStart();
         if (client == null) {
+            
+            AsyncHttpClientConfig config = null;
+            
             if (clientConfig != null) {
-                client = new AsyncHttpClient(clientConfig);
+                AsyncHttpClientConfig.Builder builder = AhcComponent.cloneConfig(clientConfig);
+                
+                if (sslContextParameters != null) {
+                    builder.setSSLContext(sslContextParameters.createSSLContext());
+                }
+                
+                config = builder.build();
             } else {
+                if (sslContextParameters != null) {
+                    AsyncHttpClientConfig.Builder builder =
+                        new AsyncHttpClientConfig.Builder();
+                    
+                    builder.setSSLContext(sslContextParameters.createSSLContext());
+                    config = builder.build();
+                }
+            }
+            
+            if (config == null) {
                 client = new AsyncHttpClient();
+            } else {
+                client = new AsyncHttpClient(config);
             }
         }
     }

Added: camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcComponentClientConfigSslContextParametersTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcComponentClientConfigSslContextParametersTest.java?rev=1151849&view=auto
==============================================================================
--- camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcComponentClientConfigSslContextParametersTest.java (added)
+++ camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcComponentClientConfigSslContextParametersTest.java Thu Jul 28 13:52:55 2011
@@ -0,0 +1,42 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.ahc;
+
+import org.apache.camel.util.jsse.SSLContextParameters;
+
+public class AhcComponentClientConfigSslContextParametersTest extends AhcComponentClientConfigTest {
+
+    public void configureComponent() {
+        super.configureComponent();
+        
+        AhcComponent component = context.getComponent("ahc", AhcComponent.class);
+        component.setSslContextParameters(context.getRegistry().lookup("sslContextParameters", SSLContextParameters.class));
+    }
+
+    protected String getTestServerEndpointUri() {
+        return super.getTestServerEndpointUri() + "?sslContextParametersRef=sslContextParameters";
+    }
+    
+    protected String getTestServerEndpointTwoUri() {
+        return super.getTestServerEndpointTwoUri() + "?sslContextParametersRef=sslContextParameters";
+    }
+
+    @Override
+    protected boolean isHttps() {
+        return true;
+    }
+}

Propchange: camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcComponentClientConfigSslContextParametersTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcComponentClientConfigTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcComponentClientConfigTest.java?rev=1151849&r1=1151848&r2=1151849&view=diff
==============================================================================
--- camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcComponentClientConfigTest.java (original)
+++ camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcComponentClientConfigTest.java Thu Jul 28 13:52:55 2011
@@ -47,7 +47,7 @@ public class AhcComponentClientConfigTes
 
         assertMockEndpointsSatisfied();
     }
-
+    
     @Override
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
@@ -56,19 +56,19 @@ public class AhcComponentClientConfigTes
                 configureComponent();
 
                 from("direct:start")
-                    .to("ahc:http://localhost:{{port}}/foo")
+                    .to(getAhcEndpointUri())
                     .to("mock:result");
 
-                from("jetty:http://localhost:{{port}}/foo")
+                from(getTestServerEndpointUri())
                         .process(new Processor() {
                             public void process(Exchange exchange) throws Exception {
                                 // redirect to test the client config worked as we told it to follow redirects
                                 exchange.getOut().setHeader(Exchange.HTTP_RESPONSE_CODE, "301");
-                                exchange.getOut().setHeader("Location", "http://localhost:" + getPort() + "/bar");
+                                exchange.getOut().setHeader("Location", getTestServerEndpointTwoUrl());
                             }
                         });
 
-                from("jetty:http://localhost:{{port}}/bar")
+                from(getTestServerEndpointTwoUri())
                         .transform(constant("Bye World"));
             }
         };

Added: camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcComponentClientConfigWithClientConfigUriParametersTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcComponentClientConfigWithClientConfigUriParametersTest.java?rev=1151849&view=auto
==============================================================================
--- camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcComponentClientConfigWithClientConfigUriParametersTest.java (added)
+++ camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcComponentClientConfigWithClientConfigUriParametersTest.java Thu Jul 28 13:52:55 2011
@@ -0,0 +1,40 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.ahc;
+
+import org.apache.camel.Endpoint;
+import org.junit.Test;
+
+public class AhcComponentClientConfigWithClientConfigUriParametersTest extends AhcComponentClientConfigTest {
+
+    @Test
+    public void testAhcComponentClientConfig() throws Exception {
+        super.testAhcComponentClientConfig();
+        
+        Endpoint ahcEndpoint = context.getEndpoint(getAhcEndpointUri());
+        assertTrue(ahcEndpoint instanceof AhcEndpoint);
+        
+        assertEquals(1, ((AhcEndpoint) ahcEndpoint).getClientConfig().getMaxTotalConnections());
+        assertEquals(3, ((AhcEndpoint) ahcEndpoint).getClientConfig().getMaxRequestRetry());
+        assertEquals(true, ((AhcEndpoint) ahcEndpoint).getClientConfig().isRedirectEnabled());
+    }
+
+    @Override
+    protected String getAhcEndpointUri() {
+        return super.getAhcEndpointUri() + "?clientConfig.maximumConnectionsTotal=1";
+    }
+}

Propchange: camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcComponentClientConfigWithClientConfigUriParametersTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduce500Test.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduce500Test.java?rev=1151849&r1=1151848&r2=1151849&view=diff
==============================================================================
--- camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduce500Test.java (original)
+++ camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduce500Test.java Thu Jul 28 13:52:55 2011
@@ -50,10 +50,10 @@ public class AhcProduce500Test extends B
             @Override
             public void configure() throws Exception {
                 from("direct:start")
-                    .to("ahc:http://localhost:{{port}}/foo")
+                    .to(getAhcEndpointUri())
                     .to("mock:result");
 
-                from("jetty:http://localhost:{{port}}/foo")
+                from(getTestServerEndpointUri())
                         .process(new Processor() {
                             public void process(Exchange exchange) throws Exception {
                                 exchange.getOut().setHeader(Exchange.HTTP_RESPONSE_CODE, 500);

Modified: camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceClientConfigTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceClientConfigTest.java?rev=1151849&r1=1151848&r2=1151849&view=diff
==============================================================================
--- camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceClientConfigTest.java (original)
+++ camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceClientConfigTest.java Thu Jul 28 13:52:55 2011
@@ -43,6 +43,11 @@ public class AhcProduceClientConfigTest 
 
         assertMockEndpointsSatisfied();
     }
+    
+    @Override
+    protected String getAhcEndpointUri() {
+        return super.getAhcEndpointUri() + "?clientConfig=#myConfig";
+    }
 
     @Override
     protected RouteBuilder createRouteBuilder() throws Exception {
@@ -50,19 +55,19 @@ public class AhcProduceClientConfigTest 
             @Override
             public void configure() throws Exception {
                 from("direct:start")
-                    .to("ahc:http://localhost:{{port}}/foo?clientConfig=#myConfig")
+                    .to(getAhcEndpointUri())
                     .to("mock:result");
 
-                from("jetty:http://localhost:{{port}}/foo")
+                from(getTestServerEndpointUri())
                         .process(new Processor() {
                             public void process(Exchange exchange) throws Exception {
                                 // redirect to test the client config worked as we told it to follow redirects
                                 exchange.getOut().setHeader(Exchange.HTTP_RESPONSE_CODE, "301");
-                                exchange.getOut().setHeader("Location", "http://localhost:" + getPort() + "/bar");
+                                exchange.getOut().setHeader("Location", getTestServerEndpointTwoUrl());
                             }
                         });
 
-                from("jetty:http://localhost:{{port}}/bar")
+                from(getTestServerEndpointTwoUri())
                         .transform(constant("Bye World"));
             }
         };

Added: camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceClientConfigWithClientConfigUriParametersTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceClientConfigWithClientConfigUriParametersTest.java?rev=1151849&view=auto
==============================================================================
--- camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceClientConfigWithClientConfigUriParametersTest.java (added)
+++ camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceClientConfigWithClientConfigUriParametersTest.java Thu Jul 28 13:52:55 2011
@@ -0,0 +1,40 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.ahc;
+
+import org.apache.camel.Endpoint;
+import org.junit.Test;
+
+public class AhcProduceClientConfigWithClientConfigUriParametersTest extends AhcProduceClientConfigTest {
+
+    @Test
+    public void testAhcProduceClientConfig() throws Exception {
+        super.testAhcProduceClientConfig();
+        
+        Endpoint ahcEndpoint = context.getEndpoint(getAhcEndpointUri());
+        assertTrue(ahcEndpoint instanceof AhcEndpoint);
+        
+        assertEquals(1, ((AhcEndpoint) ahcEndpoint).getClientConfig().getMaxTotalConnections());
+        assertEquals(3, ((AhcEndpoint) ahcEndpoint).getClientConfig().getMaxRequestRetry());
+        assertEquals(true, ((AhcEndpoint) ahcEndpoint).getClientConfig().isRedirectEnabled());
+    }
+
+    @Override
+    protected String getAhcEndpointUri() {
+        return super.getAhcEndpointUri() + "&clientConfig.maximumConnectionsTotal=1";
+    }
+}

Propchange: camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceClientConfigWithClientConfigUriParametersTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceGetHeadersTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceGetHeadersTest.java?rev=1151849&r1=1151848&r2=1151849&view=diff
==============================================================================
--- camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceGetHeadersTest.java (original)
+++ camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceGetHeadersTest.java Thu Jul 28 13:52:55 2011
@@ -48,10 +48,10 @@ public class AhcProduceGetHeadersTest ex
             @Override
             public void configure() throws Exception {
                 from("direct:start")
-                    .to("ahc:http://localhost:{{port}}/foo")
+                    .to(getAhcEndpointUri())
                     .to("mock:result");
 
-                from("jetty:http://localhost:{{port}}/foo")
+                from(getTestServerEndpointUri())
                         .transform(constant("Bye World"));
             }
         };

Modified: camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceGetNoSlashInUriTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceGetNoSlashInUriTest.java?rev=1151849&r1=1151848&r2=1151849&view=diff
==============================================================================
--- camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceGetNoSlashInUriTest.java (original)
+++ camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceGetNoSlashInUriTest.java Thu Jul 28 13:52:55 2011
@@ -31,16 +31,21 @@ public class AhcProduceGetNoSlashInUriTe
     }
 
     @Override
+    protected String getAhcEndpointUri() {
+        return "ahc:" + getProtocol() + ":localhost:{{port}}/foo";
+    }
+
+    @Override
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
                 from("direct:start")
                     // no // slash in uri should still work
-                    .to("ahc:http:localhost:{{port}}/foo")
+                    .to(getAhcEndpointUri())
                     .to("mock:result");
 
-                from("jetty:http://localhost:{{port}}/foo")
+                from(getTestServerEndpointUri())
                         .transform(constant("Bye World"));
             }
         };

Modified: camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceGetTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceGetTest.java?rev=1151849&r1=1151848&r2=1151849&view=diff
==============================================================================
--- camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceGetTest.java (original)
+++ camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceGetTest.java Thu Jul 28 13:52:55 2011
@@ -42,7 +42,7 @@ public class AhcProduceGetTest extends B
 
     @Test
     public void testAhcProduceDirectly() throws Exception {
-        Object out = template.requestBody("ahc:http://localhost:{{port}}/foo", null, String.class);
+        Object out = template.requestBody(getAhcEndpointUri(), null, String.class);
         assertEquals("Bye World", out);
     }
 
@@ -61,10 +61,10 @@ public class AhcProduceGetTest extends B
             @Override
             public void configure() throws Exception {
                 from("direct:start")
-                    .to("ahc:http://localhost:{{port}}/foo")
+                    .to(getAhcEndpointUri())
                     .to("mock:result");
 
-                from("jetty:http://localhost:{{port}}/foo")
+                from(getTestServerEndpointUri())
                         .transform(constant("Bye World"));
             }
         };

Modified: camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceNoThrowExceptionOnFailureTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceNoThrowExceptionOnFailureTest.java?rev=1151849&r1=1151848&r2=1151849&view=diff
==============================================================================
--- camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceNoThrowExceptionOnFailureTest.java (original)
+++ camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceNoThrowExceptionOnFailureTest.java Thu Jul 28 13:52:55 2011
@@ -32,6 +32,11 @@ public class AhcProduceNoThrowExceptionO
 
         assertMockEndpointsSatisfied();
     }
+    
+    @Override
+    protected String getAhcEndpointUri() {
+        return super.getAhcEndpointUri() + "?throwExceptionOnFailure=false";
+    }
 
     @Override
     protected RouteBuilder createRouteBuilder() throws Exception {
@@ -39,10 +44,10 @@ public class AhcProduceNoThrowExceptionO
             @Override
             public void configure() throws Exception {
                 from("direct:start")
-                    .to("ahc:http://localhost:{{port}}/foo?throwExceptionOnFailure=false")
+                    .to(getAhcEndpointUri())
                     .to("mock:result");
 
-                from("jetty:http://localhost:{{port}}/foo")
+                from(getTestServerEndpointUri())
                         .process(new Processor() {
                             public void process(Exchange exchange) throws Exception {
                                 exchange.getOut().setHeader(Exchange.HTTP_RESPONSE_CODE, 500);

Modified: camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProducePostHeadersTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProducePostHeadersTest.java?rev=1151849&r1=1151848&r2=1151849&view=diff
==============================================================================
--- camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProducePostHeadersTest.java (original)
+++ camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProducePostHeadersTest.java Thu Jul 28 13:52:55 2011
@@ -48,10 +48,10 @@ public class AhcProducePostHeadersTest e
             @Override
             public void configure() throws Exception {
                 from("direct:start")
-                    .to("ahc:http://localhost:{{port}}/foo")
+                    .to(getAhcEndpointUri())
                     .to("mock:result");
 
-                from("jetty:http://localhost:{{port}}/foo")
+                from(getTestServerEndpointUri())
                         .transform(simple("Bye ${body}"));
             }
         };

Modified: camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProducePostTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProducePostTest.java?rev=1151849&r1=1151848&r2=1151849&view=diff
==============================================================================
--- camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProducePostTest.java (original)
+++ camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProducePostTest.java Thu Jul 28 13:52:55 2011
@@ -42,7 +42,7 @@ public class AhcProducePostTest extends 
 
     @Test
     public void testAhcProduceDirectly() throws Exception {
-        Object out = template.requestBody("ahc:http://localhost:{{port}}/foo", "World", String.class);
+        Object out = template.requestBody(getAhcEndpointUri(), "World", String.class);
         assertEquals("Bye World", out);
     }
 
@@ -61,10 +61,10 @@ public class AhcProducePostTest extends 
             @Override
             public void configure() throws Exception {
                 from("direct:start")
-                    .to("ahc:http://localhost:{{port}}/foo")
+                    .to(getAhcEndpointUri())
                     .to("mock:result");
 
-                from("jetty:http://localhost:{{port}}/foo")
+                from(getTestServerEndpointUri())
                         .transform(simple("Bye ${body}"));
             }
         };

Added: camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceSSLContextParametersGetTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceSSLContextParametersGetTest.java?rev=1151849&view=auto
==============================================================================
--- camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceSSLContextParametersGetTest.java (added)
+++ camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceSSLContextParametersGetTest.java Thu Jul 28 13:52:55 2011
@@ -0,0 +1,34 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.ahc;
+
+
+public class AhcProduceSSLContextParametersGetTest extends AhcProduceGetTest {
+
+    protected String getTestServerEndpointUri() {
+        return super.getTestServerEndpointUri() + "?sslContextParametersRef=sslContextParameters";
+    }
+    
+    protected String getAhcEndpointUri() {
+        return super.getAhcEndpointUri() + "?sslContextParameters=#sslContextParameters";
+    }
+
+    @Override
+    protected boolean isHttps() {
+        return true;
+    }
+}

Propchange: camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceSSLContextParametersGetTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceTransferExceptionTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceTransferExceptionTest.java?rev=1151849&r1=1151848&r2=1151849&view=diff
==============================================================================
--- camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceTransferExceptionTest.java (original)
+++ camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceTransferExceptionTest.java Thu Jul 28 13:52:55 2011
@@ -39,15 +39,25 @@ public class AhcProduceTransferException
     }
 
     @Override
+    protected String getTestServerEndpointUri() {
+        return super.getTestServerEndpointUri() + "?transferException=true";
+    }
+
+    @Override
+    protected String getAhcEndpointUri() {
+        return super.getAhcEndpointUri()  + "?transferException=true";
+    }
+
+    @Override
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
                 from("direct:start")
-                    .to("ahc:http://localhost:{{port}}/foo?transferException=true")
+                    .to(getAhcEndpointUri())
                     .to("mock:result");
 
-                from("jetty:http://localhost:{{port}}/foo?transferException=true")
+                from(getTestServerEndpointUri())
                     .throwException(new MyOrderException("123"));
             }
         };

Added: camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceWithClientConfigUriParametersTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceWithClientConfigUriParametersTest.java?rev=1151849&view=auto
==============================================================================
--- camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceWithClientConfigUriParametersTest.java (added)
+++ camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceWithClientConfigUriParametersTest.java Thu Jul 28 13:52:55 2011
@@ -0,0 +1,62 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.ahc;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.junit.Test;
+
+public class AhcProduceWithClientConfigUriParametersTest extends BaseAhcTest {
+    @Test
+    public void testAhcProduceClientConfig() throws Exception {
+        getMockEndpoint("mock:result").expectedBodiesReceived("Bye World");
+
+        template.sendBody("direct:start", null);
+
+        assertMockEndpointsSatisfied();
+    }
+    
+    @Override
+    protected String getAhcEndpointUri() {
+        return super.getAhcEndpointUri() + "?clientConfig.maxRequestRetry=3&clientConfig.followRedirects=true";
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start")
+                    .to(getAhcEndpointUri())
+                    .to("mock:result");
+
+                from(getTestServerEndpointUri())
+                        .process(new Processor() {
+                            public void process(Exchange exchange) throws Exception {
+                                // redirect to test the client config worked as we told it to follow redirects
+                                exchange.getOut().setHeader(Exchange.HTTP_RESPONSE_CODE, "301");
+                                exchange.getOut().setHeader("Location", getTestServerEndpointTwoUrl());
+                            }
+                        });
+
+                from(getTestServerEndpointTwoUri())
+                        .transform(constant("Bye World"));
+            }
+        };
+    }
+}

Propchange: camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProduceWithClientConfigUriParametersTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProducerTwoParametersWithSameKeyTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProducerTwoParametersWithSameKeyTest.java?rev=1151849&r1=1151848&r2=1151849&view=diff
==============================================================================
--- camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProducerTwoParametersWithSameKeyTest.java (original)
+++ camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/AhcProducerTwoParametersWithSameKeyTest.java Thu Jul 28 13:52:55 2011
@@ -38,7 +38,7 @@ public class AhcProducerTwoParametersWit
         assertEquals("OK", out.getOut().getBody(String.class));
         assertEquals("yes", out.getOut().getHeader("bar"));
 
-        List foo = out.getOut().getHeader("foo", List.class);
+        List<?> foo = out.getOut().getHeader("foo", List.class);
         assertNotNull(foo);
         assertEquals(2, foo.size());
         assertEquals("123", foo.get(0));
@@ -63,7 +63,7 @@ public class AhcProducerTwoParametersWit
         assertEquals("OK", out.getOut().getBody(String.class));
         assertEquals("yes", out.getOut().getHeader("bar"));
 
-        List foo = out.getOut().getHeader("foo", List.class);
+        List<?> foo = out.getOut().getHeader("foo", List.class);
         assertNotNull(foo);
         assertEquals(2, foo.size());
         assertEquals("123", foo.get(0));
@@ -80,7 +80,7 @@ public class AhcProducerTwoParametersWit
                         String from = exchange.getIn().getHeader("from", String.class);
                         assertEquals("me", from);
 
-                        List to = exchange.getIn().getHeader("to", List.class);
+                        List<?> to = exchange.getIn().getHeader("to", List.class);
                         assertNotNull(to);
                         assertEquals(2, to.size());
                         assertEquals("foo", to.get(0));

Modified: camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/BaseAhcTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/BaseAhcTest.java?rev=1151849&r1=1151848&r2=1151849&view=diff
==============================================================================
--- camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/BaseAhcTest.java (original)
+++ camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/BaseAhcTest.java Thu Jul 28 13:52:55 2011
@@ -26,13 +26,19 @@ import org.apache.camel.converter.IOConv
 import org.apache.camel.impl.JndiRegistry;
 import org.apache.camel.test.AvailablePortFinder;
 import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.camel.util.jsse.ClientAuthentication;
+import org.apache.camel.util.jsse.KeyManagersParameters;
+import org.apache.camel.util.jsse.KeyStoreParameters;
+import org.apache.camel.util.jsse.SSLContextParameters;
+import org.apache.camel.util.jsse.SSLContextServerParameters;
+import org.apache.camel.util.jsse.TrustManagersParameters;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 
-/**
- *
- */
-public class BaseAhcTest extends CamelTestSupport {
+public abstract class BaseAhcTest extends CamelTestSupport {
+    
+    protected static final String KEY_STORE_PASSWORD = "changeit";
+    
     private static volatile int port;
 
     @BeforeClass
@@ -50,6 +56,7 @@ public class BaseAhcTest extends CamelTe
             // use next port
             port++;
         }
+
     }
 
     @AfterClass
@@ -80,9 +87,86 @@ public class BaseAhcTest extends CamelTe
         Properties prop = new Properties();
         prop.setProperty("port", "" + getPort());
         jndi.bind("prop", prop);
+        
+        if (isHttps()) {
+            addSslContextParametersToRegistry(jndi);
+        }
 
         return jndi;
     }
+    
+    protected void addSslContextParametersToRegistry(JndiRegistry registry) {
+        KeyStoreParameters ksp = new KeyStoreParameters();
+        ksp.setResource(this.getClass().getClassLoader().getResource("jsse/localhost.ks").toString());
+        ksp.setPassword(KEY_STORE_PASSWORD);
+
+        KeyManagersParameters kmp = new KeyManagersParameters();
+        kmp.setKeyPassword(KEY_STORE_PASSWORD);
+        kmp.setKeyStore(ksp);
+
+        TrustManagersParameters tmp = new TrustManagersParameters();
+        tmp.setKeyStore(ksp);
+
+        // NOTE: Needed since the client uses a loose trust configuration when no ssl context
+        // is provided.  We turn on client-auth to ensure that the tests onlt pass when
+        // the client is configured explicitly.
+        SSLContextServerParameters scsp = new SSLContextServerParameters();
+        scsp.setClientAuthentication(ClientAuthentication.REQUIRE.name());
+        
+        SSLContextParameters sslContextParameters = new SSLContextParameters();
+        sslContextParameters.setKeyManagers(kmp);
+        sslContextParameters.setTrustManagers(tmp);
+        sslContextParameters.setServerParameters(scsp);
+
+        registry.bind("sslContextParameters", sslContextParameters);
+    }
+    
+    /**
+     * Indicates if the URIs returned from {@link #getTestServerEndpointUri()} and
+     * {@link #getAhcEndpointUri()} should use the HTTPS protocol instead of
+     * the HTTP protocol.
+     * 
+     * If true, an {@link SSLContextParameters} is also placed in the registry under the
+     * key {@code sslContextParameters}.  The parameters are not added to the endpoint URIs
+     * as that is test specific.
+     * 
+     * @return false by default
+     */
+    protected boolean isHttps() {
+        return false;
+    }
+    
+    protected String getProtocol() {
+        String protocol = "http";
+        if (isHttps()) {
+            protocol = protocol + "s";
+        }
+        
+        return protocol;
+    }
+    
+    protected String getTestServerEndpointUrl() {
+        return getProtocol() + "://localhost:{{port}}/foo";
+    }
+    
+    protected String getTestServerEndpointUri() {
+        return "jetty:" + getTestServerEndpointUrl();
+    }
+    
+    protected String getTestServerEndpointTwoUrl() {
+        // Don't use the property placeholder here since we use the value outside of a
+        // field that supports the placeholders.
+        return getProtocol() + "://localhost:" + getPort() + "/bar";
+    }
+    
+    protected String getTestServerEndpointTwoUri() {
+        
+        return "jetty:" + getTestServerEndpointTwoUrl();
+    }
+    
+    protected String getAhcEndpointUri() {
+        return "ahc:" + getProtocol() + "://localhost:{{port}}/foo";
+    }
 
     protected int getNextPort() {
         port = AvailablePortFinder.getNextAvailable(port + 1);
@@ -92,6 +176,4 @@ public class BaseAhcTest extends CamelTe
     protected int getPort() {
         return port;
     }
-
 }
-

Modified: camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/MyOrderException.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/MyOrderException.java?rev=1151849&r1=1151848&r2=1151849&view=diff
==============================================================================
--- camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/MyOrderException.java (original)
+++ camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/MyOrderException.java Thu Jul 28 13:52:55 2011
@@ -23,6 +23,8 @@ import java.io.Serializable;
  */
 public class MyOrderException extends Exception implements Serializable {
 
+    private static final long serialVersionUID = 1L;
+    
     private final String orderId;
 
     public MyOrderException(String orderId) {

Modified: camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/javabody/AhcProduceJavaBodyTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/javabody/AhcProduceJavaBodyTest.java?rev=1151849&r1=1151848&r2=1151849&view=diff
==============================================================================
--- camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/javabody/AhcProduceJavaBodyTest.java (original)
+++ camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/javabody/AhcProduceJavaBodyTest.java Thu Jul 28 13:52:55 2011
@@ -38,7 +38,7 @@ public class AhcProduceJavaBodyTest exte
         context.addRoutes(new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                from("jetty:http://localhost:{{port}}/myapp/myservice")
+                from(getTestServerEndpointUri())
                         .process(new Processor() {
                             public void process(Exchange exchange) throws Exception {
                                 MyCoolBean cool = exchange.getIn().getBody(MyCoolBean.class);
@@ -58,7 +58,7 @@ public class AhcProduceJavaBodyTest exte
 
         MyCoolBean cool = new MyCoolBean(123, "Camel");
 
-        String reply = template.requestBodyAndHeader("ahc:http:localhost:{{port}}/myapp/myservice", cool,
+        String reply = template.requestBodyAndHeader(getAhcEndpointUri(), cool,
                 Exchange.CONTENT_TYPE, AhcConstants.CONTENT_TYPE_JAVA_SERIALIZED_OBJECT, String.class);
 
         assertEquals("OK", reply);
@@ -69,7 +69,7 @@ public class AhcProduceJavaBodyTest exte
         context.addRoutes(new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                from("jetty:http://localhost:{{port}}/myapp/myservice")
+                from(getTestServerEndpointUri())
                         .process(new Processor() {
                             public void process(Exchange exchange) throws Exception {
                                 MyCoolBean cool = exchange.getIn().getBody(MyCoolBean.class);
@@ -89,7 +89,7 @@ public class AhcProduceJavaBodyTest exte
 
         MyCoolBean cool = new MyCoolBean(123, "Camel");
 
-        MyCoolBean reply = template.requestBodyAndHeader("ahc:http://localhost:{{port}}/myapp/myservice", cool,
+        MyCoolBean reply = template.requestBodyAndHeader(getAhcEndpointUri(), cool,
                 Exchange.CONTENT_TYPE, AhcConstants.CONTENT_TYPE_JAVA_SERIALIZED_OBJECT, MyCoolBean.class);
 
         assertEquals(456, reply.getId());
@@ -101,7 +101,7 @@ public class AhcProduceJavaBodyTest exte
         context.addRoutes(new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                from("jetty:http://localhost:{{port}}/myapp/myservice")
+                from(getTestServerEndpointUri())
                         .process(new Processor() {
                             public void process(Exchange exchange) throws Exception {
                                 String body = exchange.getIn().getBody(String.class);
@@ -117,7 +117,7 @@ public class AhcProduceJavaBodyTest exte
         });
         context.start();
 
-        MyCoolBean reply = template.requestBody("ahc:http://localhost:{{port}}/myapp/myservice", "Hello World", MyCoolBean.class);
+        MyCoolBean reply = template.requestBody(getAhcEndpointUri(), "Hello World", MyCoolBean.class);
 
         assertEquals(456, reply.getId());
         assertEquals("Camel rocks", reply.getName());

Modified: camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/javabody/MyCoolBean.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/javabody/MyCoolBean.java?rev=1151849&r1=1151848&r2=1151849&view=diff
==============================================================================
--- camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/javabody/MyCoolBean.java (original)
+++ camel/trunk/components/camel-ahc/src/test/java/org/apache/camel/component/ahc/javabody/MyCoolBean.java Thu Jul 28 13:52:55 2011
@@ -23,6 +23,7 @@ import java.io.Serializable;
  */
 public class MyCoolBean implements Serializable {
 
+    private static final long serialVersionUID = 1L;
     private final int id;
     private final String name;
 

Added: camel/trunk/components/camel-ahc/src/test/resources/jsse/localhost.ks
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ahc/src/test/resources/jsse/localhost.ks?rev=1151849&view=auto
==============================================================================
Binary file - no diff available.

Propchange: camel/trunk/components/camel-ahc/src/test/resources/jsse/localhost.ks
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: camel/trunk/parent/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/parent/pom.xml?rev=1151849&r1=1151848&r2=1151849&view=diff
==============================================================================
--- camel/trunk/parent/pom.xml (original)
+++ camel/trunk/parent/pom.xml Thu Jul 28 13:52:55 2011
@@ -37,7 +37,7 @@
     <abdera-version>1.1.2</abdera-version>
     <!-- Note that activemq dependency is only used for testing! -->
     <activemq-version>5.5.0</activemq-version>
-    <ahc-version>1.6.3</ahc-version>
+    <ahc-version>1.6.4</ahc-version>
     <apacheds-version>1.5.7</apacheds-version>
     <aries-blueprint-version>0.3</aries-blueprint-version>
     <atomikos-trascations-version>3.7.0</atomikos-trascations-version>