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