Search in sources :

Example 76 with Exchange

use of org.apache.cxf.message.Exchange in project cxf by apache.

the class HttpHeadersImplTest method testInvalidCookieSeparator.

@Test(expected = InternalServerErrorException.class)
public void testInvalidCookieSeparator() throws Exception {
    Message m = new MessageImpl();
    Exchange ex = new ExchangeImpl();
    ex.setInMessage(m);
    ex.put("org.apache.cxf.http.cookie.separator", "(e+)+");
    m.setExchange(ex);
    MetadataMap<String, String> headers = createHeaders();
    headers.putSingle(HttpHeaders.COOKIE, "a=b,c=d");
    m.put(Message.PROTOCOL_HEADERS, headers);
    HttpHeaders h = new HttpHeadersImpl(m);
    h.getCookies();
}
Also used : Exchange(org.apache.cxf.message.Exchange) HttpHeaders(javax.ws.rs.core.HttpHeaders) Message(org.apache.cxf.message.Message) MessageImpl(org.apache.cxf.message.MessageImpl) ExchangeImpl(org.apache.cxf.message.ExchangeImpl) Test(org.junit.Test)

Example 77 with Exchange

use of org.apache.cxf.message.Exchange in project cxf by apache.

the class HttpHeadersImplTest method testGetCookiesWithComma.

@Test
public void testGetCookiesWithComma() throws Exception {
    Message m = new MessageImpl();
    Exchange ex = new ExchangeImpl();
    ex.setInMessage(m);
    ex.put("org.apache.cxf.http.cookie.separator", ",");
    m.setExchange(ex);
    MetadataMap<String, String> headers = createHeaders();
    headers.putSingle(HttpHeaders.COOKIE, "a=b,c=d");
    m.put(Message.PROTOCOL_HEADERS, headers);
    HttpHeaders h = new HttpHeadersImpl(m);
    Map<String, Cookie> cookies = h.getCookies();
    assertEquals(2, cookies.size());
    assertEquals("b", cookies.get("a").getValue());
    assertEquals("d", cookies.get("c").getValue());
}
Also used : Exchange(org.apache.cxf.message.Exchange) Cookie(javax.ws.rs.core.Cookie) HttpHeaders(javax.ws.rs.core.HttpHeaders) Message(org.apache.cxf.message.Message) MessageImpl(org.apache.cxf.message.MessageImpl) ExchangeImpl(org.apache.cxf.message.ExchangeImpl) Test(org.junit.Test)

Example 78 with Exchange

use of org.apache.cxf.message.Exchange 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.createMock(Endpoint.class);
    e.put(Endpoint.class, endp);
    EasyMock.expect(endp.isEmpty()).andReturn(true).anyTimes();
    endp.get(ServerProviderFactory.class.getName());
    EasyMock.expectLastCall().andReturn(ServerProviderFactory.getInstance()).anyTimes();
    ServletDestination d = control.createMock(ServletDestination.class);
    e.setDestination(d);
    EndpointInfo epr = new EndpointInfo();
    epr.setAddress(baseAddress);
    d.getEndpointInfo();
    EasyMock.expectLastCall().andReturn(epr).anyTimes();
    endp.getEndpointInfo();
    EasyMock.expectLastCall().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, List<String>>(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);
    bi.getProperties();
    EasyMock.expectLastCall().andReturn(Collections.emptyMap()).anyTimes();
    control.replay();
    return m;
}
Also used : ServerProviderFactory(org.apache.cxf.jaxrs.provider.ServerProviderFactory) Message(org.apache.cxf.message.Message) TreeMap(java.util.TreeMap) Exchange(org.apache.cxf.message.Exchange) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) ServletDestination(org.apache.cxf.transport.servlet.ServletDestination) Endpoint(org.apache.cxf.endpoint.Endpoint) BindingInfo(org.apache.cxf.service.model.BindingInfo) List(java.util.List) MessageImpl(org.apache.cxf.message.MessageImpl) ExchangeImpl(org.apache.cxf.message.ExchangeImpl)

Example 79 with Exchange

use of org.apache.cxf.message.Exchange in project cxf by apache.

the class ResponseImplTest method createMessage.

private Message createMessage() {
    ProviderFactory factory = ServerProviderFactory.getInstance();
    Message m = new MessageImpl();
    m.put("org.apache.cxf.http.case_insensitive_queries", false);
    Exchange e = new ExchangeImpl();
    m.setExchange(e);
    e.setInMessage(m);
    e.setOutMessage(new MessageImpl());
    Endpoint endpoint = EasyMock.createMock(Endpoint.class);
    endpoint.getEndpointInfo();
    EasyMock.expectLastCall().andReturn(null).anyTimes();
    endpoint.get(Application.class.getName());
    EasyMock.expectLastCall().andReturn(null);
    endpoint.size();
    EasyMock.expectLastCall().andReturn(0).anyTimes();
    endpoint.isEmpty();
    EasyMock.expectLastCall().andReturn(true).anyTimes();
    endpoint.get(ServerProviderFactory.class.getName());
    EasyMock.expectLastCall().andReturn(factory).anyTimes();
    EasyMock.replay(endpoint);
    e.put(Endpoint.class, endpoint);
    return m;
}
Also used : Exchange(org.apache.cxf.message.Exchange) ServerProviderFactory(org.apache.cxf.jaxrs.provider.ServerProviderFactory) Message(org.apache.cxf.message.Message) Endpoint(org.apache.cxf.endpoint.Endpoint) ProviderFactory(org.apache.cxf.jaxrs.provider.ProviderFactory) ServerProviderFactory(org.apache.cxf.jaxrs.provider.ServerProviderFactory) MessageImpl(org.apache.cxf.message.MessageImpl) Application(javax.ws.rs.core.Application) ExchangeImpl(org.apache.cxf.message.ExchangeImpl)

Example 80 with Exchange

use of org.apache.cxf.message.Exchange 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)

Aggregations

Exchange (org.apache.cxf.message.Exchange)272 Message (org.apache.cxf.message.Message)151 ExchangeImpl (org.apache.cxf.message.ExchangeImpl)131 MessageImpl (org.apache.cxf.message.MessageImpl)118 Test (org.junit.Test)93 Endpoint (org.apache.cxf.endpoint.Endpoint)66 BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)50 QName (javax.xml.namespace.QName)42 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)33 SoapMessage (org.apache.cxf.binding.soap.SoapMessage)32 Bus (org.apache.cxf.Bus)30 Fault (org.apache.cxf.interceptor.Fault)27 AddressingProperties (org.apache.cxf.ws.addressing.AddressingProperties)26 IOException (java.io.IOException)25 ArrayList (java.util.ArrayList)25 Conduit (org.apache.cxf.transport.Conduit)25 MessageContentsList (org.apache.cxf.message.MessageContentsList)22 SOAPMessage (javax.xml.soap.SOAPMessage)19 XMLStreamReader (javax.xml.stream.XMLStreamReader)19 ServerProviderFactory (org.apache.cxf.jaxrs.provider.ServerProviderFactory)19