Search in sources :

Example 31 with RouteBuilder

use of org.apache.camel.builder.RouteBuilder in project camel by apache.

the class MultiMasterCuratorLeaderRoutePolicyTest method ensureRoutesDoNotStartAutomatically.

@Test
public void ensureRoutesDoNotStartAutomatically() throws Exception {
    DefaultCamelContext context = new DefaultCamelContext();
    context.addRoutes(new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            CuratorMultiMasterLeaderRoutePolicy policy = new CuratorMultiMasterLeaderRoutePolicy("zookeeper:localhost:" + getServerPort() + BASE_ZNODE + ZNODE + 2);
            from("timer://foo?fixedRate=true&period=5").routePolicy(policy).id("single_route").autoStartup(true).to("mock:controlled");
        }
    });
    context.start();
    // this check verifies that a route marked as autostartable is not started automatically. It will be the policy responsibility to eventually start it.
    assertThat(context.getRouteStatus("single_route").isStarted(), is(false));
    assertThat(context.getRouteStatus("single_route").isStarting(), is(false));
    try {
        context.shutdown();
    } catch (Exception e) {
    //concurrency can raise some InterruptedException but we don't really care in this scenario.
    }
}
Also used : RouteBuilder(org.apache.camel.builder.RouteBuilder) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) Test(org.junit.Test)

Example 32 with RouteBuilder

use of org.apache.camel.builder.RouteBuilder in project camel by apache.

the class MyBatisUnknownStatementTypeTest method testStatementTypeNotSet.

@Test
public void testStatementTypeNotSet() throws Exception {
    context.addRoutes(new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            from("direct:start").to("mybatis:selectAllAccounts");
        }
    });
    try {
        context.start();
        fail("Should have thrown exception");
    } catch (Exception e) {
        assertIsInstanceOf(IllegalArgumentException.class, e.getCause().getCause());
        assertEquals("statementType must be specified on: mybatis://selectAllAccounts", e.getCause().getCause().getMessage());
    }
}
Also used : RouteBuilder(org.apache.camel.builder.RouteBuilder) Test(org.junit.Test)

Example 33 with RouteBuilder

use of org.apache.camel.builder.RouteBuilder in project camel by apache.

the class NagiosAsyncSendTest method createRouteBuilder.

@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            String uri = "nagios:127.0.0.1:25664?password=secret&sendSync=false";
            NagiosComponent nagiosComponent = new NagiosComponent();
            nagiosComponent.setCamelContext(context);
            NagiosEndpoint nagiousEndpoint = (NagiosEndpoint) nagiosComponent.createEndpoint(uri);
            nagiousEndpoint.setSender(nagiosPassiveCheckSender);
            Producer nagiosProducer = nagiousEndpoint.createProducer();
            from("direct:start").to(nagiousEndpoint).to("mock:result");
        }
    };
}
Also used : RouteBuilder(org.apache.camel.builder.RouteBuilder) Producer(org.apache.camel.Producer)

Example 34 with RouteBuilder

use of org.apache.camel.builder.RouteBuilder in project camel by apache.

the class NagiosTest method createRouteBuilder.

@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            String uri = "nagios:127.0.0.1:25664?password=secret";
            NagiosComponent nagiosComponent = new NagiosComponent();
            nagiosComponent.setCamelContext(context);
            NagiosEndpoint nagiousEndpoint = (NagiosEndpoint) nagiosComponent.createEndpoint(uri);
            nagiousEndpoint.setSender(nagiosPassiveCheckSender);
            Producer nagiosProducer = nagiousEndpoint.createProducer();
            from("direct:start").to(nagiousEndpoint).to("mock:result");
        }
    };
}
Also used : RouteBuilder(org.apache.camel.builder.RouteBuilder) Producer(org.apache.camel.Producer)

Example 35 with RouteBuilder

use of org.apache.camel.builder.RouteBuilder in project camel by apache.

the class NagiosXorEncryptionTest method createRouteBuilder.

@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            String uri = "nagios:127.0.0.1:25664?password=secret&encryptionMethod=Xor";
            NagiosComponent nagiosComponent = new NagiosComponent();
            nagiosComponent.setCamelContext(context);
            NagiosEndpoint nagiousEndpoint = (NagiosEndpoint) nagiosComponent.createEndpoint(uri);
            nagiousEndpoint.setSender(nagiosPassiveCheckSender);
            Producer nagiosProducer = nagiousEndpoint.createProducer();
            from("direct:start").to(nagiousEndpoint).to("mock:result");
        }
    };
}
Also used : RouteBuilder(org.apache.camel.builder.RouteBuilder) Producer(org.apache.camel.Producer)

Aggregations

RouteBuilder (org.apache.camel.builder.RouteBuilder)1759 Exchange (org.apache.camel.Exchange)628 Processor (org.apache.camel.Processor)545 Test (org.junit.Test)476 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)341 CamelExecutionException (org.apache.camel.CamelExecutionException)135 FailedToCreateRouteException (org.apache.camel.FailedToCreateRouteException)119 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)104 File (java.io.File)68 CamelContext (org.apache.camel.CamelContext)64 IOException (java.io.IOException)61 ResolveEndpointFailedException (org.apache.camel.ResolveEndpointFailedException)42 HashMap (java.util.HashMap)35 Path (org.apache.hadoop.fs.Path)34 CountDownLatch (java.util.concurrent.CountDownLatch)32 Configuration (org.apache.hadoop.conf.Configuration)32 Endpoint (org.apache.camel.Endpoint)30 ArrayFile (org.apache.hadoop.io.ArrayFile)30 SequenceFile (org.apache.hadoop.io.SequenceFile)30 RuntimeCamelException (org.apache.camel.RuntimeCamelException)26