You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2012/11/19 09:54:54 UTC
svn commit: r1411103 - in /camel/trunk/tests: ./ camel-blueprint-cxf-test/
camel-blueprint-cxf-test/src/ camel-blueprint-cxf-test/src/test/
camel-blueprint-cxf-test/src/test/java/
camel-blueprint-cxf-test/src/test/java/org/ camel-blueprint-cxf-test/src...
Author: ningjiang
Date: Mon Nov 19 08:54:51 2012
New Revision: 1411103
URL: http://svn.apache.org/viewvc?rev=1411103&view=rev
Log:
CAMEL-5791 Added camel-blueprint-cxf-test with thanks to Aki
Added:
camel/trunk/tests/camel-blueprint-cxf-test/
camel/trunk/tests/camel-blueprint-cxf-test/pom.xml
camel/trunk/tests/camel-blueprint-cxf-test/src/
camel/trunk/tests/camel-blueprint-cxf-test/src/test/
camel/trunk/tests/camel-blueprint-cxf-test/src/test/java/
camel/trunk/tests/camel-blueprint-cxf-test/src/test/java/org/
camel/trunk/tests/camel-blueprint-cxf-test/src/test/java/org/apache/
camel/trunk/tests/camel-blueprint-cxf-test/src/test/java/org/apache/camel/
camel/trunk/tests/camel-blueprint-cxf-test/src/test/java/org/apache/camel/component/
camel/trunk/tests/camel-blueprint-cxf-test/src/test/java/org/apache/camel/component/cxf/
camel/trunk/tests/camel-blueprint-cxf-test/src/test/java/org/apache/camel/component/cxf/CXFTestSupport.java
camel/trunk/tests/camel-blueprint-cxf-test/src/test/java/org/apache/camel/component/cxf/HelloService.java
camel/trunk/tests/camel-blueprint-cxf-test/src/test/java/org/apache/camel/test/
camel/trunk/tests/camel-blueprint-cxf-test/src/test/java/org/apache/camel/test/cxf/
camel/trunk/tests/camel-blueprint-cxf-test/src/test/java/org/apache/camel/test/cxf/blueprint/
camel/trunk/tests/camel-blueprint-cxf-test/src/test/java/org/apache/camel/test/cxf/blueprint/CxfEndpointBeansTest.java
camel/trunk/tests/camel-blueprint-cxf-test/src/test/java/org/apache/camel/test/cxf/blueprint/CxfPayloadProviderRouterTest.java
camel/trunk/tests/camel-blueprint-cxf-test/src/test/java/org/apache/camel/test/cxf/blueprint/MyProcessor.java
camel/trunk/tests/camel-blueprint-cxf-test/src/test/resources/
camel/trunk/tests/camel-blueprint-cxf-test/src/test/resources/log4j.properties
camel/trunk/tests/camel-blueprint-cxf-test/src/test/resources/org/
camel/trunk/tests/camel-blueprint-cxf-test/src/test/resources/org/apache/
camel/trunk/tests/camel-blueprint-cxf-test/src/test/resources/org/apache/camel/
camel/trunk/tests/camel-blueprint-cxf-test/src/test/resources/org/apache/camel/test/
camel/trunk/tests/camel-blueprint-cxf-test/src/test/resources/org/apache/camel/test/cxf/
camel/trunk/tests/camel-blueprint-cxf-test/src/test/resources/org/apache/camel/test/cxf/blueprint/
camel/trunk/tests/camel-blueprint-cxf-test/src/test/resources/org/apache/camel/test/cxf/blueprint/CxfEndpointBeans.xml
camel/trunk/tests/camel-blueprint-cxf-test/src/test/resources/org/apache/camel/test/cxf/blueprint/CxfPayloadProviderRouterBeans.xml
Modified:
camel/trunk/tests/pom.xml
Added: camel/trunk/tests/camel-blueprint-cxf-test/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-blueprint-cxf-test/pom.xml?rev=1411103&view=auto
==============================================================================
--- camel/trunk/tests/camel-blueprint-cxf-test/pom.xml (added)
+++ camel/trunk/tests/camel-blueprint-cxf-test/pom.xml Mon Nov 19 08:54:51 2012
@@ -0,0 +1,122 @@
+<?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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>tests</artifactId>
+ <version>2.11-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>camel-blueprint-cxf-test</artifactId>
+ <name>Camel :: Blueprint CXF :: Tests </name>
+ <description>Tests the camel-cxf blueprint features</description>
+
+ <dependencies>
+ <!-- assuming camel is pulling aries 1.0.0, pull asm 4.0 first -->
+ <dependency>
+ <groupId>org.ow2.asm</groupId>
+ <artifactId>asm-all</artifactId>
+ <version>4.0</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-blueprint</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-test-blueprint</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-http</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-cxf</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-transports-http</artifactId>
+ <version>${cxf-version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-transports-http-jetty</artifactId>
+ <version>${cxf-version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-testutils</artifactId>
+ <version>${cxf-version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- osgi -->
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- test -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+</project>
Added: camel/trunk/tests/camel-blueprint-cxf-test/src/test/java/org/apache/camel/component/cxf/CXFTestSupport.java
URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-blueprint-cxf-test/src/test/java/org/apache/camel/component/cxf/CXFTestSupport.java?rev=1411103&view=auto
==============================================================================
--- camel/trunk/tests/camel-blueprint-cxf-test/src/test/java/org/apache/camel/component/cxf/CXFTestSupport.java (added)
+++ camel/trunk/tests/camel-blueprint-cxf-test/src/test/java/org/apache/camel/component/cxf/CXFTestSupport.java Mon Nov 19 08:54:51 2012
@@ -0,0 +1,84 @@
+/**
+ * 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.camel.test.AvailablePortFinder;
+
+/**
+ * For test cases that use unique contexts, they can share the
+ * ports which will make things a bit faster as ports aren't opened
+ * and closed all the time.
+ */
+/*
+ * REVIST this class is a copy of the same named class in org.apache.camel.component.cxf's test folder.
+ * It should go into some reusable test-util jar so that it can be used from other test packages
+ */
+public final class CXFTestSupport {
+
+ static final int PORT1 = AvailablePortFinder.getNextAvailable();
+ static final int PORT2 = AvailablePortFinder.getNextAvailable();
+ static final int PORT3 = AvailablePortFinder.getNextAvailable();
+ static final int PORT4 = AvailablePortFinder.getNextAvailable();
+ static final int PORT5 = AvailablePortFinder.getNextAvailable();
+ static final int PORT6 = AvailablePortFinder.getNextAvailable();
+
+ static {
+ //set them as system properties so Spring can use the property placeholder
+ //things to set them into the URL's in the spring contexts
+ System.setProperty("CXFTestSupport.port1", Integer.toString(PORT1));
+ System.setProperty("CXFTestSupport.port2", Integer.toString(PORT2));
+ System.setProperty("CXFTestSupport.port3", Integer.toString(PORT3));
+ System.setProperty("CXFTestSupport.port4", Integer.toString(PORT4));
+ System.setProperty("CXFTestSupport.port5", Integer.toString(PORT5));
+ System.setProperty("CXFTestSupport.port6", Integer.toString(PORT6));
+ System.setProperty("org.apache.cxf.transports.http_jetty.DontClosePort", "true");
+ }
+
+ private CXFTestSupport() {
+ }
+
+ public static int getPort(String name) {
+ int port = AvailablePortFinder.getNextAvailable();
+ System.setProperty(name, Integer.toString(port));
+ return port;
+ }
+
+ public static int getPort1() {
+ return PORT1;
+ }
+
+ public static int getPort2() {
+ return PORT2;
+ }
+
+ public static int getPort3() {
+ return PORT3;
+ }
+
+ public static int getPort4() {
+ return PORT4;
+ }
+
+ public static int getPort5() {
+ return PORT5;
+ }
+
+ public static int getPort6() {
+ return PORT6;
+ }
+}
Added: camel/trunk/tests/camel-blueprint-cxf-test/src/test/java/org/apache/camel/component/cxf/HelloService.java
URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-blueprint-cxf-test/src/test/java/org/apache/camel/component/cxf/HelloService.java?rev=1411103&view=auto
==============================================================================
--- camel/trunk/tests/camel-blueprint-cxf-test/src/test/java/org/apache/camel/component/cxf/HelloService.java (added)
+++ camel/trunk/tests/camel-blueprint-cxf-test/src/test/java/org/apache/camel/component/cxf/HelloService.java Mon Nov 19 08:54:51 2012
@@ -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.cxf;
+
+import java.util.List;
+
+public interface HelloService {
+ String sayHello();
+
+ void ping();
+
+ int getInvocationCount();
+
+ String echo(String text) throws Exception;
+
+ Boolean echoBoolean(Boolean bool);
+
+ String complexParameters(List<String> par1, List<String> par2);
+
+}
\ No newline at end of file
Added: camel/trunk/tests/camel-blueprint-cxf-test/src/test/java/org/apache/camel/test/cxf/blueprint/CxfEndpointBeansTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-blueprint-cxf-test/src/test/java/org/apache/camel/test/cxf/blueprint/CxfEndpointBeansTest.java?rev=1411103&view=auto
==============================================================================
--- camel/trunk/tests/camel-blueprint-cxf-test/src/test/java/org/apache/camel/test/cxf/blueprint/CxfEndpointBeansTest.java (added)
+++ camel/trunk/tests/camel-blueprint-cxf-test/src/test/java/org/apache/camel/test/cxf/blueprint/CxfEndpointBeansTest.java Mon Nov 19 08:54:51 2012
@@ -0,0 +1,115 @@
+/**
+ * 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.test.cxf.blueprint;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+import javax.xml.namespace.QName;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.component.cxf.CXFTestSupport;
+import org.apache.camel.component.cxf.CxfEndpoint;
+import org.apache.camel.component.cxf.common.message.CxfConstants;
+import org.apache.camel.test.blueprint.CamelBlueprintTestSupport;
+import org.apache.camel.util.URISupport;
+import org.apache.cxf.transport.http.HTTPException;
+
+import org.junit.Test;
+
+public class CxfEndpointBeansTest extends CamelBlueprintTestSupport {
+
+ @Override
+ protected String getBlueprintDescriptor() {
+ return "org/apache/camel/test/cxf/blueprint/CxfEndpointBeans.xml";
+ }
+
+ @Override
+ protected String getBundleDirectives() {
+ return "blueprint.aries.xml-validation:=false";
+ }
+
+ @Override
+ protected Properties useOverridePropertiesWithPropertiesComponent() {
+ Properties extra = new Properties();
+ extra.put("router.address", "http://localhost:" + CXFTestSupport.getPort1() + "/CxfEndpointBeansRouterTest/router");
+ return extra;
+ }
+
+ @Test
+ public void testCxfEndpointBeanDefinitionParser() {
+ CxfEndpoint routerEndpoint = context.getEndpoint("routerEndpoint", CxfEndpoint.class);
+ assertEquals("Got the wrong endpoint address", routerEndpoint.getAddress(),
+ "http://localhost:" + CXFTestSupport.getPort1() + "/CxfEndpointBeansRouterTest/router");
+ assertEquals("Got the wrong endpont service class",
+ "org.apache.camel.component.cxf.HelloService",
+ routerEndpoint.getServiceClass().getName());
+ }
+
+ @Test
+ public void testCreateCxfEndpointFromURI() throws Exception {
+ CxfEndpoint endpoint1 = context.getEndpoint("cxf:bean:routerEndpoint?address=http://localhost:9000/test1", CxfEndpoint.class);
+ CxfEndpoint endpoint2 = context.getEndpoint("cxf:bean:routerEndpoint?address=http://localhost:8000/test2", CxfEndpoint.class);
+ assertEquals("Get a wrong endpoint address.", "http://localhost:9000/test1", endpoint1.getAddress());
+ assertEquals("Get a wrong endpoint address.", "http://localhost:8000/test2", endpoint2.getAddress());
+
+ // the uri will always be normalized
+ String uri1 = URISupport.normalizeUri("cxf://bean:routerEndpoint?address=http://localhost:9000/test1");
+ String uri2 = URISupport.normalizeUri("cxf://bean:routerEndpoint?address=http://localhost:8000/test2");
+ assertEquals("Get a wrong endpoint key.", uri1, endpoint1.getEndpointKey());
+ assertEquals("Get a wrong endpoint key.", uri2, endpoint2.getEndpointKey());
+ }
+
+ @Test
+ public void testCxfBusConfiguration() throws Exception {
+ // get the camelContext from application context
+ ProducerTemplate template = context.createProducerTemplate();
+
+ Exchange reply = template.request("cxf:bean:serviceEndpoint", new Processor() {
+ public void process(final Exchange exchange) {
+ final List<String> params = new ArrayList<String>();
+ params.add("hello");
+ exchange.getIn().setBody(params);
+ exchange.getIn().setHeader(CxfConstants.OPERATION_NAME, "echo");
+ }
+ });
+
+ Exception ex = reply.getException();
+ assertTrue("Should get the fault here",
+ ex instanceof org.apache.cxf.interceptor.Fault
+ || ex instanceof HTTPException);
+ }
+
+ @Test
+ public void testCxfBeanWithCamelPropertiesHolder() throws Exception {
+ // get the camelContext from application context
+ CxfEndpoint testEndpoint = context.getEndpoint("cxf:bean:testEndpoint", CxfEndpoint.class);
+ QName endpointName = QName.valueOf("{http://org.apache.camel.component.cxf}myEndpoint");
+ QName serviceName = QName.valueOf("{http://org.apache.camel.component.cxf}myService");
+
+ assertEquals("Got a wrong address", "http://localhost:9000/testEndpoint", testEndpoint.getAddress());
+ assertEquals("Got a wrong bindingId", "http://schemas.xmlsoap.org/wsdl/soap12/", testEndpoint.getBindingId());
+ assertEquals("Got a wrong transportId", "http://cxf.apache.org/transports/http", testEndpoint.getTransportId());
+ assertEquals("Got a wrong endpointName", endpointName, testEndpoint.getPortName());
+ assertEquals("Got a wrong WsdlURL", "wsdl/test.wsdl", testEndpoint.getWsdlURL());
+ assertEquals("Got a wrong serviceName", serviceName, testEndpoint.getServiceName());
+ }
+}
Added: camel/trunk/tests/camel-blueprint-cxf-test/src/test/java/org/apache/camel/test/cxf/blueprint/CxfPayloadProviderRouterTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-blueprint-cxf-test/src/test/java/org/apache/camel/test/cxf/blueprint/CxfPayloadProviderRouterTest.java?rev=1411103&view=auto
==============================================================================
--- camel/trunk/tests/camel-blueprint-cxf-test/src/test/java/org/apache/camel/test/cxf/blueprint/CxfPayloadProviderRouterTest.java (added)
+++ camel/trunk/tests/camel-blueprint-cxf-test/src/test/java/org/apache/camel/test/cxf/blueprint/CxfPayloadProviderRouterTest.java Mon Nov 19 08:54:51 2012
@@ -0,0 +1,130 @@
+/**
+ * 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.test.cxf.blueprint;
+
+import java.util.Properties;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.Endpoint;
+import javax.xml.ws.Service;
+
+import org.apache.camel.component.cxf.CXFTestSupport;
+import org.apache.camel.test.blueprint.CamelBlueprintTestSupport;
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.AbstractPhaseInterceptor;
+import org.apache.cxf.phase.Phase;
+import org.apache.hello_world_soap_http.Greeter;
+import org.apache.hello_world_soap_http.GreeterImpl;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class CxfPayloadProviderRouterTest extends CamelBlueprintTestSupport {
+ protected static Endpoint endpoint;
+ protected static GreeterImpl implementor;
+
+ private final QName serviceName = new QName("http://apache.org/hello_world_soap_http",
+ "SOAPService");
+ private final QName routerPortName = new QName("http://apache.org/hello_world_soap_http",
+ "RouterPort");
+
+ @AfterClass
+ public static void stopService() {
+ if (endpoint != null) {
+ endpoint.stop();
+ }
+ }
+
+ @BeforeClass
+ public static void startService() {
+ implementor = new GreeterImpl();
+ String address = "http://localhost:" + CXFTestSupport.getPort1() + "/CxfPayLoadProviderRouterTest/SoapContext/SoapPort";
+ endpoint = Endpoint.publish(address, implementor);
+ }
+
+ @Override
+ protected Properties useOverridePropertiesWithPropertiesComponent() {
+ Properties extra = new Properties();
+ extra.put("router.address", "http://localhost:" + CXFTestSupport.getPort2() + "/CxfPayloadProviderRouterTest/CamelContext/RouterPort");
+ extra.put("service.address", "http://localhost:" + CXFTestSupport.getPort1() + "/CxfPayLoadProviderRouterTest/SoapContext/SoapPort");
+ return extra;
+ }
+
+ @Override
+ protected String getBlueprintDescriptor() {
+ return "org/apache/camel/test/cxf/blueprint/CxfPayloadProviderRouterBeans.xml";
+ }
+
+ @Test
+ public void testPublishEndpointUrl() throws Exception {
+ final String path = "CxfPayloadProviderRouterTest/CamelContext/RouterPort";
+ String response = template.requestBody("http://localhost:" + CXFTestSupport.getPort2() + "/" + path
+ + "?wsdl", null, String.class);
+ assertTrue("Can't find the right service location.", response.indexOf(path) > 0);
+ }
+
+ @Test
+ public void testInvokeGreetMeOverProvider() throws Exception {
+ Service service = Service.create(serviceName);
+ service.addPort(routerPortName, "http://schemas.xmlsoap.org/soap/",
+ "http://localhost:" + CXFTestSupport.getPort2() + "/"
+ + getClass().getSimpleName() + "/CamelContext/RouterPort");
+ Greeter greeter = service.getPort(routerPortName, Greeter.class);
+ org.apache.cxf.endpoint.Client client = org.apache.cxf.frontend.ClientProxy.getClient(greeter);
+ VerifyInboundInterceptor icp = new VerifyInboundInterceptor();
+ client.getInInterceptors().add(icp);
+
+ int ic = implementor.getInvocationCount();
+
+ icp.setCalled(false);
+ String reply = greeter.greetMe("test");
+ assertEquals("Got the wrong reply ", "Hello test", reply);
+ assertTrue("No Inbound message received", icp.isCalled());
+ assertEquals("The target service not invoked", ++ic, implementor.getInvocationCount());
+
+ icp.setCalled(false);
+ greeter.greetMeOneWay("call greetMe OneWay !");
+ assertFalse("An unnecessary inbound message", icp.isCalled());
+ // wait a few seconds for the async oneway service to be invoked
+ Thread.sleep(3000);
+ assertEquals("The target service not invoked", ++ic, implementor.getInvocationCount());
+ }
+
+ static class VerifyInboundInterceptor extends AbstractPhaseInterceptor<Message> {
+ private boolean called;
+
+ public VerifyInboundInterceptor() {
+ super(Phase.USER_PROTOCOL);
+ }
+
+ @Override
+ public void handleMessage(Message message) throws Fault {
+ called = true;
+ }
+
+ public boolean isCalled() {
+ return called;
+ }
+
+ public void setCalled(boolean b) {
+ called = b;
+ }
+
+ }
+}
Added: camel/trunk/tests/camel-blueprint-cxf-test/src/test/java/org/apache/camel/test/cxf/blueprint/MyProcessor.java
URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-blueprint-cxf-test/src/test/java/org/apache/camel/test/cxf/blueprint/MyProcessor.java?rev=1411103&view=auto
==============================================================================
--- camel/trunk/tests/camel-blueprint-cxf-test/src/test/java/org/apache/camel/test/cxf/blueprint/MyProcessor.java (added)
+++ camel/trunk/tests/camel-blueprint-cxf-test/src/test/java/org/apache/camel/test/cxf/blueprint/MyProcessor.java Mon Nov 19 08:54:51 2012
@@ -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.test.cxf.blueprint;
+
+import java.util.List;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.Processor;
+import org.apache.camel.component.cxf.common.message.CxfConstants;
+
+/**
+ *
+ */
+public class MyProcessor implements Processor {
+
+ public void process(Exchange exchange) throws Exception {
+ Thread.sleep(1000);
+ Message in = exchange.getIn();
+ // Get the parameter list
+ List<?> parameter = in.getBody(List.class);
+ // Get the operation name
+ String operation = (String)in.getHeader(CxfConstants.OPERATION_NAME);
+ Object result = operation + " " + (String)parameter.get(0);
+ exchange.getOut().setBody(result);
+ }
+
+}
Added: camel/trunk/tests/camel-blueprint-cxf-test/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-blueprint-cxf-test/src/test/resources/log4j.properties?rev=1411103&view=auto
==============================================================================
--- camel/trunk/tests/camel-blueprint-cxf-test/src/test/resources/log4j.properties (added)
+++ camel/trunk/tests/camel-blueprint-cxf-test/src/test/resources/log4j.properties Mon Nov 19 08:54:51 2012
@@ -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.
+## ---------------------------------------------------------------------------
+
+#
+# The logging properties used during tests..
+#
+log4j.rootLogger=INFO, out
+
+# Use the following line to turn on debug output for camel
+#log4j.logger.org.apache.camel=DEBUG
+
+#log4j.logger.org.ops4j.pax=DEBUG
+# is very noisy at INFO level
+log4j.logger.org.ops4j.io=WARN
+
+# CONSOLE appender not used by default
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+
+# File appender
+log4j.appender.out=org.apache.log4j.FileAppender
+log4j.appender.out.layout=org.apache.log4j.PatternLayout
+log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+log4j.appender.out.file=target/camel-test-blueprint-cxf.log
+log4j.appender.out.append=true
Added: camel/trunk/tests/camel-blueprint-cxf-test/src/test/resources/org/apache/camel/test/cxf/blueprint/CxfEndpointBeans.xml
URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-blueprint-cxf-test/src/test/resources/org/apache/camel/test/cxf/blueprint/CxfEndpointBeans.xml?rev=1411103&view=auto
==============================================================================
--- camel/trunk/tests/camel-blueprint-cxf-test/src/test/resources/org/apache/camel/test/cxf/blueprint/CxfEndpointBeans.xml (added)
+++ camel/trunk/tests/camel-blueprint-cxf-test/src/test/resources/org/apache/camel/test/cxf/blueprint/CxfEndpointBeans.xml Mon Nov 19 08:54:51 2012
@@ -0,0 +1,75 @@
+<?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.
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:camel="http://camel.apache.org/schema/blueprint"
+ xmlns:cxf="http://camel.apache.org/schema/blueprint/cxf"
+ xmlns:http-conf="http://cxf.apache.org/transports/http/configuration"
+ xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0"
+ xmlns:s="http://cxf.apache.org/hello_world_soap_http"
+ xsi:schemaLocation="
+ http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd
+ http://camel.apache.org/schema/blueprint/cxf http://camel.apache.org/schema/blueprint/cxf/camel-cxf.xsd
+ http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd
+ http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0 http://aries.apache.org/schemas/blueprint-cm/blueprint-cm-1.0.0.xsd
+ http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
+
+ <!-- blueprint property placeholders -->
+ <cm:property-placeholder persistent-id="my-placeholders">
+ <cm:default-properties>
+ <cm:property name="router.address" value="http://localhost:9000/routerEndpoint" />
+ <cm:property name="service.address" value="http://localhost:8000/serviceEndpoint" />
+ <cm:property name="test.address" value="http://localhost:9000/testEndpoint" />
+ <cm:property name="bindingId" value="http://schemas.xmlsoap.org/wsdl/soap12/" />
+ <cm:property name="transportId" value="http://cxf.apache.org/transports/http" />
+ <cm:property name="serviceName" value="{http://org.apache.camel.component.cxf}myService" />
+ <cm:property name="endpointName" value="{http://org.apache.camel.component.cxf}myEndpoint" />
+ <cm:property name="wsdlURL" value="wsdl/test.wsdl" />
+ </cm:default-properties>
+ </cm:property-placeholder>
+
+ <cxf:cxfEndpoint id="routerEndpoint" address="{{router.address}}"
+ serviceClass="org.apache.camel.component.cxf.HelloService"/>
+
+ <cxf:cxfEndpoint id="serviceEndpoint" address="{{service.address}}"
+ serviceClass="org.apache.camel.component.cxf.HelloService"/>
+
+ <cxf:cxfEndpoint id="testEndpoint" address="{{test.address}}"
+ bindingId="{{bindingId}}" transportId="{{transportId}}"
+ serviceName="{{serviceName}}" endpointName="{{endpointName}}"
+ wsdlURL="{{wsdlURL}}"
+ serviceClass="org.apache.camel.component.cxf.HelloService"/>
+
+ <!-- Setting the http conduit policy -->
+ <http-conf:conduit name="{http://cxf.component.camel.apache.org/}HelloServicePort.http-conduit">
+ <http-conf:client ReceiveTimeout="500"
+ MaxRetransmits="1"
+ AllowChunking="false" />
+ </http-conf:conduit>
+
+ <bean id="myProcessor" class="org.apache.camel.test.cxf.blueprint.MyProcessor"/>
+
+ <camel:camelContext id="camel">
+ <camel:route>
+ <camel:from uri="cxf:bean:routerEndpoint" />
+ <camel:process ref="myProcessor" />
+ <camel:to uri="mock:result" />
+ </camel:route>
+ </camel:camelContext>
+
+</blueprint>
Added: camel/trunk/tests/camel-blueprint-cxf-test/src/test/resources/org/apache/camel/test/cxf/blueprint/CxfPayloadProviderRouterBeans.xml
URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-blueprint-cxf-test/src/test/resources/org/apache/camel/test/cxf/blueprint/CxfPayloadProviderRouterBeans.xml?rev=1411103&view=auto
==============================================================================
--- camel/trunk/tests/camel-blueprint-cxf-test/src/test/resources/org/apache/camel/test/cxf/blueprint/CxfPayloadProviderRouterBeans.xml (added)
+++ camel/trunk/tests/camel-blueprint-cxf-test/src/test/resources/org/apache/camel/test/cxf/blueprint/CxfPayloadProviderRouterBeans.xml Mon Nov 19 08:54:51 2012
@@ -0,0 +1,65 @@
+<?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.
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:camel="http://camel.apache.org/schema/blueprint"
+ xmlns:cxf="http://camel.apache.org/schema/blueprint/cxf"
+ xmlns:http-conf="http://cxf.apache.org/transports/http/configuration"
+ xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0"
+ xmlns:s="http://cxf.apache.org/hello_world_soap_http"
+ xsi:schemaLocation="
+ http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd
+ http://camel.apache.org/schema/blueprint/cxf http://camel.apache.org/schema/blueprint/cxf/camel-cxf.xsd
+ http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd
+ http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0 http://aries.apache.org/schemas/blueprint-cm/blueprint-cm-1.0.0.xsd
+ http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
+
+ <!-- blueprint property placeholders -->
+ <cm:property-placeholder persistent-id="my-placeholders">
+ <cm:default-properties>
+ <cm:property name="router.address" value="http://localhost:9000/routerEndpoint" />
+ <cm:property name="service.address" value="http://localhost:8000/serviceEndpoint" />
+ </cm:default-properties>
+ </cm:property-placeholder>
+
+ <cxf:cxfEndpoint id="routerEndpoint" address="{{router.address}}">
+ <cxf:properties>
+ <entry key="dataFormat" value="PAYLOAD"/>
+ </cxf:properties>
+ </cxf:cxfEndpoint>
+
+ <cxf:cxfEndpoint id="serviceEndpoint" address="{{service.address}}">
+ <cxf:properties>
+ <entry key="dataFormat" value="PAYLOAD"/>
+ </cxf:properties>
+ </cxf:cxfEndpoint>
+
+ <camel:camelContext id="camel">
+ <camel:route>
+ <camel:from uri="cxf:bean:routerEndpoint?synchronous=true" />
+ <camel:setHeader headerName="operationNamespace">
+ <camel:constant>http://camel.apache.org/cxf/jaxws/dispatch</camel:constant>
+ </camel:setHeader>
+ <camel:setHeader headerName="operationName">
+ <camel:constant>Invoke</camel:constant>
+ </camel:setHeader>
+ <camel:to uri="cxf:bean:serviceEndpoint?synchronous=true" />
+ </camel:route>
+ </camel:camelContext>
+
+</blueprint>
Modified: camel/trunk/tests/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/tests/pom.xml?rev=1411103&r1=1411102&r2=1411103&view=diff
==============================================================================
--- camel/trunk/tests/pom.xml (original)
+++ camel/trunk/tests/pom.xml Mon Nov 19 08:54:51 2012
@@ -37,6 +37,7 @@
<module>camel-itest</module>
<module>camel-itest-cdi</module>
<module>camel-itest-spring30</module>
+ <module>camel-blueprint-cxf-test</module>
<module>camel-partial-classpath-test</module>
<module>camel-typeconverterscan-test</module>
<module>camel-itest-performance</module>