use of org.apache.cxf.message.ExchangeImpl 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;
}
use of org.apache.cxf.message.ExchangeImpl 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);
EasyMock.expect(endpoint.getEndpointInfo()).andReturn(null).anyTimes();
EasyMock.expect(endpoint.get(Application.class.getName())).andReturn(null);
EasyMock.expect(endpoint.size()).andReturn(0).anyTimes();
EasyMock.expect(endpoint.isEmpty()).andReturn(true).anyTimes();
EasyMock.expect(endpoint.get(ServerProviderFactory.class.getName())).andReturn(factory).anyTimes();
EasyMock.replay(endpoint);
e.put(Endpoint.class, endpoint);
return m;
}
use of org.apache.cxf.message.ExchangeImpl in project cxf by apache.
the class OperationResourceInfoTest method createMessage.
private static Message createMessage() {
Message m = new MessageImpl();
Exchange e = new ExchangeImpl();
m.setExchange(e);
e.setInMessage(m);
Endpoint endpoint = EasyMock.createMock(Endpoint.class);
EasyMock.expect(endpoint.get("org.apache.cxf.jaxrs.comparator")).andReturn(null);
EasyMock.replay(endpoint);
e.put(Endpoint.class, endpoint);
return m;
}
use of org.apache.cxf.message.ExchangeImpl in project cxf by apache.
the class DefaultLogEventMapperTest method testUriValue.
/**
* Test for address concatenation in CXF-8127
*/
@Test
public void testUriValue() {
DefaultLogEventMapper mapper = new DefaultLogEventMapper();
Message message = new MessageImpl();
message.put(Message.ENDPOINT_ADDRESS, "http://localhost:9001/");
message.put(Message.REQUEST_URI, "/api");
Exchange exchange = new ExchangeImpl();
message.setExchange(exchange);
LogEvent event = mapper.map(message, Collections.emptySet());
assertEquals("http://localhost:9001/api", event.getAddress());
}
use of org.apache.cxf.message.ExchangeImpl in project cxf by apache.
the class DefaultLogEventMapperTest method testRest.
@Test
public void testRest() {
DefaultLogEventMapper mapper = new DefaultLogEventMapper();
Message message = new MessageImpl();
message.put(Message.HTTP_REQUEST_METHOD, "GET");
message.put(Message.REQUEST_URI, "test");
Exchange exchange = new ExchangeImpl();
message.setExchange(exchange);
LogEvent event = mapper.map(message, Collections.emptySet());
assertEquals("GET[test]", event.getOperationName());
}
Aggregations