camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cmoulli...@apache.org
Subject svn commit: r824323 - in /camel/trunk/components/camel-bindy/src: main/java/org/apache/camel/dataformat/bindy/ main/java/org/apache/camel/dataformat/bindy/annotation/ main/java/org/apache/camel/dataformat/bindy/csv/ main/java/org/apache/camel/dataforma...
Date Mon, 12 Oct 2009 13:05:53 GMT
Author: cmoulliard
Date: Mon Oct 12 13:05:52 2009
New Revision: 824323

URL: http://svn.apache.org/viewvc?rev=824323&view=rev
Log:
Add a new annotation allowing to generate the header columns name when CSV is created + new unit tests

Added:
    camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindyComplexCsvGenerateHeaderMarshallTest.java   (with props)
    camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindySimpleCsvGenerateHeaderMarshallTest.java   (with props)
    camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindySimpleCsvUnmarshallBadIntegerTest.java   (with props)
    camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/complex/generateheader/
    camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/complex/generateheader/Client.java   (with props)
    camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/complex/generateheader/Order.java   (with props)
    camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/complex/generateheader/Security.java   (with props)
    camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/simple/oneclassgenerateheader/
    camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/simple/oneclassgenerateheader/Order.java   (with props)
    camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/simple/oneclassmath/
    camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/simple/oneclassmath/Math.java   (with props)
Modified:
    camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyCsvFactory.java
    camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/FormatFactory.java
    camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/CsvRecord.java
    camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/DataField.java
    camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/csv/BindyCsvDataFormat.java
    camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/IntegerPatternFormat.java
    camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/NumberPatternFormat.java

Modified: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyCsvFactory.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyCsvFactory.java?rev=824323&r1=824322&r2=824323&view=diff
==============================================================================
--- camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyCsvFactory.java (original)
+++ camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyCsvFactory.java Mon Oct 12 13:05:52 2009
@@ -55,6 +55,7 @@
 
     private String separator;
     private boolean skipFirstLine;
+    private boolean generateHeaderColumnNames;
     private boolean messageOrdered;
 
     public BindyCsvFactory(PackageScanClassResolver resolver, String... packageNames) throws Exception {
@@ -237,7 +238,7 @@
             LOG.debug("Separator converted : '0x" + Integer.toHexString(separator) + "', from : "
                       + this.getSeparator());
         }
-
+        
         while (it.hasNext()) {
 
             DataField dataField = dataFieldsSorted.get(it.next());
@@ -259,6 +260,7 @@
             Object modelField = model.get(field.getDeclaringClass().getName());
 
             if (modelField != null) {
+           	
                 // Get field value
                 Object value = field.get(modelField);
                 String strValue = "";
@@ -295,9 +297,6 @@
                     }
 
                 } else {
-                    // Get field value
-                    // Object value = field.get(modelField);
-                    // String strValue = null;
 
                     // Add value to the list if not null
                     if (value != null) {
@@ -344,31 +343,41 @@
                 }
             }
         }
+        
+       	return builder.toString();
 
-        return builder.toString();
     }
+    
+    public String generateHeader() {
+    	
+        Map<Integer, DataField> dataFieldsSorted = new TreeMap<Integer, DataField>(dataFields);
+		Iterator<Integer> it = dataFieldsSorted.keySet().iterator();
 
-    /**
-     * Find the separator used to delimit the CSV fields
-     */
-    public String getSeparator() {
-        return separator;
-    }
+		StringBuilder builderHeader = new StringBuilder();
 
-    /**
-     * Find the separator used to delimit the CSV fields
-     */
-    public boolean getSkipFirstLine() {
-        return skipFirstLine;
-    }
+		while (it.hasNext()) {
 
-    /**
-     * Flag indicating if the message must be ordered
-     * 
-     * @return boolean
-     */
-    public boolean isMessageOrdered() {
-        return messageOrdered;
+			DataField dataField = dataFieldsSorted.get(it.next());
+
+			// Retrieve the field
+			Field field = annotedFields.get(dataField.pos());
+			// Change accessibility to allow to read protected/private fields
+			field.setAccessible(true);
+
+			// Get dataField
+			if ( ! dataField.columnName().equals("") ) {
+				builderHeader.append(dataField.columnName());
+			} else {
+				builderHeader.append(field.getName());
+			}
+
+			if (it.hasNext()) {
+				builderHeader.append(separator);
+			}
+
+		} 
+        
+        return builderHeader.toString();
     }
 
     /**
@@ -379,6 +388,7 @@
     private void initCsvRecordParameters() {
         if (separator == null) {
             for (Class<?> cl : models) {
+            	
                 // Get annotation @CsvRecord from the class
                 CsvRecord record = cl.getAnnotation(CsvRecord.class);
 
@@ -395,7 +405,13 @@
                     if (LOG.isDebugEnabled()) {
                         LOG.debug("Skip First Line parameter of the CSV : " + skipFirstLine);
                     }
-
+                    
+                    // Get generateHeaderColumnNames parameter
+                    generateHeaderColumnNames = record.generateHeaderColumns();
+                    if (LOG.isDebugEnabled()) {
+                        LOG.debug("Generate header column names parameter of the CSV : " + generateHeaderColumnNames);
+                    }
+                    
                     // Get Separator parameter
                     ObjectHelper.notNull(record.separator(),
                             "No separator has been defined in the @Record annotation !");
@@ -421,4 +437,34 @@
             }
         }
     }
+    
+    /**
+     * Find the separator used to delimit the CSV fields
+     */
+    public String getSeparator() {
+        return separator;
+    }
+
+    /**
+     * Flag indicating if the first line of the CSV must be skipped
+     */
+    public boolean getGenerateHeaderColumnNames() {
+        return generateHeaderColumnNames;
+    }
+    
+    /**
+     * Find the separator used to delimit the CSV fields
+     */
+    public boolean getSkipFirstLine() {
+        return skipFirstLine;
+    }
+
+    /**
+     * Flag indicating if the message must be ordered
+     * 
+     * @return boolean
+     */
+    public boolean isMessageOrdered() {
+        return messageOrdered;
+    }
 }

