use of org.apache.cxf.message.MessageImpl 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.MessageImpl 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.MessageImpl 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.MessageImpl in project cxf by apache.
the class SearchContextImplCustomParserTest method testQuery.
@Test
public void testQuery() {
Message m = new MessageImpl();
m.put(SearchContextImpl.CUSTOM_SEARCH_QUERY_PARAM_NAME, "$customfilter");
m.put(SearchContextImpl.CUSTOM_SEARCH_PARSER_PROPERTY, new CustomParser());
m.put(Message.QUERY_STRING, "$customfilter=color is red");
SearchCondition<Color> sc = new SearchContextImpl(m).getCondition(Color.class);
assertTrue(sc.isMet(new Color("red")));
assertFalse(sc.isMet(new Color("blue")));
}
use of org.apache.cxf.message.MessageImpl in project cxf by apache.
the class SearchContextImplTest method testPrimitiveStatementSearchBean.
@Test
public void testPrimitiveStatementSearchBean() {
Message m = new MessageImpl();
m.put(Message.QUERY_STRING, "_s=name==CXF");
SearchContext context = new SearchContextImpl(m);
SearchCondition<SearchBean> sc = context.getCondition(SearchBean.class);
assertNotNull(sc);
PrimitiveStatement ps = sc.getStatement();
assertNotNull(ps);
assertEquals("name", ps.getProperty());
assertEquals("CXF", ps.getValue());
assertEquals(ConditionType.EQUALS, ps.getCondition());
assertEquals(String.class, ps.getValueType());
}
Aggregations