Search in sources :

Example 66 with MessageImpl

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;
}
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 67 with MessageImpl

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;
}
Also used : Exchange(org.apache.cxf.message.Exchange) 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 68 with MessageImpl

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;
}
Also used : Exchange(org.apache.cxf.message.Exchange) Message(org.apache.cxf.message.Message) Endpoint(org.apache.cxf.endpoint.Endpoint) MessageImpl(org.apache.cxf.message.MessageImpl) ExchangeImpl(org.apache.cxf.message.ExchangeImpl)

Example 69 with MessageImpl

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")));
}
Also used : Message(org.apache.cxf.message.Message) MessageImpl(org.apache.cxf.message.MessageImpl) Test(org.junit.Test)

Example 70 with MessageImpl

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());
}
Also used : Message(org.apache.cxf.message.Message) MessageImpl(org.apache.cxf.message.MessageImpl) Test(org.junit.Test)

Aggregations

MessageImpl (org.apache.cxf.message.MessageImpl)610 Message (org.apache.cxf.message.Message)291 Test (org.junit.Test)290 ExchangeImpl (org.apache.cxf.message.ExchangeImpl)193 WrappedMessageContext (org.apache.cxf.jaxws.context.WrappedMessageContext)152 Exchange (org.apache.cxf.message.Exchange)148 StaticSTSProperties (org.apache.cxf.sts.StaticSTSProperties)137 PasswordCallbackHandler (org.apache.cxf.sts.common.PasswordCallbackHandler)115 Crypto (org.apache.wss4j.common.crypto.Crypto)113 CustomTokenPrincipal (org.apache.wss4j.common.principal.CustomTokenPrincipal)107 JAXBElement (javax.xml.bind.JAXBElement)100 RequestSecurityTokenType (org.apache.cxf.ws.security.sts.provider.model.RequestSecurityTokenType)93 RequestSecurityTokenResponseType (org.apache.cxf.ws.security.sts.provider.model.RequestSecurityTokenResponseType)86 STSPropertiesMBean (org.apache.cxf.sts.STSPropertiesMBean)83 Element (org.w3c.dom.Element)74 ArrayList (java.util.ArrayList)62 ServiceMBean (org.apache.cxf.sts.service.ServiceMBean)61 StaticService (org.apache.cxf.sts.service.StaticService)61 Principal (java.security.Principal)59 Endpoint (org.apache.cxf.endpoint.Endpoint)58