Camel Object to CSV Marshalling -
to all,
i fear bit of newbie question, hope find answers here nevertheless.
what do: have custom object marshall csv, , later on perform process in opositie direction. have got working xml using jaxb, same csv
note; in bit of strict environment here, possible utilize bindy, take time, looking solution without bindy (if possible).
here code:
public class csvmarshallingtest extends cameltestsupport { @endpointinject(uri = "mock:marshall") private mockendpoint mockmarshall; @endpointinject(uri = "mock:unmarshall") private mockendpoint mockunmarshall; @test public void testmarshallfromobjecttocsv() throws exception { mockmarshall.expectedmessagecount(1); string expected = "00000000123,12300000000,20121212"; map<string, responsestructure> firstline = new hashmap<string, responsestructure> (); firstline.put("1", new responsestructure ("00000000123", "12300000000", "20121212")); list<map<string, responsestructure>> input = new arraylist<map<string, responsestructure>> (); input.add(firstline); template.sendbody("direct:marshall", input); mockmarshall.expectedbodiesreceived(expected); assertmockendpointssatisfied(); string payload = mockmarshall.getexchanges().get(0).getin().getbody(string.class); log.info(payload); } @override protected routebuilder createroutebuilder() throws exception { homecoming new routebuilder() { @override public void configure() throws exception { csvdataformat csv = new csvdataformat(); csv.setdelimiter(";"); from("direct:marshall") .marshal(csv) .wiretap("log:test") .to("mock:marshall"); from("direct:unmarshall") .unmarshal().csv() .wiretap("log:test") .to("mock:unmarshall"); } }; }
obviously, class reponsestructure has 3 fields, strings
my problem 'rows' not marshalled expect, wiretap outputs:
413 [camel (camel-1) thread #0 - wiretap] info test - exchange[exchangepattern:inonly, bodytype:byte[], body:be.smals.dp.processor.responsestructure@b02928
]
and assertion fails next message:
java.lang.assertionerror: mock://marshall body of message: 0. expected: <00000000123,12300000000,20121212> was: <null>
any help appreciated, barrel
apache-camel
No comments:
Post a Comment