You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2016/05/28 13:58:32 UTC
[1/4] camel git commit: Added documentation (and some minor
corrections)
Repository: camel
Updated Branches:
refs/heads/master 8a7e8fc7f -> 7c3beb5dc
Added documentation (and some minor corrections)
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/7c3beb5d
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/7c3beb5d
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/7c3beb5d
Branch: refs/heads/master
Commit: 7c3beb5dc1a78ad4be86650a40211b1ceb51ddc2
Parents: 37c4c0d
Author: Arno Noordover <an...@users.noreply.github.com>
Authored: Sat May 28 15:41:38 2016 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Sat May 28 15:55:54 2016 +0200
----------------------------------------------------------------------
components/camel-cxf/src/main/docs/cxf.adoc | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/7c3beb5d/components/camel-cxf/src/main/docs/cxf.adoc
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/main/docs/cxf.adoc b/components/camel-cxf/src/main/docs/cxf.adoc
index fdd17a1..925ada1 100644
--- a/components/camel-cxf/src/main/docs/cxf.adoc
+++ b/components/camel-cxf/src/main/docs/cxf.adoc
@@ -263,10 +263,16 @@ cases.
PhaseInterceptorChain skips logging the Fault that it catches.
|`cxfEndpointConfigurer` |No |New in *Camel 2.11*. This option could apply the implementation of
-`org.apache.camel.component.cxf.CxfEndpointConfigurer which `supports to
+`org.apache.camel.component.cxf.CxfEndpointConfigurer` which supports to
configure the CXF endpoint in �programmatic way. Since *Camel
-2.15.0,*user can configure the CXF server and client by implementing
-configure\{Server|Client} method of `CxfEndpointConfigurer`.
+2.15.0*,user can configure the CXF server and client by implementing
+configure\{Server/Client} method of `CxfEndpointConfigurer`.
+
+|`sslContextParameters` |No |New in *Camel 2.18.0*. This option can be use to reference a
+Camel SSL-context. You can reference the SSL-context by using the # convention.
+
+|`hostnameVerifier` |No |New in *Camel 2.18.0*. This option can be used to reference a
+HostnameVerifier from the registry using the # convention.
|`username` |No |New in *Camel 2.12.3* This option is used to set the basic
authentication information of username for the CXF client.
@@ -274,7 +280,7 @@ authentication information of username for the CXF client.
|`password` |No |New in *Camel 2.12.3* This option is used to set the basic
authentication information of password for the CXF client.
-|`continuationTimeout` |No |New in *Camel 2.14.0*This option is used to set the CXF continuation
+|`continuationTimeout` |No |New in *Camel 2.14.0*. This option is used to set the CXF continuation
timeout which could be used in CxfConsumer by default when the CXF
server is using Jetty or Servlet transport. (Before *Camel 2.14.0*,
CxfConsumer just set the continuation timeout to be 0, which means the
[3/4] camel git commit: Added unittest for new SSL-config (good trust,
no trust, wrong trust)
Posted by da...@apache.org.
Added unittest for new SSL-config (good trust, no trust, wrong trust)
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/37c4c0df
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/37c4c0df
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/37c4c0df
Branch: refs/heads/master
Commit: 37c4c0df05f3b6ed1a8cdbdbcd0c6ca86ded9bd5
Parents: 36be62e
Author: Arno Noordover <an...@users.noreply.github.com>
Authored: Sat May 28 10:37:57 2016 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Sat May 28 15:55:54 2016 +0200
----------------------------------------------------------------------
.../camel/component/cxf/CXFTestSupport.java | 2 +
.../apache/camel/component/cxf/GreeterImpl.java | 26 +++++
.../apache/camel/component/cxf/ssl/SslTest.java | 102 +++++++++++++++++++
.../camel/component/cxf/CxfSslContext.xml | 96 +++++++++++++++++
.../src/test/resources/ssl/keystore-server.jks | Bin 0 -> 2033 bytes
.../src/test/resources/ssl/keystore-wrong.jks | Bin 0 -> 2057 bytes
.../src/test/resources/ssl/keystores.txt | 7 ++
.../test/resources/ssl/truststore-client.jks | Bin 0 -> 743 bytes
.../src/test/resources/ssl/truststore-wrong.jks | Bin 0 -> 767 bytes
9 files changed, 233 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/37c4c0df/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFTestSupport.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFTestSupport.java b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFTestSupport.java
index de475a6..a40c2d8 100644
--- a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFTestSupport.java
+++ b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CXFTestSupport.java
@@ -32,6 +32,7 @@ public final class CXFTestSupport {
static final int PORT4 = AvailablePortFinder.getNextAvailable();
static final int PORT5 = AvailablePortFinder.getNextAvailable();
static final int PORT6 = AvailablePortFinder.getNextAvailable();
+ static final int SSL_PORT = AvailablePortFinder.getNextAvailable();
static {
//set them as system properties so Spring can use the property placeholder
@@ -42,6 +43,7 @@ public final class CXFTestSupport {
System.setProperty("CXFTestSupport.port4", Integer.toString(PORT4));
System.setProperty("CXFTestSupport.port5", Integer.toString(PORT5));
System.setProperty("CXFTestSupport.port6", Integer.toString(PORT6));
+ System.setProperty("CXFTestSupport.sslPort", Integer.toString(SSL_PORT));
System.setProperty("org.apache.cxf.transports.http_jetty.DontClosePort", "true");
}
http://git-wip-us.apache.org/repos/asf/camel/blob/37c4c0df/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/GreeterImpl.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/GreeterImpl.java b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/GreeterImpl.java
new file mode 100644
index 0000000..c2f05d7
--- /dev/null
+++ b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/GreeterImpl.java
@@ -0,0 +1,26 @@
+/**
+ * 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.cxf;
+
+public class GreeterImpl extends org.apache.hello_world_soap_http.GreeterImpl {
+
+ @Override
+ public String greetMe(String hi) {
+ return "Greet " + hi;
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/37c4c0df/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/ssl/SslTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/ssl/SslTest.java b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/ssl/SslTest.java
new file mode 100644
index 0000000..856858d
--- /dev/null
+++ b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/ssl/SslTest.java
@@ -0,0 +1,102 @@
+/**
+ * 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.cxf.ssl;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.ws.Endpoint;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.component.cxf.CXFTestSupport;
+import org.apache.camel.component.cxf.GreeterImpl;
+import org.apache.camel.component.cxf.common.message.CxfConstants;
+import org.apache.camel.test.spring.CamelSpringTestSupport;
+import org.apache.hello_world_soap_http.Greeter;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+import static org.hamcrest.core.Is.is;
+
+public class SslTest extends CamelSpringTestSupport {
+
+ protected static final String GREET_ME_OPERATION = "greetMe";
+ protected static final String TEST_MESSAGE = "Hello World!";
+ protected static final String JAXWS_SERVER_ADDRESS
+ = "https://localhost:" + CXFTestSupport.getPort1() + "/CxfSslTest/SoapContext/SoapPort";
+
+ @Override
+ public boolean isCreateCamelContextPerClass() {
+ return true;
+ }
+
+ @AfterClass
+ public static void cleanUp() {
+ //System.getProperties().remove("cxf.config.file");
+ }
+
+ @BeforeClass
+ public static void startService() {
+ //System.getProperties().put("cxf.config.file", "/org/apache/camel/component/cxf/CxfSslContext.xml");
+ //Greeter implementor = new GreeterImpl();
+ //Endpoint.publish(JAXWS_SERVER_ADDRESS, implementor);
+ }
+
+ @Test
+ public void testInvokingTrustRoute() throws Exception {
+ Exchange reply = sendJaxWsMessage("direct:trust");
+ assertFalse("We expect no exception here", reply.isFailed());
+ }
+
+ @Test
+ public void testInvokingNoTrustRoute() throws Exception {
+ Exchange reply = sendJaxWsMessage("direct:noTrust");
+ assertTrue("We expect the exception here", reply.isFailed());
+ Throwable e = reply.getException().getCause();
+ assertThat(e.getClass().getCanonicalName(), is("javax.net.ssl.SSLHandshakeException"));
+ }
+
+ @Test
+ public void testInvokingWrongTrustRoute() throws Exception {
+ Exchange reply = sendJaxWsMessage("direct:wrongTrust");
+ assertTrue("We expect the exception here", reply.isFailed());
+ Throwable e = reply.getException().getCause();
+ assertThat(e.getClass().getCanonicalName(), is("javax.net.ssl.SSLHandshakeException"));
+ }
+
+ protected Exchange sendJaxWsMessage(String endpointUri) throws InterruptedException {
+ Exchange exchange = template.send(endpointUri, new Processor() {
+ public void process(final Exchange exchange) {
+ final List<String> params = new ArrayList<String>();
+ params.add(TEST_MESSAGE);
+ exchange.getIn().setBody(params);
+ exchange.getIn().setHeader(CxfConstants.OPERATION_NAME, GREET_ME_OPERATION);
+ }
+ });
+ return exchange;
+ }
+
+ @Override
+ protected AbstractXmlApplicationContext createApplicationContext() {
+ // we can put the http conduit configuration here
+ return new ClassPathXmlApplicationContext("org/apache/camel/component/cxf/CxfSslContext.xml");
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/37c4c0df/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/CxfSslContext.xml
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/CxfSslContext.xml b/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/CxfSslContext.xml
new file mode 100644
index 0000000..4e9c339
--- /dev/null
+++ b/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/CxfSslContext.xml
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:cxf="http://camel.apache.org/schema/cxf"
+ xmlns:sec="http://cxf.apache.org/configuration/security"
+ xmlns:httpj="http://cxf.apache.org/transports/http-jetty/configuration"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://camel.apache.org/schema/cxf http://camel.apache.org/schema/cxf/camel-cxf.xsd
+ http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+ http://cxf.apache.org/configuration/security http://cxf.apache.org/schemas/configuration/security.xsd
+ http://cxf.apache.org/transports/http-jetty/configuration http://cxf.apache.org/schemas/configuration/http-jetty.xsd
+">
+
+ <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
+
+ <httpj:engine-factory bus="cxf">
+ <!-- you just need to specify the TLS Server configuration for the certain port -->
+ <httpj:engine port="${CXFTestSupport.sslPort}">
+ <httpj:tlsServerParameters>
+ <sec:keyManagers keyPassword="changeit">
+ <sec:keyStore type="JKS" password="changeit"
+ resource="/ssl/keystore-server.jks"/>
+ </sec:keyManagers>
+ <sec:clientAuthentication want="false" required="false"/>
+ </httpj:tlsServerParameters>
+ </httpj:engine>
+ </httpj:engine-factory>
+
+ <import resource="classpath:META-INF/cxf/cxf.xml"/>
+
+ <sslContextParameters xmlns="http://camel.apache.org/schema/spring"
+ id="wrongSslContext">
+ <trustManagers>
+ <keyStore type="JKS" resource="/ssl/truststore-wrong.jks"
+ password="changeit"/>
+ </trustManagers>
+ </sslContextParameters>
+ <sslContextParameters xmlns="http://camel.apache.org/schema/spring"
+ id="mySslContext">
+ <trustManagers>
+ <keyStore type="JKS" resource="/ssl/truststore-client.jks"
+ password="changeit"/>
+ </trustManagers>
+ </sslContextParameters>
+
+ <bean id="defaultHostnameVerifier"
+ class="org.apache.cxf.transport.https.httpclient.DefaultHostnameVerifier"/>
+
+ <cxf:cxfEndpoint id="springEndpoint"
+ address="https://localhost:${CXFTestSupport.sslPort}/CxfSslTest/SoapContext/SoapPort"
+ serviceClass="org.apache.hello_world_soap_http.Greeter"/>
+
+ <bean id="greeter" class="org.apache.camel.component.cxf.GreeterImpl"/>
+ <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring" errorHandlerRef="noErrorHandler">
+ <route errorHandlerRef="noErrorHandler">
+ <from uri="cxf:bean:springEndpoint"/>
+ <to uri="bean:greeter?method=greetMe"/>
+ </route>
+
+ <route errorHandlerRef="noErrorHandler">
+ <from uri="direct:trust"/>
+ <to uri="cxf:bean:springEndpoint?sslContextParameters=#mySslContext&hostnameVerifier=#defaultHostnameVerifier"/>
+ </route>
+
+ <route errorHandlerRef="noErrorHandler">
+ <from uri="direct:wrongTrust"/>
+ <to uri="cxf:bean:springEndpoint?sslContextParameters=#wrongSslContext&hostnameVerifier=#defaultHostnameVerifier"/>
+ </route>
+
+ <route errorHandlerRef="noErrorHandler">
+ <from uri="direct:noTrust"/>
+ <to uri="cxf:bean:springEndpoint"/>
+ </route>
+
+ </camelContext>
+
+ <bean id="noErrorHandler" class="org.apache.camel.builder.NoErrorHandlerBuilder"/>
+
+</beans>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/37c4c0df/components/camel-cxf/src/test/resources/ssl/keystore-server.jks
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/test/resources/ssl/keystore-server.jks b/components/camel-cxf/src/test/resources/ssl/keystore-server.jks
new file mode 100644
index 0000000..41e39c7
Binary files /dev/null and b/components/camel-cxf/src/test/resources/ssl/keystore-server.jks differ
http://git-wip-us.apache.org/repos/asf/camel/blob/37c4c0df/components/camel-cxf/src/test/resources/ssl/keystore-wrong.jks
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/test/resources/ssl/keystore-wrong.jks b/components/camel-cxf/src/test/resources/ssl/keystore-wrong.jks
new file mode 100644
index 0000000..9b6dd28
Binary files /dev/null and b/components/camel-cxf/src/test/resources/ssl/keystore-wrong.jks differ
http://git-wip-us.apache.org/repos/asf/camel/blob/37c4c0df/components/camel-cxf/src/test/resources/ssl/keystores.txt
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/test/resources/ssl/keystores.txt b/components/camel-cxf/src/test/resources/ssl/keystores.txt
new file mode 100644
index 0000000..1317d5d
--- /dev/null
+++ b/components/camel-cxf/src/test/resources/ssl/keystores.txt
@@ -0,0 +1,7 @@
+passwords: changeit
+Keystore for server:
+keystore-server.jks
+
+Keystore on client side matching keystore-server.jks:
+truststore-client.jks
+
http://git-wip-us.apache.org/repos/asf/camel/blob/37c4c0df/components/camel-cxf/src/test/resources/ssl/truststore-client.jks
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/test/resources/ssl/truststore-client.jks b/components/camel-cxf/src/test/resources/ssl/truststore-client.jks
new file mode 100644
index 0000000..0d6d55a
Binary files /dev/null and b/components/camel-cxf/src/test/resources/ssl/truststore-client.jks differ
http://git-wip-us.apache.org/repos/asf/camel/blob/37c4c0df/components/camel-cxf/src/test/resources/ssl/truststore-wrong.jks
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/test/resources/ssl/truststore-wrong.jks b/components/camel-cxf/src/test/resources/ssl/truststore-wrong.jks
new file mode 100644
index 0000000..8e5723d
Binary files /dev/null and b/components/camel-cxf/src/test/resources/ssl/truststore-wrong.jks differ
[4/4] camel git commit: Use Camel SSLContext in CXF-endpoint
Posted by da...@apache.org.
Use Camel SSLContext in CXF-endpoint
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/30a4e16d
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/30a4e16d
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/30a4e16d
Branch: refs/heads/master
Commit: 30a4e16dc9e0d01bb44a7a89b1ba03d0ecf5304b
Parents: 8a7e8fc
Author: Arno Noordover <ar...@noordover.net>
Authored: Thu May 26 21:34:32 2016 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Sat May 28 15:55:54 2016 +0200
----------------------------------------------------------------------
.../cxf/ChainedCxfEndpointConfigurer.java | 76 ++++++++++++++++++
.../camel/component/cxf/CxfComponent.java | 7 +-
.../apache/camel/component/cxf/CxfEndpoint.java | 43 ++++++++++
.../apache/camel/component/cxf/CxfProducer.java | 8 +-
.../HostnameVerifierCxfEndpointConfigurer.java | 64 +++++++++++++++
.../component/cxf/SslCxfEndpointConfigurer.java | 80 +++++++++++++++++++
.../camel/component/cxf/CxfEndpointTest.java | 5 +-
.../camel-cxf/src/test/resources/localhost.ks | Bin 0 -> 2414 bytes
.../src/test/resources/log4j.properties | 2 +-
.../component/cxf/cxfConduitTimeOutContext.xml | 79 ++++++++++--------
10 files changed, 321 insertions(+), 43 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/30a4e16d/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/ChainedCxfEndpointConfigurer.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/ChainedCxfEndpointConfigurer.java b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/ChainedCxfEndpointConfigurer.java
new file mode 100644
index 0000000..bc69741
--- /dev/null
+++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/ChainedCxfEndpointConfigurer.java
@@ -0,0 +1,76 @@
+/**
+ * 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.cxf;
+
+import org.apache.cxf.endpoint.Client;
+import org.apache.cxf.endpoint.Server;
+import org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory;
+
+public final class ChainedCxfEndpointConfigurer implements CxfEndpointConfigurer {
+ private CxfEndpointConfigurer parent;
+ private CxfEndpointConfigurer child;
+
+ private ChainedCxfEndpointConfigurer() {
+ }
+
+ public static ChainedCxfEndpointConfigurer create(CxfEndpointConfigurer parent, CxfEndpointConfigurer child) {
+ ChainedCxfEndpointConfigurer result = new ChainedCxfEndpointConfigurer();
+ result.parent = parent;
+ result.child = child;
+ return result;
+ }
+
+ public ChainedCxfEndpointConfigurer addChild(CxfEndpointConfigurer cxfEndpointConfigurer) {
+ ChainedCxfEndpointConfigurer result = new ChainedCxfEndpointConfigurer();
+ result.parent = this;
+ result.child = cxfEndpointConfigurer;
+ return result;
+ }
+
+ @Override
+ public void configure(AbstractWSDLBasedEndpointFactory factoryBean) {
+ parent.configure(factoryBean);
+ child.configure(factoryBean);
+ }
+
+ @Override
+ public void configureClient(Client client) {
+ parent.configureClient(client);
+ child.configureClient(client);
+ }
+
+ @Override
+ public void configureServer(Server server) {
+ parent.configureServer(server);
+ child.configureServer(server);
+ }
+
+ public static class NullCxfEndpointConfigurer implements CxfEndpointConfigurer {
+
+ @Override
+ public void configure(AbstractWSDLBasedEndpointFactory factoryBean) {
+ }
+
+ @Override
+ public void configureClient(Client client) {
+ }
+
+ @Override
+ public void configureServer(Server server) {
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/30a4e16d/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfComponent.java b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfComponent.java
index 85776b6..da7158a 100644
--- a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfComponent.java
+++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfComponent.java
@@ -24,6 +24,7 @@ import org.apache.camel.component.cxf.common.message.CxfConstants;
import org.apache.camel.impl.HeaderFilterStrategyComponent;
import org.apache.camel.util.CamelContextHelper;
import org.apache.camel.util.IntrospectionSupport;
+import org.apache.camel.util.jsse.SSLContextParameters;
import org.apache.cxf.message.Message;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -36,7 +37,7 @@ public class CxfComponent extends HeaderFilterStrategyComponent {
private static final Logger LOG = LoggerFactory.getLogger(CxfComponent.class);
private Boolean allowStreaming;
-
+
public CxfComponent() {
super(CxfEndpoint.class);
}
@@ -74,7 +75,7 @@ public class CxfComponent extends HeaderFilterStrategyComponent {
parameters.put("defaultBus", value);
}
}
-
+
if (allowStreaming != null && !parameters.containsKey("allowStreaming")) {
parameters.put("allowStreaming", Boolean.toString(allowStreaming));
}
@@ -97,6 +98,7 @@ public class CxfComponent extends HeaderFilterStrategyComponent {
// endpoint URI does not specify a bean
result = createCxfEndpoint(remaining);
}
+
if (result.getCamelContext() == null) {
result.setCamelContext(getCamelContext());
}
@@ -129,4 +131,5 @@ public class CxfComponent extends HeaderFilterStrategyComponent {
CxfEndpoint cxfEndpoint = (CxfEndpoint) endpoint;
cxfEndpoint.updateEndpointUri(uri);
}
+
}
http://git-wip-us.apache.org/repos/asf/camel/blob/30a4e16d/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
index 9fb77e7..88f32ae 100644
--- a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
+++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
@@ -25,6 +25,7 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
+import javax.net.ssl.HostnameVerifier;
import javax.wsdl.Definition;
import javax.wsdl.WSDLException;
import javax.xml.namespace.QName;
@@ -69,6 +70,7 @@ import org.apache.camel.util.CastUtils;
import org.apache.camel.util.EndpointHelper;
import org.apache.camel.util.ObjectHelper;
import org.apache.camel.util.UnsafeUriCharactersEncoder;
+import org.apache.camel.util.jsse.SSLContextParameters;
import org.apache.cxf.Bus;
import org.apache.cxf.BusFactory;
import org.apache.cxf.binding.BindingConfiguration;
@@ -163,6 +165,10 @@ public class CxfEndpoint extends DefaultEndpoint implements AsyncEndpoint, Heade
private String defaultOperationNamespace;
@UriParam(label = "producer")
private boolean wrapped;
+ @UriParam(label = "producer")
+ private SSLContextParameters sslContextParameters;
+ @UriParam(label = "producer")
+ private HostnameVerifier hostnameVerifier;
@UriParam
private Boolean wrappedStyle;
@UriParam(label = "advanced")
@@ -1132,6 +1138,21 @@ public class CxfEndpoint extends DefaultEndpoint implements AsyncEndpoint, Heade
this.username = username;
}
+ public CxfEndpointConfigurer getChainedCxfEndpointConfigurer() {
+ return ChainedCxfEndpointConfigurer
+ .create(getNullSafeCxfEndpointConfigurer(),
+ SslCxfEndpointConfigurer.create(sslContextParameters, getCamelContext()))
+ .addChild(HostnameVerifierCxfEndpointConfigurer.create(hostnameVerifier));
+ }
+
+ private CxfEndpointConfigurer getNullSafeCxfEndpointConfigurer() {
+ if (cxfEndpointConfigurer == null) {
+ return new ChainedCxfEndpointConfigurer.NullCxfEndpointConfigurer();
+ } else {
+ return cxfEndpointConfigurer;
+ }
+ }
+
/**
* We need to override the {@link ClientImpl#setParameters} method
* to insert parameters into CXF Message for {@link DataFormat#PAYLOAD} mode.
@@ -1397,4 +1418,26 @@ public class CxfEndpoint extends DefaultEndpoint implements AsyncEndpoint, Heade
this.continuationTimeout = continuationTimeout;
}
+ public SSLContextParameters getSslContextParameters() {
+ return sslContextParameters;
+ }
+
+ /**
+ * The Camel SSL setting reference. Use the # notation to reference the SSL Context.
+ */
+ public void setSslContextParameters(SSLContextParameters sslContextParameters) {
+ this.sslContextParameters = sslContextParameters;
+ }
+
+ public HostnameVerifier getHostnameVerifier() {
+ return hostnameVerifier;
+ }
+
+ /**
+ * The hostname verifier to be used. Use the # notation to reference a HostnameVerifier
+ * from the registry.
+ */
+ public void setHostnameVerifier(HostnameVerifier hostnameVerifier) {
+ this.hostnameVerifier = hostnameVerifier;
+ }
}
http://git-wip-us.apache.org/repos/asf/camel/blob/30a4e16d/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfProducer.java b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfProducer.java
index f778e5f..2d105f2 100644
--- a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfProducer.java
+++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfProducer.java
@@ -79,12 +79,10 @@ public class CxfProducer extends DefaultProducer implements AsyncProcessor {
if (client == null) {
client = endpoint.createClient();
}
- // Apply the server configurer if it is possible
- if (endpoint.getCxfEndpointConfigurer() != null) {
- endpoint.getCxfEndpointConfigurer().configureClient(client);
- }
+
+ endpoint.getChainedCxfEndpointConfigurer().configureClient(client);
}
-
+
@Override
protected void doStop() throws Exception {
super.doStop();
http://git-wip-us.apache.org/repos/asf/camel/blob/30a4e16d/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/HostnameVerifierCxfEndpointConfigurer.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/HostnameVerifierCxfEndpointConfigurer.java b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/HostnameVerifierCxfEndpointConfigurer.java
new file mode 100644
index 0000000..913ce59
--- /dev/null
+++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/HostnameVerifierCxfEndpointConfigurer.java
@@ -0,0 +1,64 @@
+/**
+ * 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.cxf;
+
+import javax.net.ssl.HostnameVerifier;
+
+import org.apache.cxf.configuration.jsse.TLSClientParameters;
+import org.apache.cxf.endpoint.Client;
+import org.apache.cxf.endpoint.Server;
+import org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory;
+import org.apache.cxf.transport.http.HTTPConduit;
+
+public final class HostnameVerifierCxfEndpointConfigurer implements CxfEndpointConfigurer {
+
+ private final HostnameVerifier hostnameVerifier;
+
+ private HostnameVerifierCxfEndpointConfigurer(HostnameVerifier hostnameVerifier) {
+ this.hostnameVerifier = hostnameVerifier;
+ }
+
+ public static CxfEndpointConfigurer create(HostnameVerifier hostnameVerifier) {
+ if (hostnameVerifier == null) {
+ return new ChainedCxfEndpointConfigurer.NullCxfEndpointConfigurer();
+ } else {
+ return new HostnameVerifierCxfEndpointConfigurer(hostnameVerifier);
+ }
+ }
+ @Override
+ public void configure(AbstractWSDLBasedEndpointFactory factoryBean) {
+ }
+
+ @Override
+ public void configureClient(Client client) {
+ HTTPConduit httpConduit = (HTTPConduit) client.getConduit();
+ TLSClientParameters tlsClientParameters = tryToGetTLSClientParametersFromConduit(httpConduit);
+ tlsClientParameters.setHostnameVerifier(hostnameVerifier);
+ httpConduit.setTlsClientParameters(tlsClientParameters);
+ }
+
+ private TLSClientParameters tryToGetTLSClientParametersFromConduit(HTTPConduit httpConduit) {
+ if (httpConduit.getTlsClientParameters() != null) {
+ return httpConduit.getTlsClientParameters();
+ }
+ return new TLSClientParameters();
+ }
+
+ @Override
+ public void configureServer(Server server) {
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/30a4e16d/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/SslCxfEndpointConfigurer.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/SslCxfEndpointConfigurer.java b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/SslCxfEndpointConfigurer.java
new file mode 100644
index 0000000..2c19dcf
--- /dev/null
+++ b/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/SslCxfEndpointConfigurer.java
@@ -0,0 +1,80 @@
+/**
+ * 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.cxf;
+
+import java.io.IOException;
+import java.security.GeneralSecurityException;
+import javax.net.ssl.SSLSocketFactory;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.util.jsse.SSLContextParameters;
+import org.apache.cxf.configuration.jsse.TLSClientParameters;
+import org.apache.cxf.endpoint.Client;
+import org.apache.cxf.endpoint.Server;
+import org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory;
+import org.apache.cxf.transport.http.HTTPConduit;
+
+public final class SslCxfEndpointConfigurer implements CxfEndpointConfigurer {
+ private final SSLContextParameters sslContextParameters;
+ private final CamelContext camelContext;
+
+ private SslCxfEndpointConfigurer(SSLContextParameters sslContextParameters,
+ CamelContext camelContext) {
+ this.camelContext = camelContext;
+ this.sslContextParameters = sslContextParameters;
+ }
+
+ public static CxfEndpointConfigurer create(SSLContextParameters sslContextParameters, CamelContext camelContext) {
+ if (sslContextParameters == null) {
+ return new ChainedCxfEndpointConfigurer.NullCxfEndpointConfigurer();
+ } else {
+ return new SslCxfEndpointConfigurer(sslContextParameters, camelContext);
+ }
+ }
+
+ @Override
+ public void configure(AbstractWSDLBasedEndpointFactory factoryBean) {
+ }
+
+ @Override
+ public void configureClient(Client client) {
+ HTTPConduit httpConduit = (HTTPConduit) client.getConduit();
+ TLSClientParameters tlsClientParameters = tryToGetTLSClientParametersFromConduit(httpConduit);
+ tlsClientParameters.setSSLSocketFactory(tryToGetSSLSocketFactory());
+ httpConduit.setTlsClientParameters(tlsClientParameters);
+ }
+
+ private TLSClientParameters tryToGetTLSClientParametersFromConduit(HTTPConduit httpConduit) {
+ if (httpConduit.getTlsClientParameters() != null) {
+ return httpConduit.getTlsClientParameters();
+ }
+ return new TLSClientParameters();
+ }
+
+ private SSLSocketFactory tryToGetSSLSocketFactory() {
+ try {
+ return sslContextParameters.createSSLContext(camelContext)
+ .getSocketFactory();
+ } catch (GeneralSecurityException | IOException e) {
+ throw new RuntimeException("Setting SSL failed", e);
+ }
+ }
+
+ @Override
+ public void configureServer(Server server) {
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/30a4e16d/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfEndpointTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfEndpointTest.java b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfEndpointTest.java
index cc28af0..485ba3a 100644
--- a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfEndpointTest.java
+++ b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfEndpointTest.java
@@ -24,6 +24,7 @@ import org.apache.camel.component.cxf.CxfEndpoint.CamelCxfClientImpl;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.camel.impl.SimpleRegistry;
import org.apache.camel.spring.SpringCamelContext;
+import org.apache.camel.util.jsse.SSLContextParameters;
import org.apache.cxf.BusFactory;
import org.apache.cxf.bus.extension.ExtensionManagerBus;
import org.apache.cxf.endpoint.Client;
@@ -99,11 +100,13 @@ public class CxfEndpointTest extends Assert {
public void testCxfEndpointConfigurer() throws Exception {
SimpleRegistry registry = new SimpleRegistry();
CxfEndpointConfigurer configurer = EasyMock.createMock(CxfEndpointConfigurer.class);
+ SSLContextParameters sslContextParameters = EasyMock.createMock(SSLContextParameters.class);
Processor processor = EasyMock.createMock(Processor.class);
registry.put("myConfigurer", configurer);
+ registry.put("sslContextParameters", sslContextParameters);
CamelContext camelContext = new DefaultCamelContext(registry);
CxfComponent cxfComponent = new CxfComponent(camelContext);
- CxfEndpoint endpoint = (CxfEndpoint)cxfComponent.createEndpoint(routerEndpointURI + "&cxfEndpointConfigurer=#myConfigurer");
+ CxfEndpoint endpoint = (CxfEndpoint)cxfComponent.createEndpoint(routerEndpointURI + "&cxfEndpointConfigurer=#myConfigurer&sslContextParameters=sslContextParameters");
configurer.configure(EasyMock.isA(AbstractWSDLBasedEndpointFactory.class));
EasyMock.expectLastCall();
http://git-wip-us.apache.org/repos/asf/camel/blob/30a4e16d/components/camel-cxf/src/test/resources/localhost.ks
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/test/resources/localhost.ks b/components/camel-cxf/src/test/resources/localhost.ks
new file mode 100644
index 0000000..83999cf
Binary files /dev/null and b/components/camel-cxf/src/test/resources/localhost.ks differ
http://git-wip-us.apache.org/repos/asf/camel/blob/30a4e16d/components/camel-cxf/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/test/resources/log4j.properties b/components/camel-cxf/src/test/resources/log4j.properties
index aa9e83b..3d39228 100644
--- a/components/camel-cxf/src/test/resources/log4j.properties
+++ b/components/camel-cxf/src/test/resources/log4j.properties
@@ -18,7 +18,7 @@
#
# The logging properties used during tests..
#
-log4j.rootLogger=INFO, file
+log4j.rootLogger=DEBUG, file
log4j.logger.org.apache.activemq.spring=WARN
#log4j.logger.org.apache.camel.component=TRACE
http://git-wip-us.apache.org/repos/asf/camel/blob/30a4e16d/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/cxfConduitTimeOutContext.xml
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/cxfConduitTimeOutContext.xml b/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/cxfConduitTimeOutContext.xml
index 3f34b54..e5d4073 100644
--- a/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/cxfConduitTimeOutContext.xml
+++ b/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/cxfConduitTimeOutContext.xml
@@ -28,43 +28,54 @@
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
- <import resource="classpath:META-INF/cxf/cxf.xml"/>
-
- <!-- You can set the timeout and other client http transport configuration here -->
-
- <http-conf:conduit name="*.http-conduit">
- <http-conf:client ReceiveTimeout="100" />
- </http-conf:conduit>
-
- <!-- setup the CxfEndpointConfigurer bean here -->
- <bean id="myConfigurer" class="org.apache.camel.component.cxf.CxfTimeoutTest$MyCxfEndpointConfigurer" />
+ <import resource="classpath:META-INF/cxf/cxf.xml"/>
- <cxf:cxfEndpoint id="springEndpoint" address="http://localhost:${CXFTestSupport.port1}/CxfTimeoutTest/SoapContext/SoapPort"
- serviceClass="org.apache.hello_world_soap_http.Greeter"/>
+ <sslContextParameters xmlns="http://camel.apache.org/schema/spring"
+ id="mySslContext">
+ <keyManagers
+ keyPassword="changeit">
+ <keyStore
+ resource="/localhost.ks"
+ password="changeit"/>
+ </keyManagers>
+ </sslContextParameters>
- <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring" errorHandlerRef="noErrorHandler">
- <route errorHandlerRef="noErrorHandler">
- <from uri="direct:start"/>
- <to uri="cxf:bean:springEndpoint"/>
- </route>
+ <http-conf:conduit name="*.http-conduit">
+ <http-conf:client ReceiveTimeout="100"/>
+ </http-conf:conduit>
- <route>
- <from uri="direct:doCatch" />
- <doTry>
- <to uri="cxf:bean:springEndpoint" />
- <doCatch>
- <!-- and catch all other exceptions they are handled by default (ie handled
- = true) -->
- <exception>java.lang.Exception</exception>
- <handled>
- <constant>false</constant>
- </handled>
- <to uri="mock:error" />
- </doCatch>
- </doTry>
- </route>
- </camelContext>
+ <!-- setup the CxfEndpointConfigurer bean here -->
+ <bean id="myConfigurer" class="org.apache.camel.component.cxf.CxfTimeoutTest$MyCxfEndpointConfigurer"/>
- <bean id="noErrorHandler" class="org.apache.camel.builder.NoErrorHandlerBuilder"/>
+ <bean id="defaultHostnameVerifier" class="org.apache.cxf.transport.https.httpclient.DefaultHostnameVerifier"/>
+
+ <cxf:cxfEndpoint id="springEndpoint"
+ address="http://localhost:${CXFTestSupport.port1}/CxfTimeoutTest/SoapContext/SoapPort"
+ serviceClass="org.apache.hello_world_soap_http.Greeter"/>
+
+ <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring" errorHandlerRef="noErrorHandler">
+ <route errorHandlerRef="noErrorHandler">
+ <from uri="direct:start"/>
+ <to uri="cxf:bean:springEndpoint?sslContextParameters=#mySslContext&hostnameVerifier=#defaultHostnameVerifier"/>
+ </route>
+
+ <route>
+ <from uri="direct:doCatch"/>
+ <doTry>
+ <to uri="cxf:bean:springEndpoint"/>
+ <doCatch>
+ <!-- and catch all other exceptions they are handled by default (ie handled
+ = true) -->
+ <exception>java.lang.Exception</exception>
+ <handled>
+ <constant>false</constant>
+ </handled>
+ <to uri="mock:error"/>
+ </doCatch>
+ </doTry>
+ </route>
+ </camelContext>
+
+ <bean id="noErrorHandler" class="org.apache.camel.builder.NoErrorHandlerBuilder"/>
</beans>
\ No newline at end of file
[2/4] camel git commit: Solved a failing unittest
Posted by da...@apache.org.
Solved a failing unittest
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/36be62ed
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/36be62ed
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/36be62ed
Branch: refs/heads/master
Commit: 36be62ed3b7aad95888b0604f2b420ba1561734c
Parents: 30a4e16
Author: Arno Noordover <ar...@noordover.net>
Authored: Fri May 27 19:36:33 2016 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Sat May 28 15:55:54 2016 +0200
----------------------------------------------------------------------
.../camel/component/cxf/CxfEndpointTest.java | 49 +++++++++-----------
.../src/test/resources/log4j.properties | 2 +-
2 files changed, 24 insertions(+), 27 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/36be62ed/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfEndpointTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfEndpointTest.java b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfEndpointTest.java
index 485ba3a..32dd03d 100644
--- a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfEndpointTest.java
+++ b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfEndpointTest.java
@@ -24,7 +24,6 @@ import org.apache.camel.component.cxf.CxfEndpoint.CamelCxfClientImpl;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.camel.impl.SimpleRegistry;
import org.apache.camel.spring.SpringCamelContext;
-import org.apache.camel.util.jsse.SSLContextParameters;
import org.apache.cxf.BusFactory;
import org.apache.cxf.bus.extension.ExtensionManagerBus;
import org.apache.cxf.endpoint.Client;
@@ -37,43 +36,43 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
/**
* A unit test for spring configured cxf endpoint.
- *
- * @version
+ *
+ * @version
*/
public class CxfEndpointTest extends Assert {
- private int port1 = CXFTestSupport.getPort1();
- private int port2 = CXFTestSupport.getPort2();
+ private int port1 = CXFTestSupport.getPort1();
+ private int port2 = CXFTestSupport.getPort2();
private String routerEndpointURI = "cxf://http://localhost:" + port1 + "/CxfEndpointTest/router"
- + "?serviceClass=org.apache.camel.component.cxf.HelloService"
- + "&dataFormat=POJO";
+ + "?serviceClass=org.apache.camel.component.cxf.HelloService"
+ + "&dataFormat=POJO";
private String wsdlEndpointURI = "cxf://http://localhost:" + port2 + "/CxfEndpointTest/helloworld"
- + "?wsdlURL=classpath:person.wsdl"
- + "&serviceName={http://camel.apache.org/wsdl-first}PersonService"
- + "&portName={http://camel.apache.org/wsdl-first}soap"
- + "&dataFormat=PAYLOAD";
+ + "?wsdlURL=classpath:person.wsdl"
+ + "&serviceName={http://camel.apache.org/wsdl-first}PersonService"
+ + "&portName={http://camel.apache.org/wsdl-first}soap"
+ + "&dataFormat=PAYLOAD";
@Test
public void testSettingContinucationTimout() throws Exception {
CamelContext context = new DefaultCamelContext();
CxfEndpoint endpoint = context.getEndpoint(routerEndpointURI + "&continuationTimeout=800000",
- CxfEndpoint.class);
+ CxfEndpoint.class);
assertEquals("Get a wrong continucationTimeout value", 800000, endpoint.getContinuationTimeout());
}
-
+
@Test
public void testSpringCxfEndpoint() throws Exception {
ClassPathXmlApplicationContext ctx =
- new ClassPathXmlApplicationContext(new String[]{"org/apache/camel/component/cxf/CxfEndpointBeans.xml"});
+ new ClassPathXmlApplicationContext(new String[]{"org/apache/camel/component/cxf/CxfEndpointBeans.xml"});
CxfComponent cxfComponent = new CxfComponent(new SpringCamelContext(ctx));
CxfSpringEndpoint endpoint = (CxfSpringEndpoint)cxfComponent.createEndpoint("cxf://bean:serviceEndpoint");
assertEquals("Got the wrong endpoint address", endpoint.getAddress(),
- "http://localhost:" + port2 + "/CxfEndpointTest/helloworld");
+ "http://localhost:" + port2 + "/CxfEndpointTest/helloworld");
assertEquals("Got the wrong endpont service class",
- endpoint.getServiceClass().getCanonicalName(),
- "org.apache.camel.component.cxf.HelloService");
+ endpoint.getServiceClass().getCanonicalName(),
+ "org.apache.camel.component.cxf.HelloService");
}
@Test
@@ -81,7 +80,7 @@ public class CxfEndpointTest extends Assert {
ExtensionManagerBus bus = (ExtensionManagerBus) BusFactory.newInstance().createBus();
bus.setId("oldCXF");
BusFactory.setThreadDefaultBus(bus);
-
+
ExtensionManagerBus newBus = (ExtensionManagerBus) BusFactory.newInstance().createBus();
newBus.setId("newCXF");
CxfComponent cxfComponent = new CxfComponent(new DefaultCamelContext());
@@ -89,25 +88,23 @@ public class CxfEndpointTest extends Assert {
endpoint.setBus(newBus);
CamelCxfClientImpl client = (CamelCxfClientImpl)endpoint.createClient();
assertEquals("CamelCxfClientImpl should has the same bus with CxfEndpoint", newBus, client.getBus());
-
+
endpoint = (CxfEndpoint)cxfComponent.createEndpoint(wsdlEndpointURI);
endpoint.setBus(newBus);
client = (CamelCxfClientImpl)endpoint.createClient();
assertEquals("CamelCxfClientImpl should has the same bus with CxfEndpoint", newBus, client.getBus());
}
-
+
@Test
public void testCxfEndpointConfigurer() throws Exception {
SimpleRegistry registry = new SimpleRegistry();
CxfEndpointConfigurer configurer = EasyMock.createMock(CxfEndpointConfigurer.class);
- SSLContextParameters sslContextParameters = EasyMock.createMock(SSLContextParameters.class);
Processor processor = EasyMock.createMock(Processor.class);
registry.put("myConfigurer", configurer);
- registry.put("sslContextParameters", sslContextParameters);
CamelContext camelContext = new DefaultCamelContext(registry);
CxfComponent cxfComponent = new CxfComponent(camelContext);
- CxfEndpoint endpoint = (CxfEndpoint)cxfComponent.createEndpoint(routerEndpointURI + "&cxfEndpointConfigurer=#myConfigurer&sslContextParameters=sslContextParameters");
-
+ CxfEndpoint endpoint = (CxfEndpoint)cxfComponent.createEndpoint(routerEndpointURI + "&cxfEndpointConfigurer=#myConfigurer");
+
configurer.configure(EasyMock.isA(AbstractWSDLBasedEndpointFactory.class));
EasyMock.expectLastCall();
configurer.configureServer(EasyMock.isA(Server.class));
@@ -115,7 +112,7 @@ public class CxfEndpointTest extends Assert {
EasyMock.replay(configurer);
endpoint.createConsumer(processor);
EasyMock.verify(configurer);
-
+
EasyMock.reset(configurer);
configurer.configure(EasyMock.isA(AbstractWSDLBasedEndpointFactory.class));
EasyMock.expectLastCall();
@@ -125,7 +122,7 @@ public class CxfEndpointTest extends Assert {
Producer producer = endpoint.createProducer();
producer.start();
EasyMock.verify(configurer);
-
+
}
}
http://git-wip-us.apache.org/repos/asf/camel/blob/36be62ed/components/camel-cxf/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/test/resources/log4j.properties b/components/camel-cxf/src/test/resources/log4j.properties
index 3d39228..aa9e83b 100644
--- a/components/camel-cxf/src/test/resources/log4j.properties
+++ b/components/camel-cxf/src/test/resources/log4j.properties
@@ -18,7 +18,7 @@
#
# The logging properties used during tests..
#
-log4j.rootLogger=DEBUG, file
+log4j.rootLogger=INFO, file
log4j.logger.org.apache.activemq.spring=WARN
#log4j.logger.org.apache.camel.component=TRACE