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 2009/07/27 09:23:21 UTC
svn commit: r798052 - in /camel/trunk/components/camel-cxf: ./
src/test/java/org/apache/camel/component/cxf/transport/
src/test/resources/org/apache/camel/component/cxf/transport/
Author: ningjiang
Date: Mon Jul 27 07:23:21 2009
New Revision: 798052
URL: http://svn.apache.org/viewvc?rev=798052&view=rev
Log:
CAMEL-1856 added a Junit test to show how to use JBIBinding with Camel transport
Added:
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/transport/CamelJBIClientProxyTest.java (with props)
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/transport/JbiServiceProcessor.java (with props)
camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/transport/CamelJBIClientProxy.xml (with props)
Modified:
camel/trunk/components/camel-cxf/pom.xml
Modified: camel/trunk/components/camel-cxf/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/pom.xml?rev=798052&r1=798051&r2=798052&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/pom.xml (original)
+++ camel/trunk/components/camel-cxf/pom.xml Mon Jul 27 07:23:21 2009
@@ -169,7 +169,14 @@
<artifactId>camel-http</artifactId>
<scope>test</scope>
</dependency>
-
+
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-bindings-jbi</artifactId>
+ <version>${cxf-version}</version>
+ <scope>test</scope>
+ </dependency>
+
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-jetty</artifactId>
@@ -363,4 +370,4 @@
</profile>
</profiles>
-</project>
\ No newline at end of file
+</project>
Added: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/transport/CamelJBIClientProxyTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/transport/CamelJBIClientProxyTest.java?rev=798052&view=auto
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/transport/CamelJBIClientProxyTest.java (added)
+++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/transport/CamelJBIClientProxyTest.java Mon Jul 27 07:23:21 2009
@@ -0,0 +1,57 @@
+/**
+ * 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.transport;
+
+import org.apache.camel.component.cxf.HelloService;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+public class CamelJBIClientProxyTest {
+ private HelloService proxy;
+ private ClassPathXmlApplicationContext applicationContext;
+
+ @Before
+ public void setUp() {
+ // setup service
+ applicationContext = new ClassPathXmlApplicationContext(new String[]{"/org/apache/camel/component/cxf/transport/CamelJBIClientProxy.xml"});
+ applicationContext.start();
+ proxy = (HelloService) applicationContext.getBean("client");
+ assertNotNull("The proxy should not be null.", proxy);
+ }
+
+ @Test
+ public void echoMethodTest() {
+ String response = proxy.echo("Hello World!");
+ assertEquals("Get a wrong response ", "echo Hello World!", response);
+ }
+
+ @After
+ public void tearDown() {
+ if (applicationContext != null) {
+ applicationContext.stop();
+ }
+ }
+
+
+
+
+}
Propchange: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/transport/CamelJBIClientProxyTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/transport/CamelJBIClientProxyTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/transport/JbiServiceProcessor.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/transport/JbiServiceProcessor.java?rev=798052&view=auto
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/transport/JbiServiceProcessor.java (added)
+++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/transport/JbiServiceProcessor.java Mon Jul 27 07:23:21 2009
@@ -0,0 +1,43 @@
+/**
+ * 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.transport;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.Processor;
+import org.apache.camel.converter.IOConverter;
+
+public class JbiServiceProcessor implements Processor {
+ private static final String ECHO_RESPONSE = "<jbi:message xmlns:jbi=\"http://java.sun.com/xml/ns/jbi/wsdl-11-wrapper\""
+ + " xmlns:msg=\"http://cxf.component.camel.apache.org\" type=\"msg:echoResponse\"><jbi:part>"
+ + "<ns1:return xmlns:ns1=\"http://cxf.component.camel.apache.org\">echo Hello World!</ns1:return>"
+ + "</jbi:part></jbi:message>";
+ /*private static final String ECHO_BOOLEAN_RESPONSE = "<ns1:echoBooleanResponse xmlns:ns1=\"http://cxf.component.camel.apache.org/\">"
+ + "<return xmlns=\"http://cxf.component.camel.apache.org/\">true</return>"
+ + "</ns1:echoBooleanResponse>";*/
+
+ public void process(Exchange exchange) throws Exception {
+ Message in = exchange.getIn();
+ System.out.println("print out the request " + in.getBody(String.class));
+ System.out.println("The message exchange pattern is " + exchange.getPattern());
+
+ exchange.getOut().setBody(ECHO_RESPONSE);
+
+ }
+
+}
Propchange: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/transport/JbiServiceProcessor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/transport/JbiServiceProcessor.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/transport/CamelJBIClientProxy.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/transport/CamelJBIClientProxy.xml?rev=798052&view=auto
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/transport/CamelJBIClientProxy.xml (added)
+++ camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/transport/CamelJBIClientProxy.xml Mon Jul 27 07:23:21 2009
@@ -0,0 +1,70 @@
+<?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:camel="http://cxf.apache.org/transports/camel"
+ xmlns:simple="http://cxf.apache.org/simple"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+ http://cxf.apache.org/transports/camel http://cxf.apache.org/transports/camel.xsd
+ http://camel.apache.org/schema/cxf http://camel.apache.org/schema/cxf/cxfEndpoint.xsd
+ http://cxf.apache.org/simple http://cxf.apache.org/schemas/simple.xsd
+ http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+ ">
+
+ <import resource="classpath:META-INF/cxf/cxf.xml"/>
+ <import resource="classpath:META-INF/cxf/cxf-extension-jbi-binding.xml"/>
+ <import resource="classpath:META-INF/cxf/cxf-extension-camel.xml"/>
+
+
+ <camelContext id="conduit_context" xmlns="http://camel.apache.org/schema/spring">
+ <route>
+ <from uri="direct://start" />
+ <process ref="myProcessor" />
+ </route>
+ </camelContext>
+
+ <camel:conduit name="{http://cxf.component.camel.apache.org}portA.camel-conduit">
+ <camel:camelContextRef>conduit_context</camel:camelContextRef>
+ </camel:conduit>
+
+ <bean id="myProcessor" class="org.apache.camel.component.cxf.transport.JbiServiceProcessor"/>
+
+ <simple:client id="client"
+ serviceClass="org.apache.camel.component.cxf.HelloService"
+ address="camel://direct://start"
+ serviceName="s:service"
+ xmlns:s="http://cxf.component.camel.apache.org"
+ endpointName="s:portA"
+ bindingId="http://cxf.apache.org/bindings/jbi"
+ transportId="http://cxf.apache.org/transports/camel">
+ </simple:client>
+
+
+
+ <!-- simple:server id="server"
+ serviceClass="org.apache.camel.component.cxf.HelloServiceImpl"
+ address="camel://direct://end"
+ serviceName="s:service"
+ xmlns:s="http://camel.apache.org/camel-test"
+ endpointName="s:portA"
+ bindingId="http://cxf.apache.org/bindings/jbi"
+ transportId="http://cxf.apache.org/transports/camel">
+ </simple:server -->
+</beans>
Propchange: camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/transport/CamelJBIClientProxy.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/transport/CamelJBIClientProxy.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/transport/CamelJBIClientProxy.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml