Search in sources :

Example 51 with DefaultCamelContext

use of org.apache.camel.impl.DefaultCamelContext in project camel by apache.

the class SqsEndpointTest method setUp.

@Before
public void setUp() throws Exception {
    amazonSQSClient = EasyMock.createMock(AmazonSQSClient.class);
    SqsConfiguration config = new SqsConfiguration();
    config.setQueueName("test-queue");
    config.setAmazonSQSClient(amazonSQSClient);
    endpoint = new SqsEndpoint("aws-sqs://test-queue", new SqsComponent(new DefaultCamelContext()), config);
}
Also used : AmazonSQSClient(com.amazonaws.services.sqs.AmazonSQSClient) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) Before(org.junit.Before)

Example 52 with DefaultCamelContext

use of org.apache.camel.impl.DefaultCamelContext in project camel by apache.

the class RouteBuilderTest method createCamelContext.

protected CamelContext createCamelContext() {
    // disable stream cache otherwise to much hazzle in this unit test to filter the stream cache
    // in all the assertion codes
    DefaultCamelContext ctx = new DefaultCamelContext();
    ctx.setStreamCaching(Boolean.FALSE);
    return ctx;
}
Also used : DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext)

Example 53 with DefaultCamelContext

use of org.apache.camel.impl.DefaultCamelContext in project camel by apache.

the class BuilderWithScopesTest method runTest.

protected void runTest(RouteBuilder builder, List<String> expected, String header) throws Exception {
    order.clear();
    CamelContext container = new DefaultCamelContext();
    container.disableJMX();
    container.addRoutes(builder);
    container.start();
    Endpoint endpoint = container.getEndpoint("direct:a");
    Exchange exchange = endpoint.createExchange();
    if (header != null) {
        exchange.getIn().setHeader("foo", header);
    }
    Producer producer = endpoint.createProducer();
    producer.process(exchange);
    log.debug("Invocation order:" + order);
    assertEquals(expected, order);
    container.stop();
}
Also used : CamelContext(org.apache.camel.CamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) Exchange(org.apache.camel.Exchange) Endpoint(org.apache.camel.Endpoint) Producer(org.apache.camel.Producer) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext)

Example 54 with DefaultCamelContext

use of org.apache.camel.impl.DefaultCamelContext in project camel by apache.

the class TransformerBuilderTest method testCustomTransformer.

public void testCustomTransformer() throws Exception {
    CamelContext ctx = new DefaultCamelContext();
    RouteBuilder builder = new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            transformer().scheme("other").withJava(MyTransformer.class);
            from("direct:input").log("test");
        }
    };
    ctx.addRoutes(builder);
    ctx.start();
    Transformer transformer = ctx.resolveTransformer("other");
    assertNotNull(transformer);
    assertEquals(MyTransformer.class, transformer.getClass());
}
Also used : DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) CamelContext(org.apache.camel.CamelContext) ProcessorTransformer(org.apache.camel.impl.transformer.ProcessorTransformer) Transformer(org.apache.camel.spi.Transformer) DataFormatTransformer(org.apache.camel.impl.transformer.DataFormatTransformer) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext)

Example 55 with DefaultCamelContext

use of org.apache.camel.impl.DefaultCamelContext in project camel by apache.

the class TransformerBuilderTest method testDataFormatTransformer.

public void testDataFormatTransformer() throws Exception {
    CamelContext ctx = new DefaultCamelContext();
    RouteBuilder builder = new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            transformer().fromType("xml:foo").toType("json:bar").withDataFormat(new StringDataFormat());
            from("direct:input").log("test");
        }
    };
    ctx.addRoutes(builder);
    ctx.start();
    Transformer transformer = ctx.resolveTransformer(new DataType("xml:foo"), new DataType("json:bar"));
    assertNotNull(transformer);
    assertEquals(DataFormatTransformer.class, transformer.getClass());
    DataFormatTransformer dft = (DataFormatTransformer) transformer;
    Field f = DataFormatTransformer.class.getDeclaredField("dataFormatType");
    f.setAccessible(true);
    Object dataFormatType = f.get(dft);
    assertEquals(StringDataFormat.class, dataFormatType.getClass());
}
Also used : DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) CamelContext(org.apache.camel.CamelContext) Field(java.lang.reflect.Field) ProcessorTransformer(org.apache.camel.impl.transformer.ProcessorTransformer) Transformer(org.apache.camel.spi.Transformer) DataFormatTransformer(org.apache.camel.impl.transformer.DataFormatTransformer) StringDataFormat(org.apache.camel.model.dataformat.StringDataFormat) DataType(org.apache.camel.spi.DataType) DataFormatTransformer(org.apache.camel.impl.transformer.DataFormatTransformer) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext)

Aggregations

DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)474 CamelContext (org.apache.camel.CamelContext)206 Test (org.junit.Test)183 DefaultExchange (org.apache.camel.impl.DefaultExchange)128 RouteBuilder (org.apache.camel.builder.RouteBuilder)101 Exchange (org.apache.camel.Exchange)91 Before (org.junit.Before)70 SimpleRegistry (org.apache.camel.impl.SimpleRegistry)61 RegisteredDelivery (org.jsmpp.bean.RegisteredDelivery)39 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)38 ESMClass (org.jsmpp.bean.ESMClass)30 ProducerTemplate (org.apache.camel.ProducerTemplate)27 CountDownLatch (java.util.concurrent.CountDownLatch)15 Endpoint (org.apache.camel.Endpoint)13 FailedToCreateRouteException (org.apache.camel.FailedToCreateRouteException)13 Processor (org.apache.camel.Processor)12 RouteStartupOrder (org.apache.camel.spi.RouteStartupOrder)12 Address (org.jsmpp.bean.Address)11 SubmitMultiResult (org.jsmpp.bean.SubmitMultiResult)11 Date (java.util.Date)10