You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2008/03/28 09:10:58 UTC
svn commit: r642120 - in /activemq/camel/trunk/components/camel-csv/src/test:
java/org/apache/camel/dataformat/csv/CsvRouteTest.java resources/daltons.csv
Author: davsclaus
Date: Fri Mar 28 01:10:56 2008
New Revision: 642120
URL: http://svn.apache.org/viewvc?rev=642120&view=rev
Log:
CAMEL-359 patch applied with thanks to Gert (I love your daltons example)
Added:
activemq/camel/trunk/components/camel-csv/src/test/resources/daltons.csv
Modified:
activemq/camel/trunk/components/camel-csv/src/test/java/org/apache/camel/dataformat/csv/CsvRouteTest.java
Modified: activemq/camel/trunk/components/camel-csv/src/test/java/org/apache/camel/dataformat/csv/CsvRouteTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-csv/src/test/java/org/apache/camel/dataformat/csv/CsvRouteTest.java?rev=642120&r1=642119&r2=642120&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-csv/src/test/java/org/apache/camel/dataformat/csv/CsvRouteTest.java (original)
+++ activemq/camel/trunk/components/camel-csv/src/test/java/org/apache/camel/dataformat/csv/CsvRouteTest.java Fri Mar 28 01:10:56 2008
@@ -39,9 +39,11 @@
MockEndpoint resultEndpoint = resolveMandatoryEndpoint("mock:result", MockEndpoint.class);
resultEndpoint.expectedMessageCount(1);
+ // START SNIPPET: marshal-result
Map body = new HashMap();
body.put("foo", "abc");
body.put("bar", 123);
+ // END SNIPPET: marshal-result
template.sendBody("direct:start", body);
resultEndpoint.assertIsSatisfied();
@@ -55,13 +57,36 @@
assertEquals("text body", "abc,123", text.trim());
}
}
+
+ public void testUnMarshal() throws Exception {
+ MockEndpoint endpoint = getMockEndpoint("mock:daltons");
+ endpoint.expectedMessageCount(1);
+ endpoint.assertIsSatisfied();
+ Exchange exchange = endpoint.getExchanges().get(0);
+ // START SNIPPET : unmarshal-result
+ List<List<String>> data = (List<List<String>>) exchange.getIn().getBody();
+ for (List<String> line : data) {
+ LOG.debug(
+ String.format("%s has an IQ of %s and is currently %s",
+ line.get(0), line.get(1), line.get(2)));
+ }
+ // END SNIPPET : unmarshal-result
+ }
protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
public void configure() {
+ // START SNIPPET: marshal
from("direct:start").
- marshal().csv().
- to("mock:result");
+ marshal().csv().
+ to("mock:result");
+ // END SNIPPET: marshal
+
+ // START SNIPPET: unmarshal
+ from("file:src/test/resources/daltons.csv?noop=true").
+ unmarshal().csv().
+ to("mock:daltons");
+ // END SNIPPET: unmarshal
}
};
}
Added: activemq/camel/trunk/components/camel-csv/src/test/resources/daltons.csv
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-csv/src/test/resources/daltons.csv?rev=642120&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-csv/src/test/resources/daltons.csv (added)
+++ activemq/camel/trunk/components/camel-csv/src/test/resources/daltons.csv Fri Mar 28 01:10:56 2008
@@ -0,0 +1,5 @@
+Jack Dalton, 115, mad at Averell
+Joe Dalton, 105, calming Joe
+William Dalton, 105, keeping Joe from killing Averell
+Averell Dalton, 80, playing with Rantanplan
+Lucky Luke, 120, capturing the Daltons