use of org.apache.camel.impl.SimpleRegistry in project camel by apache.
the class OsgiDataFormatResolverTest method testOsgiResolverFindLanguageDoubleFallbackTest.
@Test
public void testOsgiResolverFindLanguageDoubleFallbackTest() throws Exception {
SimpleRegistry registry = new SimpleRegistry();
registry.put("allstar", new SampleDataFormat(false));
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);
assertFalse("We should NOT find the fallback dataformat", ((SampleDataFormat) dataformat).isFallback());
}
use of org.apache.camel.impl.SimpleRegistry in project camel by apache.
the class LdapRouteTest method setup.
@Before
public void setup() throws Exception {
// you can assign port number in the @CreateTransport annotation
port = super.getLdapServer().getPort();
LdapContext ctx = getWiredContext(ldapServer);
SimpleRegistry reg = new SimpleRegistry();
reg.put("localhost:" + port, ctx);
camel = new DefaultCamelContext(reg);
template = camel.createProducerTemplate();
}
use of org.apache.camel.impl.SimpleRegistry in project opennms by OpenNMS.
the class NCSPathProviderTest method setUp.
@Before
public void setUp() throws Exception {
NCSPathRouteUtil pathUtil = new NCSPathRouteUtil(new MockNCSComponentRepository(), new MockNodeDao());
SimpleRegistry registry = new SimpleRegistry();
registry.put("pathProviderUtil", pathUtil);
CamelContext camel = new DefaultCamelContext(registry);
camel.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start").setHeader(Exchange.HTTP_URI, simple("http://localhost:10346/ncs-provider/api/space/nsas/service-management/services/884779")).to("http://dummyhost").beanRef("pathProviderUtil", "getServiceName").setHeader(Exchange.HTTP_URI, simple("http://localhost:10346/ncs-provider/api/space/nsas/eline-ptp/service-management/services/884779/servicepath?deviceA=${header.deviceA}&deviceZ=${header.deviceZ}")).to("http://dummyhost").beanRef("pathProviderUtil", "createPath");
}
});
camel.start();
m_ncsPathService = new NCSPathProviderService(camel);
}
use of org.apache.camel.impl.SimpleRegistry in project opennms by OpenNMS.
the class EchoRpcIT method getContext.
@Override
public CamelContext getContext() {
SimpleRegistry registry = new SimpleRegistry();
CamelContext context = new DefaultCamelContext(registry);
context.addComponent("queuingservice", queuingservice);
return context;
}
use of org.apache.camel.impl.SimpleRegistry in project opennms by OpenNMS.
the class JaxbUtilsUnmarshalProcessorTest method testSpeed.
@Test
public void testSpeed() throws Exception {
TestMe test = new TestMe();
test.lets = "lets";
test.make = "make";
test.an = "an";
test.object = "object";
String marshalled = JaxbUtils.marshal(test);
final int numberOfMessages = 10000;
final int warmUp = 4000;
CamelContext m_camel = new DefaultCamelContext(new SimpleRegistry());
JaxbUtilsUnmarshalProcessor processor = new JaxbUtilsUnmarshalProcessor(TestMe.class);
List<Exchange> exchanges = IntStream.range(0, numberOfMessages).mapToObj(i -> {
return new ExchangeBuilder(m_camel).withBody(marshalled).build();
}).collect(Collectors.toList());
int counter = 0;
long begin = 0;
long end = 0;
for (Exchange exchange : exchanges) {
processor.process(exchange);
if (counter++ < warmUp) {
// Warm up
continue;
}
if (begin == 0) {
begin = System.currentTimeMillis();
}
// System.out.println(end = System.currentTimeMillis());
end = System.currentTimeMillis();
}
System.out.println("BEGIN: " + begin);
System.out.println("END: " + end);
System.out.println("TOTAL TIME: " + (end - begin));
System.out.println("RATE: " + ((double) (numberOfMessages - warmUp) / (double) (end - begin)) + "/ms");
}
Aggregations