camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r1447146 - in /camel/trunk/components/camel-cxf: ./ src/main/java/org/apache/camel/component/cxf/ src/test/java/org/apache/camel/component/cxf/jms/ src/test/resources/org/apache/camel/component/cxf/jms/
Date Mon, 18 Feb 2013 08:27:17 GMT
Author: ningjiang
Date: Mon Feb 18 08:27:17 2013
New Revision: 1447146

URL: http://svn.apache.org/r1447146
Log:
CAMEL-6084 Fix the issue that SOAP over JMS doesn't work with camel-cxf endpoint

Added:
    camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jms/
    camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jms/CxfEndpointJMSConsumerTest.java
    camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jms/
    camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jms/camel-context.xml
Modified:
    camel/trunk/components/camel-cxf/pom.xml
    camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfConsumer.java

Modified: camel/trunk/components/camel-cxf/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/pom.xml?rev=1447146&r1=1447145&r2=1447146&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/pom.xml (original)
+++ camel/trunk/components/camel-cxf/pom.xml Mon Feb 18 08:27:17 2013
@@ -160,6 +160,26 @@
       <artifactId>camel-test-spring</artifactId>
       <scope>test</scope>
     </dependency>
+    
+    <!-- test for the cxf jms transport -->
+    <dependency>
+       <groupId>org.apache.activemq</groupId>
+       <artifactId>activemq-broker</artifactId>
+       <scope>test</scope>
+    </dependency>
+    
+    <dependency>
+        <groupId>org.apache.activemq</groupId>
+        <artifactId>activemq-kahadb-store</artifactId>
+        <scope>test</scope>
+    </dependency>
+    
+    <dependency>
+      <groupId>org.apache.cxf</groupId>
+      <artifactId>cxf-rt-transports-jms</artifactId>
+      <version>${cxf-version}</version>
+      <scope>test</scope>
+    </dependency>
 
     <dependency>
       <groupId>org.apache.cxf</groupId>

Modified: camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfConsumer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfConsumer.java?rev=1447146&r1=1447145&r2=1447146&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfConsumer.java
(original)
+++ camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfConsumer.java
Mon Feb 18 08:27:17 2013
@@ -76,7 +76,8 @@ public class CxfConsumer extends Default
                 }
             }            
             
