use of org.wildfly.camel.test.common.types.Customer in project wildfly-camel by wildfly-extras.
the class YamlDataFormatIntegrationTest method testUnmarshalYaml.
@Test
public void testUnmarshalYaml() throws Exception {
SnakeYAMLDataFormat yaml = new SnakeYAMLDataFormat();
yaml.addTypeFilters(TypeFilters.types(Customer.class));
CamelContext camelctx = new DefaultCamelContext();
camelctx.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start").unmarshal(yaml);
}
});
camelctx.start();
try {
ProducerTemplate template = camelctx.createProducerTemplate();
Customer result = template.requestBody("direct:start", CUSTOMER_YAML, Customer.class);
Assert.assertNotNull(result);
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 YamlDataFormatIntegrationTest method testMarshalYaml.
@Test
public void testMarshalYaml() throws Exception {
CamelContext camelctx = new DefaultCamelContext();
camelctx.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start").marshal().yaml(YAMLLibrary.SnakeYAML);
}
});
camelctx.start();
try {
ProducerTemplate template = camelctx.createProducerTemplate();
String result = template.requestBody("direct:start", new Customer("John", "Doe"), String.class);
Assert.assertEquals(CUSTOMER_YAML, result.trim());
} finally {
camelctx.stop();
}
}
use of org.wildfly.camel.test.common.types.Customer in project wildfly-camel by wildfly-extras.
the class JSONDataFormatTest method testMarshalJohnzon.
@Test
public void testMarshalJohnzon() throws Exception {
CamelContext camelctx = new DefaultCamelContext();
camelctx.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start").marshal().json(JsonLibrary.Johnzon);
}
});
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();
}
}
use of org.wildfly.camel.test.common.types.Customer in project wildfly-camel by wildfly-extras.
the class JSONDataFormatTest method testUnmarshalJohnzon.
@Test
public void testUnmarshalJohnzon() throws Exception {
CamelContext camelctx = new DefaultCamelContext();
camelctx.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start").unmarshal().json(JsonLibrary.Johnzon, Customer.class);
}
});
String input = "{'firstName':'John','lastName':'Doe'}";
camelctx.start();
try {
ProducerTemplate producer = camelctx.createProducerTemplate();
Customer customer = producer.requestBody("direct:start", input.replace('\'', '"'), Customer.class);
Assert.assertEquals("John", customer.getFirstName());
Assert.assertEquals("Doe", customer.getLastName());
} finally {
camelctx.stop();
}
}
use of org.wildfly.camel.test.common.types.Customer in project wildfly-camel by wildfly-extras.
the class JSONDataFormatTest method testUnmarshalGson.
@Test
public void testUnmarshalGson() throws Exception {
CamelContext camelctx = new DefaultCamelContext();
camelctx.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start").unmarshal().json(JsonLibrary.Gson, Customer.class);
}
});
String input = "{'firstName':'John','lastName':'Doe'}";
camelctx.start();
try {
ProducerTemplate producer = camelctx.createProducerTemplate();
Customer customer = producer.requestBody("direct:start", input.replace('\'', '"'), Customer.class);
Assert.assertEquals("John", customer.getFirstName());
Assert.assertEquals("Doe", customer.getLastName());
} finally {
camelctx.stop();
}
}
Aggregations