org.apache.cxf.bus.extension.ExtensionManagerBus Java Examples

The following examples show how to use org.apache.cxf.bus.extension.ExtensionManagerBus. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AtmosphereWebSocketServletDestinationTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testRegisteration() throws Exception {
    Bus bus = new ExtensionManagerBus();
    DestinationRegistry registry = new HTTPTransportFactory().getRegistry();
    EndpointInfo endpoint = new EndpointInfo();
    endpoint.setAddress(ENDPOINT_ADDRESS);
    endpoint.setName(ENDPOINT_NAME);

    TestAtmosphereWebSocketServletDestination dest =
        new TestAtmosphereWebSocketServletDestination(bus, registry, endpoint, ENDPOINT_ADDRESS);

    dest.activate();

    assertNotNull(registry.getDestinationForPath(ENDPOINT_ADDRESS));

    dest.deactivate();

    assertNull(registry.getDestinationForPath(ENDPOINT_ADDRESS));
}
 
Example #2
Source File: HTTPConduitURLConnectionTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
private Object doTestTLSServerParameters() throws Exception {
    Bus bus = new ExtensionManagerBus();
    EndpointInfo ei = new EndpointInfo();
    ei.setAddress("https://secure.nowhere.null/" + "bar/foo");
    HTTPConduit conduit = new URLConnectionHTTPConduit(bus, ei, null);
    conduit.finalizeConfig();

    Message message = getNewMessage();
    // We need an SSL policy, or we can't use "https".
    conduit.setTlsClientParameters(new TLSClientParameters());

    // Test call
    conduit.prepare(message);

    return message.get("http.connection");
}
 
Example #3
Source File: HTTPConduitURLConnectionTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
/**
 * This test verifies that URL used is overridden by having the
 * ENDPOINT_ADDRESS set on the Message.
 */
@Test
public void testConnectionURLOverride() throws Exception {
    Bus bus = new ExtensionManagerBus();
    EndpointInfo ei = new EndpointInfo();
    ei.setAddress("http://nowhere.null/bar/foo");
    HTTPConduit conduit = new URLConnectionHTTPConduit(bus, ei, null);
    conduit.finalizeConfig();

    Message message = getNewMessage();
    message.put(Message.ENDPOINT_ADDRESS, "http://somewhere.different/");

    // Test call
    conduit.prepare(message);

    HttpURLConnection con =
        (HttpURLConnection) message.get("http.connection");
    assertEquals("Unexpected URL address",
            con.getURL().toString(),
            "http://somewhere.different/");
}
 
Example #4
Source File: HTTPConduitURLConnectionTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
/**
 * This test verifies that the "prepare" call places an HttpURLConnection on
 * the Message and that its URL matches the endpoint.
 */
@Test
public void testConnectionURL() throws Exception {
    Bus bus = new ExtensionManagerBus();
    EndpointInfo ei = new EndpointInfo();
    ei.setAddress("http://nowhere.com/bar/foo");
    HTTPConduit conduit = new URLConnectionHTTPConduit(bus, ei, null);
    conduit.finalizeConfig();

    Message message = getNewMessage();

    conduit.prepare(message);

    HttpURLConnection con =
        (HttpURLConnection) message.get("http.connection");
    assertEquals("Unexpected URL address",
            con.getURL().toString(),
            ei.getAddress());
}
 
Example #5
Source File: HttpConduitConfigApplierTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testTrustVerificationEnabled() throws IOException {
    HttpConduitConfigApplier configApplier = new HttpConduitConfigApplier();

    Dictionary<String, String> configValues = new Hashtable<>();
    configValues.put("tlsClientParameters.disableCNCheck", "true");
    configValues.put("tlsClientParameters.trustManagers.disableTrustVerification", "false");
    String address = "https://localhost:12345";
    Bus bus = new ExtensionManagerBus();
    EndpointInfo ei = new EndpointInfo();
    ei.setAddress(address);
    HTTPConduit conduit = new URLConnectionHTTPConduit(bus, ei, null);

    configApplier.apply(configValues, conduit, address);

    assertNotNull(conduit.getTlsClientParameters().getTrustManagers());
    assertEquals(conduit.getTlsClientParameters().getTrustManagers().length, 1);
    assertFalse(conduit.getTlsClientParameters().getTrustManagers()[0].getClass()
            .getName().startsWith(InsecureTrustManager.class.getName()));
    assertTrue(conduit.getTlsClientParameters().isDisableCNCheck());
}
 
