camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cschnei...@apache.org
Subject camel git commit: Prepare tests for jetty 9
Date Thu, 11 Dec 2014 16:41:55 GMT
Repository: camel
Updated Branches:
  refs/heads/master 906985f07 -> c840f1f47


Prepare tests for jetty 9


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

Branch: refs/heads/master
Commit: c840f1f4784a6a202e6c0c9757296a0043578f10
Parents: 906985f
Author: Christian Schneider <chris@die-schneider.net>
Authored: Thu Dec 11 17:41:46 2014 +0100
Committer: Christian Schneider <chris@die-schneider.net>
Committed: Thu Dec 11 17:41:46 2014 +0100

----------------------------------------------------------------------
 .../camel/component/jetty/BaseJettyTest.java    | 23 +++++++++++++++++++-
 ...HttpsRouteAddSslConnectorPropertiesTest.java | 11 ++--------
 ...outeSslContextParametersInComponentTest.java |  6 +----
 ...HttpsRouteSslContextParametersInUriTest.java |  9 +-------
 .../jetty/JettyResponseBodyWhenErrorTest.java   |  2 +-
 5 files changed, 27 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/c840f1f4/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 1379e36..7d7e9d1 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
@@ -68,6 +68,20 @@ public abstract class BaseJettyTest extends CamelTestSupport {
         return AvailablePortFinder.getNextAvailable(startWithPort);
     }
 
+    public void setSSLProps(JettyHttpComponent jetty, String path, String keyStorePasswd,
String keyPasswd) {
+        if (jettyVersion() == 9) {
+            jetty.addSslSocketConnectorProperty("keyStorePassword", keyStorePasswd);
+            jetty.addSslSocketConnectorProperty("keyManagerPassword", keyPasswd);
+            jetty.addSslSocketConnectorProperty("keyStorePath", path);
+            jetty.addSslSocketConnectorProperty("trustStoreType", "JKS");
+        } else {
+            jetty.addSslSocketConnectorProperty("password", keyStorePasswd);
+            jetty.addSslSocketConnectorProperty("keyPassword", keyPasswd);
+            jetty.addSslSocketConnectorProperty("keystore", path);
+            jetty.addSslSocketConnectorProperty("truststoreType", "JKS");
+        }
+    }
+
     protected static int getPort() {
         return port;
     }
@@ -76,5 +90,12 @@ public abstract class BaseJettyTest extends CamelTestSupport {
         return port2;
     }
 
