use of org.wildfly.camel.test.jaxb.model.Customer in project wildfly-camel by wildfly-extras.
the class JAXBIntegrationTest method testJaxbUnmarshal.
@Test
public void testJaxbUnmarshal() 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").unmarshal(format);
}
});
camelctx.start();
try (InputStream input = getClass().getResourceAsStream("/customer.xml")) {
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();
}
}
use of org.wildfly.camel.test.jaxb.model.Customer in project wildfly-camel by wildfly-extras.
the class SOAPIntegrationTest method testSoapV1_2Marshal.
@Test
public void testSoapV1_2Marshal() throws Exception {
final SoapJaxbDataFormat format = new SoapJaxbDataFormat();
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("/envelope-1.2-marshal.xml")) {
String expected = camelctx.getTypeConverter().mandatoryConvertTo(String.class, input);
ProducerTemplate producer = camelctx.createProducerTemplate();
Customer customer = new Customer("John", "Doe");
String customerXML = producer.requestBody("direct:start", customer, String.class);
Assert.assertEquals(expected, XMLUtils.compactXML(customerXML));
} finally {
camelctx.stop();
}
}
use of org.wildfly.camel.test.jaxb.model.Customer in project wildfly-camel by wildfly-extras.
the class SOAPIntegrationTest method testSoapMarshal.
@Test
public void testSoapMarshal() throws Exception {
final SoapJaxbDataFormat format = new SoapJaxbDataFormat();
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("/envelope.xml")) {
String expected = XMLUtils.compactXML(input);
ProducerTemplate producer = camelctx.createProducerTemplate();
Customer customer = new Customer("John", "Doe");
String customerXML = producer.requestBody("direct:start", customer, String.class);
Assert.assertEquals(expected, XMLUtils.compactXML(customerXML));
} finally {
camelctx.stop();
}
}
use of org.wildfly.camel.test.jaxb.model.Customer in project wildfly-camel by wildfly-extras.
the class SOAPIntegrationTest method deployment.
@Deployment
public static JavaArchive deployment() {
return ShrinkWrap.create(JavaArchive.class, "soap-dataformat-tests").addPackage(Customer.class.getPackage()).addClasses(XMLUtils.class).addAsResource(new StringAsset("Customer"), "org/wildfly/camel/test/jaxb/model/jaxb.index").addAsResource("soap/envelope.xml", "envelope.xml").addAsResource("soap/envelope-1.2-marshal.xml", "envelope-1.2-marshal.xml").addAsResource("soap/envelope-1.2-unmarshal.xml", "envelope-1.2-unmarshal.xml").setManifest(() -> {
ManifestBuilder builder = new ManifestBuilder();
builder.addManifestHeader("Dependencies", "org.jdom");
return builder.openStream();
});
}
use of org.wildfly.camel.test.jaxb.model.Customer in project wildfly-camel by wildfly-extras.
the class JAXBIntegrationTest method deployment.
@Deployment
public static WebArchive deployment() {
final WebArchive archive = ShrinkWrap.create(WebArchive.class, "jaxb-integration-tests.war");
archive.addPackage(Customer.class.getPackage());
archive.addClasses(XMLUtils.class);
archive.addAsResource(new StringAsset("Customer"), "org/wildfly/camel/test/jaxb/model/jaxb.index");
archive.addAsResource("jaxb/customer.xml", "customer.xml");
archive.setManifest(new Asset() {
@Override
public InputStream openStream() {
ManifestBuilder builder = new ManifestBuilder();
builder.addManifestHeader("Dependencies", "org.jdom");
return builder.openStream();
}
});
return archive;
}
Aggregations