use of org.wildfly.camel.test.beanio.subA.Customer in project wildfly-camel by wildfly-extras.
the class BeanIOIntegrationTest method testMarshal.
@Test
public void testMarshal() throws Exception {
DataFormat beanio = new BeanIODataFormat(MAPPINGS_XML, "customerStream");
CamelContext camelctx = new DefaultCamelContext();
camelctx.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start").marshal(beanio);
}
});
camelctx.start();
try {
ProducerTemplate producer = camelctx.createProducerTemplate();
Customer customer = new Customer("Peter", "Post", "Street", "12345");
String result = producer.requestBody("direct:start", customer, String.class);
Assert.assertEquals("Peter,Post,Street,12345", result.trim());
} finally {
camelctx.stop();
}
}
use of org.wildfly.camel.test.beanio.subA.Customer in project wildfly-camel by wildfly-extras.
the class BeanIOIntegrationTest method testUnmarshal.
@Test
public void testUnmarshal() throws Exception {
DataFormat beanio = new BeanIODataFormat(MAPPINGS_XML, "customerStream");
CamelContext camelctx = new DefaultCamelContext();
camelctx.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start").unmarshal(beanio);
}
});
camelctx.start();
try {
ProducerTemplate producer = camelctx.createProducerTemplate();
List<?> result = producer.requestBody("direct:start", "Peter,Post,Street,12345", List.class);
Assert.assertEquals(1, result.size());
Customer customer = (Customer) result.get(0);
Assert.assertEquals("Peter", customer.getFirstName());
Assert.assertEquals("Post", customer.getLastName());
Assert.assertEquals("Street", customer.getStreet());
Assert.assertEquals("12345", customer.getZip());
} finally {
camelctx.stop();
}
}
Aggregations