use of org.apache.camel.impl.DefaultExchange in project camel by apache.
the class ExchangeBuilderTest method testBuildAnExchangeWithDefaultPattern.
public void testBuildAnExchangeWithDefaultPattern() {
Exchange exchange = new DefaultExchange(CONTEXT);
Exchange builtExchange = ExchangeBuilder.anExchange(CONTEXT).build();
assertEquals(exchange.getPattern(), builtExchange.getPattern());
}
use of org.apache.camel.impl.DefaultExchange in project camel by apache.
the class XsltDTDTest method testSendingInputStreamMessage.
public void testSendingInputStreamMessage() throws Exception {
InputStream is = IOConverter.toInputStream(MESSAGE, new DefaultExchange(context));
sendEntityMessage(is);
}
use of org.apache.camel.impl.DefaultExchange in project camel by apache.
the class TransformerRouteTest method testDataFormatTransformer.
public void testDataFormatTransformer() throws Exception {
MockEndpoint xyzresult = getMockEndpoint("mock:xyzresult");
xyzresult.expectedMessageCount(1);
xyzresult.whenAnyExchangeReceived(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
LOG.info("Asserting String -> XOrderResponse convertion is not yet performed");
assertEquals("response", exchange.getIn().getBody());
}
});
Exchange exchange = new DefaultExchange(context, ExchangePattern.InOut);
((DataTypeAware) exchange.getIn()).setBody("{name:XOrder}", new DataType("json:JsonXOrder"));
Exchange answerEx = template.send("direct:dataFormat", exchange);
if (answerEx.getException() != null) {
throw answerEx.getException();
}
assertEquals("{name:XOrderResponse}", answerEx.getOut().getBody(String.class));
assertMockEndpointsSatisfied();
}
use of org.apache.camel.impl.DefaultExchange in project camel by apache.
the class TransformerRouteTest method testJavaTransformer.
public void testJavaTransformer() throws Exception {
MockEndpoint abcresult = getMockEndpoint("mock:abcresult");
abcresult.expectedMessageCount(1);
abcresult.whenAnyExchangeReceived(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
LOG.info("Asserting String -> XOrderResponse convertion");
assertEquals(XOrderResponse.class, exchange.getIn().getBody().getClass());
}
});
MockEndpoint xyzresult = getMockEndpoint("mock:xyzresult");
xyzresult.expectedMessageCount(1);
xyzresult.whenAnyExchangeReceived(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
LOG.info("Asserting String -> XOrderResponse convertion is not yet performed");
assertEquals("response", exchange.getIn().getBody());
}
});
Exchange exchange = new DefaultExchange(context, ExchangePattern.InOut);
exchange.getIn().setBody(new AOrder());
Exchange answerEx = template.send("direct:abc", exchange);
if (answerEx.getException() != null) {
throw answerEx.getException();
}
assertEquals(AOrderResponse.class, answerEx.getOut().getBody().getClass());
assertMockEndpointsSatisfied();
}
use of org.apache.camel.impl.DefaultExchange in project camel by apache.
the class TransformerRouteTest method testEndpointTransformer.
public void testEndpointTransformer() throws Exception {
MockEndpoint xyzresult = getMockEndpoint("mock:xyzresult");
xyzresult.expectedMessageCount(1);
xyzresult.whenAnyExchangeReceived(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
LOG.info("Asserting String -> XOrderResponse convertion is not yet performed");
assertEquals("response", exchange.getIn().getBody());
}
});
Exchange exchange = new DefaultExchange(context, ExchangePattern.InOut);
exchange.getIn().setBody("<XOrder/>");
Exchange answerEx = template.send("direct:endpoint", exchange);
if (answerEx.getException() != null) {
throw answerEx.getException();
}
assertEquals("<XOrderResponse/>", answerEx.getOut().getBody(String.class));
assertMockEndpointsSatisfied();
}
Aggregations