-            // NOTE this code cannot work with CXF 2.2.x
+            // NOTE this code cannot work with CXF 2.2.x and JMSContinuation
+            // as it doesn't break out the interceptor chain when we call it 
             private Object asyncInvoke(Exchange cxfExchange, final Continuation continuation)
{
                 synchronized (continuation) {
                     if (continuation.isNew()) {
@@ -114,7 +115,14 @@ public class CxfConsumer extends Default
             private Continuation getContinuation(Exchange cxfExchange) {
                 ContinuationProvider provider = 
                     (ContinuationProvider)cxfExchange.getInMessage().get(ContinuationProvider.class.getName());
-                return provider == null ? null : provider.getContinuation();
+                Continuation continuation = provider == null ? null : provider.getContinuation();
+                // Make sure we don't return the JMSContinuation, as it doesn't support the
Continuation we wants
+                // Don't want to introduce the dependency of cxf-rt-transprot-jms here
+                if (continuation != null && continuation.getClass().getName().equals("org.apache.cxf.transport.jms.continuations.JMSContinuation"))
{
+                    return null;
+                } else {
+                    return continuation;
+                }
             }
             
             private Object syncInvoke(Exchange cxfExchange) {

Added: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jms/CxfEndpointJMSConsumerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jms/CxfEndpointJMSConsumerTest.java?rev=1447146&view=auto
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jms/CxfEndpointJMSConsumerTest.java
(added)
+++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jms/CxfEndpointJMSConsumerTest.java
Mon Feb 18 08:27:17 2013
@@ -0,0 +1,93 @@
+/**
+ * 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.jms;
+import org.apache.camel.CamelContext;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.spring.SpringCamelContext;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
+import org.apache.hello_world_soap_http.Greeter;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class CxfEndpointJMSConsumerTest extends CamelTestSupport {
+    protected AbstractXmlApplicationContext applicationContext;
+
+    @Before
+    public void setUp() throws Exception {
+        applicationContext = createApplicationContext();
+        super.setUp();
+        assertNotNull("Should have created a valid spring context", applicationContext);
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        
+        if (applicationContext != null) {
+            applicationContext.destroy();
+        }
+        super.tearDown();
+    }
+    
+    @Override
+    protected CamelContext createCamelContext() throws Exception {
+        return SpringCamelContext.springCamelContext(applicationContext);
+    }
+    
+    protected ClassPathXmlApplicationContext createApplicationContext() {
+        return new ClassPathXmlApplicationContext("org/apache/camel/component/cxf/jms/camel-context.xml");
+    }
+
+    protected RouteBuilder createRouteBuilder() {
+        return new RouteBuilder() {
+            public void configure() {
+                from("cxf:bean:jmsEndpoint").process(new Processor() {
+                    @Override
+                    public void process(Exchange exchange) throws Exception {
+                        // just set the response for greetme operation here
+                        String me = exchange.getIn().getBody(String.class);
+                        exchange.getOut().setBody("Hello " + me);
+                    }
+                });
+            }
+        };
+    }
+    
+    @Test
+    public void testInvocation() {
+        // Here we just the address with JMS URI
+        String address = "jms:jndi:dynamicQueues/test.cxf.jmstransport.queue"
+            + "?jndiInitialContextFactory"
+            + "=org.apache.activemq.jndi.ActiveMQInitialContextFactory"
+            + "&jndiConnectionFactoryName=ConnectionFactory&jndiURL="
+            + "vm://localhost";
+   
+        JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
+        factory.setServiceClass(Greeter.class);
+        factory.setAddress(address);
+        Greeter greeter = factory.create(Greeter.class);
+        String response = greeter.greetMe("Willem");
+        assertEquals("Get a wrong response", "Hello Willem", response);
+    }
+    
+    
+}

Added: camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jms/camel-context.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jms/camel-context.xml?rev=1447146&view=auto
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jms/camel-context.xml
(added)
+++ camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/jms/camel-context.xml
Mon Feb 18 08:27:17 2013
@@ -0,0 +1,50 @@
+<?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://camel.apache.org/schema/spring"
+xmlns:osgi="http://www.springframework.org/schema/osgi"
+xmlns:cxf="http://camel.apache.org/schema/cxf"
+xmlns:jms="http://cxf.apache.org/transports/jms"
+xsi:schemaLocation="
+http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd
+http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+http://camel.apache.org/schema/cxf http://camel.apache.org/schema/cxf/camel-cxf.xsd
+http://cxf.apache.org/transports/jms http://cxf.apache.org/schemas/configuration/jms.xsd">
+
+<bean id="logginOutInterceptor" class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
+<bean id="logginInInterceptor" class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
+
+<cxf:cxfEndpoint id="jmsEndpoint"
+address="jms:jndi:dynamicQueues/test.cxf.jmstransport.queue?jndiInitialContextFactory=org.apache.activemq.jndi.ActiveMQInitialContextFactory&amp;jndiConnectionFactoryName=ConnectionFactory&amp;jndiURL=vm://localhost"
+  serviceClass="org.apache.hello_world_soap_http.Greeter"
+  endpointName="s:SoapPort"
+  serviceName="s:SOAPService"
+  xmlns:s="http://apache.org/hello_world_soap_http">
+
+<cxf:inInterceptors>
+<ref bean="logginInInterceptor"/>
+</cxf:inInterceptors>
+
+<cxf:outInterceptors>
+<ref bean="logginOutInterceptor"/>
+</cxf:outInterceptors>
+</cxf:cxfEndpoint>
+
+</beans>
\ No newline at end of file



Mime
View raw message