Example #6
Source File: HttpConduitConfigApplierTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testDisableTrustVerification() throws IOException {
    HttpConduitConfigApplier configApplier = new HttpConduitConfigApplier();

    Dictionary<String, String> configValues = new Hashtable<>();
    configValues.put("tlsClientParameters.disableCNCheck", "true");
    configValues.put("tlsClientParameters.trustManagers.disableTrustVerification", "true");
    String address = "https://localhost:12345";
    Bus bus = new ExtensionManagerBus();
    EndpointInfo ei = new EndpointInfo();
    ei.setAddress(address);
    HTTPConduit conduit = new URLConnectionHTTPConduit(bus, ei, null);

    configApplier.apply(configValues, conduit, address);

    assertNotNull(conduit.getTlsClientParameters().getTrustManagers());
    assertEquals(conduit.getTlsClientParameters().getTrustManagers().length, 1);
    assertTrue(conduit.getTlsClientParameters().getTrustManagers()[0].getClass()
            .getName().startsWith(InsecureTrustManager.class.getName()));
    assertTrue(conduit.getTlsClientParameters().isDisableCNCheck());
}
 
Example #7
Source File: HttpConduitConfigApplierTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testNormalTrustLoading() throws IOException {
    HttpConduitConfigApplier configApplier = new HttpConduitConfigApplier();

    Dictionary<String, String> configValues = new Hashtable<>();
    configValues.put("tlsClientParameters.disableCNCheck", "false");
    String address = "https://localhost:12345";
    Bus bus = new ExtensionManagerBus();
    EndpointInfo ei = new EndpointInfo();
    ei.setAddress(address);
    HTTPConduit conduit = new URLConnectionHTTPConduit(bus, ei, null);

    configApplier.apply(configValues, conduit, address);

    assertNull(conduit.getTlsClientParameters().getTrustManagers());
    assertFalse(conduit.getTlsClientParameters().isDisableCNCheck());
}
 
Example #8
Source File: HTTPConduitTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testAuthPolicyFromEndpointInfo() throws Exception {
    Bus bus = new ExtensionManagerBus();
    EndpointInfo ei = new EndpointInfo();
    AuthorizationPolicy ap = new AuthorizationPolicy();
    ap.setPassword("password");
    ap.setUserName("testUser");
    ei.addExtensor(ap);
    ei.setAddress("http://nowhere.com/bar/foo");
    HTTPConduit conduit = new URLConnectionHTTPConduit(bus, ei, null);
    conduit.finalizeConfig();
    Message message = getNewMessage();

    // Test call
    conduit.prepare(message);

    Map<String, List<String>> headers =
        CastUtils.cast((Map<?, ?>)message.get(Message.PROTOCOL_HEADERS));

    assertNotNull("Authorization Header should exist",
            headers.get("Authorization"));

    assertEquals("Unexpected Authorization Token",
        DefaultBasicAuthSupplier.getBasicAuthHeader("testUser", "password"),
            headers.get("Authorization").get(0));
}
 
Example #9
Source File: HTTPConduitTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
/**
 * Verfies one of the tenents of our interface -- the Conduit sets up
 * an OutputStream on the message after a "prepare".
 */
@Test
public void testConduitOutputStream() throws Exception {
    Bus bus = new ExtensionManagerBus();
    EndpointInfo ei = new EndpointInfo();
    ei.setAddress("http://nowhere.com/bar/foo");
    HTTPConduit conduit = new URLConnectionHTTPConduit(bus, ei, null);
    conduit.finalizeConfig();

    Message message = getNewMessage();

    // Test call
    conduit.prepare(message);

    assertNotNull("Conduit should always set output stream.",
                    message.getContent(OutputStream.class));
}
 
