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.
}
}
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());
}
}
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");
}
};
}
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");
}
};
}
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");
}
};
}
Aggregations