Modified: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/FormatFactory.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/FormatFactory.java?rev=824323&r1=824322&r2=824323&view=diff
==============================================================================
--- camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/FormatFactory.java (original)
+++ camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/FormatFactory.java Mon Oct 12 13:05:52 2009
@@ -58,26 +58,37 @@
     public static Format<?> getFormat(Class<?> clazz, String pattern, int precision) throws Exception {
         if (clazz == byte.class || clazz == Byte.class) {
             return pattern != null ? new BytePatternFormat(pattern) : new ByteFormat();
+            
         } else if (clazz == short.class || clazz == Short.class) {
             return pattern != null ? new ShortPatternFormat(pattern) : new ShortFormat();
+            
         } else if (clazz == int.class || clazz == Integer.class) {
             return pattern != null ? new IntegerPatternFormat(pattern) : new IntegerFormat();
+            
         } else if (clazz == long.class || clazz == Long.class) {
             return pattern != null ? new LongPatternFormat(pattern) : new LongFormat();
+            
         } else if (clazz == float.class || clazz == Float.class) {
             return pattern != null ? new FloatPatternFormat(pattern) : new FloatFormat();
+            
         } else if (clazz == double.class || clazz == Double.class) {
             return pattern != null ? new DoublePatternFormat(pattern) : new DoubleFormat();
+            
         } else if (clazz == BigDecimal.class) {
             return new BigDecimalFormat(precision);
+            
         } else if (clazz == BigInteger.class) {
             return new BigIntegerFormat();
+            
         } else if (clazz == String.class) {
             return new StringFormat();
+            
         } else if (clazz == Date.class) {
             return new DatePatternFormat(pattern);
+            
         } else if (clazz == char.class || clazz == Character.class) {
             return new CharacterFormat();
+            
         } else {
             throw new IllegalArgumentException("Can not find a suitable formatter for the type: " + clazz.getCanonicalName());
         }

Modified: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/CsvRecord.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/CsvRecord.java?rev=824323&r1=824322&r2=824323&view=diff
==============================================================================
--- camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/CsvRecord.java (original)
+++ camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/CsvRecord.java Mon Oct 12 13:05:52 2009
@@ -28,6 +28,7 @@
  * The separator (mandatory)
  * The name is optional and could be used in the future to bind a property which a different name
  * The skipfirstline (optional) allows to skip the first line of the file/content received
+ * The generateHeaderColumnNames (optional) allow to add in the CSV generated the header containing names of the columns
  * The crlf (optional) is used to add a new line after a record. By default, the value is WINDOWS 
  */
 @Documented
@@ -63,5 +64,15 @@
      * @return String
      */
     String crlf() default "WINDOWS";
+    
+    /**
+     * 
+     * The generateHeaderColumns parameter allow to add in the CSV generated
+     * the header containing names of the columns
+     * 
+     * @return boolean
+     */
+    boolean generateHeaderColumns() default false;
+    
 
 }

Modified: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/DataField.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/DataField.java?rev=824323&r1=824322&r2=824323&view=diff
==============================================================================
--- camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/DataField.java (original)
+++ camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/DataField.java Mon Oct 12 13:05:52 2009
@@ -25,6 +25,7 @@
  * a record (csv, ...).
  * The pos (mandatory) identifies the position of the data in the record
  * The name is optional and could be used in the future to bind a property which a different name