Example #10
Source File: JettyWebSocketDestinationTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testRegisteration() throws Exception {
    Bus bus = new ExtensionManagerBus();
    DestinationRegistry registry = new HTTPTransportFactory().getRegistry();
    EndpointInfo endpoint = new EndpointInfo();
    endpoint.setAddress(ENDPOINT_ADDRESS);
    endpoint.setName(ENDPOINT_NAME);
    JettyHTTPServerEngine engine = EasyMock.createMock(JettyHTTPServerEngine.class);

    control.replay();

    TestJettyWebSocketDestination dest = new TestJettyWebSocketDestination(bus, registry, endpoint, null, engine);

    dest.activate();

    assertNotNull(registry.getDestinationForPath(ENDPOINT_ADDRESS));

    dest.deactivate();

    assertNull(registry.getDestinationForPath(ENDPOINT_ADDRESS));
}
 
Example #11
Source File: AtmosphereWebSocketServletDestinationTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testUseCustomAtmoosphereInterceptors() throws Exception {
    Bus bus = new ExtensionManagerBus();
    bus.setProperty("atmosphere.interceptors", Arrays.asList(new CustomInterceptor1(), new CustomInterceptor2()));
    DestinationRegistry registry = new HTTPTransportFactory().getRegistry();
    EndpointInfo endpoint = new EndpointInfo();
    endpoint.setAddress(ENDPOINT_ADDRESS);
    endpoint.setName(ENDPOINT_NAME);

    AtmosphereWebSocketServletDestination dest =
        new AtmosphereWebSocketServletDestination(bus, registry, endpoint, ENDPOINT_ADDRESS);

    List<AtmosphereInterceptor> ais = dest.getAtmosphereFramework().interceptors();
    int added = 0;
    for (AtmosphereInterceptor a : ais) {
        if (CustomInterceptor1.class.equals(a.getClass())) {
            added++;
        } else if (CustomInterceptor2.class.equals(a.getClass())) {
            added++;
            break;
        }
    }
    assertEquals(2, added);
}
 
Example #12
Source File: AtmosphereWebSocketServletDestinationTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testUseCustomAtmoosphereInterceptor() throws Exception {
    Bus bus = new ExtensionManagerBus();
    bus.setProperty("atmosphere.interceptors", new CustomInterceptor1());
    DestinationRegistry registry = new HTTPTransportFactory().getRegistry();
    EndpointInfo endpoint = new EndpointInfo();
    endpoint.setAddress(ENDPOINT_ADDRESS);
    endpoint.setName(ENDPOINT_NAME);

    AtmosphereWebSocketServletDestination dest =
        new AtmosphereWebSocketServletDestination(bus, registry, endpoint, ENDPOINT_ADDRESS);

    List<AtmosphereInterceptor> ais = dest.getAtmosphereFramework().interceptors();
    int added = 0;
    for (AtmosphereInterceptor a : ais) {
        if (CustomInterceptor1.class.equals(a.getClass())) {
            added++;
            break;
        }
    }
    assertEquals(1, added);
}
 
Example #13
Source File: AtmosphereWebSocketServletDestinationTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testUseCXFDefaultAtmoosphereInterceptor() throws Exception {
    Bus bus = new ExtensionManagerBus();
    DestinationRegistry registry = new HTTPTransportFactory().getRegistry();
    EndpointInfo endpoint = new EndpointInfo();
    endpoint.setAddress(ENDPOINT_ADDRESS);
    endpoint.setName(ENDPOINT_NAME);

    AtmosphereWebSocketServletDestination dest =
        new AtmosphereWebSocketServletDestination(bus, registry, endpoint, ENDPOINT_ADDRESS);

    List<AtmosphereInterceptor> ais = dest.getAtmosphereFramework().interceptors();
    int added = 0;
    for (AtmosphereInterceptor a : ais) {
        if (DefaultProtocolInterceptor.class.equals(a.getClass())) {
            added++;
            break;
        }
    }
    assertEquals(1, added);
}
 
