Hello. If I feed a CSV file that contains *multiple* rows into my route
(which contains a splitter), each exchange message body comes back with a
List type (for each row of the CSV file), which is good. If I pass in a CSV
with *one* row, then the exchange message body comes back with a String
type, and not a List.

To see this, I modifed the PurchaseOrderCsvTest test from Chapter 3 of the
Camel in Action book as follows:

- Delete the second row in the orders.csv file, leaving only the first row

- In the PurchaseOrderCsvTest  unit test, comment out:

        List line2 =
mock.getReceivedExchanges().get(1).getIn().getBody(List.class);
        assertEquals("Activemq in Action", line2.get(0));
        assertEquals("4495", line2.get(1));
        assertEquals("2", line2.get(2));

- Run the test

- A NPE occurs, because this line now returns null for the List:

List line1 = mock.getReceivedExchanges().get(0).getIn().getBody(List.class);

Is this a bug? If not, how would I get back a list consistently in both
single and multi-row scenarios? Please let me know if I am using the
splitter incorrectly. A single row scenario is likely, and the splitter
implementation should be able to handle a single row in the same way that it
does multiple rows.

ps - If you change the route in the test case to:

.split(body(List.class).tokenize("\n"))

it will return all columns in a single string within braces, but not in a
list of strings for each column as desired.

Thanks in advance for any insight.



--
View this message in context: 
http://camel.465427.n5.nabble.com/Bug-in-Splitter-Implementation-Camel-2-8-3-tp5713873.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to