Search in sources :

Example 21 with EndpointImpl

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;
}
Also used : Exchange(org.apache.cxf.message.Exchange) ServerProviderFactory(org.apache.cxf.jaxrs.provider.ServerProviderFactory) JAXRSServiceImpl(org.apache.cxf.jaxrs.JAXRSServiceImpl) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) ServletDestination(org.apache.cxf.transport.servlet.ServletDestination) Message(org.apache.cxf.message.Message) Endpoint(org.apache.cxf.endpoint.Endpoint) EndpointImpl(org.apache.cxf.endpoint.EndpointImpl) BindingInfo(org.apache.cxf.service.model.BindingInfo) MessageImpl(org.apache.cxf.message.MessageImpl) ExchangeImpl(org.apache.cxf.message.ExchangeImpl)

Example 22 with EndpointImpl

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;
}
Also used : Exchange(org.apache.cxf.message.Exchange) JAXRSServiceImpl(org.apache.cxf.jaxrs.JAXRSServiceImpl) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) ServletDestination(org.apache.cxf.transport.servlet.ServletDestination) Message(org.apache.cxf.message.Message) Endpoint(org.apache.cxf.endpoint.Endpoint) EndpointImpl(org.apache.cxf.endpoint.EndpointImpl) BindingInfo(org.apache.cxf.service.model.BindingInfo) MessageImpl(org.apache.cxf.message.MessageImpl) ExchangeImpl(org.apache.cxf.message.ExchangeImpl)

Example 23 with EndpointImpl

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;
    }
}
Also used : Bus(org.apache.cxf.Bus) ExtensionManagerBus(org.apache.cxf.bus.extension.ExtensionManagerBus) Message(org.apache.cxf.message.Message) EndpointImpl(org.apache.cxf.endpoint.EndpointImpl) WrappedOutputStream(org.apache.cxf.transport.http.HTTPConduit.WrappedOutputStream) OutputStream(java.io.OutputStream) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) Exchange(org.apache.cxf.message.Exchange) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) Executor(java.util.concurrent.Executor) Endpoint(org.apache.cxf.endpoint.Endpoint) HTTPClientPolicy(org.apache.cxf.transports.http.configuration.HTTPClientPolicy) WrappedOutputStream(org.apache.cxf.transport.http.HTTPConduit.WrappedOutputStream) ExtensionManagerBus(org.apache.cxf.bus.extension.ExtensionManagerBus) ExchangeImpl(org.apache.cxf.message.ExchangeImpl) Test(org.junit.Test)

Example 24 with EndpointImpl

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);
}
Also used : Bus(org.apache.cxf.Bus) WSDLServiceFactory(org.apache.cxf.wsdl11.WSDLServiceFactory) XMLWSDLExtensionLoader(org.apache.cxf.binding.xml.wsdl11.XMLWSDLExtensionLoader) QName(javax.xml.namespace.QName) EndpointImpl(org.apache.cxf.endpoint.EndpointImpl) WSDLManagerImpl(org.apache.cxf.wsdl11.WSDLManagerImpl) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) Endpoint(org.apache.cxf.endpoint.Endpoint) WSDLManager(org.apache.cxf.wsdl.WSDLManager) JAXBDataBinding(org.apache.cxf.jaxb.JAXBDataBinding)

Example 25 with EndpointImpl

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();
}
Also used : Bus(org.apache.cxf.Bus) ExtensionManagerBus(org.apache.cxf.bus.extension.ExtensionManagerBus) DestinationFactory(org.apache.cxf.transport.DestinationFactory) Destination(org.apache.cxf.transport.Destination) Message(org.apache.cxf.message.Message) DestinationFactoryManager(org.apache.cxf.transport.DestinationFactoryManager) ServiceImpl(org.apache.cxf.service.ServiceImpl) QName(javax.xml.namespace.QName) EndpointImpl(org.apache.cxf.endpoint.EndpointImpl) AttributedURIType(org.apache.cxf.ws.addressing.AttributedURIType) Service(org.apache.cxf.service.Service) Exchange(org.apache.cxf.message.Exchange) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) Endpoint(org.apache.cxf.endpoint.Endpoint) SoapBindingInfo(org.apache.cxf.binding.soap.model.SoapBindingInfo) AddressingProperties(org.apache.cxf.ws.addressing.AddressingProperties) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo) MessageImpl(org.apache.cxf.message.MessageImpl) ExtensionManagerBus(org.apache.cxf.bus.extension.ExtensionManagerBus) ExchangeImpl(org.apache.cxf.message.ExchangeImpl) Test(org.junit.Test)

Aggregations

EndpointImpl (org.apache.cxf.endpoint.EndpointImpl)31 Endpoint (org.apache.cxf.endpoint.Endpoint)24 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)18 Service (org.apache.cxf.service.Service)14 ExchangeImpl (org.apache.cxf.message.ExchangeImpl)13 QName (javax.xml.namespace.QName)12 Exchange (org.apache.cxf.message.Exchange)12 MessageImpl (org.apache.cxf.message.MessageImpl)12 WSDLServiceFactory (org.apache.cxf.wsdl11.WSDLServiceFactory)9 ServiceInfo (org.apache.cxf.service.model.ServiceInfo)8 Feature (org.apache.cxf.feature.Feature)7 ServiceImpl (org.apache.cxf.service.ServiceImpl)7 BindingInfo (org.apache.cxf.service.model.BindingInfo)7 Bus (org.apache.cxf.Bus)6 Message (org.apache.cxf.message.Message)6 ArrayList (java.util.ArrayList)5 SoapBindingInfo (org.apache.cxf.binding.soap.model.SoapBindingInfo)5 AbstractFeature (org.apache.cxf.feature.AbstractFeature)5 List (java.util.List)4 SourceDataBinding (org.apache.cxf.databinding.source.SourceDataBinding)4