Search in sources :

Example 81 with DefaultExchange

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;
}
Also used : DefaultExchange(org.apache.camel.impl.DefaultExchange)

Example 82 with DefaultExchange

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());
}
Also used : DefaultExchange(org.apache.camel.impl.DefaultExchange) DefaultExchange(org.apache.camel.impl.DefaultExchange)

Example 83 with DefaultExchange

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());
}
Also used : DefaultExchange(org.apache.camel.impl.DefaultExchange) DefaultExchange(org.apache.camel.impl.DefaultExchange)

Example 84 with DefaultExchange

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());
}
Also used : DefaultExchange(org.apache.camel.impl.DefaultExchange) DefaultExchange(org.apache.camel.impl.DefaultExchange)

Example 85 with DefaultExchange

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;
}
Also used : DefaultExchange(org.apache.camel.impl.DefaultExchange) DefaultExchange(org.apache.camel.impl.DefaultExchange)

Aggregations

DefaultExchange (org.apache.camel.impl.DefaultExchange)473 Exchange (org.apache.camel.Exchange)381 Test (org.junit.Test)254 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)127 CamelContext (org.apache.camel.CamelContext)54 RegisteredDelivery (org.jsmpp.bean.RegisteredDelivery)39 HashMap (java.util.HashMap)33 Message (org.apache.camel.Message)32 Before (org.junit.Before)32 Tx (org.nhindirect.common.tx.model.Tx)31 ESMClass (org.jsmpp.bean.ESMClass)30 Processor (org.apache.camel.Processor)22 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)22 Expression (org.apache.camel.Expression)21 File (java.io.File)20 DefaultMessage (org.apache.camel.impl.DefaultMessage)20 ArrayList (java.util.ArrayList)18 ByteArrayInputStream (java.io.ByteArrayInputStream)17 URL (java.net.URL)16 Date (java.util.Date)16