You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by cm...@apache.org on 2010/06/18 12:52:36 UTC

svn commit: r955929 - in /camel/trunk/components/camel-bindy/src: main/java/org/apache/camel/dataformat/bindy/ main/java/org/apache/camel/dataformat/bindy/fixed/ test/java/org/apache/camel/dataformat/bindy/fixed/ test/java/org/apache/camel/dataformat/b...

Author: cmoulliard
Date: Fri Jun 18 10:52:35 2010
New Revision: 955929

URL: http://svn.apache.org/viewvc?rev=955929&view=rev
Log:
CAMEL-2731: Add marshalling/padding and alignment left or right

Added:
    camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/marshall/
    camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/marshall/simple/
    camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/marshall/simple/BindySimpleFixedLengthMarshallTest.java   (with props)
    camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/unmarshall/
    camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/unmarshall/simple/
    camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/unmarshall/simple/BindySimpleFixedLengthUnmarshallTest.java
      - copied, changed from r955843, camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/BindySimpleFixedLengthUnmarshallTest.java
    camel/trunk/components/camel-bindy/src/test/resources/org/apache/camel/dataformat/bindy/fixed/marshall/
    camel/trunk/components/camel-bindy/src/test/resources/org/apache/camel/dataformat/bindy/fixed/marshall/simple/
    camel/trunk/components/camel-bindy/src/test/resources/org/apache/camel/dataformat/bindy/fixed/marshall/simple/BindySimpleFixedLengthMarshallTest-context.xml   (with props)
    camel/trunk/components/camel-bindy/src/test/resources/org/apache/camel/dataformat/bindy/fixed/unmarshall/
    camel/trunk/components/camel-bindy/src/test/resources/org/apache/camel/dataformat/bindy/fixed/unmarshall/simple/
    camel/trunk/components/camel-bindy/src/test/resources/org/apache/camel/dataformat/bindy/fixed/unmarshall/simple/BindySimpleFixedLengthUnmarshallTest-context.xml
      - copied, changed from r955843, camel/trunk/components/camel-bindy/src/test/resources/org/apache/camel/dataformat/bindy/fixed/BindySimpleFixedLengthUnmarshallTest-context.xml
Removed:
    camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/BindySimpleFixedLengthUnmarshallTest.java
    camel/trunk/components/camel-bindy/src/test/resources/org/apache/camel/dataformat/bindy/fixed/BindySimpleFixedLengthUnmarshallTest-context.xml
Modified:
    camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyAbstractFactory.java
    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/BindyFixedLengthFactory.java
    camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/fixed/BindyFixedLengthDataFormat.java

Modified: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyAbstractFactory.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyAbstractFactory.java?rev=955929&r1=955928&r2=955929&view=diff
==============================================================================
--- camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyAbstractFactory.java (original)
+++ camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyAbstractFactory.java Fri Jun 18 10:52:35 2010
@@ -192,4 +192,31 @@ public abstract class BindyAbstractFacto
     public String getCarriageReturn() {
         return crlf;
     }
+    
+    /**
+     * Format the object into a string according to the format rue defined
+     * 
+     * @param format
+     * @param value
+     * @return String
+     * @throws Exception
+     */
+    public String formatString(Format format, Object value) throws Exception {
+
+        String strValue = "";
+
+        if (value != null) {
+
+            // Format field value
+            try {
+                strValue = format.format(value);
+            } catch (Exception e) {
+                throw new IllegalArgumentException("Formatting error detected for the value : " + value, e);
+            }
+
+        }
+
+        return strValue;
+
+    }
 }

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=955929&r1=955928&r2=955929&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 Fri Jun 18 10:52:35 2010
@@ -379,6 +379,17 @@ public class BindyCsvFactory extends Bin
         return product;
     }
 
+    /**
+     * 
+     * Generate a table containing the data formated and sorted with their position/offset
+     * If the model is Ordered than a key is created combining the annotation @Section and Position of the field
+     * If a relation @OneToMany is defined, than we iterate recursivelu through this function
+     * The result is placed in the Map<Integer, List> results
+     * 
+     * @param clazz
+     * @param obj
+     * @throws Exception
+     */
     private void generateCsvPositionMap(Class clazz, Object obj) throws Exception {
 
         String result = "";
@@ -481,26 +492,12 @@ public class BindyCsvFactory extends Bin
         }
 
     }