+ * The columnName (optional) represents the name of the column who will appear in the header
  * The pattern (optional) allows to define the pattern of the data (useful for Date, ...)
  * The length (optional) allows to define for fixed length message the size of the data's block
  * The precision(optional) reflects the precision to be used with BigDecimal number
@@ -48,6 +49,13 @@
      * @return String
      */
     String name() default "";
+    
+    /**
+     * name of the header column (optional)
+     *  
+     * @return String
+     */
+    String columnName() default "";
 
     /**
      * pattern that the formater will use to transform the data (optional)

Modified: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/csv/BindyCsvDataFormat.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/csv/BindyCsvDataFormat.java?rev=824323&r1=824322&r2=824323&view=diff
==============================================================================
--- camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/csv/BindyCsvDataFormat.java (original)
+++ camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/csv/BindyCsvDataFormat.java Mon Oct 12 13:05:52 2009
@@ -59,17 +59,30 @@
         
         List<Map<String, Object>> models = (ArrayList<Map<String, Object>>) body;
         byte[] bytesCRLF;
+    
      
         // Get CRLF
         bytesCRLF = Converter.getByteReturn(factory.getCarriageReturn());
-
+        
+        if ( factory.getGenerateHeaderColumnNames() ) {
+        	
+        	String result = factory.generateHeader();
+        	byte[] bytes = exchange.getContext().getTypeConverter().convertTo(byte[].class, exchange, result);
+            outputStream.write( bytes );
+            
+            // Add a carriage return
+            outputStream.write( bytesCRLF );
+        }
+        
+        // We iterate over the list of CSV record
         for (Map<String, Object> model : models) {
-            String result = factory.unbind(model);
-            byte[] bytes = exchange.getContext().getTypeConverter().convertTo(byte[].class, exchange, result);
-            outputStream.write(bytes);
+        	
+        	String result = factory.unbind(model);
+        	byte[] bytes = exchange.getContext().getTypeConverter().convertTo(byte[].class, exchange, result);
+            outputStream.write( bytes );
             
             // Add a carriage return
-            outputStream.write(bytesCRLF);
+            outputStream.write( bytesCRLF );
         }
     }
 

Modified: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/IntegerPatternFormat.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/IntegerPatternFormat.java?rev=824323&r1=824322&r2=824323&view=diff
==============================================================================
--- camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/IntegerPatternFormat.java (original)
+++ camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/IntegerPatternFormat.java Mon Oct 12 13:05:52 2009
@@ -16,6 +16,9 @@
  */
 package org.apache.camel.dataformat.bindy.format;
 
