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