use of org.apache.camel.converter.dozer.DozerTypeConverterLoader in project wildfly-camel by wildfly-extras.
the class DozerIntegrationTest method testBeanMapping.
@Test
public void testBeanMapping() throws Exception {
CamelContext camelctx = new DefaultCamelContext();
camelctx.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start").convertBodyTo(CustomerB.class);
}
});
DozerBeanMapperConfiguration mconfig = new DozerBeanMapperConfiguration();
mconfig.setMappingFiles(Arrays.asList(new String[] { DOZER_MAPPINGS_XML }));
new DozerTypeConverterLoader(camelctx, mconfig);
CustomerA customerA = new CustomerA("Peter", "Post", "Street", "12345");
camelctx.start();
try {
ProducerTemplate producer = camelctx.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 {
camelctx.stop();
}
}
use of org.apache.camel.converter.dozer.DozerTypeConverterLoader in project wildfly-camel by wildfly-extras.
the class CSVIntegrationTest method testMarshalViaDozer.
@Test
public void testMarshalViaDozer() throws Exception {
CamelContext camelctx = new DefaultCamelContext();
camelctx.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start").marshal().csv();
}
});
DozerBeanMapperConfiguration mconfig = new DozerBeanMapperConfiguration();
mconfig.setMappingFiles(Arrays.asList(new String[] { DOZER_MAPPINGS_XML }));
new DozerTypeConverterLoader(camelctx, mconfig);
camelctx.start();
try {
ProducerTemplate producer = camelctx.createProducerTemplate();
String result = producer.requestBody("direct:start", new Customer("John", "Doe"), String.class);
Assert.assertEquals("John,Doe", result.trim());
} finally {
camelctx.stop();
}
}
Aggregations