-
+    public int jettyVersion() {
+        try {
+            this.getClass().getClassLoader().loadClass("org.eclipse.jetty.server.ssl.SslSelectChannelConnector");
+            return 8;
+        } catch (ClassNotFoundException e) {
+            return 9;
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/c840f1f4/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpsRouteAddSslConnectorPropertiesTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpsRouteAddSslConnectorPropertiesTest.java
b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpsRouteAddSslConnectorPropertiesTest.java
index 6b3671e..395a7cb 100644
--- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpsRouteAddSslConnectorPropertiesTest.java
+++ b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpsRouteAddSslConnectorPropertiesTest.java
@@ -34,16 +34,8 @@ public class HttpsRouteAddSslConnectorPropertiesTest extends HttpsRouteTest
{
                 URL keyStoreUrl = this.getClass().getClassLoader().getResource("jsse/localhost.ks");
                 String path = keyStoreUrl.toURI().getPath();
 
-                // create jetty component
                 JettyHttpComponent jetty = new JettyHttpComponent();
-
-                // add SSL properties
-                jetty.addSslSocketConnectorProperty("keyPassword", pwd);
-                jetty.addSslSocketConnectorProperty("password", pwd);
-                jetty.addSslSocketConnectorProperty("keystore", path);
-                jetty.addSslSocketConnectorProperty("truststoreType", "JKS");
-
-                // add jetty to camel context
+                setSSLProps(jetty, path, pwd, pwd);
                 context.addComponent("jetty", jetty);
                 // END SNIPPET: e1
 
@@ -58,6 +50,7 @@ public class HttpsRouteAddSslConnectorPropertiesTest extends HttpsRouteTest
{
 
                 from("jetty:https://localhost:" + port2 + "/test").to("mock:b");
             }
+
         };
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/c840f1f4/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpsRouteSslContextParametersInComponentTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpsRouteSslContextParametersInComponentTest.java
b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpsRouteSslContextParametersInComponentTest.java
index 40e4148..9850e02 100644
--- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpsRouteSslContextParametersInComponentTest.java
+++ b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpsRouteSslContextParametersInComponentTest.java
@@ -45,12 +45,8 @@ public class HttpsRouteSslContextParametersInComponentTest extends HttpsRouteTes
                 SSLContextParameters sslContextParameters = new SSLContextParameters();
                 sslContextParameters.setKeyManagers(kmp);
                 jetty.setSslContextParameters(sslContextParameters);
-                
                 // NOTE: These are here to check that they are properly ignored.
-                jetty.addSslSocketConnectorProperty("keyPassword", "sadfasdfasdfas");
-                jetty.addSslSocketConnectorProperty("password", "asdfasdfasdfdasfs");
-                jetty.addSslSocketConnectorProperty("keystore", "");
-                jetty.addSslSocketConnectorProperty("truststoreType", "JKS");
+                setSSLProps(jetty, "", "asdfasdfasdfdasfs", "sadfasdfasdfas");
 
                 // add jetty to camel context
                 context.addComponent("jetty", jetty);

http://git-wip-us.apache.org/repos/asf/camel/blob/c840f1f4/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpsRouteSslContextParametersInUriTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpsRouteSslContextParametersInUriTest.java
b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpsRouteSslContextParametersInUriTest.java
index a9e09c7..00c4dfc 100644
--- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpsRouteSslContextParametersInUriTest.java
+++ b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpsRouteSslContextParametersInUriTest.java
@@ -51,16 +51,9 @@ public class HttpsRouteSslContextParametersInUriTest extends HttpsRouteTest
{
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             public void configure() throws URISyntaxException {
-                // create jetty component
                 JettyHttpComponent jetty = new JettyHttpComponent();
-                
                 // NOTE: These are here to check that they are properly ignored.
-                jetty.addSslSocketConnectorProperty("keyPassword", "sadfasdfasdfas");
-                jetty.addSslSocketConnectorProperty("password", "asdfasdfasdfdasfs");
-                jetty.addSslSocketConnectorProperty("keystore", "");
-                jetty.addSslSocketConnectorProperty("truststoreType", "JKS");
-
-                // add jetty to camel context
+                setSSLProps(jetty, "", "asdfasdfasdfdasfs", "sadfasdfasdfas");
                 context.addComponent("jetty", jetty);
 
                 from("jetty:https://localhost:" + port1 + "/test?sslContextParametersRef=sslContextParameters").to("mock:a");

http://git-wip-us.apache.org/repos/asf/camel/blob/c840f1f4/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyResponseBodyWhenErrorTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyResponseBodyWhenErrorTest.java
b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyResponseBodyWhenErrorTest.java
index c90e295..80de7d6 100644
--- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyResponseBodyWhenErrorTest.java
+++ b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyResponseBodyWhenErrorTest.java
@@ -34,7 +34,7 @@ public class JettyResponseBodyWhenErrorTest extends BaseJettyTest {
             template.requestBody("http://localhost:{{port}}/myapp/myservice", "bookid=123");
             fail("Should have thrown an exception");
         } catch (RuntimeCamelException e) {
-            HttpOperationFailedException cause = (HttpOperationFailedException) e.getCause();
+            HttpOperationFailedException cause = assertThrowable(HttpOperationFailedException.class,
e.getCause());
             assertEquals(500, cause.getStatusCode());
             String body = context.getTypeConverter().convertTo(String.class, cause.getResponseBody());
             assertTrue(body.indexOf("Damm") > -1);


Mime
View raw message