Example #14
Source File: AtmosphereWebSocketJettyDestinationTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testUseCustomAtmoosphereInterceptors() throws Exception {
    Bus bus = new ExtensionManagerBus();
    bus.setProperty("atmosphere.interceptors", Arrays.asList(new CustomInterceptor1(), new CustomInterceptor2()));
    DestinationRegistry registry = new HTTPTransportFactory().getRegistry();
    EndpointInfo endpoint = new EndpointInfo();
    endpoint.setAddress(ENDPOINT_ADDRESS);
    endpoint.setName(ENDPOINT_NAME);

    AtmosphereWebSocketServletDestination dest =
        new AtmosphereWebSocketServletDestination(bus, registry, endpoint, ENDPOINT_ADDRESS);

    List<AtmosphereInterceptor> ais = dest.getAtmosphereFramework().interceptors();
    int added = 0;
    for (AtmosphereInterceptor a : ais) {
        if (CustomInterceptor1.class.equals(a.getClass())) {
            added++;
        } else if (CustomInterceptor2.class.equals(a.getClass())) {
            added++;
            break;
        }
    }
    assertEquals(2, added);
}
 
Example #15
Source File: CXFBusImplTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example #16
Source File: AtmosphereWebSocketJettyDestinationTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testUseCXFDefaultAtmoosphereInterceptor() throws Exception {
    Bus bus = new ExtensionManagerBus();
    DestinationRegistry registry = new HTTPTransportFactory().getRegistry();
    EndpointInfo endpoint = new EndpointInfo();
    endpoint.setAddress(ENDPOINT_ADDRESS);
    endpoint.setName(ENDPOINT_NAME);

    AtmosphereWebSocketServletDestination dest =
        new AtmosphereWebSocketServletDestination(bus, registry, endpoint, ENDPOINT_ADDRESS);

    List<AtmosphereInterceptor> ais = dest.getAtmosphereFramework().interceptors();
    int added = 0;
    for (AtmosphereInterceptor a : ais) {
        if (DefaultProtocolInterceptor.class.equals(a.getClass())) {
            added++;
            break;
        }
    }
    assertEquals(1, added);
}
 
Example #17
Source File: NettyHttpDestinationTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testServerPolicyInServiceModel()
    throws Exception {
    policy = new HTTPServerPolicy();
    address = getEPR("bar/foo");
    bus = new ExtensionManagerBus();

    transportFactory = new HTTPTransportFactory();

    ServiceInfo serviceInfo = new ServiceInfo();
    serviceInfo.setName(new QName("bla", "Service"));
    endpointInfo = new EndpointInfo(serviceInfo, "");
    endpointInfo.setName(new QName("bla", "Port"));
    endpointInfo.addExtensor(policy);

    engine = EasyMock.createMock(NettyHttpServerEngine.class);
    EasyMock.replay();
    endpointInfo.setAddress(NOWHERE + "bar/foo");

    NettyHttpDestination dest =
        new EasyMockJettyHTTPDestination(
                bus, transportFactory.getRegistry(), endpointInfo, null, engine);
    assertEquals(policy, dest.getServer());
}
 
Example #18
Source File: PolicyEngineTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testAccessors() throws Exception {
    engine = new PolicyEngineImpl(false);
    assertNotNull(engine.getRegistry());
    assertNull(engine.getBus());
    assertNotNull(engine.getPolicyProviders());
    assertNull(engine.getAlternativeSelector());
    assertFalse(engine.isEnabled());
    Bus bus = new ExtensionManagerBus();

    engine.setBus(bus);
    List<PolicyProvider> providers = CastUtils.cast(Collections.EMPTY_LIST, PolicyProvider.class);
    engine.setPolicyProviders(providers);
    PolicyRegistry reg = control.createMock(PolicyRegistry.class);
    engine.setRegistry(reg);
    engine.setEnabled(true);
    AlternativeSelector selector = control.createMock(AlternativeSelector.class);
    engine.setAlternativeSelector(selector);
    assertSame(bus, engine.getBus());
    assertSame(reg, engine.getRegistry());
    assertTrue(engine.isEnabled());
    assertSame(selector, engine.getAlternativeSelector());
    assertNotNull(engine.createOutPolicyInfo());
    bus.shutdown(true);
}
 
