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();
}
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());
}
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;
}
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;
}
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;
}
Aggregations