use of org.apache.camel.impl.DefaultExchange in project camel by apache.
the class ExchangeHelper method copyExchangeAndSetCamelContext.
/**
* Copies the exchange but the copy will be tied to the given context
*
* @param exchange the source exchange
* @param context the camel context
* @param handover whether to handover on completions from the source to the copy
* @return a copy with the given camel context
*/
public static Exchange copyExchangeAndSetCamelContext(Exchange exchange, CamelContext context, boolean handover) {
DefaultExchange answer = new DefaultExchange(context, exchange.getPattern());
if (exchange.hasProperties()) {
answer.setProperties(safeCopy(exchange.getProperties()));
}
if (handover) {
// Need to hand over the completion for async invocation
exchange.handoverCompletions(answer);
}
answer.setIn(exchange.getIn().copy());
if (exchange.hasOut()) {
answer.setOut(exchange.getOut().copy());
}
answer.setException(exchange.getException());
return answer;
}
use of org.apache.camel.impl.DefaultExchange in project camel by apache.
the class CamelExceptionsTest method testNoSuchPropertyException.
public void testNoSuchPropertyException() {
Exchange exchange = new DefaultExchange(context);
NoSuchPropertyException e = new NoSuchPropertyException(exchange, "foo", Integer.class);
assertEquals(Integer.class, e.getType());
assertEquals("foo", e.getPropertyName());
assertSame(exchange, e.getExchange());
}
use of org.apache.camel.impl.DefaultExchange in project camel by apache.
the class CamelExceptionsTest method testInvalidPayloadException.
public void testInvalidPayloadException() {
Exchange exchange = new DefaultExchange(context);
InvalidPayloadException e = new InvalidPayloadException(exchange, Integer.class);
assertSame(exchange, e.getExchange());
assertEquals(Integer.class, e.getType());
}
use of org.apache.camel.impl.DefaultExchange in project camel by apache.
the class CamelExceptionsTest method testExpectedBodyTypeException.
public void testExpectedBodyTypeException() {
Exchange exchange = new DefaultExchange(context);
ExpectedBodyTypeException e = new ExpectedBodyTypeException(exchange, Integer.class);
assertSame(exchange, e.getExchange());
assertEquals(Integer.class, e.getExpectedBodyType());
}
use of org.apache.camel.impl.DefaultExchange in project camel by apache.
the class TestSupport method createExchangeWithBody.
/**
* Creates an exchange with the given body
*/
protected Exchange createExchangeWithBody(CamelContext camelContext, Object body) {
Exchange exchange = new DefaultExchange(camelContext);
Message message = exchange.getIn();
message.setHeader("testName", getName());
message.setHeader("testClass", getClass().getName());
message.setBody(body);
return exchange;
}
Aggregations