Example #19
Source File: AtmosphereWebSocketJettyDestinationTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testUseCustomAtmoosphereInterceptor() throws Exception {
    Bus bus = new ExtensionManagerBus();
    bus.setProperty("atmosphere.interceptors", new CustomInterceptor1());
    DestinationRegistry registry = new HTTPTransportFactory().getRegistry();
    EndpointInfo endpoint = new EndpointInfo();
    endpoint.setAddress(ENDPOINT_ADDRESS);
    endpoint.setName(ENDPOINT_NAME);

    AtmosphereWebSocketServletDestination dest =
        new AtmosphereWebSocketServletDestination(bus, registry, endpoint, ENDPOINT_ADDRESS);

    List<AtmosphereInterceptor> ais = dest.getAtmosphereFramework().interceptors();
    int added = 0;
    for (AtmosphereInterceptor a : ais) {
        if (CustomInterceptor1.class.equals(a.getClass())) {
            added++;
            break;
        }
    }
    assertEquals(1, added);
}
 
Example #20
Source File: CXFBusImplTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testConstructionWithExtensions() throws BusException {

    IMocksControl control;
    BindingFactoryManager bindingFactoryManager;
    InstrumentationManager instrumentationManager;
    PhaseManager phaseManager;

    control = EasyMock.createNiceControl();

    Map<Class<?>, Object> extensions = new HashMap<>();
    bindingFactoryManager = control.createMock(BindingFactoryManager.class);
    instrumentationManager = control.createMock(InstrumentationManager.class);
    phaseManager = control.createMock(PhaseManager.class);

    extensions.put(BindingFactoryManager.class, bindingFactoryManager);
    extensions.put(InstrumentationManager.class, instrumentationManager);
    extensions.put(PhaseManager.class, phaseManager);

    Bus bus = new ExtensionManagerBus(extensions);

    assertSame(bindingFactoryManager, bus.getExtension(BindingFactoryManager.class));
    assertSame(instrumentationManager, bus.getExtension(InstrumentationManager.class));
    assertSame(phaseManager, bus.getExtension(PhaseManager.class));

}
 
