Search in sources :

Example 6 with Customer

use of org.wildfly.camel.test.jaxb.model.Customer 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();
    }
}
Also used : CamelContext(org.apache.camel.CamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) ProducerTemplate(org.apache.camel.ProducerTemplate) RouteBuilder(org.apache.camel.builder.RouteBuilder) Customer(org.wildfly.camel.test.jaxb.model.Customer) InputStream(java.io.InputStream) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) JaxbDataFormat(org.apache.camel.model.dataformat.JaxbDataFormat) Test(org.junit.Test)

Aggregations

Customer (org.wildfly.camel.test.jaxb.model.Customer)6 InputStream (java.io.InputStream)5 CamelContext (org.apache.camel.CamelContext)4 ProducerTemplate (org.apache.camel.ProducerTemplate)4 RouteBuilder (org.apache.camel.builder.RouteBuilder)4 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)4 Test (org.junit.Test)4 SoapJaxbDataFormat (org.apache.camel.dataformat.soap.SoapJaxbDataFormat)2 JaxbDataFormat (org.apache.camel.model.dataformat.JaxbDataFormat)2 Deployment (org.jboss.arquillian.container.test.api.Deployment)2 ManifestBuilder (org.jboss.gravia.resource.ManifestBuilder)2 StringAsset (org.jboss.shrinkwrap.api.asset.StringAsset)2 Asset (org.jboss.shrinkwrap.api.asset.Asset)1 JavaArchive (org.jboss.shrinkwrap.api.spec.JavaArchive)1 WebArchive (org.jboss.shrinkwrap.api.spec.WebArchive)1 XMLUtils (org.wildfly.camel.test.common.utils.XMLUtils)1