use of org.apache.cxf.message.Message in project camel by apache.
the class CamelConduitTest method testSendOutRunTrip.
@Test
public void testSendOutRunTrip() 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 false
sendoutMessage(conduit, message, false, "HelloWorld");
// verify the endpoint get the response
assertMockEndpointsSatisfied();
verifyReceivedMessage("HelloWorld");
}
use of org.apache.cxf.message.Message in project camel by apache.
the class DataInInterceptor method handleMessage.
public void handleMessage(Message message) throws Fault {
DepthXMLStreamReader xmlReader = getXMLStreamReader(message);
try {
// put the payload source as a document
Document doc = StaxUtils.read(xmlReader);
message.setContent(Source.class, new DOMSource(doc));
} catch (XMLStreamException e) {
throw new Fault(new org.apache.cxf.common.i18n.Message("XMLSTREAM_EXCEPTION", JUL_LOG), e);
}
}
use of org.apache.cxf.message.Message in project camel by apache.
the class RawMessageWSDLGetInterceptor method handleMessage.
public void handleMessage(Message message) throws Fault {
String method = (String) message.get(Message.HTTP_REQUEST_METHOD);
String query = (String) message.get(Message.QUERY_STRING);
if (!"GET".equals(method) || StringUtils.isEmpty(query)) {
return;
}
String baseUri = (String) message.get(Message.REQUEST_URL);
String ctx = (String) message.get(Message.PATH_INFO);
Map<String, String> map = UrlUtils.parseQueryString(query);
if (isRecognizedQuery(map, baseUri, ctx, message.getExchange().getEndpoint().getEndpointInfo())) {
Document doc = getDocument(message, baseUri, map, ctx);
Endpoint e = message.getExchange().get(Endpoint.class);
Message mout = new MessageImpl();
mout.setExchange(message.getExchange());
mout = e.getBinding().createMessage(mout);
mout.setInterceptorChain(OutgoingChainInterceptor.getOutInterceptorChain(message.getExchange()));
message.getExchange().setOutMessage(mout);
mout.put(DOCUMENT_HOLDER, doc);
Iterator<Interceptor<? extends Message>> iterator = mout.getInterceptorChain().iterator();
while (iterator.hasNext()) {
Interceptor<? extends Message> inInterceptor = iterator.next();
if (inInterceptor instanceof AbstractPhaseInterceptor) {
AbstractPhaseInterceptor<?> interceptor = (AbstractPhaseInterceptor<?>) inInterceptor;
if (interceptor.getPhase().equals(Phase.PREPARE_SEND) || interceptor.getPhase().equals(Phase.PRE_STREAM)) {
// just make sure we keep the right interceptors
continue;
}
}
mout.getInterceptorChain().remove(inInterceptor);
}
// notice this is being added after the purge above, don't swap the order!
mout.getInterceptorChain().add(RawMessageWSDLGetOutInterceptor.INSTANCE);
// skip the service executor and goto the end of the chain.
message.getInterceptorChain().doInterceptStartingAt(message, OutgoingChainInterceptor.class.getName());
}
}
use of org.apache.cxf.message.Message in project cxf by apache.
the class TestUtilities method invokeBytes.
public byte[] invokeBytes(String address, String transport, byte[] message) throws Exception {
EndpointInfo ei = new EndpointInfo(null, "http://schemas.xmlsoap.org/soap/http");
ei.setAddress(address);
ConduitInitiatorManager conduitMgr = getBus().getExtension(ConduitInitiatorManager.class);
ConduitInitiator conduitInit = conduitMgr.getConduitInitiator(transport);
Conduit conduit = conduitInit.getConduit(ei, getBus());
TestMessageObserver obs = new TestMessageObserver();
conduit.setMessageObserver(obs);
Message m = new MessageImpl();
conduit.prepare(m);
OutputStream os = m.getContent(OutputStream.class);
os.write(message);
// TODO: shouldn't have to do this. IO caching needs cleaning
// up or possibly removal...
os.flush();
os.close();
return obs.getResponseStream().toByteArray();
}
use of org.apache.cxf.message.Message in project ddf by codice.
the class MetricsInInterceptorTest method testHandleMessageWithOneWayClientMessage.
/**
* Test method for
* {@link ddf.metrics.interceptor.MetricsInInterceptor#handleMessage(org.apache.cxf.message.Message)}
* .
*
* @throws InterruptedException
*/
@Test
public void testHandleMessageWithOneWayClientMessage() {
// Setup
MetricsInInterceptor inInterceptor = new MetricsInInterceptor();
Message mockMessage = mock(Message.class);
Exchange ex = new ExchangeImpl();
Bus mockBus = mock(Bus.class);
ex.put(Bus.class, mockBus);
ex.setOneWay(true);
when(mockBus.getId()).thenReturn("bus_id");
when(mockMessage.getExchange()).thenReturn(ex);
when(mockMessage.get(Message.REQUESTOR_ROLE)).thenReturn(true);
// Perform test
inInterceptor.handleMessage(mockMessage);
// validate that there is not an instance of LatencyTimeRecorder on the
// exchange
assertNull(ex.get(LatencyTimeRecorder.class));
}
Aggregations