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 2008/07/16 07:00:24 UTC

svn commit: r677156 - in /activemq/camel/trunk/tests/camel-itest/src/test: java/org/apache/camel/itest/customerrelations/CustomerServicesTest.java resources/spring-config/client-applicationContext.xml resources/spring-config/server-applicationContext.xml

Author: ningjiang
Date: Tue Jul 15 22:00:23 2008
New Revision: 677156

URL: http://svn.apache.org/viewvc?rev=677156&view=rev
Log:
CAMEL-727 Applied the test patch with thanks to William

Modified:
    activemq/camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/customerrelations/CustomerServicesTest.java
    activemq/camel/trunk/tests/camel-itest/src/test/resources/spring-config/client-applicationContext.xml
    activemq/camel/trunk/tests/camel-itest/src/test/resources/spring-config/server-applicationContext.xml

Modified: activemq/camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/customerrelations/CustomerServicesTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/customerrelations/CustomerServicesTest.java?rev=677156&r1=677155&r2=677156&view=diff
==============================================================================
--- activemq/camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/customerrelations/CustomerServicesTest.java (original)
+++ activemq/camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/customerrelations/CustomerServicesTest.java Tue Jul 15 22:00:23 2008
@@ -16,7 +16,19 @@
  */
 package org.apache.camel.itest.customerrelations;
 
+import java.lang.reflect.Proxy;
+import java.util.List;
+import java.util.Map;
+
 import junit.framework.TestCase;
+
+import org.apache.cxf.helpers.CastUtils;
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.jaxws.EndpointImpl;
+import org.apache.cxf.jaxws.JaxWsClientProxy;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.AbstractPhaseInterceptor;
+import org.apache.cxf.phase.Phase;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 
 public class CustomerServicesTest extends TestCase {
@@ -29,10 +41,19 @@
                 new String[] {"spring-config/server-applicationContext.xml"});
             Object server = serverContext.getBean("org.apache.camel.itest.customerrelations.CustomerServiceV1");
             assertNotNull("We should get server here", server);
-
+            
+            // add an interceptor to verify headers
+            EndpointImpl.class.cast(server).getServer().getEndpoint().getInInterceptors()
+                .add(new HeaderChecker(Phase.PRE_STREAM));
+            
             clientContext =  new ClassPathXmlApplicationContext(
                 new String[] {"spring-config/client-applicationContext.xml"});
             CustomerServiceV1 customerService = (CustomerServiceV1) clientContext.getBean("org.apache.camel.itest.customerrelations.CustomerServiceV1");
+            
+            // add an interceptor to verify headers
+            JaxWsClientProxy.class.cast(Proxy.getInvocationHandler(customerService))
+                .getClient().getInInterceptors().add(new HeaderChecker(Phase.PRE_STREAM));
+            
             Customer customer = customerService.getCustomer("12345");
             assertNotNull("We should get Customer here", customer);
         } finally {
@@ -44,5 +65,17 @@
             }
         }
     }
-
+    
+    class HeaderChecker extends AbstractPhaseInterceptor<Message> {
+        public HeaderChecker(String phase) {
+            super(phase);
+        }
+        
+        public void handleMessage(Message message) throws Fault {
+            Map<String, List<String>> headers 
+                = CastUtils.cast((Map<?, ?>)message.get(Message.PROTOCOL_HEADERS));
+            assertNotNull(headers);
+            assertEquals("\"getCustomer\"", headers.get("SOAPAction").get(0));
+        }   
+    }
 }

Modified: activemq/camel/trunk/tests/camel-itest/src/test/resources/spring-config/client-applicationContext.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/tests/camel-itest/src/test/resources/spring-config/client-applicationContext.xml?rev=677156&r1=677155&r2=677156&view=diff
==============================================================================
--- activemq/camel/trunk/tests/camel-itest/src/test/resources/spring-config/client-applicationContext.xml (original)
+++ activemq/camel/trunk/tests/camel-itest/src/test/resources/spring-config/client-applicationContext.xml Tue Jul 15 22:00:23 2008
@@ -22,22 +22,11 @@
 		http://activemq.apache.org/camel/schema/spring http://activemq.apache.org/camel/schema/spring/camel-spring.xsd
 		http://cxf.apache.org/transports/camel http://cxf.apache.org/transports/camel.xsd">
 
