camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1061719 - in /camel/trunk/components/camel-bindy/src: main/java/org/apache/camel/dataformat/bindy/ test/java/org/apache/camel/dataformat/bindy/fixed/unmarshall/simple/notrim/ test/java/org/apache/camel/dataformat/bindy/fixed/unmarshall/sim...
Date Fri, 21 Jan 2011 10:19:50 GMT
Author: davsclaus
Date: Fri Jan 21 10:19:49 2011
New Revision: 1061719

URL: http://svn.apache.org/viewvc?rev=1061719&view=rev
Log:
CAMEL-3562: Fixed trim option not working on @DataField in fixed length mode.

Added:
    camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/unmarshall/simple/trimfield/
    camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/unmarshall/simple/trimfield/BindySimpleFixedLengthUnmarshallTrimFieldTest.java
      - copied, changed from r1061715, camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/unmarshall/simple/trim/BindySimpleFixedLengthUnmarshallTest.java
    camel/trunk/components/camel-bindy/src/test/resources/org/apache/camel/dataformat/bindy/fixed/unmarshall/simple/trimfield/
    camel/trunk/components/camel-bindy/src/test/resources/org/apache/camel/dataformat/bindy/fixed/unmarshall/simple/trimfield/BindySimpleFixedLengthUnmarshallTrimFieldTest-context.xml
      - copied, changed from r1061715, camel/trunk/components/camel-bindy/src/test/resources/org/apache/camel/dataformat/bindy/fixed/unmarshall/simple/trim/BindySimpleFixedLengthUnmarshallTest-context.xml
Removed:
    camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/unmarshall/simple/notrim/
Modified:
    camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyFixedLengthFactory.java

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=1061719&r1=1061718&r2=1061719&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 Jan 21 10:19:49 2011
@@ -179,6 +179,10 @@ public class BindyFixedLengthFactory ext
 
             token = record.substring(offset - 1, offset + length - 1);
 