Example #21
Source File: BusExtensionLoadingTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
/**
 * 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);
    }
}
 
Example #22
Source File: CXFBusFactory.java    From cxf with Apache License 2.0 5 votes vote down vote up
public Bus createBus(Map<Class<?>, Object> e, Map<String, Object> properties) {
    ExtensionManagerBus bus = new ExtensionManagerBus(e, properties);
    possiblySetDefaultBus(bus);
    initializeBus(bus);
    bus.initialize();
    return bus;
}
 
Example #23
Source File: CXFBusImplTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #24
Source File: CXFBusImplTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #25
Source File: JettyHTTPDestinationTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testContinuationsIgnored() throws Exception {

    HttpServletRequest httpRequest = EasyMock.createMock(HttpServletRequest.class);

    ServiceInfo serviceInfo = new ServiceInfo();
    serviceInfo.setName(new QName("bla", "Service"));
    EndpointInfo ei = new EndpointInfo(serviceInfo, "");
    ei.setName(new QName("bla", "Port"));

    final JettyHTTPServerEngine httpEngine = new JettyHTTPServerEngine();
    httpEngine.setContinuationsEnabled(false);
    JettyHTTPServerEngineFactory factory = new JettyHTTPServerEngineFactory() {
        @Override
        public JettyHTTPServerEngine retrieveJettyHTTPServerEngine(int port) {
            return httpEngine;
        }
    };
    Bus b2 = new ExtensionManagerBus();
    transportFactory = new HTTPTransportFactory();
    b2.setExtension(factory, JettyHTTPServerEngineFactory.class);

    TestJettyDestination testDestination =
        new TestJettyDestination(b2,
                                 transportFactory.getRegistry(),
                                 ei,
                                 factory);
    testDestination.finalizeConfig();
    Message mi = testDestination.retrieveFromContinuation(httpRequest);
    assertNull("Continuations must be ignored", mi);
}
 
Example #26
Source File: CXFBusImplTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testConstructionWithoutExtensions() throws BusException {

    Bus bus = new ExtensionManagerBus();
    assertNotNull(bus.getExtension(BindingFactoryManager.class));
    assertNotNull(bus.getExtension(ConduitInitiatorManager.class));
    assertNotNull(bus.getExtension(DestinationFactoryManager.class));
    assertNotNull(bus.getExtension(PhaseManager.class));
    bus.shutdown(true);
}
 
Example #27
Source File: JettyHTTPDestinationTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testDoService() throws Exception {
    Bus defaultBus = new ExtensionManagerBus();
    assertSame("Default thread bus has not been set",
               defaultBus, BusFactory.getThreadDefaultBus());
    destination = setUpDestination(false, false);
    setUpDoService(false);
    assertSame("Default thread bus has been unexpectedly reset",
               defaultBus, BusFactory.getThreadDefaultBus());
    destination.doService(request, response);
    verifyDoService();
    assertSame("Default thread bus has not been reset",
                defaultBus, BusFactory.getThreadDefaultBus());
}
 
Example #28
Source File: UndertowHTTPDestinationTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testContinuationsIgnored() throws Exception {

    HttpServletRequest httpRequest = EasyMock.createMock(HttpServletRequest.class);

    ServiceInfo serviceInfo = new ServiceInfo();
    serviceInfo.setName(new QName("bla", "Service"));
    EndpointInfo ei = new EndpointInfo(serviceInfo, "");
    ei.setName(new QName("bla", "Port"));

    final UndertowHTTPServerEngine httpEngine = new UndertowHTTPServerEngine();
    httpEngine.setContinuationsEnabled(false);
    UndertowHTTPServerEngineFactory factory = new UndertowHTTPServerEngineFactory() {
        @Override
        public UndertowHTTPServerEngine retrieveUndertowHTTPServerEngine(int port) {
            return httpEngine;
        }
    };
    Bus b2 = new ExtensionManagerBus();
    transportFactory = new HTTPTransportFactory();
    b2.setExtension(factory, UndertowHTTPServerEngineFactory.class);

    TestUndertowDestination testDestination =
        new TestUndertowDestination(b2,
                                 transportFactory.getRegistry(),
                                 ei,
                                 factory);
    testDestination.finalizeConfig();
    Message mi = testDestination.retrieveFromContinuation(httpRequest);
    assertNull("Continuations must be ignored", mi);
}
 
Example #29
Source File: NettyHttpDestinationTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testDoService() throws Exception {
    Bus defaultBus = new ExtensionManagerBus();
    assertSame("Default thread bus has not been set",
               defaultBus, BusFactory.getThreadDefaultBus());
    destination = setUpDestination(false, false);
    setUpDoService(false);
    assertSame("Default thread bus has been unexpectedly reset",
               defaultBus, BusFactory.getThreadDefaultBus());
    destination.doService(request, response);
    verifyDoService();
    assertSame("Default thread bus has not been reset",
                defaultBus, BusFactory.getThreadDefaultBus());
}
 
Example #30
Source File: UndertowHTTPDestinationTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testDoService() throws Exception {
    Bus defaultBus = new ExtensionManagerBus();
    assertSame("Default thread bus has not been set",
               defaultBus, BusFactory.getThreadDefaultBus());
    destination = setUpDestination(false, false);
    setUpDoService(false);
    assertSame("Default thread bus has been unexpectedly reset",
               defaultBus, BusFactory.getThreadDefaultBus());
    destination.doService(request, response);
    verifyDoService();
    assertSame("Default thread bus has not been reset",
                defaultBus, BusFactory.getThreadDefaultBus());
}