use of org.apache.camel.model.dataformat.JaxbDataFormat in project wildfly-camel by wildfly-extras.
the class JAXBIntegrationTest method testJaxbMarshal.
@Test
public void testJaxbMarshal() throws Exception {
final JaxbDataFormat format = new JaxbDataFormat();
format.setContextPath("org.wildfly.camel.test.jaxb.model");
CamelContext camelctx = new DefaultCamelContext();
camelctx.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start").marshal(format);
}
});
camelctx.start();
try (InputStream input = getClass().getResourceAsStream("/customer.xml")) {
String expected = XMLUtils.compactXML(input);
ProducerTemplate producer = camelctx.createProducerTemplate();
Customer customer = new Customer("John", "Doe");
String result = producer.requestBody("direct:start", customer, String.class);
Assert.assertEquals(expected, XMLUtils.compactXML(result));
} finally {
camelctx.stop();
}
}
Aggregations