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);
}
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());
}
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();
}
}
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();
}
}
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;
}
Aggregations