Author: davsclaus
Date: Sun Mar 18 10:17:02 2012
New Revision: 1302108

URL: http://svn.apache.org/viewvc?rev=1302108&view=rev
Log:
Added snippet for documentation

Modified:
    
camel/trunk/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/BeanIODataFormatSimpleTest.java

Modified: 
camel/trunk/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/BeanIODataFormatSimpleTest.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/BeanIODataFormatSimpleTest.java?rev=1302108&r1=1302107&r2=1302108&view=diff
==============================================================================
--- 
camel/trunk/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/BeanIODataFormatSimpleTest.java
 (original)
+++ 
camel/trunk/components/camel-beanio/src/test/java/org/apache/camel/dataformat/beanio/BeanIODataFormatSimpleTest.java
 Sun Mar 18 10:17:02 2012
@@ -29,9 +29,12 @@ import org.junit.Test;
 
 public class BeanIODataFormatSimpleTest extends CamelTestSupport {
 
-    private static final String FIXED_DATA = 
"Joe,Smith,Developer,75000,10012009" + LS
+    // START SNIPPET: e2
+    private static final String FIXED_DATA =
+            "Joe,Smith,Developer,75000,10012009" + LS
             + "Jane,Doe,Architect,80000,01152008" + LS
             + "Jon,Anderson,Manager,85000,03182007" + LS;
+    // END SNIPPET: e2
 
     @Test
     public void testMarshal() throws Exception {
@@ -62,15 +65,25 @@ public class BeanIODataFormatSimpleTest 
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
+                // START SNIPPET: e1
+                // setup beanio data format using the mapping file, loaded 
from the classpath
                 DataFormat format = new BeanIODataFormat(
                         "org/apache/camel/dataformat/beanio/mappings.xml",
                         "employeeFile");
 
-                from("direct:unmarshal").unmarshal(format)
-                        .split(simple("body")).to("mock:beanio-unmarshal");
-
-                from("direct:marshal").marshal(format)
-                        .to("mock:beanio-marshal");
+                // a route which uses the bean io data format to format a CSV 
data
+                // to java objects
+                from("direct:unmarshal")
+                    .unmarshal(format)
+                    // and then split the message body so we get a message for 
each row
+                    .split(body())
+                        .to("mock:beanio-unmarshal");
+
+                // convert list of java objects back to flat format
+                from("direct:marshal")
+                    .marshal(format)
+                    .to("mock:beanio-marshal");
+                // END SNIPPET: e1
             }
         };
     }


Reply via email to