Search in sources :

Example 11 with Customer

use of org.wildfly.camel.test.common.types.Customer 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();
    }
}
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.common.types.Customer) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) BoonDataFormat(org.apache.camel.model.dataformat.BoonDataFormat) Test(org.junit.Test)

Example 12 with Customer

use of org.wildfly.camel.test.common.types.Customer in project wildfly-camel by wildfly-extras.

the class JacksonXMLIntegrationTest 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().jacksonxml(Customer.class);
        }
    });
    camelctx.start();
    try {
        ProducerTemplate producer = camelctx.createProducerTemplate();
        Customer customer = producer.requestBody("direct:start", XML_STRING, Customer.class);
        Assert.assertEquals("John", customer.getFirstName());
        Assert.assertEquals("Doe", customer.getLastName());
    } 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.common.types.Customer) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) Test(org.junit.Test)

Example 13 with Customer

use of org.wildfly.camel.test.common.types.Customer in project wildfly-camel by wildfly-extras.

the class JacksonXMLIntegrationTest 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().jacksonxml();
        }
    });
    camelctx.start();
    try {
        ProducerTemplate producer = camelctx.createProducerTemplate();
        String result = producer.requestBody("direct:start", new Customer("John", "Doe"), String.class);
        Assert.assertEquals(XML_STRING, 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.common.types.Customer) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) Test(org.junit.Test)

Example 14 with Customer

use of org.wildfly.camel.test.common.types.Customer in project wildfly-camel by wildfly-extras.

the class SOAPServiceInterfaceStrategyIntegrationTest method testSOAPServiceInterfaceStrategyMarshal.

@Test
public void testSOAPServiceInterfaceStrategyMarshal() throws Exception {
    ServiceInterfaceStrategy strategy = new ServiceInterfaceStrategy(CustomerService.class, true);
    final SoapJaxbDataFormat format = new SoapJaxbDataFormat("org.wildfly.camel.test.common.types", strategy);
    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("/envelope.xml")) {
        Customer customer = new Customer();
        customer.setFirstName("Kermit");
        customer.setLastName("The Frog");
        ProducerTemplate template = camelctx.createProducerTemplate();
        String result = template.requestBody("direct:start", customer, String.class);
        Assert.assertEquals(XMLUtils.compactXML(input), XMLUtils.compactXML(result));
    } finally {
        camelctx.stop();
    }
}
Also used : ServiceInterfaceStrategy(org.apache.camel.dataformat.soap.name.ServiceInterfaceStrategy) 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.common.types.Customer) InputStream(java.io.InputStream) SoapJaxbDataFormat(org.apache.camel.dataformat.soap.SoapJaxbDataFormat) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) Test(org.junit.Test)

Example 15 with Customer

use of org.wildfly.camel.test.common.types.Customer in project wildfly-camel by wildfly-extras.

the class SOAPServiceInterfaceStrategyIntegrationTest method createDeployment.

@Deployment
public static WebArchive createDeployment() {
    return ShrinkWrap.create(WebArchive.class, "camel-soap-sis-tests.war").addClasses(XMLUtils.class, Customer.class, CustomerService.class).addAsResource(new StringAsset("Customer"), "org/wildfly/camel/test/common/types/jaxb.index").addAsResource("soap/envelope-sis.xml", "envelope.xml").setManifest(() -> {
        ManifestBuilder builder = new ManifestBuilder();
        builder.addManifestHeader("Dependencies", "org.jdom");
        return builder.openStream();
    });
}
Also used : XMLUtils(org.wildfly.camel.test.common.utils.XMLUtils) ManifestBuilder(org.jboss.gravia.resource.ManifestBuilder) CustomerService(org.wildfly.camel.test.soap.subA.CustomerService) StringAsset(org.jboss.shrinkwrap.api.asset.StringAsset) Customer(org.wildfly.camel.test.common.types.Customer) Deployment(org.jboss.arquillian.container.test.api.Deployment)

Aggregations

Customer (org.wildfly.camel.test.common.types.Customer)23 CamelContext (org.apache.camel.CamelContext)22 ProducerTemplate (org.apache.camel.ProducerTemplate)22 RouteBuilder (org.apache.camel.builder.RouteBuilder)22 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)22 Test (org.junit.Test)22 IOException (java.io.IOException)2 LinkedHashMap (java.util.LinkedHashMap)2 CastorDataFormat (org.apache.camel.dataformat.castor.CastorDataFormat)2 BoonDataFormat (org.apache.camel.model.dataformat.BoonDataFormat)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 InputStream (java.io.InputStream)1 ObjectInputStream (java.io.ObjectInputStream)1 ObjectOutputStream (java.io.ObjectOutputStream)1 Map (java.util.Map)1 SnakeYAMLDataFormat (org.apache.camel.component.snakeyaml.SnakeYAMLDataFormat)1 DozerBeanMapperConfiguration (org.apache.camel.converter.dozer.DozerBeanMapperConfiguration)1 DozerTypeConverterLoader (org.apache.camel.converter.dozer.DozerTypeConverterLoader)1 SoapJaxbDataFormat (org.apache.camel.dataformat.soap.SoapJaxbDataFormat)1