use of org.apache.cxf.bus.extension.ExtensionManagerBus in project cxf by apache.
the class HTTPConduitURLConnectionTest method testConnectionURLOverride.
/**
* 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/");
}
use of org.apache.cxf.bus.extension.ExtensionManagerBus in project cxf by apache.
the class HTTPConduitURLConnectionTest method testConnectionURL.
/**
* 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());
}
use of org.apache.cxf.bus.extension.ExtensionManagerBus in project cxf by apache.
the class RestClientCdiTest method testCreationalContextsNotReleasedOnClientCloseUsingNormalScope.
@Test
@SuppressWarnings({ "unchecked", "rawTypes" })
public void testCreationalContextsNotReleasedOnClientCloseUsingNormalScope() 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("xyz"));
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) NormalScope.class);
EasyMock.expect(mockedBeanMgr.isNormalScope(NormalScope.class)).andReturn(true);
control.replay();
Bus bus = new ExtensionManagerBus();
bus.setExtension(mockedBeanMgr, BeanManager.class);
Instance<List> i = CDIUtils.getInstanceFromCDI(List.class, bus);
i.release();
control.verify();
}
use of org.apache.cxf.bus.extension.ExtensionManagerBus in project cxf by apache.
the class MAPAggregatorTest method testGetReplyToUsingBaseAddress.
@Test
public void testGetReplyToUsingBaseAddress() throws Exception {
Message message = new MessageImpl();
Exchange exchange = new ExchangeImpl();
message.setExchange(exchange);
final String localReplyTo = "/SoapContext/decoupled";
final String decoupledEndpointBase = "http://localhost:8181/cxf";
final String replyTo = decoupledEndpointBase + localReplyTo;
ServiceInfo s = new ServiceInfo();
Service svc = new ServiceImpl(s);
EndpointInfo ei = new EndpointInfo();
InterfaceInfo ii = s.createInterface(new QName("FooInterface"));
s.setInterface(ii);
ii.addOperation(new QName("fooOp"));
SoapBindingInfo b = new SoapBindingInfo(s, "http://schemas.xmlsoap.org/soap/", Soap11.getInstance());
b.setTransportURI("http://schemas.xmlsoap.org/soap/http");
ei.setBinding(b);
ei.setAddress("http://nowhere.com/bar/foo");
ei.setName(new QName("http://nowhere.com/port", "foo"));
Bus bus = new ExtensionManagerBus();
DestinationFactoryManager dfm = control.createMock(DestinationFactoryManager.class);
DestinationFactory df = control.createMock(DestinationFactory.class);
Destination d = control.createMock(Destination.class);
bus.setExtension(dfm, DestinationFactoryManager.class);
EasyMock.expect(dfm.getDestinationFactoryForUri(localReplyTo)).andReturn(df);
EasyMock.expect(df.getDestination(EasyMock.anyObject(EndpointInfo.class), EasyMock.anyObject(Bus.class))).andReturn(d);
EasyMock.expect(d.getAddress()).andReturn(EndpointReferenceUtils.getEndpointReference(localReplyTo));
Endpoint ep = new EndpointImpl(bus, svc, ei);
exchange.put(Endpoint.class, ep);
exchange.put(Bus.class, bus);
exchange.setOutMessage(message);
setUpMessageProperty(message, REQUESTOR_ROLE, Boolean.TRUE);
message.getContextualProperty(WSAContextUtils.REPLYTO_PROPERTY);
message.put(WSAContextUtils.REPLYTO_PROPERTY, localReplyTo);
message.put(WSAContextUtils.DECOUPLED_ENDPOINT_BASE_PROPERTY, decoupledEndpointBase);
AddressingProperties maps = new AddressingProperties();
AttributedURIType id = ContextUtils.getAttributedURI("urn:uuid:12345");
maps.setMessageID(id);
maps.setAction(ContextUtils.getAttributedURI(""));
setUpMessageProperty(message, CLIENT_ADDRESSING_PROPERTIES, maps);
control.replay();
aggregator.mediate(message, false);
AddressingProperties props = (AddressingProperties) message.get(JAXWSAConstants.ADDRESSING_PROPERTIES_OUTBOUND);
assertEquals(replyTo, props.getReplyTo().getAddress().getValue());
control.verify();
}
use of org.apache.cxf.bus.extension.ExtensionManagerBus in project cxf by apache.
the class AtmosphereWebSocketServletDestinationTest method testUseCustomAtmoosphereInterceptors.
@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);
}
Aggregations