Author: ningjiang
Date: Fri Oct 19 07:17:40 2012
New Revision: 1399986

URL: http://svn.apache.org/viewvc?rev=1399986&view=rev
Log:
Add JmsToCxf integration test

Added:
    
camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/greeter/JmsToCxfInOutTest.java
    
camel/trunk/tests/camel-itest/src/test/resources/org/apache/camel/itest/greeter/JmsToCxfInOutTest-context.xml

Added: 
camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/greeter/JmsToCxfInOutTest.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/greeter/JmsToCxfInOutTest.java?rev=1399986&view=auto
==============================================================================
--- 
camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/greeter/JmsToCxfInOutTest.java
 (added)
+++ 
camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/greeter/JmsToCxfInOutTest.java
 Fri Oct 19 07:17:40 2012
@@ -0,0 +1,39 @@
+package org.apache.camel.itest.greeter;
+
+
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.component.cxf.common.message.CxfConstants;
+import org.apache.camel.test.AvailablePortFinder;
+import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import 
org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+@ContextConfiguration
+public class JmsToCxfInOutTest extends AbstractJUnit4SpringContextTests {
+    private static int port = AvailablePortFinder.getNextAvailable(20025);
+    static {
+        //set them as system properties so Spring can use the property place 
holder
+        //things to set them into the URL's in the spring contexts 
+        System.setProperty("JmsToCxfInOutTest.port", Integer.toString(port));
+    }
+    
+    @Autowired
+    protected ProducerTemplate template;
+
+    @Test
+    public void testJmsToCxfInOut() throws Exception {
+        assertNotNull(template);
+        
+        String out = template.requestBodyAndHeader("jms:queue:bridge.cxf", 
"Willem", CxfConstants.OPERATION_NAME, "greetMe", String.class);
+        assertEquals("Hello Willem", out);
+
+        // call for the other opertion
+        out = template.requestBodyAndHeader("jms:queue:bridge.cxf", new 
Object[0], CxfConstants.OPERATION_NAME, "sayHi", String.class);
+        assertEquals("Bonjour", out);
+    }
+
+}

Added: 
camel/trunk/tests/camel-itest/src/test/resources/org/apache/camel/itest/greeter/JmsToCxfInOutTest-context.xml
URL: 
http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest/src/test/resources/org/apache/camel/itest/greeter/JmsToCxfInOutTest-context.xml?rev=1399986&view=auto
==============================================================================
--- 
camel/trunk/tests/camel-itest/src/test/resources/org/apache/camel/itest/greeter/JmsToCxfInOutTest-context.xml
 (added)
+++ 
camel/trunk/tests/camel-itest/src/test/resources/org/apache/camel/itest/greeter/JmsToCxfInOutTest-context.xml
 Fri Oct 19 07:17:40 2012
@@ -0,0 +1,63 @@
+<?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:jaxws="http://cxf.apache.org/jaxws";
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans.xsd
+       http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.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
+    ">
+
+    <import resource="classpath:META-INF/cxf/cxf.xml"/>
+    
+    <bean 
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
+    
+    <jaxws:endpoint id="greeter" 
+         implementor="org.apache.camel.itest.greeter.GreeterImpl" 
+         
address="http://localhost:${JmsToCxfInOutTest.port}/SoapContext/SoapPort";
+      endpointName="s:SoapOverHttp"
+      serviceName="s:SOAPService"
+      xmlns:s="http://apache.org/hello_world_soap_http"/>
+         
+
+    <cxf:cxfEndpoint id="serviceEndpoint" 
address="http://localhost:${JmsToCxfInOutTest.port}/SoapContext/SoapPort";
+                     wsdlURL="wsdl/hello_world.wsdl"
+                     serviceClass="org.apache.hello_world_soap_http.Greeter"
+                     endpointName="s:SoapOverHttp"
+                     serviceName="s:SOAPService"
+                     xmlns:s="http://apache.org/hello_world_soap_http";>
+    </cxf:cxfEndpoint>
+    
+
+    <bean id="jms" 
class="org.apache.activemq.camel.component.ActiveMQComponent">
+        <property name="brokerURL" 
value="vm://localhost?broker.persistent=false"/>
+    </bean>
+
+    <camelContext xmlns="http://camel.apache.org/schema/spring";>
+        <route>
+            <from uri="jms:queue:bridge.cxf"/>
+            <to uri="log:jms"/>
+            <to uri="cxf://bean:serviceEndpoint"/>
+        </route>
+
+    </camelContext>
+
+</beans>


Reply via email to