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 2011/03/07 04:18:35 UTC
svn commit: r1078662 -
/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfProducerRouterTest.java
Author: ningjiang
Date: Mon Mar 7 03:18:34 2011
New Revision: 1078662
URL: http://svn.apache.org/viewvc?rev=1078662&view=rev
Log:
Added an unit test of CxfProducer with PayloadMessage
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=1078662&r1=1078661&r2=1078662&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 Mon Mar 7 03:18:34 2011
@@ -16,11 +16,18 @@
*/
package org.apache.camel.component.cxf;
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.w3c.dom.Document;
+
import org.apache.camel.Exchange;
import org.apache.camel.ExchangePattern;
import org.apache.camel.builder.RouteBuilder;
@@ -44,6 +51,8 @@ public class CxfProducerRouterTest exten
+ "<soap:Body><ns1:echo xmlns:ns1=\"http://cxf.component.camel.apache.org/\">"
+ "<arg0 xmlns=\"http://cxf.component.camel.apache.org/\">Hello World!</arg0>"
+ "</ns1:echo></soap:Body></soap:Envelope>";
+ private static final String REQUEST_PAYLOAD = "<ns1:echo xmlns:ns1=\"http://cxf.component.camel.apache.org/\">"
+ + "<arg0 xmlns=\"http://cxf.component.camel.apache.org/\">Hello World!</arg0></ns1:echo>";
private static final String ECHO_OPERATION = "echo";
private static final String TEST_MESSAGE = "Hello World!";
@@ -65,6 +74,7 @@ public class CxfProducerRouterTest exten
public void configure() {
from("direct:EndpointA").to(getSimpleEndpointUri());
from("direct:EndpointB").to(getSimpleEndpointUri() + "&dataFormat=MESSAGE");
+ from("direct:EndpointC").to(getSimpleEndpointUri() + "&dataFormat=PAYLOAD");
}
};
}
@@ -116,6 +126,21 @@ public class CxfProducerRouterTest exten
assertTrue("It should has the echoResponse tag", response.indexOf("echoResponse") > 0);
}
+
+ @Test
+ public void testInvokingSimpleServerWithPayLoadDataFormat() throws Exception {
+ Exchange senderExchange = new DefaultExchange(context, ExchangePattern.InOut);
+ senderExchange.getIn().setBody(REQUEST_PAYLOAD);
+ // We need to specify the operation name to help CxfProducer to look up the BindingOperationInfo
+ senderExchange.getIn().setHeader(CxfConstants.OPERATION_NAME, "echo");
+ Exchange exchange = template.send("direct:EndpointC", senderExchange);
+
+ org.apache.camel.Message out = exchange.getOut();
+ String response = out.getBody(String.class);
+ assertTrue("It should has the echo message", response.indexOf("echo " + TEST_MESSAGE) > 0);
+ assertTrue("It should has the echoResponse tag", response.indexOf("echoResponse") > 0);
+
+ }
private String getSimpleEndpointUri() {
return "cxf://" + SIMPLE_SERVER_ADDRESS