Search in sources :

Example 21 with DefaultCamelContext

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

the class LoadDistributorFeatureTest method startRoutePojo.

private void startRoutePojo() throws Exception {
    String proxy = "cxf://" + POJO_PROXY_ADDRESS + "?serviceClass=" + "org.apache.camel.component.cxf.HelloService" + "&dataFormat=POJO";
    String backend = "cxf://" + SERVICE_ADDRESS_1 + "?serviceClass=" + "org.apache.camel.component.cxf.HelloService" + "&dataFormat=POJO";
    context2 = new DefaultCamelContext();
    startRoute(context2, proxy, backend);
}
Also used : DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext)

Example 22 with DefaultCamelContext

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

the class CxfRsEndpointTest method testCxfRsEndpointCamelContextAware.

@Test
public void testCxfRsEndpointCamelContextAware() throws Exception {
    String endpointUri = "cxfrs://simple";
    CxfRsEndpoint endpoint = new CxfRsEndpoint();
    endpoint.setAddress("http://localhost:9000/test");
    endpoint.setResourceClasses(CustomerService.class);
    CamelContext context = new DefaultCamelContext();
    context.addEndpoint(endpointUri, endpoint);
    assertEquals("Get a wrong camel context.", context, endpoint.getCamelContext());
}
Also used : CamelContext(org.apache.camel.CamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) Test(org.junit.Test)

Example 23 with DefaultCamelContext

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

the class DozerBeanMappingTest method testBeanMapping.

@Test
public void testBeanMapping() throws Exception {
    CamelContext context = new DefaultCamelContext();
    context.addRoutes(new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            from("direct:start").convertBodyTo(CustomerB.class);
        }
    });
    DozerBeanMapperConfiguration mconfig = new DozerBeanMapperConfiguration();
    mconfig.setMappingFiles(Arrays.asList("bean-to-bean-dozer-mappings.xml"));
    new DozerTypeConverterLoader(context, mconfig);
    CustomerA customerA = new CustomerA("Peter", "Post", "SomeStreet", "12345");
    context.start();
    try {
        ProducerTemplate producer = context.createProducerTemplate();
        CustomerB result = producer.requestBody("direct:start", customerA, CustomerB.class);
        Assert.assertEquals(customerA.getFirstName(), result.getFirstName());
        Assert.assertEquals(customerA.getLastName(), result.getLastName());
        Assert.assertEquals(customerA.getStreet(), result.getAddress().getStreet());
        Assert.assertEquals(customerA.getZip(), result.getAddress().getZip());
    } finally {
        context.stop();
    }
}
Also used : CamelContext(org.apache.camel.CamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) ProducerTemplate(org.apache.camel.ProducerTemplate) CustomerA(org.apache.camel.converter.dozer.model.CustomerA) RouteBuilder(org.apache.camel.builder.RouteBuilder) CustomerB(org.apache.camel.converter.dozer.model.CustomerB) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) Test(org.junit.Test)

Example 24 with DefaultCamelContext

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

the class DozerBeanMappingTest method testMarshalViaDozer.

@Test
public void testMarshalViaDozer() throws Exception {
    CamelContext context = new DefaultCamelContext();
    context.addRoutes(new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            from("direct:start").convertBodyTo(HashMap.class);
        }
    });
    DozerBeanMapperConfiguration mconfig = new DozerBeanMapperConfiguration();
    mconfig.setMappingFiles(Arrays.asList("bean-to-map-dozer-mappings.xml"));
    new DozerTypeConverterLoader(context, mconfig);
    context.start();
    try {
        ProducerTemplate producer = context.createProducerTemplate();
        Map<?, ?> result = producer.requestBody("direct:start", new Customer("John", "Doe", null), Map.class);
        Assert.assertEquals("John", result.get("firstName"));
        Assert.assertEquals("Doe", result.get("lastName"));
    } finally {
        context.stop();
    }
}
Also used : CamelContext(org.apache.camel.CamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) ProducerTemplate(org.apache.camel.ProducerTemplate) RouteBuilder(org.apache.camel.builder.RouteBuilder) HashMap(java.util.HashMap) Customer(org.apache.camel.converter.dozer.model.Customer) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) Test(org.junit.Test)

Example 25 with DefaultCamelContext

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

the class GreaterCamelEjbPropertiesTest method createCamelContext.

@Override
protected CamelContext createCamelContext() throws Exception {
    // use simple registry to not conflict with jndi used by EJB
    CamelContext answer = new DefaultCamelContext(new SimpleRegistry());
    // enlist EJB component using JndiContext
    Properties properties = new Properties();
    properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.LocalInitialContextFactory");
    EjbComponent ejb = answer.getComponent("ejb", EjbComponent.class);
    ejb.setProperties(properties);
    return answer;
}
Also used : CamelContext(org.apache.camel.CamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) SimpleRegistry(org.apache.camel.impl.SimpleRegistry) Properties(java.util.Properties) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext)

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