Search in sources :

Example 11 with DefaultCamelContext

use of org.apache.camel.impl.DefaultCamelContext 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);
}
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 12 with DefaultCamelContext

use of org.apache.camel.impl.DefaultCamelContext 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 13 with DefaultCamelContext

use of org.apache.camel.impl.DefaultCamelContext in project camel by apache.

the class ECDSASignatureTest method doSignatureRouteTest.

public Exchange doSignatureRouteTest(RouteBuilder builder, Exchange e, Map<String, Object> headers) throws Exception {
    CamelContext context = new DefaultCamelContext();
    try {
        context.addRoutes(builder);
        context.start();
        MockEndpoint mock = context.getEndpoint("mock:result", MockEndpoint.class);
        mock.setExpectedMessageCount(1);
        ProducerTemplate template = context.createProducerTemplate();
        if (e != null) {
            template.send("direct:in", e);
        } else {
            template.sendBodyAndHeaders("direct:in", payload, headers);
        }
        assertMockEndpointsSatisfied();
        return mock.getReceivedExchanges().get(0);
    } finally {
        context.stop();
    }
}
Also used : CamelContext(org.apache.camel.CamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) ProducerTemplate(org.apache.camel.ProducerTemplate) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext)

Example 14 with DefaultCamelContext

use of org.apache.camel.impl.DefaultCamelContext in project camel by apache.

the class SignatureTests method doSignatureRouteTest.

public Exchange doSignatureRouteTest(RouteBuilder builder, Exchange e, Map<String, Object> headers) throws Exception {
    CamelContext context = new DefaultCamelContext();
    try {
        context.addRoutes(builder);
        context.start();
        MockEndpoint mock = context.getEndpoint("mock:result", MockEndpoint.class);
        mock.setExpectedMessageCount(1);
        ProducerTemplate template = context.createProducerTemplate();
        if (e != null) {
            template.send("direct:in", e);
        } else {
            template.sendBodyAndHeaders("direct:in", payload, headers);
        }
        assertMockEndpointsSatisfied();
        return mock.getReceivedExchanges().get(0);
    } finally {
        context.stop();
    }
}
Also used : DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) CamelContext(org.apache.camel.CamelContext) ProducerTemplate(org.apache.camel.ProducerTemplate) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext)

Example 15 with DefaultCamelContext

use of org.apache.camel.impl.DefaultCamelContext in project camel by apache.

the class CxfEndpointTest method testSettingClientBus.

@Test
public void testSettingClientBus() throws Exception {
    ExtensionManagerBus bus = (ExtensionManagerBus) BusFactory.newInstance().createBus();
    bus.setId("oldCXF");
    BusFactory.setThreadDefaultBus(bus);
    ExtensionManagerBus newBus = (ExtensionManagerBus) BusFactory.newInstance().createBus();
    newBus.setId("newCXF");
    CxfComponent cxfComponent = new CxfComponent(new DefaultCamelContext());
    CxfEndpoint endpoint = (CxfEndpoint) cxfComponent.createEndpoint(routerEndpointURI);
    endpoint.setBus(newBus);
    CamelCxfClientImpl client = (CamelCxfClientImpl) endpoint.createClient();
    assertEquals("CamelCxfClientImpl should has the same bus with CxfEndpoint", newBus, client.getBus());
    endpoint = (CxfEndpoint) cxfComponent.createEndpoint(wsdlEndpointURI);
    endpoint.setBus(newBus);
    client = (CamelCxfClientImpl) endpoint.createClient();
    assertEquals("CamelCxfClientImpl should has the same bus with CxfEndpoint", newBus, client.getBus());
}
Also used : CamelCxfClientImpl(org.apache.camel.component.cxf.CxfEndpoint.CamelCxfClientImpl) ExtensionManagerBus(org.apache.cxf.bus.extension.ExtensionManagerBus) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) Test(org.junit.Test)

Aggregations

DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)474 CamelContext (org.apache.camel.CamelContext)206 Test (org.junit.Test)183 DefaultExchange (org.apache.camel.impl.DefaultExchange)128 RouteBuilder (org.apache.camel.builder.RouteBuilder)101 Exchange (org.apache.camel.Exchange)91 Before (org.junit.Before)70 SimpleRegistry (org.apache.camel.impl.SimpleRegistry)61 RegisteredDelivery (org.jsmpp.bean.RegisteredDelivery)39 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)38 ESMClass (org.jsmpp.bean.ESMClass)30 ProducerTemplate (org.apache.camel.ProducerTemplate)27 CountDownLatch (java.util.concurrent.CountDownLatch)15 Endpoint (org.apache.camel.Endpoint)13 FailedToCreateRouteException (org.apache.camel.FailedToCreateRouteException)13 Processor (org.apache.camel.Processor)12 RouteStartupOrder (org.apache.camel.spi.RouteStartupOrder)12 Address (org.jsmpp.bean.Address)11 SubmitMultiResult (org.jsmpp.bean.SubmitMultiResult)11 Date (java.util.Date)10