camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r771528 - in /camel/branches/camel-1.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf: CxfRawMessageRouterTest.java CxfSimpleRouterTest.java
Date Tue, 05 May 2009 03:05:15 GMT
Author: ningjiang
Date: Tue May  5 03:05:14 2009
New Revision: 771528

URL: http://svn.apache.org/viewvc?rev=771528&view=rev
Log:
Added the unit test for getting the response context in MESSAGE dataformat

Modified:
    camel/branches/camel-1.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfRawMessageRouterTest.java
    camel/branches/camel-1.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfSimpleRouterTest.java

Modified: camel/branches/camel-1.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfRawMessageRouterTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-1.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfRawMessageRouterTest.java?rev=771528&r1=771527&r2=771528&view=diff
==============================================================================
--- camel/branches/camel-1.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfRawMessageRouterTest.java
(original)
+++ camel/branches/camel-1.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfRawMessageRouterTest.java
Tue May  5 03:05:14 2009
@@ -16,7 +16,11 @@
  */
 package org.apache.camel.component.cxf;
 
+import java.util.Map;
+
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.cxf.jaxws.context.WrappedMessageContext;
 
 public class CxfRawMessageRouterTest extends CxfSimpleRouterTest {
     private String routerEndpointURI = "cxf://" + ROUTER_ADDRESS + "?" + SERVICE_CLASS +
"&dataFormat=MESSAGE";
@@ -24,8 +28,18 @@
     protected RouteBuilder createRouteBuilder() {
         return new RouteBuilder() {
             public void configure() {
-                from(routerEndpointURI).to("log:org.apache.camel?level=DEBUG").to(serviceEndpointURI);
+                from(routerEndpointURI).to("log:org.apache.camel?level=DEBUG").to(serviceEndpointURI).to("mock:result");
             }
         };
     }
+    
+    public void testTheContentType() throws Exception {
+        MockEndpoint result = getMockEndpoint("mock:result");
+        result.reset();
+        HelloService client = getCXFClient();
+        client.echo("hello world");        
+        Map context = (Map)result.assertExchangeReceived(0).getIn().getHeaders().get("ResponseContext");

+        assertNotNull("Expect to get the protocal header ", context.get("org.apache.cxf.message.Message.PROTOCOL_HEADERS"));
+        assertEquals("Should get the response code ", context.get("org.apache.cxf.message.Message.RESPONSE_CODE"),
200);
+    }
 }

Modified: camel/branches/camel-1.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfSimpleRouterTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-1.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfSimpleRouterTest.java?rev=771528&r1=771527&r2=771528&view=diff
==============================================================================
--- camel/branches/camel-1.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfSimpleRouterTest.java
(original)
+++ camel/branches/camel-1.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfSimpleRouterTest.java
Tue May  5 03:05:14 2009
@@ -57,9 +57,8 @@
     protected CamelContext createCamelContext() throws Exception {
         return new DefaultCamelContext();
     }
-
-
-    public void testInvokingServiceFromCXFClient() throws Exception {
+    
+    protected HelloService getCXFClient() throws Exception {
         ClientProxyFactoryBean proxyFactory = new ClientProxyFactoryBean();
         ClientFactoryBean clientBean = proxyFactory.getClientFactoryBean();
         clientBean.setAddress(ROUTER_ADDRESS);
@@ -67,19 +66,19 @@
         clientBean.setBus(bus);
 
         HelloService client = (HelloService) proxyFactory.create();
+        return client;
+    }
 
+
+    public void testInvokingServiceFromCXFClient() throws Exception {        
+        HelloService client = getCXFClient();
         String result = client.echo("hello world");
         assertEquals("we should get the right answer from router", result, "echo hello world");
 
     }
 
     public void testOnwayInvocation() throws Exception {
-        ClientProxyFactoryBean proxyFactory = new ClientProxyFactoryBean();
-        ClientFactoryBean clientBean = proxyFactory.getClientFactoryBean();
-        clientBean.setAddress(ROUTER_ADDRESS);
-        clientBean.setServiceClass(HelloService.class);
-        clientBean.setBus(bus);
-        HelloService client = (HelloService) proxyFactory.create();
+        HelloService client = getCXFClient();
         int count = client.getInvocationCount();
         client.ping();
         //oneway ping invoked, so invocationCount ++



Mime
View raw message