use of org.wildfly.camel.test.common.types.Customer in project wildfly-camel by wildfly-extras.
the class CastorIntegrationTest method testUnmarshal.
@Test
public void testUnmarshal() throws Exception {
CastorDataFormat castor = new CastorDataFormat();
castor.setMappingFile("castor-mapping.xml");
castor.setAllowClasses(Customer.class);
CamelContext camelctx = new DefaultCamelContext();
camelctx.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start").unmarshal(castor);
}
});
camelctx.start();
try {
ProducerTemplate producer = camelctx.createProducerTemplate();
Customer result = producer.requestBody("direct:start", CUSTOMER_XML, Customer.class);
Assert.assertEquals("John", result.getFirstName());
Assert.assertEquals("Doe", result.getLastName());
} finally {
camelctx.stop();
}
}
use of org.wildfly.camel.test.common.types.Customer in project wildfly-camel by wildfly-extras.
the class CastorIntegrationTest method testMarshal.
@Test
public void testMarshal() throws Exception {
CastorDataFormat castor = new CastorDataFormat();
castor.setMappingFile("castor-mapping.xml");
CamelContext camelctx = new DefaultCamelContext();
camelctx.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start").marshal(castor);
}
});
camelctx.start();
try {
ProducerTemplate producer = camelctx.createProducerTemplate();
String result = producer.requestBody("direct:start", new Customer("John", "Doe"), String.class);
Assert.assertTrue("Ends with: " + result, result.endsWith(CUSTOMER_XML));
} finally {
camelctx.stop();
}
}
use of org.wildfly.camel.test.common.types.Customer in project wildfly-camel by wildfly-extras.
the class CSVIntegrationTest method testMarshalViaDozer.
@Test
public void testMarshalViaDozer() throws Exception {
CamelContext camelctx = new DefaultCamelContext();
camelctx.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start").marshal().csv();
}
});
DozerBeanMapperConfiguration mconfig = new DozerBeanMapperConfiguration();
mconfig.setMappingFiles(Arrays.asList(new String[] { DOZER_MAPPINGS_XML }));
new DozerTypeConverterLoader(camelctx, mconfig);
camelctx.start();
try {
ProducerTemplate producer = camelctx.createProducerTemplate();
String result = producer.requestBody("direct:start", new Customer("John", "Doe"), String.class);
Assert.assertEquals("John,Doe", result.trim());
} finally {
camelctx.stop();
}
}
use of org.wildfly.camel.test.common.types.Customer in project wildfly-camel by wildfly-extras.
the class CustomConverterTest 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").convertBodyTo(Map.class);
}
});
camelctx.start();
try {
ProducerTemplate producer = camelctx.createProducerTemplate();
Map<?, ?> result = producer.requestBody("direct:start", new Customer("John", "Doe"), Map.class);
Assert.assertEquals("{firstName=John, lastName=Doe}", result.toString());
} finally {
camelctx.stop();
}
}
use of org.wildfly.camel.test.common.types.Customer in project wildfly-camel by wildfly-extras.
the class JSONDataFormatTest method testMarshalJackson.
@Test
public void testMarshalJackson() throws Exception {
CamelContext camelctx = new DefaultCamelContext();
camelctx.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start").marshal().json(JsonLibrary.Jackson);
}
});
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();
}
}
Aggregations