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 JettyHTTPDestinationTest method setUpDestination.
private JettyHTTPDestination setUpDestination(boolean contextMatchOnStem, boolean mockedBus) throws Exception {
policy = new HTTPServerPolicy();
address = getEPR("bar/foo");
transportFactory = new HTTPTransportFactory();
final ConduitInitiator ci = new ConduitInitiator() {
public Conduit getConduit(EndpointInfo targetInfo, Bus b) throws IOException {
return decoupledBackChannel;
}
public Conduit getConduit(EndpointInfo localInfo, EndpointReferenceType target, Bus b) throws IOException {
return decoupledBackChannel;
}
public List<String> getTransportIds() {
return null;
}
public Set<String> getUriPrefixes() {
return new HashSet<>(Collections.singletonList("http"));
}
};
ConduitInitiatorManager mgr = new ConduitInitiatorManager() {
public void deregisterConduitInitiator(String name) {
}
public ConduitInitiator getConduitInitiator(String name) throws BusException {
return null;
}
public ConduitInitiator getConduitInitiatorForUri(String uri) {
return ci;
}
public void registerConduitInitiator(String name, ConduitInitiator factory) {
}
};
if (!mockedBus) {
bus = new ExtensionManagerBus();
bus.setExtension(mgr, ConduitInitiatorManager.class);
} else {
bus = EasyMock.createMock(Bus.class);
bus.getExtension(EndpointResolverRegistry.class);
EasyMock.expectLastCall().andReturn(null);
bus.getExtension(ContinuationProviderFactory.class);
EasyMock.expectLastCall().andReturn(null).anyTimes();
bus.getExtension(PolicyDataEngine.class);
EasyMock.expectLastCall().andReturn(null).anyTimes();
bus.hasExtensionByName("org.apache.cxf.ws.policy.PolicyEngine");
EasyMock.expectLastCall().andReturn(false);
bus.getExtension(ClassLoader.class);
EasyMock.expectLastCall().andReturn(this.getClass().getClassLoader());
EasyMock.replay(bus);
}
engine = EasyMock.createNiceMock(JettyHTTPServerEngine.class);
ServiceInfo serviceInfo = new ServiceInfo();
serviceInfo.setName(new QName("bla", "Service"));
endpointInfo = new EndpointInfo(serviceInfo, "");
endpointInfo.setName(new QName("bla", "Port"));
endpointInfo.setAddress(NOWHERE + "bar/foo");
endpointInfo.addExtensor(policy);
engine.addServant(EasyMock.eq(new URL(NOWHERE + "bar/foo")), EasyMock.isA(JettyHTTPHandler.class));
EasyMock.expectLastCall();
engine.getContinuationsEnabled();
EasyMock.expectLastCall().andReturn(true);
EasyMock.replay(engine);
JettyHTTPDestination dest = new EasyMockJettyHTTPDestination(bus, transportFactory.getRegistry(), endpointInfo, null, engine);
dest.retrieveEngine();
policy = dest.getServer();
observer = new MessageObserver() {
public void onMessage(Message m) {
inMessage = m;
threadDefaultBus = BusFactory.getThreadDefaultBus();
}
};
dest.setMessageObserver(observer);
return dest;
}
use of org.apache.cxf.bus.extension.ExtensionManagerBus in project cxf by apache.
the class ClientProviderFactoryTest method testParameterHandlerProviderWithConstraints.
@Test
public void testParameterHandlerProviderWithConstraints() throws Exception {
final Bus bus = new ExtensionManagerBus();
final ProviderFactory pf = ClientProviderFactory.createInstance(bus);
@ConstrainedTo(RuntimeType.SERVER)
class ServerParameterHandler extends CustomerParameterHandler {
// Server parameter handler
}
@ConstrainedTo(RuntimeType.CLIENT)
class ClientParameterHandler extends CustomerParameterHandler {
// Client parameter handler
}
ParamConverterProvider h = new ServerParameterHandler();
ParamConverterProvider hp = new ClientParameterHandler();
pf.registerUserProvider(h);
pf.registerUserProvider(hp);
ParamConverter<Customer> h2 = pf.createParameterHandler(Customer.class, Customer.class, null, new MessageImpl());
assertSame(h2, hp);
}
use of org.apache.cxf.bus.extension.ExtensionManagerBus in project cxf by apache.
the class ClientProviderFactoryTest method testParameterHandlerProviderWithPriority.
@Test
public void testParameterHandlerProviderWithPriority() throws Exception {
final Bus bus = new ExtensionManagerBus();
final ProviderFactory pf = ClientProviderFactory.createInstance(bus);
ParamConverterProvider h = new CustomerParameterHandler();
ParamConverterProvider hp = new PriorityCustomerParameterHandler();
pf.registerUserProvider(h);
pf.registerUserProvider(hp);
ParamConverter<Customer> h2 = pf.createParameterHandler(Customer.class, Customer.class, null, new MessageImpl());
assertSame(h2, hp);
}
use of org.apache.cxf.bus.extension.ExtensionManagerBus in project cxf by apache.
the class RestClientCdiTest method testCreationalContextsReleasedOnClientClose.
@Test
@SuppressWarnings({ "unchecked", "rawTypes" })
public void testCreationalContextsReleasedOnClientClose() throws Exception {
IMocksControl control = EasyMock.createStrictControl();
BeanManager mockedBeanMgr = control.createMock(BeanManager.class);
CreationalContext<?> mockedCreationalCtx = control.createMock(CreationalContext.class);
Bean<?> mockedBean = control.createMock(Bean.class);
List<String> stringList = new ArrayList<>(Collections.singleton("abc"));
EasyMock.expect(mockedBeanMgr.getBeans(List.class)).andReturn(Collections.singleton(mockedBean));
EasyMock.expect(mockedBeanMgr.createCreationalContext(mockedBean)).andReturn((CreationalContext) mockedCreationalCtx);
EasyMock.expect(mockedBeanMgr.getReference(mockedBean, List.class, mockedCreationalCtx)).andReturn(stringList);
EasyMock.expect(mockedBean.getScope()).andReturn((Class) ApplicationScoped.class);
EasyMock.expect(mockedBeanMgr.isNormalScope(ApplicationScoped.class)).andReturn(false);
mockedCreationalCtx.release();
EasyMock.expectLastCall().once();
control.replay();
Bus bus = new ExtensionManagerBus();
bus.setExtension(mockedBeanMgr, BeanManager.class);
Instance<List> i = CDIUtils.getInstanceFromCDI(List.class, bus);
assertEquals(stringList, i.getValue());
i.release();
control.verify();
}
Aggregations