use of org.apache.camel.model.dataformat.BoonDataFormat in project camel by apache.
the class DataFormatClause method boon.
/**
* Uses the Boon data format
*
* @param classType the POJO class type
*/
public T boon(Class<?> classType) {
BoonDataFormat boon = new BoonDataFormat();
boon.setUnmarshalType(classType);
return dataFormat(boon);
}
use of org.apache.camel.model.dataformat.BoonDataFormat in project wildfly-camel by wildfly-extras.
the class BoonDataFormatTest method testMarshal.
@Test
public void testMarshal() throws Exception {
CamelContext camelctx = new DefaultCamelContext();
camelctx.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start").marshal(new BoonDataFormat(Customer.class));
}
});
String expected = "{'firstName':'John','lastName':'Doe'}";
camelctx.start();
try {
ProducerTemplate producer = camelctx.createProducerTemplate();
String result = producer.requestBody("direct:start", new Customer("John", "Doe"), String.class);
Assert.assertEquals(expected.replace('\'', '"'), result);
} finally {
camelctx.stop();
}
}
use of org.apache.camel.model.dataformat.BoonDataFormat in project wildfly-camel by wildfly-extras.
the class BoonDataFormatTest method testUnmarshal.
@Test
public void testUnmarshal() throws Exception {
CamelContext camelctx = new DefaultCamelContext();
camelctx.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start").unmarshal(new BoonDataFormat(Customer.class));
}
});
String input = "{'firstName':'John','lastName':'Doe'}";
camelctx.start();
try {
ProducerTemplate producer = camelctx.createProducerTemplate();
Customer customer = producer.requestBody("direct:start", input, Customer.class);
Assert.assertEquals("John", customer.getFirstName());
Assert.assertEquals("Doe", customer.getLastName());
} finally {
camelctx.stop();
}
}
Aggregations