use of org.apache.camel.builder.RouteBuilder in project camel by apache.
the class PropertiesComponentTest method testCacheRoute.
public void testCacheRoute() throws Exception {
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start").setBody(simple("${properties:cool.mock}${body}")).to("mock:result");
}
});
context.start();
getMockEndpoint("mock:result").expectedMessageCount(2000);
for (int i = 0; i < 2000; i++) {
template.sendBody("direct:start", i);
}
assertMockEndpointsSatisfied();
}
use of org.apache.camel.builder.RouteBuilder in project camel by apache.
the class PropertiesComponentSimpleLanguageTest method testNoExistingPropertiesComponentWithLocation.
public void testNoExistingPropertiesComponentWithLocation() throws Exception {
context.removeComponent("properties");
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start").transform().simple("Hi ${body}. ${properties-location:org/apache/camel/component/properties/bar.properties:bar.quote}.");
}
});
context.start();
String reply = template.requestBody("direct:start", "Claus", String.class);
assertEquals("Hi Claus. Beer taste good.", reply);
}
use of org.apache.camel.builder.RouteBuilder in project camel by apache.
the class PropertiesComponentTest method testPropertiesComponentNever.
public void testPropertiesComponentNever() throws Exception {
System.setProperty("cool.result", "bar");
System.setProperty("beer", "Carlsberg");
PropertiesComponent pc = context.getComponent("properties", PropertiesComponent.class);
pc.setSystemPropertiesMode(PropertiesComponent.SYSTEM_PROPERTIES_MODE_NEVER);
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:foo").to("mock:{{beer}}").to("mock:{{cool.result}}");
}
});
try {
context.start();
fail("Should have thrown exception");
} catch (FailedToCreateRouteException e) {
assertEquals("Property with key [beer] not found in properties from text: mock:{{beer}}", e.getCause().getMessage());
}
System.clearProperty("cool.result");
System.clearProperty("beer");
}
use of org.apache.camel.builder.RouteBuilder in project camel by apache.
the class PropertiesComponentTest method testPropertiesComponentLocationOverride.
public void testPropertiesComponentLocationOverride() throws Exception {
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start").to("properties:{{bar.end}}?locations=org/apache/camel/component/properties/bar.properties");
}
});
context.start();
getMockEndpoint("mock:bar").expectedMessageCount(1);
template.sendBody("direct:start", "Hello World");
assertMockEndpointsSatisfied();
}
use of org.apache.camel.builder.RouteBuilder in project camel by apache.
the class PropertiesComponentTest method testPropertiesComponentMockMock.
public void testPropertiesComponentMockMock() throws Exception {
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start").to("properties:{{cool.mock}}:{{cool.mock}}");
}
});
context.start();
getMockEndpoint("mock:mock").expectedMessageCount(1);
template.sendBody("direct:start", "Hello World");
assertMockEndpointsSatisfied();
}
Aggregations