I wanted to verify if the approach below is the correct one regarding Camel cxfEndpoint usage and testability.
I have a camelRoute using an cxfEndpoint (payload dataformat) to consume webservice messages. <cxf:cxfEndpoint id="soapMessageEndpoint" address="http://localhost:9080/app/webservices/service1" endpointName="s:SoapOverHttpRouter" serviceName="s:SOAPService" xmlns:s="http://apache.org/service_soap_http"> <cxf:properties> <entry key="dataFormat" value="PAYLOAD"/> </cxf:properties> </cxf:cxfEndpoint> <from uri="cxf:bean:soapMessageEndpoint"/> I can "unit test" this route using a CamelSpringTestSupport testcase easily as the cxfEndpoint component starts an embedded jetty server and I can have my test send SOAP messages over this embedded HTTP server. It's not really a unit test, but it runs it in a J2SE environment without too much dependencies. We deploy the route on an JEE application server, so our target environment is a JEE container. When deployed in a JEE container I'm not using the embedded jetty but I'm using the CXFServlet (the route is bootstrapped from a WAR file). <servlet> <servlet-name>CXFServlet</servlet-name> <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>CXFServlet</servlet-name> <url-pattern>/webservices/*</url-pattern> </servlet-mapping> As a consequence, the route definition is a bit different. In the JEE environment I don't need the cxfEndpoint component, but rather use a from uri like this: <from uri="cxf://service1?dataFormat=PAYLOAD"/> I'm looking for a way to have 1 single camel route definition that can be used in the JEE container, but also used in a standalone J2SE environment for testing. As such, I've created a single Camel route that I used both for unit testing and at runtime in the container. For the unit test, I'm using an adviceWith/replaceFromWith to replace the original from (cxf://service1?dataFormat=PAYLOAD , used by the JEE container) with a from suitable for unit testing (cxf:bean:soapMessageEndpoint). private static final String UNITTEST_ENDPOINT_NAME = "cxf:bean:soapMessageEndpoint"; CamelContext camelContext = createCamelContext(); RouteDefinition routeDefinition = camelContext.getRouteDefinition(FLOW_ID); if (!UNITTEST_ENDPOINT_NAME.equals(routeDefinition.getInputs().get(0).getUri())) { routeDefinition.adviceWith(camelContext, new AdviceWithRouteBuilder() { @Override public void configure() throws Exception { replaceFromWith(UNITTEST_ENDPOINT_NAME); } }); } Is this the correct way of handling this ? -- View this message in context: http://camel.465427.n5.nabble.com/Camel-cxfEndpoint-testing-guidelines-tp5731082.html Sent from the Camel - Users mailing list archive at Nabble.com.