camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cschnei...@apache.org
Subject [1/2] camel git commit: Make sure tests work for jetty 8
Date Tue, 13 Jan 2015 13:41:53 GMT
Repository: camel
Updated Branches:
  refs/heads/temp-jetty9 95fc3e928 -> 85c890f73


http://git-wip-us.apache.org/repos/asf/camel/blob/85c890f7/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/BaseJettyTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/BaseJettyTest.java
b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/BaseJettyTest.java
index 365b1fa..aeb196f 100644
--- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/BaseJettyTest.java
+++ b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/BaseJettyTest.java
@@ -115,4 +115,5 @@ public abstract class BaseJettyTest extends CamelTestSupport {
         String majorVersion = Server.getVersion().split("\\.")[0];
         return "8".equals(majorVersion);
     }
+
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/85c890f7/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/ExplicitHttpsRouteTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/ExplicitHttpsRouteTest.java
b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/ExplicitHttpsRouteTest.java
index e5f1e2a..179f18c 100644
--- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/ExplicitHttpsRouteTest.java
+++ b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/ExplicitHttpsRouteTest.java
@@ -24,20 +24,22 @@ import java.util.Map;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
-import org.eclipse.jetty.util.ssl.SslContextFactory;
+import org.eclipse.jetty.server.Connector;
+import org.eclipse.jetty.server.ssl.SslSelectChannelConnector;
 
 public class ExplicitHttpsRouteTest extends HttpsRouteTest {
 
     // START SNIPPET: e2
-    private SslContextFactory createSslContextFactory(int port) throws URISyntaxException
{
+    private Connector createSslSocketConnector(int port) throws URISyntaxException {
         // From Camel 2.5.0 Camel-Jetty is using SslSelectChannelConnector instead of SslSocketConnector
-        SslContextFactory sslContextFactory = new SslContextFactory();
-        sslContextFactory.setKeyManagerPassword(pwd);
-        sslContextFactory.setKeyStorePassword(pwd);
+        SslSelectChannelConnector sslSocketConnector = new SslSelectChannelConnector();
+        sslSocketConnector.getSslContextFactory().setKeyManagerPassword(pwd);
+        sslSocketConnector.getSslContextFactory().setKeyStorePassword(pwd);
         URL keyStoreUrl = this.getClass().getClassLoader().getResource("jsse/localhost.ks");
-        sslContextFactory.setKeyStorePath(keyStoreUrl.toURI().getPath());
-        sslContextFactory.setTrustStoreType("JKS");
-        return sslContextFactory;
+        sslSocketConnector.getSslContextFactory().setKeyStorePath(keyStoreUrl.toURI().getPath());
+        sslSocketConnector.getSslContextFactory().setTrustStoreType("JKS");
+        sslSocketConnector.setPort(port);
+        return sslSocketConnector;
     }
     // END SNIPPET: e2
 
@@ -47,9 +49,9 @@ public class ExplicitHttpsRouteTest extends HttpsRouteTest {
             public void configure() throws URISyntaxException {
                 // START SNIPPET: e1
                 // create SSL select channel connectors for port 9080 and 9090
-                Map<Integer, SslContextFactory> connectors = new HashMap<Integer,
SslContextFactory>();
-                connectors.put(port1, createSslContextFactory(port1));
-                connectors.put(port2, createSslContextFactory(port2));
+                Map<Integer, Connector> connectors = new HashMap<Integer, Connector>();
+                connectors.put(port1, createSslSocketConnector(port1));
+                connectors.put(port2, createSslSocketConnector(port2));
 
                 JettyHttpComponent jetty = getContext().getComponent("jetty", JettyHttpComponent.class);
                 jetty.setSslSocketConnectors(connectors);

http://git-wip-us.apache.org/repos/asf/camel/blob/85c890f7/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/ExplicitHttpsSslContextParametersRouteTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/ExplicitHttpsSslContextParametersRouteTest.java
b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/ExplicitHttpsSslContextParametersRouteTest.java
index 2c0151f..0bec7d1 100644
--- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/ExplicitHttpsSslContextParametersRouteTest.java
+++ b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/ExplicitHttpsSslContextParametersRouteTest.java
@@ -19,18 +19,20 @@ package org.apache.camel.component.jetty;
 import java.util.HashMap;
 import java.util.Map;
 
+import org.apache.camel.CamelContext;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.util.jsse.KeyManagersParameters;
 import org.apache.camel.util.jsse.KeyStoreParameters;
 import org.apache.camel.util.jsse.SSLContextParameters;
-import org.eclipse.jetty.util.ssl.SslContextFactory;
+import org.eclipse.jetty.server.Connector;
+import org.eclipse.jetty.server.ssl.SslSelectChannelConnector;
 
 public class ExplicitHttpsSslContextParametersRouteTest extends HttpsRouteTest {
 
     // START SNIPPET: e2
-    private SslContextFactory createSslSocketConnector() throws Exception {
+    private Connector createSslSocketConnector(CamelContext context, int port) throws Exception
{
         KeyStoreParameters ksp = new KeyStoreParameters();
         ksp.setResource(this.getClass().getClassLoader().getResource("jsse/localhost.ks").toString());
         ksp.setPassword(pwd);
@@ -42,10 +44,12 @@ public class ExplicitHttpsSslContextParametersRouteTest extends HttpsRouteTest
{
         SSLContextParameters sslContextParameters = new SSLContextParameters();
         sslContextParameters.setKeyManagers(kmp);
         
-        SslContextFactory sslContextFactory = new SslContextFactory();
-        sslContextFactory.setSslContext(sslContextParameters.createSSLContext());
-
-        return sslContextFactory;
+        // From Camel 2.5.0 Camel-Jetty is using SslSelectChannelConnector instead of SslSocketConnector
+        SslSelectChannelConnector sslSocketConnector = new SslSelectChannelConnector();
+        sslSocketConnector.getSslContextFactory().setSslContext(sslContextParameters.createSSLContext());
+        sslSocketConnector.setPort(port);
+        
+        return sslSocketConnector;
     }
     // END SNIPPET: e2
 
@@ -55,9 +59,9 @@ public class ExplicitHttpsSslContextParametersRouteTest extends HttpsRouteTest
{
             public void configure() throws Exception {
                 // START SNIPPET: e1
                 // create SSL select channel connectors for port 9080 and 9090
-                Map<Integer, SslContextFactory> connectors = new HashMap<Integer,
SslContextFactory>();
-                connectors.put(port1, createSslSocketConnector());
-                connectors.put(port2, createSslSocketConnector());
+                Map<Integer, Connector> connectors = new HashMap<Integer, Connector>();
+                connectors.put(port1, createSslSocketConnector(getContext(), port1));
+                connectors.put(port2, createSslSocketConnector(getContext(), port2));
 
                 JettyHttpComponent jetty = getContext().getComponent("jetty", JettyHttpComponent.class);
                 jetty.setSslSocketConnectors(connectors);

http://git-wip-us.apache.org/repos/asf/camel/blob/85c890f7/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpProducerSendEmptyHeaderTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpProducerSendEmptyHeaderTest.java
b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpProducerSendEmptyHeaderTest.java
index c27cf52..10b795c 100644
--- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpProducerSendEmptyHeaderTest.java
+++ b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpProducerSendEmptyHeaderTest.java
@@ -45,7 +45,7 @@ public class HttpProducerSendEmptyHeaderTest extends BaseJettyTest {
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                from("jetty:http://localhost:{{port}}/myapp/mytest?allowNullValues=true")
+                from("jetty:http://localhost:{{port}}/myapp/mytest")
                     .convertBodyTo(String.class)
                     .to("mock:result");
             }

http://git-wip-us.apache.org/repos/asf/camel/blob/85c890f7/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpsRouteAliasTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpsRouteAliasTest.java
b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpsRouteAliasTest.java
index 1c55fd9..1c99e5d 100644
--- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpsRouteAliasTest.java
+++ b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpsRouteAliasTest.java
@@ -46,6 +46,7 @@ public class HttpsRouteAliasTest extends HttpsRouteTest {
                 
                 // Specify "server" cert alias
                 sslContextParameters.setCertAlias("server");
+                
                 jetty.setSslContextParameters(sslContextParameters);
                 
                 setSSLProps(jetty, "", "asdfasdfasdfdasfs", "sadfasdfasdfas");

http://git-wip-us.apache.org/repos/asf/camel/blob/85c890f7/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpsRouteWithSslConnectorPropertiesTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpsRouteWithSslConnectorPropertiesTest.java
b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpsRouteWithSslConnectorPropertiesTest.java
index 6c11866..b85bd61 100644
--- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpsRouteWithSslConnectorPropertiesTest.java
+++ b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpsRouteWithSslConnectorPropertiesTest.java
@@ -18,6 +18,8 @@ package org.apache.camel.component.jetty;
 
 import java.net.URISyntaxException;
 import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
 
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;

http://git-wip-us.apache.org/repos/asf/camel/blob/85c890f7/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyHttpClientOptionsTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyHttpClientOptionsTest.java
b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyHttpClientOptionsTest.java
index 94b3a5a..a3325fa 100644
--- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyHttpClientOptionsTest.java
+++ b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyHttpClientOptionsTest.java
@@ -19,7 +19,7 @@ package org.apache.camel.component.jetty;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.http.HttpEndpoint;
 import org.apache.camel.component.http.HttpProducer;
-import org.eclipse.jetty.client.ProxyConfiguration.Proxy;
+import org.eclipse.jetty.client.HttpClient;
 import org.junit.Test;
 
 /**
@@ -46,18 +46,14 @@ public class JettyHttpClientOptionsTest extends BaseJettyTest {
         HttpEndpoint jettyEndpoint = context.getEndpoint("jetty://http://localhost:{{port}}/proxy/setting?proxyHost=192.168.0.1&proxyPort=9090",
HttpEndpoint.class);
         assertNotNull("Jetty endpoint should not be null ", jettyEndpoint);
         JettyHttpProducer producer = (JettyHttpProducer)jettyEndpoint.createProducer();
-        Proxy proxy = producer.getClient().getProxyConfiguration().getProxies().get(0);
-        assertEquals("Get the wrong http proxy host parameter", "192.168.0.1", proxy.getAddress().getHost());
-        assertEquals("Get the wrong http proxy port paramerter", 9090, proxy.getAddress().getPort());
-        
+        assertProxyAddress(producer.getClient(), "192.168.0.1", 9090);
+
         // setup the context properties
         context.getProperties().put("http.proxyHost", "192.168.0.2");
         context.getProperties().put("http.proxyPort", "8080");
         jettyEndpoint = context.getEndpoint("jetty://http://localhost:{{port}}/proxy2/setting",
HttpEndpoint.class);
         producer = (JettyHttpProducer)jettyEndpoint.createProducer();
-        proxy = producer.getClient().getProxyConfiguration().getProxies().get(0);
-        assertEquals("Get the wrong http proxy host parameter", "192.168.0.2", proxy.getAddress().getHost());
-        assertEquals("Get the wrong http proxy port paramerter", 8080, proxy.getAddress().getPort());
+        assertProxyAddress(producer.getClient(), "192.168.0.2", 8080);
         context.getProperties().clear();
 
     }
@@ -71,5 +67,12 @@ public class JettyHttpClientOptionsTest extends BaseJettyTest {
             }
         };
     }
+    
+    private void assertProxyAddress(HttpClient client, String expectedHost, int expectedPort)
{
+        //org.eclipse.jetty.client.Origin.Address address = client.getProxyConfiguration().getProxies().get(0).getAddress();
+        org.eclipse.jetty.client.Address address = client.getProxy();
+        assertEquals("Got the wrong http proxy host parameter", expectedHost, address.getHost());
+        assertEquals("Got the wrong http proxy port paramerter", expectedPort, address.getPort());
+    }
 
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/85c890f7/components/camel-jetty/src/test/resources/org/apache/camel/component/jetty/JettyComponentSpringConfiguredTest.xml
----------------------------------------------------------------------
diff --git a/components/camel-jetty/src/test/resources/org/apache/camel/component/jetty/JettyComponentSpringConfiguredTest.xml
b/components/camel-jetty/src/test/resources/org/apache/camel/component/jetty/JettyComponentSpringConfiguredTest.xml
index 0c3f98c..0809f5b 100644
--- a/components/camel-jetty/src/test/resources/org/apache/camel/component/jetty/JettyComponentSpringConfiguredTest.xml
+++ b/components/camel-jetty/src/test/resources/org/apache/camel/component/jetty/JettyComponentSpringConfiguredTest.xml
@@ -22,7 +22,7 @@
        http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
     ">
 
-	<bean id="jetty2" class="org.apache.camel.component.jetty9.JettyHttpComponent9">
+	<bean id="jetty2" class="org.apache.camel.component.jetty8.JettyHttpComponent8">
 		<property name="enableJmx" value="true"/>
 		<property name="minThreads" value="10"/>
 		<property name="maxThreads" value="50"/>

http://git-wip-us.apache.org/repos/asf/camel/blob/85c890f7/components/camel-jetty/src/test/resources/org/apache/camel/component/jetty/jetty-https.xml
----------------------------------------------------------------------
diff --git a/components/camel-jetty/src/test/resources/org/apache/camel/component/jetty/jetty-https.xml
b/components/camel-jetty/src/test/resources/org/apache/camel/component/jetty/jetty-https.xml
index c8e4ae4..b58cf77 100644
--- a/components/camel-jetty/src/test/resources/org/apache/camel/component/jetty/jetty-https.xml
+++ b/components/camel-jetty/src/test/resources/org/apache/camel/component/jetty/jetty-https.xml
@@ -21,7 +21,7 @@
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
     ">
-    <bean id="jetty" class="org.apache.camel.component.jetty9.JettyHttpComponent9">
+    <bean id="jetty" class="org.apache.camel.component.jetty8.JettyHttpComponent8">
         <property name="sslPassword" value="changeit"/>
         <property name="sslKeyPassword" value="changeit"/>
         <property name="keystore" value="src/test/resources/jsse/localhost.ks"/>


Mime
View raw message