Author: ningjiang
Date: Wed Mar 6 01:17:10 2013
New Revision: 1453114
URL: http://svn.apache.org/r1453114
Log:
Added an unit test based on the user forum
Modified:
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfProducerRouterTest.java
Modified:
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfProducerRouterTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfProducerRouterTest.java?rev=1453114&r1=1453113&r2=1453114&view=diff
==============================================================================
---
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfProducerRouterTest.java
(original)
+++
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfProducerRouterTest.java
Wed Mar 6 01:17:10 2013
@@ -24,6 +24,7 @@ import org.apache.camel.Exchange;
import org.apache.camel.ExchangePattern;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.cxf.common.message.CxfConstants;
+import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.impl.DefaultExchange;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.apache.camel.util.URISupport;
@@ -72,11 +73,32 @@ public class CxfProducerRouterTest exten
from("direct:EndpointA").to(getSimpleEndpointUri());
from("direct:EndpointB").to(getSimpleEndpointUri() +
"&dataFormat=MESSAGE");
from("direct:EndpointC").to(getSimpleEndpointUri() +
"&dataFormat=PAYLOAD");
+ // This route is for checking camel-cxf producer throwing
exception
+ from("direct:start")
+ .doTry()
+
.to("cxf://http://localhost:10000/false?serviceClass=org.apache.camel.component.cxf.HelloService")
+ .doCatch(org.apache.cxf.interceptor.Fault.class)
+ .to("mock:error");
}
};
}
@Test
+ public void testCannotSendRequest() throws Exception {
+ MockEndpoint error = getMockEndpoint("mock:error");
+ error.expectedMessageCount(1);
+
+ Exchange senderExchange = new DefaultExchange(context,
ExchangePattern.InOut);
+ final List<String> params = new ArrayList<String>();
+ // Prepare the request message for the camel-cxf procedure
+ params.add(TEST_MESSAGE);
+ senderExchange.getIn().setBody(params);
+ senderExchange.getIn().setHeader(CxfConstants.OPERATION_NAME,
ECHO_OPERATION);
+ template.send("direct:start", senderExchange);
+ error.assertIsSatisfied();
+ }
+
+ @Test
public void testCxfEndpointUris() throws Exception {
CxfEndpoint endpoint = context.getEndpoint(getSimpleEndpointUri(),
CxfEndpoint.class);
assertEquals("Get a wrong endpoint uri", getSimpleEndpointUri(),
endpoint.getEndpointUri());