+            if (dataField.trim()) {
+                token = token.trim();
+            }
+
             // Check mandatory field
             if (dataField.required()) {
 

Copied: camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/unmarshall/simple/trimfield/BindySimpleFixedLengthUnmarshallTrimFieldTest.java
(from r1061715, camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/unmarshall/simple/trim/BindySimpleFixedLengthUnmarshallTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/unmarshall/simple/trimfield/BindySimpleFixedLengthUnmarshallTrimFieldTest.java?p2=camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/unmarshall/simple/trimfield/BindySimpleFixedLengthUnmarshallTrimFieldTest.java&p1=camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/unmarshall/simple/trim/BindySimpleFixedLengthUnmarshallTest.java&r1=1061715&r2=1061719&rev=1061719&view=diff
==============================================================================
--- camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/unmarshall/simple/trim/BindySimpleFixedLengthUnmarshallTest.java
(original)
+++ camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/unmarshall/simple/trimfield/BindySimpleFixedLengthUnmarshallTrimFieldTest.java
Fri Jan 21 10:19:49 2011
@@ -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.unmarshall.simple.trim;
+package org.apache.camel.dataformat.bindy.fixed.unmarshall.simple.trimfield;
 
 import java.math.BigDecimal;
 import java.util.Date;
@@ -36,7 +36,7 @@ import org.springframework.test.context.
 import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
 
 @ContextConfiguration
-public class BindySimpleFixedLengthUnmarshallTest extends AbstractJUnit4SpringContextTests
{
+public class BindySimpleFixedLengthUnmarshallTrimFieldTest extends AbstractJUnit4SpringContextTests
{
 
     private static final String URI_MOCK_RESULT = "mock:result";
     private static final String URI_MOCK_ERROR = "mock:error";
@@ -57,7 +57,7 @@ public class BindySimpleFixedLengthUnmar
     @DirtiesContext
     public void testUnMarshallMessage() throws Exception {
 
-        expected = "10A9  PaulineM    ISINXD12345678BUYShare000002500.45USD01-08-2009Hello
    ";
+        expected = "10A9  PaulineM    ISINXD12345678BUYShare000002500.45USD01-08-2009  Hello
  ";
 
         template.sendBody(expected);
 
@@ -66,16 +66,16 @@ public class BindySimpleFixedLengthUnmar
 
         // check the model
         Map map = (Map) result.getReceivedExchanges().get(0).getIn().getBody(List.class).get(0);
-        BindySimpleFixedLengthUnmarshallTest.Order order = (BindySimpleFixedLengthUnmarshallTest.Order)
map.values().iterator().next();
+        BindySimpleFixedLengthUnmarshallTrimFieldTest.Order order = (BindySimpleFixedLengthUnmarshallTrimFieldTest.Order)
map.values().iterator().next();
         Assert.assertEquals(10, order.getOrderNr());
         // the field is not trimmed
-        Assert.assertEquals("  Pauline", order.getFirstName());
-        Assert.assertEquals("M    ", order.getLastName());
-        Assert.assertEquals("Hello     ", order.getComment());
+        Assert.assertEquals("Pauline", order.getFirstName());
+        Assert.assertEquals("M    ", order.getLastName()); // no trim
+        Assert.assertEquals("Hello", order.getComment());
     }
 
     public static class ContextConfig extends RouteBuilder {
-        BindyFixedLengthDataFormat camelDataFormat = new BindyFixedLengthDataFormat("org.apache.camel.dataformat.bindy.fixed.unmarshall.simple.trim");
+        BindyFixedLengthDataFormat camelDataFormat = new BindyFixedLengthDataFormat("org.apache.camel.dataformat.bindy.fixed.unmarshall.simple.trimfield");
 
         public void configure() {
             from(URI_DIRECT_START).unmarshal(camelDataFormat).to(URI_MOCK_RESULT);
@@ -92,7 +92,7 @@ public class BindySimpleFixedLengthUnmar
         @DataField(pos = 3, length = 2)
         private String clientNr;
 
-        @DataField(pos = 5, length = 9)
+        @DataField(pos = 5, length = 9, trim = true)
         private String firstName;
 
         @DataField(pos = 14, length = 5, align = "L")
@@ -119,7 +119,7 @@ public class BindySimpleFixedLengthUnmar
         @DataField(pos = 56, length = 10, pattern = "dd-MM-yyyy")
         private Date orderDate;
 
-        @DataField(pos = 66, length = 10)
+        @DataField(pos = 66, length = 10, trim = true)
         private String comment;
 
         public int getOrderNr() {

Copied: camel/trunk/components/camel-bindy/src/test/resources/org/apache/camel/dataformat/bindy/fixed/unmarshall/simple/trimfield/BindySimpleFixedLengthUnmarshallTrimFieldTest-context.xml
(from r1061715, camel/trunk/components/camel-bindy/src/test/resources/org/apache/camel/dataformat/bindy/fixed/unmarshall/simple/trim/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/trimfield/BindySimpleFixedLengthUnmarshallTrimFieldTest-context.xml?p2=camel/trunk/components/camel-bindy/src/test/resources/org/apache/camel/dataformat/bindy/fixed/unmarshall/simple/trimfield/BindySimpleFixedLengthUnmarshallTrimFieldTest-context.xml&p1=camel/trunk/components/camel-bindy/src/test/resources/org/apache/camel/dataformat/bindy/fixed/unmarshall/simple/trim/BindySimpleFixedLengthUnmarshallTest-context.xml&r1=1061715&r2=1061719&rev=1061719&view=diff
==============================================================================
--- camel/trunk/components/camel-bindy/src/test/resources/org/apache/camel/dataformat/bindy/fixed/unmarshall/simple/trim/BindySimpleFixedLengthUnmarshallTest-context.xml
(original)
+++ camel/trunk/components/camel-bindy/src/test/resources/org/apache/camel/dataformat/bindy/fixed/unmarshall/simple/trimfield/BindySimpleFixedLengthUnmarshallTrimFieldTest-context.xml
Fri Jan 21 10:19:49 2011
@@ -27,6 +27,6 @@
 		<routeBuilder ref="myBuilder" /> 
 	</camelContext>
 	
-	<bean id="myBuilder" class="org.apache.camel.dataformat.bindy.fixed.unmarshall.simple.trim.BindySimpleFixedLengthUnmarshallTest$ContextConfig"/>
+	<bean id="myBuilder" class="org.apache.camel.dataformat.bindy.fixed.unmarshall.simple.trimfield.BindySimpleFixedLengthUnmarshallTrimFieldTest$ContextConfig"/>
 	
 </beans>



Mime
View raw message