use of org.apache.cxf.message.MessageImpl in project camel by apache.
the class DefaultCxfBindingTest method testOverridePayloadBodyNamespace.
@Test
public void testOverridePayloadBodyNamespace() throws Exception {
MessageImpl message = new MessageImpl();
Map<String, String> nsMap = new HashMap<String, String>();
Document document = getDocument(SOAP_MESSAGE_2);
message.setContent(Node.class, document);
DefaultCxfBinding.getPayloadBodyElements(message, nsMap);
assertEquals(2, nsMap.size());
assertEquals("http://www.mycompany.com/test/", nsMap.get("xmlns"));
Element element = (Element) document.getElementsByTagName("ns1:identifier").item(0);
assertNotNull("We should get the element", element);
DefaultCxfBinding.addNamespace(element, nsMap);
assertEquals("http://www.mycompany.com/test/1/", element.getAttribute("xmlns"));
assertEquals("http://www.mycompany.com/test/", element.getAttribute("xmlns:ns1"));
}
use of org.apache.cxf.message.MessageImpl in project camel by apache.
the class CamelDestination method incoming.
protected void incoming(org.apache.camel.Exchange camelExchange) {
LOG.debug("server received request: ", camelExchange);
DefaultCxfMessageMapper beanBinding = new DefaultCxfMessageMapper();
org.apache.cxf.message.Message inMessage = beanBinding.createCxfMessageFromCamelExchange(camelExchange, headerFilterStrategy);
inMessage.put(CamelTransportConstants.CAMEL_EXCHANGE, camelExchange);
((MessageImpl) inMessage).setDestination(this);
// Handling the incoming message
// The response message will be send back by the outgoing chain
incomingObserver.onMessage(inMessage);
}
use of org.apache.cxf.message.MessageImpl in project camel by apache.
the class CamelDestinationTest method testRoundTripDestination.
@Test
public void testRoundTripDestination() throws Exception {
inMessage = null;
EndpointInfo conduitEpInfo = new EndpointInfo();
conduitEpInfo.setAddress("camel://direct:Producer");
// set up the conduit send to be true
CamelConduit conduit = setupCamelConduit(conduitEpInfo, true, false);
final Message outMessage = new MessageImpl();
endpointInfo.setAddress("camel://direct:EndpointA");
final CamelDestination destination = setupCamelDestination(endpointInfo, true);
// set up MessageObserver for handling the conduit message
MessageObserver observer = new MessageObserver() {
public void onMessage(Message m) {
try {
Exchange exchange = new ExchangeImpl();
exchange.setInMessage(m);
m.setExchange(exchange);
verifyReceivedMessage(m, "HelloWorld");
//verifyHeaders(m, outMessage);
// setup the message for
Conduit backConduit;
backConduit = getBackChannel(destination, m);
// wait for the message to be got from the conduit
Message replyMessage = new MessageImpl();
sendoutMessage(backConduit, replyMessage, true, "HelloWorld Response");
} catch (Exception e) {
throw new RuntimeException(e);
}
}
};
MockEndpoint error = context.getEndpoint("mock:error", MockEndpoint.class);
error.expectedMessageCount(0);
//this call will active the camelDestination
destination.setMessageObserver(observer);
// set is one way false for get response from destination
// need to use another thread to send the request message
sendoutMessage(conduit, outMessage, false, "HelloWorld");
// wait for the message to be got from the destination,
// create the thread to handler the Destination incoming message
verifyReceivedMessage(inMessage, "HelloWorld Response");
error.assertIsSatisfied();
destination.shutdown();
}
use of org.apache.cxf.message.MessageImpl in project camel by apache.
the class CamelDestinationTest method testOneWayDestination.
@Test
public void testOneWayDestination() throws Exception {
destMessage = null;
inMessage = null;
EndpointInfo conduitEpInfo = new EndpointInfo();
conduitEpInfo.setAddress("camel://direct:Producer");
CamelConduit conduit = setupCamelConduit(conduitEpInfo, true, false);
Message outMessage = new MessageImpl();
CamelDestination destination = null;
try {
endpointInfo.setAddress("camel://direct:EndpointA");
destination = setupCamelDestination(endpointInfo, true);
// destination.activate();
} catch (IOException e) {
assertFalse("The CamelDestination activate should not through exception ", false);
e.printStackTrace();
}
sendoutMessage(conduit, outMessage, true, "HelloWorld");
// just verify the Destination inMessage
assertTrue("The destiantion should have got the message ", destMessage != null);
verifyReceivedMessage(destMessage, "HelloWorld");
destination.shutdown();
}
use of org.apache.cxf.message.MessageImpl in project camel by apache.
the class CamelConduitTest method testSendOut.
@Test
public void testSendOut() throws Exception {
endpointInfo.setAddress("camel://direct:Producer");
CamelConduit conduit = setupCamelConduit(endpointInfo, true, false);
MockEndpoint endpoint = getMockEndpoint("mock:EndpointA");
endpoint.expectedMessageCount(1);
Message message = new MessageImpl();
// set the isOneWay to be true
sendoutMessage(conduit, message, true, "HelloWorld");
assertMockEndpointsSatisfied();
// verify the endpoint get the response
}
Aggregations