Search in sources :

Example 96 with RouteBuilder

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();
}
Also used : RouteBuilder(org.apache.camel.builder.RouteBuilder) FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException) ResolveEndpointFailedException(org.apache.camel.ResolveEndpointFailedException)

Example 97 with RouteBuilder

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);
}
Also used : RouteBuilder(org.apache.camel.builder.RouteBuilder) RuntimeCamelException(org.apache.camel.RuntimeCamelException) CamelExecutionException(org.apache.camel.CamelExecutionException)

Example 98 with RouteBuilder

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");
}
Also used : FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException) RouteBuilder(org.apache.camel.builder.RouteBuilder) FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException) ResolveEndpointFailedException(org.apache.camel.ResolveEndpointFailedException)

Example 99 with RouteBuilder

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();
}
Also used : RouteBuilder(org.apache.camel.builder.RouteBuilder) FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException) ResolveEndpointFailedException(org.apache.camel.ResolveEndpointFailedException)

Example 100 with RouteBuilder

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();
}
Also used : RouteBuilder(org.apache.camel.builder.RouteBuilder) FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException) ResolveEndpointFailedException(org.apache.camel.ResolveEndpointFailedException)

Aggregations

RouteBuilder (org.apache.camel.builder.RouteBuilder)1744 Exchange (org.apache.camel.Exchange)624 Processor (org.apache.camel.Processor)542 Test (org.junit.Test)470 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)338 CamelExecutionException (org.apache.camel.CamelExecutionException)135 FailedToCreateRouteException (org.apache.camel.FailedToCreateRouteException)119 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)100 File (java.io.File)65 IOException (java.io.IOException)61 CamelContext (org.apache.camel.CamelContext)61 ResolveEndpointFailedException (org.apache.camel.ResolveEndpointFailedException)42 HashMap (java.util.HashMap)34 Path (org.apache.hadoop.fs.Path)34 CountDownLatch (java.util.concurrent.CountDownLatch)32 Configuration (org.apache.hadoop.conf.Configuration)32 ArrayFile (org.apache.hadoop.io.ArrayFile)30 SequenceFile (org.apache.hadoop.io.SequenceFile)30 Endpoint (org.apache.camel.Endpoint)27 RuntimeCamelException (org.apache.camel.RuntimeCamelException)26