Search in sources :

Example 1 with ServletDestination

use of org.apache.cxf.transport.servlet.ServletDestination in project cxf by apache.

the class UriInfoImplTest method mockMessage.

private Message mockMessage(String baseAddress, String pathInfo, String query, String fragment) {
    Message m = new MessageImpl();
    control.reset();
    Exchange e = new ExchangeImpl();
    m.setExchange(e);
    ServletDestination d = control.createMock(ServletDestination.class);
    e.setDestination(d);
    EndpointInfo epr = new EndpointInfo();
    epr.setAddress(baseAddress);
    d.getEndpointInfo();
    EasyMock.expectLastCall().andReturn(epr).anyTimes();
    m.put(Message.REQUEST_URI, pathInfo);
    m.put(Message.QUERY_STRING, query);
    control.replay();
    return m;
}
Also used : Exchange(org.apache.cxf.message.Exchange) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) ServletDestination(org.apache.cxf.transport.servlet.ServletDestination) Message(org.apache.cxf.message.Message) MessageImpl(org.apache.cxf.message.MessageImpl) ExchangeImpl(org.apache.cxf.message.ExchangeImpl)

Example 2 with ServletDestination

use of org.apache.cxf.transport.servlet.ServletDestination in project cxf by apache.

the class RequestPreprocessorTest method mockMessage.

private Message mockMessage(String baseAddress, String pathInfo, String query, String method, String methodHeader) {
    Message m = new MessageImpl();
    m.put("org.apache.cxf.http.case_insensitive_queries", false);
    m.put("org.apache.cxf.endpoint.private", false);
    Exchange e = new ExchangeImpl();
    m.setExchange(e);
    control.reset();
    Endpoint endp = control.mock(Endpoint.class);
    e.put(Endpoint.class, endp);
    EasyMock.expect(endp.isEmpty()).andReturn(true).anyTimes();
    EasyMock.expect(endp.get(ServerProviderFactory.class.getName())).andReturn(ServerProviderFactory.getInstance()).anyTimes();
    ServletDestination d = control.createMock(ServletDestination.class);
    e.setDestination(d);
    EndpointInfo epr = new EndpointInfo();
    epr.setAddress(baseAddress);
    EasyMock.expect(d.getEndpointInfo()).andReturn(epr).anyTimes();
    EasyMock.expect(endp.getEndpointInfo()).andReturn(epr).anyTimes();
    m.put(Message.REQUEST_URI, pathInfo);
    m.put(Message.QUERY_STRING, query);
    m.put(Message.HTTP_REQUEST_METHOD, method);
    Map<String, List<String>> headers = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
    if (methodHeader != null) {
        headers.put("X-HTTP-Method-Override", Collections.singletonList(methodHeader));
    }
    m.put(Message.PROTOCOL_HEADERS, headers);
    BindingInfo bi = control.createMock(BindingInfo.class);
    epr.setBinding(bi);
    EasyMock.expect(bi.getProperties()).andReturn(Collections.emptyMap()).anyTimes();
    control.replay();
    return m;
}
Also used : Exchange(org.apache.cxf.message.Exchange) 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) BindingInfo(org.apache.cxf.service.model.BindingInfo) List(java.util.List) TreeMap(java.util.TreeMap) MessageImpl(org.apache.cxf.message.MessageImpl) ExchangeImpl(org.apache.cxf.message.ExchangeImpl)

Example 3 with ServletDestination

use of org.apache.cxf.transport.servlet.ServletDestination 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 4 with ServletDestination

use of org.apache.cxf.transport.servlet.ServletDestination 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)

Aggregations

Exchange (org.apache.cxf.message.Exchange)4 ExchangeImpl (org.apache.cxf.message.ExchangeImpl)4 Message (org.apache.cxf.message.Message)4 MessageImpl (org.apache.cxf.message.MessageImpl)4 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)4 ServletDestination (org.apache.cxf.transport.servlet.ServletDestination)4 Endpoint (org.apache.cxf.endpoint.Endpoint)3 BindingInfo (org.apache.cxf.service.model.BindingInfo)3 EndpointImpl (org.apache.cxf.endpoint.EndpointImpl)2 JAXRSServiceImpl (org.apache.cxf.jaxrs.JAXRSServiceImpl)2 List (java.util.List)1 TreeMap (java.util.TreeMap)1 ServerProviderFactory (org.apache.cxf.jaxrs.provider.ServerProviderFactory)1