+import java.text.DecimalFormat;
+import java.text.NumberFormat;
+
 public class IntegerPatternFormat extends NumberPatternFormat<Integer> {
 
     public IntegerPatternFormat() {
@@ -26,8 +29,27 @@
     }
 
     @Override
-    public Integer parse(String string) throws Exception {
-        return super.getNumberFormat().parse(string).intValue();
+    public Integer parse(String string) throws FormatException {
+    	
+    	Integer res = null;
+    	NumberFormat pat;
+    	
+    	// First we will test if the string can become an Integer
+    	try {
+    		res = Integer.parseInt( string );
+    		
+    		// Second, we will parse the string using DecimalPattern
+    		// to apply pattern
+    		
+    		pat = super.getNumberFormat();
+    		pat.parse(string).intValue();
+    		
+    	} catch (Exception ex) {
+    		throw new FormatException("String provided does not fit the Integer pattern defined or is not parseable");
+    	}
+    	
+    	return res;
+    	
     }
 
 }

Modified: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/NumberPatternFormat.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/NumberPatternFormat.java?rev=824323&r1=824322&r2=824323&view=diff
==============================================================================
--- camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/NumberPatternFormat.java (original)
+++ camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/format/NumberPatternFormat.java Mon Oct 12 13:05:52 2009
@@ -21,10 +21,13 @@
 
 import org.apache.camel.dataformat.bindy.PatternFormat;
 import org.apache.camel.util.ObjectHelper;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 public abstract class NumberPatternFormat<T> implements PatternFormat<T> {
 
     private String pattern;
+    private DecimalFormat df;
 
     public NumberPatternFormat() {
     }
@@ -45,7 +48,7 @@
     }
 
     protected NumberFormat getNumberFormat() {
-        return new DecimalFormat(pattern);
+    	return new DecimalFormat(pattern);
     }
 
     public String getPattern() {

Added: camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindyComplexCsvGenerateHeaderMarshallTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindyComplexCsvGenerateHeaderMarshallTest.java?rev=824323&view=auto
==============================================================================
--- camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindyComplexCsvGenerateHeaderMarshallTest.java (added)
+++ camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindyComplexCsvGenerateHeaderMarshallTest.java Mon Oct 12 13:05:52 2009
@@ -0,0 +1,117 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.dataformat.bindy.csv;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.GregorianCalendar;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.camel.EndpointInject;
+import org.apache.camel.Produce;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.dataformat.bindy.model.complex.generateheader.Client;
+import org.apache.camel.dataformat.bindy.model.complex.generateheader.Order;
+import org.apache.camel.dataformat.bindy.model.complex.generateheader.Security;
+import org.apache.camel.spring.javaconfig.SingleRouteCamelConfiguration;
+import org.junit.Test;
+import org.springframework.config.java.annotation.Bean;
+import org.springframework.config.java.annotation.Configuration;
+import org.springframework.config.java.test.JavaConfigContextLoader;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
+
+@ContextConfiguration(locations = "org.apache.camel.dataformat.bindy.csv.BindyComplexCsvGenerateHeaderMarshallTest$ContextConfig", loader = JavaConfigContextLoader.class)
+public class BindyComplexCsvGenerateHeaderMarshallTest extends AbstractJUnit4SpringContextTests {
+
+    private List<Map<String, Object>> models = new ArrayList<Map<String, Object>>();
+    private String result = "Order Nr,Client Nr,First Name,Last Name,Instrument Code,Instrument Nr,Order Type,Instrument Type,amount,currency,Order Date\r\n" + 
+    	"10,A1,Julia,Roberts,ISIN,LU123456789,BUY,Share,150,USD,14-01-2009\r\n";
+
+    @Produce(uri = "direct:start")
+    private ProducerTemplate template;
+
+    @EndpointInject(uri = "mock:result")
+    private MockEndpoint resultEndpoint;
+
+    @Test
+    public void testMarshallMessage() throws Exception {
+        resultEndpoint.expectedBodiesReceived(result);
+
+        template.sendBody(generateModel());
+
+        resultEndpoint.assertIsSatisfied();
+    }
+
+    private List<Map<String, Object>> generateModel() {
+        Map<String, Object> model = new HashMap<String, Object>();
+
+        Order order = new Order();
+        order.setOrderNr(10);
+        order.setAmount(new BigDecimal("150"));
+        order.setOrderType("BUY");
+        order.setInstrumentType("Share");
+        order.setCurrency("USD");
+
+        Calendar calendar = new GregorianCalendar();
+        calendar.set(2009, 0, 14);
+        order.setOrderDate(calendar.getTime());
+
+        Client client = new Client();
+        client.setClientNr("A1");
+        client.setFirstName("Julia");
+        client.setLastName("Roberts");
+
+        order.setClient(client);
+        
+        Security security = new Security();
+        security.setInstrumentCode("ISIN");
+        security.setInstrumentNumber("LU123456789");
+        
+        order.setSecurity(security);        
+
+        model.put(order.getClass().getName(), order);
+        model.put(client.getClass().getName(), client);
+        model.put(security.getClass().getName(), security);
+
+        models.add(0, model);
+
+        return models;
+    }
+
+    @Configuration
+    public static class ContextConfig extends SingleRouteCamelConfiguration {
+        BindyCsvDataFormat camelDataFormat = new BindyCsvDataFormat("org.apache.camel.dataformat.bindy.model.complex.generateheader");
+
+        @Override
+        @Bean
+        public RouteBuilder route() {
+            return new RouteBuilder() {
+                @Override
+                public void configure() {
+                    from("direct:start").marshal(camelDataFormat).to("mock:result");
+                }
+            };
+        }
+    }
+
+}

Propchange: camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindyComplexCsvGenerateHeaderMarshallTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindySimpleCsvGenerateHeaderMarshallTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindySimpleCsvGenerateHeaderMarshallTest.java?rev=824323&view=auto
==============================================================================
--- camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindySimpleCsvGenerateHeaderMarshallTest.java (added)
+++ camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindySimpleCsvGenerateHeaderMarshallTest.java Mon Oct 12 13:05:52 2009
@@ -0,0 +1,105 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.dataformat.bindy.csv;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.GregorianCalendar;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.camel.EndpointInject;
+import org.apache.camel.Produce;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.dataformat.bindy.model.simple.oneclassgenerateheader.Order;
+import org.apache.camel.spring.javaconfig.SingleRouteCamelConfiguration;
+import org.junit.Test;
+import org.springframework.config.java.annotation.Bean;
+import org.springframework.config.java.annotation.Configuration;
+import org.springframework.config.java.test.JavaConfigContextLoader;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
+
+@ContextConfiguration(locations = "org.apache.camel.dataformat.bindy.csv.BindySimpleCsvGenerateHeaderMarshallTest$ContextConfig", loader = JavaConfigContextLoader.class)
+public class BindySimpleCsvGenerateHeaderMarshallTest extends AbstractJUnit4SpringContextTests {
+
+    private List<Map<String, Object>> models = new ArrayList<Map<String, Object>>();
+    private String result = "Order Nr,Client Nr,First Name,Last Name,Instrument Code,Instrument Nr,Order Type,Instrument Type,amount,currency,Order Date\r\n" +
+    		"1,B2,Keira,Knightley,ISIN,XX23456789,BUY,Share,400.25,EUR,14-01-2009\r\n";
+
+    @Produce(uri = "direct:start")
+    private ProducerTemplate template;
+
+    @EndpointInject(uri = "mock:result")
+    private MockEndpoint resultEndpoint;
+
+    @Test
+    public void testMarshallMessage() throws Exception {
+        resultEndpoint.expectedBodiesReceived(result);
+
+        template.sendBody(generateModel());
+
+        resultEndpoint.assertIsSatisfied();
+    }
+
+    public List<Map<String, Object>> generateModel() {
+        Map<String, Object> modelObjects = new HashMap<String, Object>();
+
+        Order order = new Order();
+        order.setOrderNr(1);
+        order.setOrderType("BUY");
+        order.setClientNr("B2");
+        order.setFirstName("Keira");
+        order.setLastName("Knightley");
+        order.setAmount(new BigDecimal("400.25"));
+        order.setInstrumentCode("ISIN");
+        order.setInstrumentNumber("XX23456789");
+        order.setInstrumentType("Share");
+        order.setCurrency("EUR");
+
+        Calendar calendar = new GregorianCalendar();
+        calendar.set(2009, 0, 14);
+        order.setOrderDate(calendar.getTime());
+
+        modelObjects.put(order.getClass().getName(), order);
+
+        models.add(modelObjects);
+
+        return models;
+    }
+
+    @Configuration
+    public static class ContextConfig extends SingleRouteCamelConfiguration {
+        BindyCsvDataFormat camelDataFormat = new BindyCsvDataFormat("org.apache.camel.dataformat.bindy.model.simple.oneclassgenerateheader");
+
+        @Override
+        @Bean
+        public RouteBuilder route() {
+            return new RouteBuilder() {
+                @Override
+                public void configure() {
+                    from("direct:start").marshal(camelDataFormat).to("mock:result");
+                }
+            };
+        }
+    }
+
+}

Propchange: camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindySimpleCsvGenerateHeaderMarshallTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindySimpleCsvUnmarshallBadIntegerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindySimpleCsvUnmarshallBadIntegerTest.java?rev=824323&view=auto
==============================================================================
--- camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindySimpleCsvUnmarshallBadIntegerTest.java (added)
+++ camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindySimpleCsvUnmarshallBadIntegerTest.java Mon Oct 12 13:05:52 2009
@@ -0,0 +1,139 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.dataformat.bindy.csv;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.camel.EndpointInject;
+import org.apache.camel.Exchange;
+import org.apache.camel.LoggingLevel;
+import org.apache.camel.Produce;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.TestSupport;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.dataformat.bindy.format.FormatException;
+import org.apache.camel.processor.interceptor.Tracer;
+import org.apache.camel.spring.javaconfig.SingleRouteCamelConfiguration;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.junit.Test;
+import org.springframework.config.java.annotation.Bean;
+import org.springframework.config.java.annotation.Configuration;
+import org.springframework.config.java.test.JavaConfigContextLoader;
+import org.springframework.test.annotation.DirtiesContext;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
+
+@ContextConfiguration(locations = "org.apache.camel.dataformat.bindy.csv.BindySimpleCsvUnmarshallBadIntegerTest$ContextConfig", loader = JavaConfigContextLoader.class)
+public class BindySimpleCsvUnmarshallBadIntegerTest extends AbstractJUnit4SpringContextTests {
+
+    private static final transient Log LOG = LogFactory.getLog(BindySimpleCsvUnmarshallBadIntegerTest.class);
+
+    private static final String uriMockResult = "mock:result";
+    private static final String uriMockError = "mock:error";  
+    private static final String uriDirectStart = "direct:start";
+    private String record;
+    
+    @EndpointInject(uri = uriMockResult)
+    private MockEndpoint result;
+    
+    @EndpointInject(uri = uriMockError)
+    private MockEndpoint error;
+
+    @Produce(uri = uriDirectStart)
+    protected ProducerTemplate template;
+    
+    @SuppressWarnings("unchecked")
+	@Test
+    @DirtiesContext
+    public void testIntegerMessage() throws Exception {
+    	
+    	record = "10000,25.10";
+    	
+   		template.sendBody(record);
+    	
+        result.expectedMessageCount(1);
+        result.assertIsSatisfied();
+        
+        List<Map<String, org.apache.camel.dataformat.bindy.model.simple.oneclassmath.Math>> model = (List<Map<String, org.apache.camel.dataformat.bindy.model.simple.oneclassmath.Math>>) result.getExchanges().get(0).getIn().getBody();
+ 
+        LOG.info(">>> Model generated : " + model.get(0).get("org.apache.camel.dataformat.bindy.model.simple.oneclassmath.Math").toString());
+
+    }
+    
+    @Test
+    @DirtiesContext
+    public void testIntegerTooBigError() throws Exception {
+    	record = "1000000000000000000000000000000000000,25.10";
+    	
+        template.sendBody(record);
+    	
+    	// We don't expect to have a message as an error will be raised
+    	result.expectedMessageCount(0);
+    	
+    	// Message has been delivered to the mock error
+        error.expectedMessageCount(1);
+        
+    	result.assertIsSatisfied();
+    	error.assertIsSatisfied();
+    	
+        // and check that we have the caused exception stored
+        Exception cause = error.getReceivedExchanges().get(0).getProperty(Exchange.EXCEPTION_CAUGHT, Exception.class);
+        TestSupport.assertIsInstanceOf(Exception.class, cause.getCause());
+        assertEquals("String provided does not fit the Integer pattern defined or is not parseable, position : 1, line : 1", cause.getMessage());
+    	
+    }
+
+    @Configuration
+    public static class ContextConfig extends SingleRouteCamelConfiguration {
+    	
+        BindyCsvDataFormat orderBindyDataFormat = new BindyCsvDataFormat("org.apache.camel.dataformat.bindy.model.simple.oneclassmath");
+
+        @Override
+        @Bean
+        public RouteBuilder route() {
+            return new RouteBuilder() {
+            	
+                @Override
+                public void configure() {
+            	
+                Tracer tracer = new Tracer();
+                tracer.setLogLevel(LoggingLevel.FATAL);
+                tracer.setLogName("org.apache.camel.bindy");
+                tracer.setLogStackTrace(true);
+                tracer.setTraceExceptions(true);
+
+                getContext().addInterceptStrategy(tracer);
+            	
+                // default should errors go to mock:error
+                errorHandler(deadLetterChannel(uriMockError).redeliverDelay(0));
+                
+                onException(Exception.class).maximumRedeliveries(0).handled(true);
+
+                from(uriDirectStart).unmarshal(orderBindyDataFormat).to(uriMockResult);
+                
+                }
+            };
+        }
+    }
+}
+
+    
\ No newline at end of file

Propchange: camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindySimpleCsvUnmarshallBadIntegerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/complex/generateheader/Client.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/complex/generateheader/Client.java?rev=824323&view=auto
==============================================================================
--- camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/complex/generateheader/Client.java (added)
+++ camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/complex/generateheader/Client.java Mon Oct 12 13:05:52 2009
@@ -0,0 +1,66 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.dataformat.bindy.model.complex.generateheader;
+
+import org.apache.camel.dataformat.bindy.annotation.DataField;
+import org.apache.camel.dataformat.bindy.annotation.Link;
+
+@Link
+public class Client {
+
+    @DataField(pos = 2, columnName = "Client Nr")
+    private String clientNr;
+
+    @DataField(pos = 3, columnName = "First Name")
+    private String firstName;
+
+    @DataField(pos = 4, columnName = "Last Name")
+    private String lastName;
+
+    public String getClientNr() {
+        return clientNr;
+    }
+
+    public void setClientNr(String clientNr) {
+        this.clientNr = clientNr;
+    }
+
+    public String getFirstName() {
+        return firstName;
+    }
+
+    public void setFirstName(String firstName) {
+        this.firstName = firstName;
+    }
+
+    public String getLastName() {
+        return lastName;
+    }
+
+    public void setLastName(String lastName) {
+        this.lastName = lastName;
+    }
+
+    @Override
+    public String toString() {
+        return "Model : " + Client.class.getName() + " : "
+            + String.valueOf(this.clientNr) + ", "
+            + String.valueOf(this.firstName) + ", "
+            + String.valueOf(this.lastName);
+    }
+
+}

Propchange: camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/complex/generateheader/Client.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/complex/generateheader/Order.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/complex/generateheader/Order.java?rev=824323&view=auto
==============================================================================
--- camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/complex/generateheader/Order.java (added)
+++ camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/complex/generateheader/Order.java Mon Oct 12 13:05:52 2009
@@ -0,0 +1,125 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.dataformat.bindy.model.complex.generateheader;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+import org.apache.camel.dataformat.bindy.annotation.CsvRecord;
+import org.apache.camel.dataformat.bindy.annotation.DataField;
+import org.apache.camel.dataformat.bindy.annotation.Link;
+import org.apache.camel.dataformat.bindy.model.complex.generateheader.Client;
+import org.apache.camel.dataformat.bindy.model.complex.generateheader.Security;
+
+@CsvRecord(separator = ",", generateHeaderColumns = true)
+public class Order {
+	
+    @DataField(pos = 1, columnName = "Order Nr")
+    private int orderNr;
+    
+    @Link
+    private Client client;
+    
+    @Link
+    private Security security;
+
+    @DataField(pos = 7, columnName = "Order Type")
+    private String orderType;
+
+    @DataField(name = "Name", pos = 8, columnName = "Instrument Type")
+    private String instrumentType;
+
+    @DataField(pos = 9, precision = 2)
+    private BigDecimal amount;
+
+    @DataField(pos = 10)
+    private String currency;
+
+    @DataField(pos = 11, pattern = "dd-MM-yyyy", columnName = "Order Date")
+    private Date orderDate;
+    
+    public Client getClient() {
+        return client;
+    }
+
+    public void setClient(Client client) {
+        this.client = client;
+    }
+    
+    public Security getSecurity() {
+        return security;
+    }
+
+    public void setSecurity(Security security) {
+        this.security = security;
+    }
+
+    public int getOrderNr() {
+        return orderNr;
+    }
+
+    public void setOrderNr(int orderNr) {
+        this.orderNr = orderNr;
+    }
+
+    public String getOrderType() {
+        return orderType;
+    }
+
+    public void setOrderType(String orderType) {
+        this.orderType = orderType;
+    }
+
+    public String getInstrumentType() {
+        return instrumentType;
+    }
+
+    public void setInstrumentType(String instrumentType) {
+        this.instrumentType = instrumentType;
+    }
+
+    public BigDecimal getAmount() {
+        return amount;
+    }
+
+    public void setAmount(BigDecimal amount) {
+        this.amount = amount;
+    }
+
+    public String getCurrency() {
+        return currency;
+    }
+
+    public void setCurrency(String currency) {
+        this.currency = currency;
+    }
+
+    public Date getOrderDate() {
+        return orderDate;
+    }
+
+    public void setOrderDate(Date orderDate) {
+        this.orderDate = orderDate;
+    }
+
+    @Override
+    public String toString() {
+        return "Model : " + Order.class.getName() + " : " + this.orderNr + ", " + this.orderType + ", "
+               + String.valueOf(this.amount) + ", " + ", " + this.instrumentType + ", " + this.currency +  ", "
+               + String.valueOf(this.orderDate);
+    }
+}

Propchange: camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/complex/generateheader/Order.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/complex/generateheader/Security.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/complex/generateheader/Security.java?rev=824323&view=auto
==============================================================================
--- camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/complex/generateheader/Security.java (added)
+++ camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/complex/generateheader/Security.java Mon Oct 12 13:05:52 2009
@@ -0,0 +1,53 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.dataformat.bindy.model.complex.generateheader;
+
+import org.apache.camel.dataformat.bindy.annotation.DataField;
+import org.apache.camel.dataformat.bindy.annotation.Link;
+
+@Link
+public class Security {
+
+    @DataField(pos = 6, columnName = "Instrument Nr")
+    private String instrumentNumber;
+
+    @DataField(pos = 5, columnName = "Instrument Code")
+    private String instrumentCode;
+
+    public String getInstrumentNumber() {
+        return instrumentNumber;
+    }
+
+    public void setInstrumentNumber(String instrumentNumber) {
+        this.instrumentNumber = instrumentNumber;
+    }
+
+    public String getInstrumentCode() {
+        return instrumentCode;
+    }
+
+    public void setInstrumentCode(String instrumentCode) {
+        this.instrumentCode = instrumentCode;
+    }
+
+    @Override
+    public String toString() {
+        return "Model : " + Security.class.getName() + " : " + this.instrumentNumber + ", "
+               + this.instrumentCode;
+    }
+
+}

Propchange: camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/complex/generateheader/Security.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/simple/oneclassgenerateheader/Order.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/simple/oneclassgenerateheader/Order.java?rev=824323&view=auto
==============================================================================
--- camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/simple/oneclassgenerateheader/Order.java (added)
+++ camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/simple/oneclassgenerateheader/Order.java Mon Oct 12 13:05:52 2009
@@ -0,0 +1,156 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.dataformat.bindy.model.simple.oneclassgenerateheader;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+import org.apache.camel.dataformat.bindy.annotation.CsvRecord;
+import org.apache.camel.dataformat.bindy.annotation.DataField;
+
+@CsvRecord(separator = ",", generateHeaderColumns = true)
+public class Order {
+
+    @DataField(pos = 1, columnName = "Order Nr")
+    private int orderNr;
+
+    @DataField(pos = 2, columnName = "Client Nr")
+    private String clientNr;
+
+    @DataField(pos = 3, columnName = "First Name")
+    private String firstName;
+
+    @DataField(pos = 4, columnName = "Last Name")
+    private String lastName;
+
+    @DataField(pos = 5, columnName = "Instrument Code")
+    private String instrumentCode;
+
+    @DataField(pos = 6, columnName = "Instrument Nr")
+    private String instrumentNumber;
+
+    @DataField(pos = 7, columnName = "Order Type")
+    private String orderType;
+
+    @DataField(name = "Name", pos = 8, columnName = "Instrument Type")
+    private String instrumentType;
+
+    @DataField(pos = 9, precision = 2)
+    private BigDecimal amount;
+
+    @DataField(pos = 10)
+    private String currency;
+
+    @DataField(pos = 11, pattern = "dd-MM-yyyy", columnName = "Order Date")
+    private Date orderDate;
+
+    public int getOrderNr() {
+        return orderNr;
+    }
+
+    public void setOrderNr(int orderNr) {
+        this.orderNr = orderNr;
+    }
+
+    public String getClientNr() {
+        return clientNr;
+    }
+
+    public void setClientNr(String clientNr) {
+        this.clientNr = clientNr;
+    }
+
+    public String getFirstName() {
+        return firstName;
+    }
+
+    public void setFirstName(String firstName) {
+        this.firstName = firstName;
+    }
+
+    public String getLastName() {
+        return lastName;
+    }
+
+    public void setLastName(String lastName) {
+        this.lastName = lastName;
+    }
+
+    public String getInstrumentCode() {
+        return instrumentCode;
+    }
+
+    public void setInstrumentCode(String instrumentCode) {
+        this.instrumentCode = instrumentCode;
+    }
+
+    public String getInstrumentNumber() {
+        return instrumentNumber;
+    }
+
+    public void setInstrumentNumber(String instrumentNumber) {
+        this.instrumentNumber = instrumentNumber;
+    }
+
+    public String getOrderType() {
+        return orderType;
+    }
+
+    public void setOrderType(String orderType) {
+        this.orderType = orderType;
+    }
+
+    public String getInstrumentType() {
+        return instrumentType;
+    }
+
+    public void setInstrumentType(String instrumentType) {
+        this.instrumentType = instrumentType;
+    }
+
+    public BigDecimal getAmount() {
+        return amount;
+    }
+
+    public void setAmount(BigDecimal amount) {
+        this.amount = amount;
+    }
+
+    public String getCurrency() {
+        return currency;
+    }
+
+    public void setCurrency(String currency) {
+        this.currency = currency;
+    }
+
+    public Date getOrderDate() {
+        return orderDate;
+    }
+
+    public void setOrderDate(Date orderDate) {
+        this.orderDate = orderDate;
+    }
+
+    @Override
+    public String toString() {
+        return "Model : " + Order.class.getName() + " : " + this.orderNr + ", " + this.orderType + ", "
+               + String.valueOf(this.amount) + ", " + this.instrumentCode + ", " + this.instrumentNumber
+               + ", " + this.instrumentType + ", " + this.currency + ", " + this.clientNr + ", "
+               + this.firstName + ", " + this.lastName + ", " + String.valueOf(this.orderDate);
+    }
+}

Propchange: camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/simple/oneclassgenerateheader/Order.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/simple/oneclassmath/Math.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/simple/oneclassmath/Math.java?rev=824323&view=auto
==============================================================================
--- camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/simple/oneclassmath/Math.java (added)
+++ camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/simple/oneclassmath/Math.java Mon Oct 12 13:05:52 2009
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.dataformat.bindy.model.simple.oneclassmath;
+
+import java.math.BigDecimal;
+
+import org.apache.camel.dataformat.bindy.annotation.CsvRecord;
+import org.apache.camel.dataformat.bindy.annotation.DataField;
+import org.apache.camel.dataformat.bindy.model.simple.oneclass.Order;
+
+@CsvRecord(separator = ",")
+public class Math {
+
+	@DataField(pos = 1, pattern = "00")
+    private Integer intAmount;
+    
+    @DataField(pos = 2, precision = 2, pattern = "00.00")
+    private BigDecimal bigDecimal;
+    
+    public Integer getIntAmount() {
+		return intAmount;
+	}
+
+	public void setIntAmount(Integer intAmount) {
+		this.intAmount = intAmount;
+	}
+
+	public BigDecimal getBigDecimal() {
+		return bigDecimal;
+	}
+
+	public void setBigDecimal(BigDecimal bigDecimal) {
+		this.bigDecimal = bigDecimal;
+	}
+	
+	@Override
+	public String toString() {
+	        return "intAmount : " + this.intAmount + ", " +
+	               "bigDecimal : " + this.bigDecimal;
+	}
+}

Propchange: camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/simple/oneclassmath/Math.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message