Hello guys,
I'd like to ask you, I have a POJO classes, holding data representation of
various kinds of data entities.
Output of my Camel routes is JSON String returned to browser as response.
I thought it would be easy to marshall POJO to JSON formatted String with
Jackson, but I have something wrong there.
Consider this code:
public class PojoDemoRouteTest extends CamelTestSupport {
@Before
public void setup() throws Exception {
super.setUp();
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start")
.marshal().json(JsonLibrary.Jackson)
.to("mock:pojodemo");
}
});
}
@Test
public void basicPojoTest() throws InterruptedException {
MockEndpoint pojoMock = getMockEndpoint("mock:pojodemo");
JsonMarshallDemo demoPojo = new JsonMarshallDemo();
demoPojo.setBar("demo bar");
demoPojo.setFoo("demo foo");
template.sendBody("direct:start", demoPojo);
pojoMock.expectedMessageCount(1);
List<Exchange> receivedExchanges = pojoMock.getExchanges();
for (Exchange receivedExchange : receivedExchanges) {
System.out.println(String.format("Exchange getIn body: %s",
receivedExchange.getIn().getBody()));
System.out.println(String.format("Exchange getOut body: %s",
receivedExchange.getOut().getBody()));
}
pojoMock.assertIsSatisfied();
}
}
Why I don't see JSON String in the incomming message's body?
When I debug this route, I can see that there is the JSON String, but not
in the body, see:
https://www.dropbox.com/sh/llvbflokwiheuby/X65PdXfwnJ/esb_pojo_marshall_debug.png
Btw, it's String representation of the Message or what?
--
S pozdravem / Best regards
Martin Stiborský
Jabber: [email protected]
Twitter: http://www.twitter.com/stibi