use of org.apache.cxf.endpoint.EndpointImpl in project cxf by apache.
the class WadlGeneratorTest method mockMessage.
private Message mockMessage(String baseAddress, String pathInfo, String query, List<ClassResourceInfo> cris) throws Exception {
Message m = new MessageImpl();
Exchange e = new ExchangeImpl();
e.put(Service.class, new JAXRSServiceImpl(cris));
m.setExchange(e);
control.reset();
ServletDestination d = control.createMock(ServletDestination.class);
EndpointInfo epr = new EndpointInfo();
epr.setAddress(baseAddress);
d.getEndpointInfo();
EasyMock.expectLastCall().andReturn(epr).anyTimes();
Endpoint endpoint = new EndpointImpl(null, null, epr);
e.put(Endpoint.class, endpoint);
endpoint.put(ServerProviderFactory.class.getName(), ServerProviderFactory.getInstance());
e.setDestination(d);
BindingInfo bi = control.createMock(BindingInfo.class);
epr.setBinding(bi);
bi.getProperties();
EasyMock.expectLastCall().andReturn(Collections.emptyMap()).anyTimes();
m.put(Message.REQUEST_URI, pathInfo);
m.put(Message.QUERY_STRING, query);
m.put(Message.HTTP_REQUEST_METHOD, "GET");
control.replay();
return m;
}
use of org.apache.cxf.endpoint.EndpointImpl in project cxf by apache.
the class WadlGeneratorJsonTest method mockMessage.
private Message mockMessage(String baseAddress, String pathInfo, String query, ClassResourceInfo cri) throws Exception {
Message m = new MessageImpl();
Exchange e = new ExchangeImpl();
e.put(Service.class, new JAXRSServiceImpl(Collections.singletonList(cri)));
m.setExchange(e);
control.reset();
ServletDestination d = control.createMock(ServletDestination.class);
EndpointInfo epr = new EndpointInfo();
epr.setAddress(baseAddress);
d.getEndpointInfo();
EasyMock.expectLastCall().andReturn(epr).anyTimes();
Endpoint endpoint = new EndpointImpl(null, null, epr);
e.put(Endpoint.class, endpoint);
e.setDestination(d);
BindingInfo bi = control.createMock(BindingInfo.class);
epr.setBinding(bi);
bi.getProperties();
EasyMock.expectLastCall().andReturn(Collections.emptyMap()).anyTimes();
m.put(Message.REQUEST_URI, pathInfo);
m.put(Message.QUERY_STRING, query);
m.put(Message.HTTP_REQUEST_METHOD, "GET");
control.replay();
return m;
}
use of org.apache.cxf.endpoint.EndpointImpl in project cxf by apache.
the class HTTPConduitTest method testHandleResponseOnWorkqueueAllowCurrentThread.
@Test
public void testHandleResponseOnWorkqueueAllowCurrentThread() throws Exception {
Message m = getNewMessage();
Exchange exchange = new ExchangeImpl();
Bus bus = new ExtensionManagerBus();
exchange.put(Bus.class, bus);
EndpointInfo endpointInfo = new EndpointInfo();
Endpoint endpoint = new EndpointImpl(null, null, endpointInfo);
exchange.put(Endpoint.class, endpoint);
m.setExchange(exchange);
HTTPClientPolicy policy = new HTTPClientPolicy();
policy.setAsyncExecuteTimeoutRejection(true);
m.put(HTTPClientPolicy.class, policy);
exchange.put(Executor.class, new Executor() {
@Override
public void execute(Runnable command) {
// forces us to use current thread
throw new RejectedExecutionException("expected");
}
});
HTTPConduit conduit = new MockHTTPConduit(bus, endpointInfo, policy);
OutputStream os = conduit.createOutputStream(m, false, false, 0);
assertTrue(os instanceof WrappedOutputStream);
WrappedOutputStream wos = (WrappedOutputStream) os;
try {
wos.handleResponseOnWorkqueue(true, false);
assertEquals(Thread.currentThread(), m.get(Thread.class));
try {
wos.handleResponseOnWorkqueue(false, false);
fail("Expected RejectedExecutionException not thrown");
} catch (RejectedExecutionException ex) {
assertEquals("expected", ex.getMessage());
}
} catch (Exception ex) {
throw ex;
}
}
use of org.apache.cxf.endpoint.EndpointImpl in project cxf by apache.
the class TestBase method common.
protected void common(String wsdl, QName portName, Class<?>... jaxbClasses) throws Exception {
Bus bus = BusFactory.getDefaultBus();
WSDLManagerImpl manager = new WSDLManagerImpl();
XMLWSDLExtensionLoader loader = new XMLWSDLExtensionLoader(bus);
loader.registerExtensors(manager);
assertNotNull(bus.getExtension(WSDLManager.class));
WSDLServiceFactory factory = new WSDLServiceFactory(bus, getClass().getResource(wsdl).toString(), new QName(portName.getNamespaceURI(), "XMLService"));
org.apache.cxf.service.Service service = factory.create();
EndpointInfo epi = service.getEndpointInfo(portName);
assertNotNull(epi);
serviceInfo = epi.getService();
JAXBDataBinding db = new JAXBDataBinding();
db.initialize(service);
db.setContext(JAXBContext.newInstance(jaxbClasses));
service.setDataBinding(db);
Endpoint endpoint = new EndpointImpl(bus, service, epi);
xmlMessage.getExchange().put(Endpoint.class, endpoint);
xmlMessage.getExchange().put(org.apache.cxf.service.Service.class, service);
}
use of org.apache.cxf.endpoint.EndpointImpl 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();
}
Aggregations