Author: gertv
Date: Thu Dec 17 19:54:17 2009
New Revision: 891861
URL: http://svn.apache.org/viewvc?rev=891861&view=rev
Log:
SMX4-447: Share the CXF Bus with the camel-cxf component to allow using the
local:// transport
Modified:
servicemix/smx4/features/trunk/camel/servicemix-camel/src/test/java/org/apache/servicemix/camel/nmr/ExceptionHandleTest.java
servicemix/smx4/features/trunk/camel/servicemix-camel/src/test/java/org/apache/servicemix/camel/nmr/SmxToCxfTest.java
Modified:
servicemix/smx4/features/trunk/camel/servicemix-camel/src/test/java/org/apache/servicemix/camel/nmr/ExceptionHandleTest.java
URL:
http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/camel/servicemix-camel/src/test/java/org/apache/servicemix/camel/nmr/ExceptionHandleTest.java?rev=891861&r1=891860&r2=891861&view=diff
==============================================================================
---
servicemix/smx4/features/trunk/camel/servicemix-camel/src/test/java/org/apache/servicemix/camel/nmr/ExceptionHandleTest.java
(original)
+++
servicemix/smx4/features/trunk/camel/servicemix-camel/src/test/java/org/apache/servicemix/camel/nmr/ExceptionHandleTest.java
Thu Dec 17 19:54:17 2009
@@ -19,6 +19,7 @@
import java.net.URL;
import java.util.Map;
+import javax.naming.Context;
import javax.xml.namespace.QName;
import javax.xml.ws.BindingProvider;
import javax.xml.ws.soap.SOAPBinding;
@@ -50,20 +51,17 @@
protected static final String SERVICE_CLASS =
"serviceClass=org.apache.hello_world_soap_http.Greeter";
private static final String WSDL_LOCATION =
"wsdlURL=/wsdl/hello_world.wsdl";
private static final String SERVICE_NAME =
"serviceName=%7bhttp://apache.org/hello_world_soap_http%7dSOAPService";
-
-
-
+
private String routerEndpointURI = "cxf://" + ROUTER_ADDRESS + "?" +
SERVICE_CLASS
- + "&" + WSDL_LOCATION + "&" + SERVICE_NAME + "&dataFormat=POJO";
- private String serviceEndpointURI = "cxf://" + SERVICE_ADDRESS + "?" +
SERVICE_CLASS
- + "&" + WSDL_LOCATION + "&" + SERVICE_NAME + "&dataFormat=POJO";
-
+ + "&" + WSDL_LOCATION + "&" + SERVICE_NAME +
"&dataFormat=POJO&bus=#Bus";
+ private String serviceEndpointURI = "cxf://" + SERVICE_ADDRESS + "?" +
SERVICE_CLASS
+ + "&" + WSDL_LOCATION + "&" + SERVICE_NAME +
"&dataFormat=POJO&bus=#Bus";
+
private CamelContext camelContext;
private ServiceMixComponent smxComponent;
private NMR nmr;
private javax.xml.ws.Endpoint endpoint;
-
-
+
@Override
protected void setUp() throws Exception {
super.setUp();
@@ -97,7 +95,7 @@
}
protected CamelContext createCamelContext() throws Exception {
- camelContext = new DefaultCamelContext();
+ camelContext = new DefaultCamelContext(createJndiContext());
Bus bus = BusFactory.getDefaultBus();
CamelTransportFactory camelTransportFactory = (CamelTransportFactory)
bus.getExtension(ConduitInitiatorManager.class)
.getConduitInitiator(CamelTransportFactory.TRANSPORT_ID);
@@ -109,8 +107,15 @@
camelContext.addComponent("smx", smxComponent);
return camelContext;
}
-
- public void testException() throws Exception {
+
+ @Override
+ protected Context createJndiContext() throws Exception {
+ Context ctx = super.createJndiContext();
+ ctx.bind("Bus", BusFactory.getDefaultBus());
+ return ctx; //To change body of overridden methods use File |
Settings | File Templates.
+ }
+
+ public void testException() throws Exception {
URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
assertNotNull(wsdl);
SOAPService service1 = new SOAPService(wsdl, new QName(
@@ -144,8 +149,7 @@
assertNotNull(brlf.getFaultInfo());
assertEquals("BadRecordLitFault", brlf.getFaultInfo());
}
- }
-
+ }
public void testOneway() throws Exception {
URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
Modified:
servicemix/smx4/features/trunk/camel/servicemix-camel/src/test/java/org/apache/servicemix/camel/nmr/SmxToCxfTest.java
URL:
http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/camel/servicemix-camel/src/test/java/org/apache/servicemix/camel/nmr/SmxToCxfTest.java?rev=891861&r1=891860&r2=891861&view=diff
==============================================================================
---
servicemix/smx4/features/trunk/camel/servicemix-camel/src/test/java/org/apache/servicemix/camel/nmr/SmxToCxfTest.java
(original)
+++
servicemix/smx4/features/trunk/camel/servicemix-camel/src/test/java/org/apache/servicemix/camel/nmr/SmxToCxfTest.java
Thu Dec 17 19:54:17 2009
@@ -26,29 +26,45 @@
import org.apache.cxf.frontend.ClientFactoryBean;
import org.apache.cxf.frontend.ClientProxyFactoryBean;
import org.apache.cxf.frontend.ServerFactoryBean;
+import org.springframework.beans.BeansException;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class SmxToCxfTest extends CamelSpringTestSupport {
+
+ private static final String BUS_BEAN_NAME = "Bus";
protected static final String ROUTER_ADDRESS =
"http://localhost:19000/router";
protected static final String SERVICE_ADDRESS = "local://smx/helloworld";
protected static final String SERVICE_CLASS =
"serviceClass=org.apache.servicemix.camel.nmr.HelloService";
-
- private String routerEndpointURI = "cxf://" + ROUTER_ADDRESS + "?" +
SERVICE_CLASS + "&dataFormat=POJO&setDefaultBus=true";
- private String serviceEndpointURI = "cxf://" + SERVICE_ADDRESS + "?" +
SERVICE_CLASS + "&dataFormat=POJO&setDefaultBus=true";
-
+
+ private String routerEndpointURI =
+
String.format("cxf://%s?%s&dataFormat=POJO&setDefaultBus=true&bus=#%s",
ROUTER_ADDRESS, SERVICE_CLASS, BUS_BEAN_NAME);
+
+ private String serviceEndpointURI =
+
String.format("cxf://%s?%s&dataFormat=POJO&setDefaultBus=true&bus=#%s",
SERVICE_ADDRESS, SERVICE_CLASS, BUS_BEAN_NAME);
+
private ServerImpl server;
+ private Bus bus;
-
@Override
protected void setUp() throws Exception {
+ bus = CXFBusFactory.getDefaultBus();
+
super.setUp();
startService();
}
protected ClassPathXmlApplicationContext createApplicationContext() {
- return new
ClassPathXmlApplicationContext("org/apache/servicemix/camel/spring/DummyBean.xml");
+ return new
ClassPathXmlApplicationContext("org/apache/servicemix/camel/spring/DummyBean.xml")
{
+ @Override
+ public Object getBean(String name, Class requiredType) throws
BeansException {
+ if (BUS_BEAN_NAME.equals(name)) {
+ return bus;
+ }
+ return super.getBean(name, requiredType); //To change body
of overridden methods use File | Settings | File Templates.
+ }
+ };
}
protected void assertValidContext(CamelContext context) {
@@ -84,8 +100,8 @@
}
};
}
-
- public void testInvokingServiceFromCXFClient() throws Exception {
+
+ public void testInvokingServiceFromCXFClient() throws Exception {
Bus bus = BusFactory.getDefaultBus();
ClientProxyFactoryBean proxyFactory = new ClientProxyFactoryBean();