Search in sources :

Example 1 with BlueprintCamelContext

use of org.apache.camel.blueprint.BlueprintCamelContext in project camel by apache.

the class EndpointPropertyTest method testEndpointProperty.

@Test
public void testEndpointProperty() throws Exception {
    getMockEndpoint("mock:result").expectedMessageCount(2);
    template.sendBody("ref:foo", "Hello World");
    template.sendBody("ref:bar", "Bye World");
    assertMockEndpointsSatisfied();
    BlueprintCamelContext blue = context().adapt(BlueprintCamelContext.class);
    SedaEndpoint foo = (SedaEndpoint) blue.getBlueprintContainer().getComponentInstance("foo");
    assertNotNull(foo);
    assertEquals(100, foo.getSize());
    assertEquals(5000, foo.getPollTimeout());
    assertEquals(true, foo.isBlockWhenFull());
    assertEquals("seda://foo?blockWhenFull=true&pollTimeout=5000&size=100", foo.getEndpointUri());
    SedaEndpoint bar = (SedaEndpoint) blue.getBlueprintContainer().getComponentInstance("bar");
    assertNotNull(bar);
    assertEquals(200, bar.getSize());
    assertEquals("seda://bar?size=200", bar.getEndpointUri());
}
Also used : BlueprintCamelContext(org.apache.camel.blueprint.BlueprintCamelContext) SedaEndpoint(org.apache.camel.component.seda.SedaEndpoint) Test(org.junit.Test)

Example 2 with BlueprintCamelContext

use of org.apache.camel.blueprint.BlueprintCamelContext in project camel by apache.

the class DuplicateNamespacePrefixIssueTest method testRoutesNamespacePrefixesNotDuplicated.

@Test
public void testRoutesNamespacePrefixesNotDuplicated() throws Exception {
    CamelContext context = new BlueprintCamelContext(bundleContext, blueprintContainer);
    context.addRoutes(new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            from("direct:foo").id("foo").choice().when(xpath("foo:foo/foo:foo = 'foo'")).log("Matched foo").when(xpath("foo:foo/foo:bar = 'bar'")).log("Matched bar").when(xpath("foo:foo/foo:cheese = 'cheese'")).log("Matched cheese");
        }
    });
    // Dump the model XML
    String originalModelXML = ModelHelper.dumpModelAsXml(context, context.getRouteDefinition("foo"));
    // Reload routes from dumped XML
    InputStream stream = new ByteArrayInputStream(originalModelXML.getBytes("UTF-8"));
    RoutesDefinition routesDefinition = ModelHelper.loadRoutesDefinition(context, stream);
    // Verify namespaces are as we expect
    String modifiedModelXML = ModelHelper.dumpModelAsXml(context, routesDefinition);
    String modifiedRoutesElementXML = modifiedModelXML.split("\n")[1];
    String expectedRoutesElementXML = "<routes xmlns=\"http://camel.apache.org/schema/spring\">";
    Assert.assertEquals(expectedRoutesElementXML, modifiedRoutesElementXML);
}
Also used : CamelContext(org.apache.camel.CamelContext) BlueprintCamelContext(org.apache.camel.blueprint.BlueprintCamelContext) BlueprintCamelContext(org.apache.camel.blueprint.BlueprintCamelContext) RouteBuilder(org.apache.camel.builder.RouteBuilder) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) RoutesDefinition(org.apache.camel.model.RoutesDefinition) Test(org.junit.Test) AbstractFeatureTest(org.apache.camel.test.karaf.AbstractFeatureTest)

Aggregations

BlueprintCamelContext (org.apache.camel.blueprint.BlueprintCamelContext)2 Test (org.junit.Test)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 InputStream (java.io.InputStream)1 CamelContext (org.apache.camel.CamelContext)1 RouteBuilder (org.apache.camel.builder.RouteBuilder)1 SedaEndpoint (org.apache.camel.component.seda.SedaEndpoint)1 RoutesDefinition (org.apache.camel.model.RoutesDefinition)1 AbstractFeatureTest (org.apache.camel.test.karaf.AbstractFeatureTest)1