use of org.apache.cxf.bus.extension.ExtensionManagerBus in project camel by apache.
the class CxfEndpointTest method testSettingClientBus.
@Test
public void testSettingClientBus() throws Exception {
ExtensionManagerBus bus = (ExtensionManagerBus) BusFactory.newInstance().createBus();
bus.setId("oldCXF");
BusFactory.setThreadDefaultBus(bus);
ExtensionManagerBus newBus = (ExtensionManagerBus) BusFactory.newInstance().createBus();
newBus.setId("newCXF");
CxfComponent cxfComponent = new CxfComponent(new DefaultCamelContext());
CxfEndpoint endpoint = (CxfEndpoint) cxfComponent.createEndpoint(routerEndpointURI);
endpoint.setBus(newBus);
CamelCxfClientImpl client = (CamelCxfClientImpl) endpoint.createClient();
assertEquals("CamelCxfClientImpl should has the same bus with CxfEndpoint", newBus, client.getBus());
endpoint = (CxfEndpoint) cxfComponent.createEndpoint(wsdlEndpointURI);
endpoint.setBus(newBus);
client = (CamelCxfClientImpl) endpoint.createClient();
assertEquals("CamelCxfClientImpl should has the same bus with CxfEndpoint", newBus, client.getBus());
}
use of org.apache.cxf.bus.extension.ExtensionManagerBus in project cxf by apache.
the class BusExtensionLoadingTest method testBusConstructionWithoutTCCL.
/**
* Tests the ExtensionManagerBus can be built using a given classloader
*
* @throws Exception
*/
@Test
public void testBusConstructionWithoutTCCL() throws Exception {
ClassLoader origClassLoader = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(new TestClassLoader());
BusFactory factory = new CXFBusFactory() {
public Bus createBus(Map<Class<?>, Object> e, Map<String, Object> properties) {
return new ExtensionManagerBus(e, properties, this.getClass().getClassLoader());
}
};
Bus bus = factory.createBus();
assertNotNullExtensions(bus);
bus.shutdown(true);
} finally {
Thread.currentThread().setContextClassLoader(origClassLoader);
}
}
use of org.apache.cxf.bus.extension.ExtensionManagerBus in project cxf by apache.
the class CXFBusImplTest method testBusID.
@Test
public void testBusID() {
Bus bus = new ExtensionManagerBus();
String id = bus.getId();
assertEquals("The bus id should be cxf", id, Bus.DEFAULT_BUS_ID + Math.abs(bus.hashCode()));
bus.setId("test");
assertEquals("The bus id should be changed", "test", bus.getId());
bus.shutdown(true);
}
use of org.apache.cxf.bus.extension.ExtensionManagerBus in project cxf by apache.
the class CXFBusImplTest method testExtensions.
@Test
public void testExtensions() {
Bus bus = new ExtensionManagerBus();
String extension = "CXF";
bus.setExtension(extension, String.class);
assertSame(extension, bus.getExtension(String.class));
bus.shutdown(true);
}
use of org.apache.cxf.bus.extension.ExtensionManagerBus in project cxf by apache.
the class CXFBusImplTest method testShutdownWithBusLifecycle.
@Test
public void testShutdownWithBusLifecycle() {
final Bus bus = new ExtensionManagerBus();
BusLifeCycleManager lifeCycleManager = bus.getExtension(BusLifeCycleManager.class);
BusLifeCycleListener listener = EasyMock.createMock(BusLifeCycleListener.class);
EasyMock.reset(listener);
listener.preShutdown();
EasyMock.expectLastCall();
listener.postShutdown();
EasyMock.expectLastCall();
EasyMock.replay(listener);
lifeCycleManager.registerLifeCycleListener(listener);
bus.shutdown(true);
EasyMock.verify(listener);
bus.shutdown(true);
}
Aggregations