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;
}
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());
}
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);
}
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));
}
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));
}
Aggregations