Search in sources :

Example 41 with ExtensionManagerBus

use of org.apache.cxf.bus.extension.ExtensionManagerBus in project cxf by apache.

the class CdiBusBean method create.

@Override
public ExtensionManagerBus create(final CreationalContext<ExtensionManagerBus> ctx) {
    final ExtensionManagerBus instance = injectionTarget.produce(ctx);
    if ("true".equals(SystemPropertyAction.getProperty("org.apache.cxf.cdi.unwrap.proxies", "true"))) {
        instance.setProperty(ClassUnwrapper.class.getName(), new CdiClassUnwrapper());
    }
    BusFactory.possiblySetDefaultBus(instance);
    instance.initialize();
    injectionTarget.inject(instance, ctx);
    injectionTarget.postConstruct(instance);
    return instance;
}
Also used : ExtensionManagerBus(org.apache.cxf.bus.extension.ExtensionManagerBus) ClassUnwrapper(org.apache.cxf.common.util.ClassUnwrapper)

Example 42 with ExtensionManagerBus

use of org.apache.cxf.bus.extension.ExtensionManagerBus in project cxf by apache.

the class JettyHTTPDestinationTest method testDoService.

@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());
}
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 43 with ExtensionManagerBus

use of org.apache.cxf.bus.extension.ExtensionManagerBus in project cxf by apache.

the class JettyHTTPDestinationTest method testContinuationsIgnored.

@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);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) Bus(org.apache.cxf.Bus) ExtensionManagerBus(org.apache.cxf.bus.extension.ExtensionManagerBus) Message(org.apache.cxf.message.Message) QName(javax.xml.namespace.QName) HTTPTransportFactory(org.apache.cxf.transport.http.HTTPTransportFactory) ExtensionManagerBus(org.apache.cxf.bus.extension.ExtensionManagerBus) Test(org.junit.Test)

Example 44 with ExtensionManagerBus

use of org.apache.cxf.bus.extension.ExtensionManagerBus in project cxf by apache.

the class HTTPConduitTest method testConduitOutputStream.

/**
 * 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));
}
Also used : Bus(org.apache.cxf.Bus) ExtensionManagerBus(org.apache.cxf.bus.extension.ExtensionManagerBus) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) Message(org.apache.cxf.message.Message) WrappedOutputStream(org.apache.cxf.transport.http.HTTPConduit.WrappedOutputStream) OutputStream(java.io.OutputStream) ExtensionManagerBus(org.apache.cxf.bus.extension.ExtensionManagerBus) Test(org.junit.Test)

Example 45 with ExtensionManagerBus

use of org.apache.cxf.bus.extension.ExtensionManagerBus in project cxf by apache.

the class HTTPConduitTest method testAuthPolicyFromEndpointInfo.

@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));
}
Also used : Bus(org.apache.cxf.Bus) ExtensionManagerBus(org.apache.cxf.bus.extension.ExtensionManagerBus) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) AuthorizationPolicy(org.apache.cxf.configuration.security.AuthorizationPolicy) Message(org.apache.cxf.message.Message) ArrayList(java.util.ArrayList) List(java.util.List) ExtensionManagerBus(org.apache.cxf.bus.extension.ExtensionManagerBus) Test(org.junit.Test)

Aggregations

ExtensionManagerBus (org.apache.cxf.bus.extension.ExtensionManagerBus)59 Bus (org.apache.cxf.Bus)48 Test (org.junit.Test)44 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)28 Message (org.apache.cxf.message.Message)14 HTTPTransportFactory (org.apache.cxf.transport.http.HTTPTransportFactory)14 QName (javax.xml.namespace.QName)8 DestinationRegistry (org.apache.cxf.transport.http.DestinationRegistry)8 ServiceInfo (org.apache.cxf.service.model.ServiceInfo)7 ArrayList (java.util.ArrayList)6 AtmosphereInterceptor (org.atmosphere.cpr.AtmosphereInterceptor)6 HashMap (java.util.HashMap)5 HashSet (java.util.HashSet)5 URL (java.net.URL)4 List (java.util.List)4 ASMHelperImpl (org.apache.cxf.common.util.ASMHelperImpl)4 MessageObserver (org.apache.cxf.transport.MessageObserver)4 HTTPServerPolicy (org.apache.cxf.transports.http.configuration.HTTPServerPolicy)4 HttpURLConnection (java.net.HttpURLConnection)3 Hashtable (java.util.Hashtable)3