Search in sources :

Example 61 with DefaultExchange

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

Example 62 with DefaultExchange

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

Example 63 with DefaultExchange

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();
}
Also used : Exchange(org.apache.camel.Exchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) Processor(org.apache.camel.Processor) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) DataTypeAware(org.apache.camel.spi.DataTypeAware) DataType(org.apache.camel.spi.DataType)

Example 64 with DefaultExchange

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

Example 65 with DefaultExchange

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

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