Search in sources :

Example 21 with SimpleRegistry

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());
}
Also used : CamelContext(org.apache.camel.CamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) SimpleRegistry(org.apache.camel.impl.SimpleRegistry) DataFormat(org.apache.camel.spi.DataFormat) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) Test(org.junit.Test)

Example 22 with SimpleRegistry

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();
}
Also used : SimpleRegistry(org.apache.camel.impl.SimpleRegistry) LdapContext(javax.naming.ldap.LdapContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) Before(org.junit.Before)

Example 23 with SimpleRegistry

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);
}
Also used : CamelContext(org.apache.camel.CamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) RouteBuilder(org.apache.camel.builder.RouteBuilder) SimpleRegistry(org.apache.camel.impl.SimpleRegistry) NCSPathRouteUtil(org.opennms.features.topology.plugins.ncs.support.NCSPathRouteUtil) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) Before(org.junit.Before)

Example 24 with SimpleRegistry

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;
}
Also used : CamelContext(org.apache.camel.CamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) SimpleRegistry(org.apache.camel.impl.SimpleRegistry) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext)

Example 25 with SimpleRegistry

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");
}
Also used : CamelContext(org.apache.camel.CamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) Exchange(org.apache.camel.Exchange) IntStream(java.util.stream.IntStream) XmlAccessorType(javax.xml.bind.annotation.XmlAccessorType) CamelContext(org.apache.camel.CamelContext) Exchange(org.apache.camel.Exchange) Test(org.junit.Test) XmlRootElement(javax.xml.bind.annotation.XmlRootElement) Collectors(java.util.stream.Collectors) XmlAccessType(javax.xml.bind.annotation.XmlAccessType) List(java.util.List) ExchangeBuilder(org.apache.camel.builder.ExchangeBuilder) JaxbUtils(org.opennms.core.xml.JaxbUtils) SimpleRegistry(org.apache.camel.impl.SimpleRegistry) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) SimpleRegistry(org.apache.camel.impl.SimpleRegistry) ExchangeBuilder(org.apache.camel.builder.ExchangeBuilder) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) Test(org.junit.Test)

Aggregations

SimpleRegistry (org.apache.camel.impl.SimpleRegistry)60 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)57 CamelContext (org.apache.camel.CamelContext)35 Test (org.junit.Test)25 RouteBuilder (org.apache.camel.builder.RouteBuilder)14 Before (org.junit.Before)8 FailedToCreateRouteException (org.apache.camel.FailedToCreateRouteException)5 ActiveMQConnectionFactory (org.apache.activemq.ActiveMQConnectionFactory)4 Component (org.apache.camel.Component)4 Exchange (org.apache.camel.Exchange)4 DummyRestConsumerFactory (org.apache.camel.component.rest.DummyRestConsumerFactory)4 HashMap (java.util.HashMap)3 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)3 SjmsComponent (org.apache.camel.component.sjms.SjmsComponent)3 Config (com.hazelcast.config.Config)2 HazelcastInstance (com.hazelcast.core.HazelcastInstance)2 Properties (java.util.Properties)2 ConnectionFactory (javax.jms.ConnectionFactory)2 FileComponent (org.apache.camel.component.file.FileComponent)2 HystrixConfigurationDefinition (org.apache.camel.model.HystrixConfigurationDefinition)2