use of org.apache.camel.impl.DefaultCamelContext in project camel by apache.
the class XsltCustomErrorListenerTest method testErrorListener.
public void testErrorListener() throws Exception {
try {
SimpleRegistry registry = new SimpleRegistry();
registry.put("myListener", listener);
RouteBuilder builder = createRouteBuilder();
CamelContext context = new DefaultCamelContext(registry);
context.addRoutes(builder);
context.start();
fail("Should have thrown an exception due XSLT file not found");
} catch (FailedToCreateRouteException e) {
// expected
}
assertFalse(listener.isWarning());
assertTrue("My error listener should been invoked", listener.isError());
assertTrue("My error listener should been invoked", listener.isFatalError());
}
use of org.apache.camel.impl.DefaultCamelContext in project camel by apache.
the class XsltReferenceParameterTest method setUp.
public void setUp() throws Exception {
JndiRegistry registry = new JndiRegistry(new JndiContext());
RouteBuilder builder = createRouteBuilder();
CamelContext context = new DefaultCamelContext(registry);
testConverter = new TestConverter();
testTransformerFactory = TransformerFactory.newInstance();
registry.bind("testConverter", testConverter);
registry.bind("testTransformerFactory", testTransformerFactory);
ProcessorEndpoint pep1 = context.getEndpoint(TEST_URI_1, ProcessorEndpoint.class);
context.addRoutes(builder);
context.start();
builder1 = (XsltBuilder) pep1.getProcessor();
}
use of org.apache.camel.impl.DefaultCamelContext in project camel by apache.
the class ValidatorEndpointClearCachedSchemaTest method createCamelContext.
@Override
protected CamelContext createCamelContext() throws Exception {
simpleReg = new SimpleRegistry();
context = new DefaultCamelContext(simpleReg);
context.setClassResolver(new ClassResolverImpl());
return context;
}
use of org.apache.camel.impl.DefaultCamelContext in project camel by apache.
the class XsltFileNotFoundTest method testNoXsltFile.
public void testNoXsltFile() throws Exception {
try {
RouteBuilder builder = createRouteBuilder();
CamelContext context = new DefaultCamelContext();
context.addRoutes(builder);
context.start();
fail("Should have thrown an exception due XSLT file not found");
} catch (FailedToCreateRouteException e) {
assertIsInstanceOf(TransformerException.class, e.getCause());
assertIsInstanceOf(FileNotFoundException.class, e.getCause().getCause());
}
}
use of org.apache.camel.impl.DefaultCamelContext in project camel by apache.
the class VmMultipleConsumersKeepRouteTest method testVmMultipleConsumersKeepRoute.
public void testVmMultipleConsumersKeepRoute() throws Exception {
CamelContext camelContext = new DefaultCamelContext();
ProducerTemplate producerTemplate = camelContext.createProducerTemplate();
RouteBuilder builder = new RouteBuilder(camelContext) {
@Override
public void configure() throws Exception {
from("vm:producer?multipleConsumers=true").routeId("route1").to("mock:route1");
}
};
RouteBuilder builder2 = new RouteBuilder(camelContext) {
@Override
public void configure() throws Exception {
from("vm:producer?multipleConsumers=true").routeId("route2").to("mock:route2");
}
};
camelContext.addRoutes(builder);
camelContext.addRoutes(builder2);
camelContext.start();
MockEndpoint mock1 = (MockEndpoint) camelContext.getEndpoint("mock:route1");
MockEndpoint mock2 = (MockEndpoint) camelContext.getEndpoint("mock:route2");
mock1.expectedMessageCount(100);
mock2.expectedMessageCount(100);
for (int i = 0; i < 100; i++) {
producerTemplate.sendBody("vm:producer?multipleConsumers=true", i);
}
MockEndpoint.assertIsSatisfied(mock1, mock2);
camelContext.stop();
}
Aggregations