camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r771531 - in /camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf: CxfRawMessageRouterTest.java CxfSimpleRouterTest.java
Date Tue, 05 May 2009 03:16:49 GMT
Author: ningjiang
Date: Tue May  5 03:16:18 2009
New Revision: 771531

URL: http://svn.apache.org/viewvc?rev=771531&view=rev
Log:
Added the unit test of getting the response context in camel-cxf

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

Modified: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfRawMessageRouterTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfRawMessageRouterTest.java?rev=771531&r1=771530&r2=771531&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfRawMessageRouterTest.java
(original)
+++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfRawMessageRouterTest.java
Tue May  5 03:16:18 2009
@@ -16,7 +16,10 @@
  */
 package org.apache.camel.component.cxf;
 
+import java.util.Map;
+
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
 
 public class CxfRawMessageRouterTest extends CxfSimpleRouterTest {
     private String routerEndpointURI = "cxf://" + ROUTER_ADDRESS + "?" + SERVICE_CLASS +
"&dataFormat=MESSAGE";
@@ -24,8 +27,23 @@
     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();
+        result.expectedMessageCount(1);
+        HelloService client = getCXFClient();
+        client.echo("hello world");
+        assertMockEndpointsSatisfied();
+        Map context = (Map)result.assertExchangeReceived(0).getIn().getHeaders().get("ResponseContext");
+        Map protocalHeaders = (Map) context.get("org.apache.cxf.message.Message.PROTOCOL_HEADERS");
+        assertEquals("Should get the content type", protocalHeaders.get("content-type").toString(),
"[text/xml; charset=utf-8]");
+        assertEquals("Should get the response code ", context.get("org.apache.cxf.message.Message.RESPONSE_CODE"),
200);
+        // get the content type directly from the message header
+        assertEquals("Should get the content type", result.assertExchangeReceived(0).getIn().getHeaders().get("content-type"),
"text/xml; charset=utf-8");        
+    }
 }

Modified: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfSimpleRouterTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfSimpleRouterTest.java?rev=771531&r1=771530&r2=771531&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfSimpleRouterTest.java
(original)
+++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfSimpleRouterTest.java
Tue May  5 03:16:18 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