use of org.apache.camel.impl.SimpleRegistry in project camel by apache.
the class GroovyShellFactoryTest method testExpressionReturnsTheCorrectValue.
@Test
public void testExpressionReturnsTheCorrectValue() {
// Given
GroovyShellFactory groovyShellFactory = mock(GroovyShellFactory.class);
given(groovyShellFactory.createGroovyShell(any(Exchange.class))).willReturn(new GroovyShell());
SimpleRegistry registry = new SimpleRegistry();
registry.put("groovyShellFactory", groovyShellFactory);
CamelContext camelContext = new DefaultCamelContext(registry);
// When
assertExpression(GroovyLanguage.groovy("exchange.in.body"), new DefaultExchange(camelContext), null);
// Then
verify(groovyShellFactory).createGroovyShell(any(Exchange.class));
}
use of org.apache.camel.impl.SimpleRegistry 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.SimpleRegistry 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.SimpleRegistry in project camel by apache.
the class ServiceCallConfigurationTest method testDefaultConfigurationFromRegistryWithDefaultName.
@Test
public void testDefaultConfigurationFromRegistryWithDefaultName() throws Exception {
StaticServiceDiscovery sd = new StaticServiceDiscovery();
sd.addServer("127.0.0.1:8080");
sd.addServer("127.0.0.1:8081");
BlacklistServiceFilter sf = new BlacklistServiceFilter();
sf.addServer("127.0.0.1:8080");
ServiceCallConfigurationDefinition conf = new ServiceCallConfigurationDefinition();
conf.setServiceDiscovery(sd);
conf.serviceFilter(sf);
SimpleRegistry reg = new SimpleRegistry();
reg.put(org.apache.camel.model.cloud.ServiceCallConstants.DEFAULT_SERVICE_CALL_CONFIG_ID, conf);
CamelContext context = new DefaultCamelContext(reg);
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start").routeId("default").serviceCall().name("scall").component("file").end();
}
});
context.start();
DefaultServiceCallProcessor proc = findServiceCallProcessor(context.getRoute("default"));
Assert.assertNotNull(proc);
Assert.assertTrue(proc.getLoadBalancer() instanceof DefaultLoadBalancer);
DefaultLoadBalancer loadBalancer = (DefaultLoadBalancer) proc.getLoadBalancer();
Assert.assertEquals(sd, loadBalancer.getServiceDiscovery());
Assert.assertEquals(sf, loadBalancer.getServiceFilter());
context.stop();
}
use of org.apache.camel.impl.SimpleRegistry in project camel by apache.
the class OsgiDataFormatResolverTest method testOsgiResolverFindDataFormatFallbackTest.
@Test
public void testOsgiResolverFindDataFormatFallbackTest() throws Exception {
SimpleRegistry registry = new SimpleRegistry();
registry.put("allstar-dataformat", new SampleDataFormat(true));
CamelContext camelContext = new DefaultCamelContext(registry);
OsgiDataFormatResolver resolver = new OsgiDataFormatResolver(getBundleContext());
DataFormat dataformat = resolver.resolveDataFormat("allstar", camelContext);
assertNotNull("We should find the super dataformat", dataformat);
assertTrue("We should get the super dataformat here", dataformat instanceof SampleDataFormat);
}
Aggregations