-
-    private String formatString(Format format, Object value) throws Exception {
-
-        String strValue = "";
-
-        if (value != null) {
-
-            // Format field value
-            try {
-                strValue = format.format(value);
-            } catch (Exception e) {
-                throw new IllegalArgumentException("Formatting error detected for the value : " + value, e);
-            }
-
-        }
-
-        return strValue;
-
-    }
-
+    
+    /**
+     * Generate for the first line the headers of the columns
+     * 
+     * @return the headers columns
+     */
     public String generateHeader() {
 
         Map<Integer, DataField> dataFieldsSorted = new TreeMap<Integer, DataField>(dataFields);
@@ -534,7 +531,7 @@ public class BindyCsvFactory extends Bin
     }
 
     /**
-     * Get paramaters defined in @Csvrecord annotation
+     * Get parameters defined in @Csvrecord annotation
      */
     private void initCsvRecordParameters() {
         if (separator == null) {

Modified: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyFixedLengthFactory.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyFixedLengthFactory.java?rev=955929&r1=955928&r2=955929&view=diff
==============================================================================
--- camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyFixedLengthFactory.java (original)
+++ camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyFixedLengthFactory.java Fri Jun 18 10:52:35 2010
@@ -255,67 +255,56 @@ public class BindyFixedLengthFactory ext
     public String unbind(Map<String, Object> model) throws Exception {
 
         StringBuilder buffer = new StringBuilder();
+        results = new HashMap<Integer, List>();
 
-        return buffer.toString();
-
-    }
-
-    private List<List> product(Map<Integer, List> values) {
-
-        TreeMap<Integer, List> sortValues = new TreeMap<Integer, List>(values);
-
-        List<List> product = new ArrayList<List>();
-        Map<Integer, Integer> index = new HashMap<Integer, Integer>();
-
-        boolean cont = true;
-        int idx = 0;
-        int idxSize;
-
-        do {
+        for (Class clazz : models) {
 
-            idxSize = 0;
-            List v = new ArrayList();
+            if (model.containsKey(clazz.getName())) {
 
-            for (int ii = 1; ii <= sortValues.lastKey(); ii++) {
+                Object obj = model.get(clazz.getName());
 
-                List l = values.get(ii);
-
-                if (l == null) {
-                    v.add("");
-                    ++idxSize;
-                    continue;
+                if (LOG.isDebugEnabled()) {
+                    LOG.debug("Model object : " + obj + ", class : " + obj.getClass().getName());
                 }
 
-                if (l.size() >= idx + 1) {
-                    v.add(l.get(idx));
-                    index.put(ii, idx);
-                    if (LOG.isDebugEnabled()) {
-                        LOG.debug("Value : " + l.get(idx) + ", pos : " + ii + ", at :" + idx);
-                    }
+                if (obj != null) {
 
-                } else {
-                    v.add(l.get(0));
-                    index.put(ii, 0);
-                    ++idxSize;
-                    if (LOG.isDebugEnabled()) {
-                        LOG.debug("Value : " + l.get(0) + ", pos : " + ii + ", at index : " + 0);
-                    }
-                }
+                    // Generate Fixed Length table
+                	// containing the positions of the fields
+                    generateFixedLengthPositionMap(clazz, obj);
 
+                }
             }
+        }
 
-            if (idxSize != sortValues.lastKey()) {
-                product.add(v);
-            }
-            ++idx;
+        // Convert Map<Integer, List> into List<List>
+        TreeMap<Integer, List> sortValues = new TreeMap<Integer, List>(results);
+        List<String> temp = new ArrayList<String>();
+
+        for (Integer key : sortValues.keySet()) {
+
+            // Get list of values
+            List<String> val = sortValues.get(key);
+            String value = (String)val.get(0);
+            
+            buffer.append(value);
 
-        } while (idxSize != sortValues.lastKey());
+        }
+        
+        return buffer.toString();
 
-        return product;
     }
-    
+
     /**
-    private void generateCsvPositionMap(Class clazz, Object obj) throws Exception {
+     * 
+     * Generate a table containing the data formated and sorted with their position/offset
+     * The result is placed in the Map<Integer, List> results
+     * 
+     * @param clazz
+     * @param obj
+     * @throws Exception
+     */
+    private void generateFixedLengthPositionMap(Class clazz, Object obj) throws Exception {
 
         String result = "";
 
@@ -342,6 +331,34 @@ public class BindyFixedLengthFactory ext
                     Object value = field.get(obj);
 
                     result = formatString(format, value);
+                    
+                    // Get length of the field, alignment (LEFT or RIGHT)
+                    int fieldLength = datafield.length();
+                    String align = datafield.align();
+                    
+                    if (fieldLength > 0) {
+                       
+                    	StringBuilder temp = new StringBuilder();
+                    	
+                       // Check if we must padd
+                       if (result.length() < fieldLength ) {
+	                    	if (align.contains("R")) {
+	                    		temp.append(generatePaddingChars(paddingChar, fieldLength, result.length()));
+	                    		temp.append(result);
+	                    	} else if (align.contains("L")) {
+	                    		temp.append(result);
+	                    		temp.append(generatePaddingChars(paddingChar, fieldLength, result.length()));
+	                    	} else {
+	                    		throw new IllegalArgumentException("Alignement for the " + field.getName() + " must be equal to R for RIGHT or L for LEFT !");
+	                    	}
+	                    	
+	                    	result = temp.toString();	                	
+	                    }                         
+                        
+                       
+                    } else {
+                    	throw new IllegalArgumentException("Lenght of the field : " + field.getName() + " is a mandatory field and cannot be equal to zero or to be negative !");
+                    }
 
                     if (LOG.isDebugEnabled()) {
                         LOG.debug("Value to be formatted : " + value + ", position : " + datafield.pos() + ", and its formated value : " + result);
@@ -352,25 +369,7 @@ public class BindyFixedLengthFactory ext
                 }
 
                 Integer key;
-
-                if (isMessageOrdered()) {
-
-                    // Generate a key using the number of the section
-                    // and the position of the field
-                    Integer key1 = sections.get(obj.getClass().getName());
-                    Integer key2 = datafield.position();
-                    Integer keyGenerated = generateKey(key1, key2);
-
-                    if (LOG.isDebugEnabled()) {
-                        LOG.debug("Key generated : " + String.valueOf(keyGenerated) + ", for section : " + key1);
-                    }
-
-                    key = keyGenerated;
-
-                } else {
-
-                    key = datafield.pos();
-                }
+                key = datafield.pos();
 
                 if (!results.containsKey(key)) {
 
@@ -386,56 +385,19 @@ public class BindyFixedLengthFactory ext
 
             }
 
-            OneToMany oneToMany = field.getAnnotation(OneToMany.class);
-            if (oneToMany != null) {
-
-                // Set global variable
-                // Will be used during generation of CSV
-                isOneToMany = true;
-
-                ArrayList list = (ArrayList)field.get(obj);
-
-                if (list != null) {
-
-                    Iterator it = list.iterator();
-
-                    while (it.hasNext()) {
-
-                        Object target = it.next();
-                        generateCsvPositionMap(target.getClass(), target);
-
-                    }
-
-                } else {
-
-                    // Call this function to add empty value
-                    // in the table
-                    generateCsvPositionMap(field.getClass(), null);
-                }
-
-            }
-        }
+         }
 
     }
-    **/
     
-    private String formatString(Format format, Object value) throws Exception {
-
-        String strValue = "";
-
-        if (value != null) {
-
-            // Format field value
-            try {
-                strValue = format.format(value);
-            } catch (Exception e) {
-                throw new IllegalArgumentException("Formatting error detected for the value : " + value, e);
-            }
-
-        }
-
-        return strValue;
-
+    private String generatePaddingChars(char pad, int lengthField, int lengthString) {
+    	
+    	StringBuilder buffer = new StringBuilder();
+    	int size = lengthField - lengthString;
+
+    	for(int i=0; i<size; i++) {
+    		buffer.append(Character.toString(pad));
+    	}
+    	return buffer.toString();
     }
 
     /**

Modified: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/fixed/BindyFixedLengthDataFormat.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/fixed/BindyFixedLengthDataFormat.java?rev=955929&r1=955928&r2=955929&view=diff
==============================================================================
--- camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/fixed/BindyFixedLengthDataFormat.java (original)
+++ camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/fixed/BindyFixedLengthDataFormat.java Fri Jun 18 10:52:35 2010
@@ -130,7 +130,7 @@ public class BindyFixedLengthDataFormat 
                 
                 // Check if the record length corresponds to the parameter
                 // provided in the @FixedLengthRecord
-                if (line.length() != factory.recordLength()-1) {
+                if ((line.length() < factory.recordLength()) || (line.length() > factory.recordLength())){
                 	throw new java.lang.IllegalArgumentException("Size of the record : " + line.length() + " is not equal to the value provided in the model : " + factory.recordLength() + " !");
                 }
 

Added: camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/marshall/simple/BindySimpleFixedLengthMarshallTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/marshall/simple/BindySimpleFixedLengthMarshallTest.java?rev=955929&view=auto
==============================================================================
--- camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/marshall/simple/BindySimpleFixedLengthMarshallTest.java (added)
+++ camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/marshall/simple/BindySimpleFixedLengthMarshallTest.java Fri Jun 18 10:52:35 2010
@@ -0,0 +1,254 @@
+/**
+ * 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.fixed.marshall.simple;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+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.LoggingLevel;
+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.annotation.DataField;
+import org.apache.camel.dataformat.bindy.annotation.FixedLengthRecord;
+import org.apache.camel.dataformat.bindy.fixed.BindyFixedLengthDataFormat;
+import org.apache.camel.dataformat.bindy.model.simple.oneclass.Order;
+import org.apache.camel.processor.interceptor.Tracer;
+import org.junit.Test;
+import org.springframework.test.annotation.DirtiesContext;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
+
+@ContextConfiguration
+public class BindySimpleFixedLengthMarshallTest extends AbstractJUnit4SpringContextTests {
+    
+    private static final String URI_MOCK_RESULT = "mock:result";
+    private static final String URI_MOCK_ERROR = "mock:error";
+    private static final String URI_DIRECT_START = "direct:start";
+
+    private List<Map<String, Object>> models = new ArrayList<Map<String, Object>>();
+    private String expected;
+
+    @Produce(uri = URI_DIRECT_START)
+    private ProducerTemplate template;
+
+    @EndpointInject(uri = URI_MOCK_RESULT)
+    private MockEndpoint result;
+
+    @EndpointInject(uri = URI_MOCK_ERROR)
+    private MockEndpoint error;
+
+    @Test
+    @DirtiesContext
+    public void testMarshallMessage() throws Exception {
+
+        expected = "10A9  PaulineM    ISINXD12345678BUYShare2500.45USD01-08-2009\r\n";
+        result.expectedBodiesReceived(expected);
+
+        template.sendBody(generateModel());
+        result.assertIsSatisfied();
+    }
+
+    public List<Map<String, Object>> generateModel() {
+        Map<String, Object> modelObjects = new HashMap<String, Object>();
+
+        Order order = new Order();
+        order.setOrderNr(10);
+        order.setOrderType("BUY");
+        order.setClientNr("A9");
+        order.setFirstName("Pauline");
+        order.setLastName("M");
+        order.setAmount(new BigDecimal("2500.45"));
+        order.setInstrumentCode("ISIN");
+        order.setInstrumentNumber("XD12345678");
+        order.setInstrumentType("Share");
+        order.setCurrency("USD");
+
+        Calendar calendar = new GregorianCalendar();
+        calendar.set(2009, 7, 1);
+        order.setOrderDate(calendar.getTime());
+
+        modelObjects.put(order.getClass().getName(), order);
+
+        models.add(modelObjects);
+
+        return models;
+    }
+
+    public static class ContextConfig extends RouteBuilder {
+    	BindyFixedLengthDataFormat camelDataFormat = new BindyFixedLengthDataFormat("org.apache.camel.dataformat.bindy.fixed.marshall.simple");
+
+        public void configure() {
+
+            Tracer tracer = new Tracer();
+            tracer.setLogLevel(LoggingLevel.FATAL);
+            tracer.setLogName("org.apache.camel.bindy");
+
+            getContext().addInterceptStrategy(tracer);
+
+            // default should errors go to mock:error
+            errorHandler(deadLetterChannel(URI_MOCK_ERROR).redeliverDelay(0));
+
+            onException(Exception.class).maximumRedeliveries(0).handled(true);
+
+            from(URI_DIRECT_START).marshal(camelDataFormat).to(URI_MOCK_RESULT);
+        }
+
+    }
+
+    @FixedLengthRecord(length=60, paddingChar=' ')
+    public static class Order {
+
+        @DataField(pos = 1, length=2)
+        private int orderNr;
+
+        @DataField(pos = 3, length=2)
+        private String clientNr;
+
+        @DataField(pos = 5, length=9)
+        private String firstName;
+
+        @DataField(pos = 14, length=5, align="L")
+        private String lastName;
+
+        @DataField(pos = 19, length=4)
+        private String instrumentCode;
+
+        @DataField(pos = 23, length=10)
+        private String instrumentNumber;
+
+        @DataField(pos = 33, length=3)
+        private String orderType;
+
+        @DataField(pos = 36, length=5)
+        private String instrumentType;
+
+        @DataField(pos = 41, precision = 2, length=7)
+        private BigDecimal amount;
+
+        @DataField(pos = 48, length=3)
+        private String currency;
+
+        @DataField(pos = 51, length=10, pattern = "dd-MM-yyyy")
+        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/fixed/marshall/simple/BindySimpleFixedLengthMarshallTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/unmarshall/simple/BindySimpleFixedLengthUnmarshallTest.java (from r955843, camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/BindySimpleFixedLengthUnmarshallTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/unmarshall/simple/BindySimpleFixedLengthUnmarshallTest.java?p2=camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/unmarshall/simple/BindySimpleFixedLengthUnmarshallTest.java&p1=camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/BindySimpleFixedLengthUnmarshallTest.java&r1=955843&r2=955929&rev=955929&view=diff
==============================================================================
--- camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/BindySimpleFixedLengthUnmarshallTest.java (original)
+++ camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/unmarshall/simple/BindySimpleFixedLengthUnmarshallTest.java Fri Jun 18 10:52:35 2010
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.camel.dataformat.bindy.fixed;
+package org.apache.camel.dataformat.bindy.fixed.unmarshall.simple;
 
 import java.math.BigDecimal;
 import java.util.Date;
@@ -27,6 +27,8 @@ import org.apache.camel.component.mock.M
 import org.apache.camel.dataformat.bindy.annotation.CsvRecord;
 import org.apache.camel.dataformat.bindy.annotation.DataField;
 import org.apache.camel.dataformat.bindy.annotation.FixedLengthRecord;
+import org.apache.camel.dataformat.bindy.fixed.BindyFixedLengthDataFormat;
+import org.apache.camel.dataformat.bindy.fixed.marshall.simple.BindySimpleFixedLengthMarshallTest.Order;
 import org.apache.camel.test.junit4.TestSupport;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -61,7 +63,7 @@ public class BindySimpleFixedLengthUnmar
     @DirtiesContext
     public void testUnMarshallMessage() throws Exception {
 
-    	expected = "10A9PaulineMISINXD12345678BUYShare2500.45USD08-01-2009";
+    	expected = "10A9  PaulineM    ISINXD12345678BUYShare2500.45USD01-08-2009";
 
         template.sendBody(expected);
 
@@ -70,7 +72,7 @@ public class BindySimpleFixedLengthUnmar
     }
 
     public static class ContextConfig extends RouteBuilder {
-        BindyFixedLengthDataFormat camelDataFormat = new BindyFixedLengthDataFormat("org.apache.camel.dataformat.bindy.fixed");
+        BindyFixedLengthDataFormat camelDataFormat = new BindyFixedLengthDataFormat("org.apache.camel.dataformat.bindy.fixed.unmarshall.simple");
 
         public void configure() {
             from(URI_DIRECT_START)
@@ -80,7 +82,7 @@ public class BindySimpleFixedLengthUnmar
 
     }
     
-    @FixedLengthRecord(length=55, paddingChar=' ')
+    @FixedLengthRecord(length=60, paddingChar=' ')
     public static class Order {
 
         @DataField(pos = 1, length=2)
@@ -89,31 +91,31 @@ public class BindySimpleFixedLengthUnmar
         @DataField(pos = 3, length=2)
         private String clientNr;
 
-        @DataField(pos = 5, length=7)
+        @DataField(pos = 5, length=9)
         private String firstName;
 
-        @DataField(pos = 12, length=1)
+        @DataField(pos = 14, length=5, align="L")
         private String lastName;
 
-        @DataField(pos = 13, length=4)
+        @DataField(pos = 19, length=4)
         private String instrumentCode;
 
-        @DataField(pos = 17, length=10)
+        @DataField(pos = 23, length=10)
         private String instrumentNumber;
 
-        @DataField(pos = 27, length=3)
+        @DataField(pos = 33, length=3)
         private String orderType;
 
-        @DataField(pos = 30, length=5)
+        @DataField(pos = 36, length=5)
         private String instrumentType;
 
-        @DataField(pos = 35, precision = 2, length=7)
+        @DataField(pos = 41, precision = 2, length=7)
         private BigDecimal amount;
 
-        @DataField(pos = 42, length=3)
+        @DataField(pos = 48, length=3)
         private String currency;
 
-        @DataField(pos = 45, length=10, pattern = "dd-MM-yyyy")
+        @DataField(pos = 51, length=10, pattern = "dd-MM-yyyy")
         private Date orderDate;
 
         public int getOrderNr() {

Added: camel/trunk/components/camel-bindy/src/test/resources/org/apache/camel/dataformat/bindy/fixed/marshall/simple/BindySimpleFixedLengthMarshallTest-context.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/test/resources/org/apache/camel/dataformat/bindy/fixed/marshall/simple/BindySimpleFixedLengthMarshallTest-context.xml?rev=955929&view=auto
==============================================================================
--- camel/trunk/components/camel-bindy/src/test/resources/org/apache/camel/dataformat/bindy/fixed/marshall/simple/BindySimpleFixedLengthMarshallTest-context.xml (added)
+++ camel/trunk/components/camel-bindy/src/test/resources/org/apache/camel/dataformat/bindy/fixed/marshall/simple/BindySimpleFixedLengthMarshallTest-context.xml Fri Jun 18 10:52:35 2010
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="
+     http://www.springframework.org/schema/beans
+     http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+     http://camel.apache.org/schema/spring
+     http://camel.apache.org/schema/spring/camel-spring.xsd">
+     
+	<camelContext xmlns="http://camel.apache.org/schema/spring">
+		<routeBuilder ref="myBuilder" /> 
+	</camelContext>
+	
+	<bean id="myBuilder" class="org.apache.camel.dataformat.bindy.fixed.marshall.simple.BindySimpleFixedLengthMarshallTest$ContextConfig"/>
+	
+</beans>
\ No newline at end of file

Propchange: camel/trunk/components/camel-bindy/src/test/resources/org/apache/camel/dataformat/bindy/fixed/marshall/simple/BindySimpleFixedLengthMarshallTest-context.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: camel/trunk/components/camel-bindy/src/test/resources/org/apache/camel/dataformat/bindy/fixed/unmarshall/simple/BindySimpleFixedLengthUnmarshallTest-context.xml (from r955843, camel/trunk/components/camel-bindy/src/test/resources/org/apache/camel/dataformat/bindy/fixed/BindySimpleFixedLengthUnmarshallTest-context.xml)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/test/resources/org/apache/camel/dataformat/bindy/fixed/unmarshall/simple/BindySimpleFixedLengthUnmarshallTest-context.xml?p2=camel/trunk/components/camel-bindy/src/test/resources/org/apache/camel/dataformat/bindy/fixed/unmarshall/simple/BindySimpleFixedLengthUnmarshallTest-context.xml&p1=camel/trunk/components/camel-bindy/src/test/resources/org/apache/camel/dataformat/bindy/fixed/BindySimpleFixedLengthUnmarshallTest-context.xml&r1=955843&r2=955929&rev=955929&view=diff
==============================================================================
--- camel/trunk/components/camel-bindy/src/test/resources/org/apache/camel/dataformat/bindy/fixed/BindySimpleFixedLengthUnmarshallTest-context.xml (original)
+++ camel/trunk/components/camel-bindy/src/test/resources/org/apache/camel/dataformat/bindy/fixed/unmarshall/simple/BindySimpleFixedLengthUnmarshallTest-context.xml Fri Jun 18 10:52:35 2010
@@ -27,6 +27,6 @@
 		<routeBuilder ref="myBuilder" /> 
 	</camelContext>
 	
-	<bean id="myBuilder" class="org.apache.camel.dataformat.bindy.fixed.BindySimpleFixedLengthUnmarshallTest$ContextConfig"/>
+	<bean id="myBuilder" class="org.apache.camel.dataformat.bindy.fixed.unmarshall.simple.BindySimpleFixedLengthUnmarshallTest$ContextConfig"/>
 	
 </beans>
\ No newline at end of file