Return-Path: Delivered-To: apmail-camel-commits-archive@www.apache.org Received: (qmail 95851 invoked from network); 5 May 2009 03:17:14 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 5 May 2009 03:17:14 -0000 Received: (qmail 96708 invoked by uid 500); 5 May 2009 03:17:14 -0000 Delivered-To: apmail-camel-commits-archive@camel.apache.org Received: (qmail 96661 invoked by uid 500); 5 May 2009 03:17:13 -0000 Mailing-List: contact commits-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list commits@camel.apache.org Received: (qmail 96652 invoked by uid 99); 5 May 2009 03:17:13 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 05 May 2009 03:17:13 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 05 May 2009 03:17:11 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id E1B12238889E; Tue, 5 May 2009 03:16:49 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@camel.apache.org From: ningjiang@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090505031649.E1B12238889E@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 ++