Search in sources :

Example 56 with MessageImpl

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

the class ContextPropertiesMappingTest method testCreateWebServiceContext.

@Test
public void testCreateWebServiceContext() {
    Exchange exchange = new ExchangeImpl();
    Message inMessage = new MessageImpl();
    Message outMessage = new MessageImpl();
    inMessage.putAll(message);
    exchange.setInMessage(inMessage);
    exchange.setOutMessage(outMessage);
    MessageContext ctx = new WrappedMessageContext(exchange.getInMessage(), Scope.APPLICATION);
    Object requestHeader = ctx.get(MessageContext.HTTP_REQUEST_HEADERS);
    assertNotNull("the request header should not be null", requestHeader);
    assertEquals("we should get the request header", requestHeader, HEADER);
    Object responseHeader = ctx.get(MessageContext.HTTP_RESPONSE_HEADERS);
    assertNull("the response header should be null", responseHeader);
    Object outMessageHeader = outMessage.get(Message.PROTOCOL_HEADERS);
    assertEquals("the outMessage PROTOCOL_HEADERS should be update", responseHeader, outMessageHeader);
    Object inAttachments = ctx.get(MessageContext.INBOUND_MESSAGE_ATTACHMENTS);
    assertNotNull("inbound attachments object must be initialized", inAttachments);
    assertTrue("inbound attachments must be in a Map", inAttachments instanceof Map);
    assertTrue("no inbound attachments expected", ((Map<?, ?>) inAttachments).isEmpty());
}
Also used : Exchange(org.apache.cxf.message.Exchange) Message(org.apache.cxf.message.Message) WrappedMessageContext(org.apache.cxf.jaxws.context.WrappedMessageContext) WrappedMessageContext(org.apache.cxf.jaxws.context.WrappedMessageContext) MessageContext(javax.xml.ws.handler.MessageContext) MessageImpl(org.apache.cxf.message.MessageImpl) HashMap(java.util.HashMap) Map(java.util.Map) ExchangeImpl(org.apache.cxf.message.ExchangeImpl) Test(org.junit.Test)

Example 57 with MessageImpl

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

the class SOAPLoggingTest method testSoap.

@Test
public void testSoap() {
    DefaultLogEventMapper mapper = new DefaultLogEventMapper();
    Message message = new MessageImpl();
    ExchangeImpl exchange = new ExchangeImpl();
    ServiceInfo service = new ServiceInfo();
    BindingInfo info = new BindingInfo(service, "bindingId");
    SoapBinding value = new SoapBinding(info);
    exchange.put(Binding.class, value);
    OperationInfo opInfo = new OperationInfo();
    opInfo.setName(new QName("http://my", "Operation"));
    BindingOperationInfo boi = new BindingOperationInfo(info, opInfo);
    exchange.put(BindingOperationInfo.class, boi);
    message.setExchange(exchange);
    LogEvent event = mapper.map(message, Collections.emptySet());
    Assert.assertEquals("{http://my}Operation", event.getOperationName());
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) OperationInfo(org.apache.cxf.service.model.OperationInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) Message(org.apache.cxf.message.Message) LogEvent(org.apache.cxf.ext.logging.event.LogEvent) QName(javax.xml.namespace.QName) BindingInfo(org.apache.cxf.service.model.BindingInfo) DefaultLogEventMapper(org.apache.cxf.ext.logging.event.DefaultLogEventMapper) MessageImpl(org.apache.cxf.message.MessageImpl) ExchangeImpl(org.apache.cxf.message.ExchangeImpl) SoapBinding(org.apache.cxf.binding.soap.SoapBinding) Test(org.junit.Test) AbstractJaxWsTest(org.apache.cxf.jaxws.AbstractJaxWsTest)

Example 58 with MessageImpl

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

the class MPRestClientCallbackTest method setUp.

@Before
public void setUp() {
    executor = Executors.newSingleThreadScheduledExecutor();
    handler = new InvocationCallback<String>() {

        @Override
        public void failed(Throwable throwable) {
        }

        @Override
        public void completed(String response) {
        }
    };
    message = new MessageImpl();
    callback = new MPRestClientCallback<String>(handler, message, String.class, null);
    future = (CompletableFuture<String>) callback.createFuture();
    ctx = new HashMap<String, Object>();
}
Also used : MessageImpl(org.apache.cxf.message.MessageImpl) Before(org.junit.Before)

Example 59 with MessageImpl

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

the class GZIPAcceptEncodingTest method setUp.

@Before
public void setUp() throws Exception {
    interceptor = new GZIPOutInterceptor();
    inMessage = new MessageImpl();
    outMessage = new MessageImpl();
    Exchange exchange = new ExchangeImpl();
    exchange.setInMessage(inMessage);
    inMessage.setExchange(exchange);
    inMessage.setContent(InputStream.class, new ByteArrayInputStream(new byte[0]));
    exchange.setOutMessage(outMessage);
    outMessage.setExchange(exchange);
    outMessage.setContent(OutputStream.class, new ByteArrayOutputStream());
    outInterceptors = EasyMock.createMock(InterceptorChain.class);
    outMessage.setInterceptorChain(outInterceptors);
}
Also used : Exchange(org.apache.cxf.message.Exchange) InterceptorChain(org.apache.cxf.interceptor.InterceptorChain) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) MessageImpl(org.apache.cxf.message.MessageImpl) ExchangeImpl(org.apache.cxf.message.ExchangeImpl) Before(org.junit.Before)

Example 60 with MessageImpl

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

the class SoapBindingTest method testCreateMessage.

@Test
public void testCreateMessage() throws Exception {
    Message message = new MessageImpl();
    SoapBinding sb = new SoapBinding(null);
    message = sb.createMessage(message);
    assertNotNull(message);
    assertTrue(message instanceof SoapMessage);
    SoapMessage soapMessage = (SoapMessage) message;
    assertEquals(Soap11.getInstance(), soapMessage.getVersion());
    assertEquals("text/xml", soapMessage.get(Message.CONTENT_TYPE));
    soapMessage.remove(Message.CONTENT_TYPE);
    sb.setSoapVersion(Soap12.getInstance());
    soapMessage = (SoapMessage) sb.createMessage(soapMessage);
    assertEquals(Soap12.getInstance(), soapMessage.getVersion());
    assertEquals("application/soap+xml", soapMessage.get(Message.CONTENT_TYPE));
}
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