-		<import resource="classpath:META-INF/cxf/cxf.xml" />
+	<import resource="classpath:META-INF/cxf/cxf.xml" />
 	<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
 	<import resource="classpath:META-INF/cxf/cxf-extension-camel.xml" />
-
-	<import
-		resource="classpath:spring-config/jms-applicationContext.xml" />
-
-	<bean class="org.apache.camel.component.cxf.transport.CamelTransportFactory" lazy-init="true">
-        <property name="bus" ref="cxf"/>
-		<property name="camelContext" ref="camelContext"/>
-        <property name="transportIds">
-            <list>
-              <value>http://cxf.apache.org/transports/camel</value>
-            </list>
-        </property>
-    </bean>
+	
+	<import resource="classpath:spring-config/jms-applicationContext.xml" />
 
 	<client id="org.apache.camel.itest.customerrelations.CustomerServiceV1"
 		xmlns="http://cxf.apache.org/jaxws"
@@ -45,7 +34,8 @@
 		serviceName="customer:CustomerServiceV1"
 		endpointName="customer:CustomerServiceV1CamelPort"
 		serviceClass="org.apache.camel.itest.customerrelations.CustomerServiceV1"
-		wsdlLocation="./src/main/resources/wsdl/CustomerService-1.0.0.wsdl">
+		address="camel://direct:clientOutbound">
+
 		<features>
 			<!-- Enables logging of SOAP messages. -->
 			<logging xmlns="http://cxf.apache.org/core" />
@@ -61,7 +51,7 @@
 		xmlns="http://activemq.apache.org/camel/schema/spring">
 		<jmxAgent id="agent" disabled="true"/>
 		<route>
-			<from uri="direct:org.apache.camel.itest.customerrelations.CustomerServiceV1" />
+			<from uri="direct:clientOutbound" />
 			<to
 				uri="jms://org.apache.camel.itest.customerrelations.CustomerServiceV1" />
 		</route>

Modified: activemq/camel/trunk/tests/camel-itest/src/test/resources/spring-config/server-applicationContext.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/tests/camel-itest/src/test/resources/spring-config/server-applicationContext.xml?rev=677156&r1=677155&r2=677156&view=diff
==============================================================================
--- activemq/camel/trunk/tests/camel-itest/src/test/resources/spring-config/server-applicationContext.xml (original)
+++ activemq/camel/trunk/tests/camel-itest/src/test/resources/spring-config/server-applicationContext.xml Tue Jul 15 22:00:23 2008
@@ -29,8 +29,7 @@
 	<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
 	<import resource="classpath:META-INF/cxf/cxf-extension-camel.xml" />
 
-	<import
-		resource="classpath:spring-config/jms-applicationContext.xml" />
+	<import	resource="classpath:spring-config/jms-applicationContext.xml" />
 
     <broker:broker useJmx="false" persistent="false" brokerName="localhost">
         <broker:transportConnectors>
@@ -38,22 +37,12 @@
         </broker:transportConnectors>
     </broker:broker>
 
-	<bean class="org.apache.camel.component.cxf.transport.CamelTransportFactory" lazy-init="true">
-        <property name="bus" ref="cxf"/>
-		<property name="camelContext" ref="camelContext"/>
-        <property name="transportIds">
-            <list>
-              <value>http://cxf.apache.org/transports/camel</value>
-            </list>
-        </property>
-    </bean>
-
 	<endpoint xmlns="http://cxf.apache.org/jaxws"
 		id="org.apache.camel.itest.customerrelations.CustomerServiceV1"
 		xmlns:customer="http://camel.apache.org/itest/customerrelations"
 		serviceName="customer:CustomerServiceV1"
 		endpointName="customer:CustomerServiceV1CamelPort"
-		address="camel://direct:org.apache.camel.itest.customerrelations.CustomerServiceV1"
+		address="camel://direct:serverInbound"
 		implementor="org.apache.camel.itest.customerrelations.CustomerServiceV1Impl">
 		<features>
 			<!-- Enables logging of SOAP messages. -->
@@ -73,7 +62,7 @@
 			<from
 				uri="jms://org.apache.camel.itest.customerrelations.CustomerServiceV1" />
 			<to
-				uri="direct:org.apache.camel.itest.customerrelations.CustomerServiceV1" />
+				uri="direct:serverInbound" />
 		</route>
 	</camelContext>
 </beans>