use of org.wildfly.camel.test.protobuf.model.AddressBookProtos.Person in project wildfly-camel by wildfly-extras.
the class ProtobufIntegrationTest method testMarshall.
@Test
public void testMarshall() throws Exception {
final ProtobufDataFormat format = new ProtobufDataFormat(Person.getDefaultInstance());
CamelContext camelctx = new DefaultCamelContext();
camelctx.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start").marshal(format);
}
});
Person person = Person.newBuilder().setId(1).setName("John Doe").build();
camelctx.start();
try {
ProducerTemplate producer = camelctx.createProducerTemplate();
String result = producer.requestBody("direct:start", person, String.class);
Assert.assertEquals("John Doe", result.trim());
} finally {
camelctx.stop();
}
}
use of org.wildfly.camel.test.protobuf.model.AddressBookProtos.Person in project wildfly-camel by wildfly-extras.
the class ProtobufIntegrationTest method testUnmarshall.
@Test
public void testUnmarshall() throws Exception {
final ProtobufDataFormat format = new ProtobufDataFormat(Person.getDefaultInstance());
CamelContext camelctx = new DefaultCamelContext();
camelctx.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start").unmarshal(format);
}
});
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
Person person = Person.newBuilder().setId(1).setName("John Doe").build();
person.writeTo(baos);
camelctx.start();
try {
ProducerTemplate producer = camelctx.createProducerTemplate();
Person result = producer.requestBody("direct:start", baos.toByteArray(), Person.class);
Assert.assertEquals("John Doe", result.getName().trim());
} finally {
camelctx.stop();
}
}
Aggregations