Search in sources :

Example 1 with ExtensionManagerBus

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());
}
Also used : CamelCxfClientImpl(org.apache.camel.component.cxf.CxfEndpoint.CamelCxfClientImpl) ExtensionManagerBus(org.apache.cxf.bus.extension.ExtensionManagerBus) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) Test(org.junit.Test)

Example 2 with ExtensionManagerBus

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);
    }
}
Also used : Bus(org.apache.cxf.Bus) ExtensionManagerBus(org.apache.cxf.bus.extension.ExtensionManagerBus) CXFBusFactory(org.apache.cxf.bus.CXFBusFactory) BusFactory(org.apache.cxf.BusFactory) Map(java.util.Map) ExtensionManagerBus(org.apache.cxf.bus.extension.ExtensionManagerBus) CXFBusFactory(org.apache.cxf.bus.CXFBusFactory) Test(org.junit.Test)

Example 3 with ExtensionManagerBus

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);
}
Also used : Bus(org.apache.cxf.Bus) ExtensionManagerBus(org.apache.cxf.bus.extension.ExtensionManagerBus) ExtensionManagerBus(org.apache.cxf.bus.extension.ExtensionManagerBus) Test(org.junit.Test)

Example 4 with ExtensionManagerBus

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);
}
Also used : Bus(org.apache.cxf.Bus) ExtensionManagerBus(org.apache.cxf.bus.extension.ExtensionManagerBus) ExtensionManagerBus(org.apache.cxf.bus.extension.ExtensionManagerBus) Test(org.junit.Test)

Example 5 with ExtensionManagerBus

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);
}
Also used : Bus(org.apache.cxf.Bus) ExtensionManagerBus(org.apache.cxf.bus.extension.ExtensionManagerBus) BusLifeCycleManager(org.apache.cxf.buslifecycle.BusLifeCycleManager) BusLifeCycleListener(org.apache.cxf.buslifecycle.BusLifeCycleListener) ExtensionManagerBus(org.apache.cxf.bus.extension.ExtensionManagerBus) Test(org.junit.Test)

Aggregations

ExtensionManagerBus (org.apache.cxf.bus.extension.ExtensionManagerBus)41 Bus (org.apache.cxf.Bus)33 Test (org.junit.Test)31 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)24 HTTPTransportFactory (org.apache.cxf.transport.http.HTTPTransportFactory)14 Message (org.apache.cxf.message.Message)13 DestinationRegistry (org.apache.cxf.transport.http.DestinationRegistry)8 QName (javax.xml.namespace.QName)7 ServiceInfo (org.apache.cxf.service.model.ServiceInfo)7 AtmosphereInterceptor (org.atmosphere.cpr.AtmosphereInterceptor)6 URL (java.net.URL)4 ConduitInitiatorManager (org.apache.cxf.transport.ConduitInitiatorManager)4 MessageObserver (org.apache.cxf.transport.MessageObserver)4 HTTPServerPolicy (org.apache.cxf.transports.http.configuration.HTTPServerPolicy)4 EndpointReferenceType (org.apache.cxf.ws.addressing.EndpointReferenceType)4 HttpURLConnection (java.net.HttpURLConnection)3 HashSet (java.util.HashSet)3 ConduitInitiator (org.apache.cxf.transport.ConduitInitiator)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2