Repository: camel
Updated Branches:
  refs/heads/master b35c335cf -> 1a5f700d7


Test case related to the fix of CAMEL-7578 issue


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/8ffb77bb
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/8ffb77bb
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/8ffb77bb

Branch: refs/heads/master
Commit: 8ffb77bb1956de618ac8314c39303cfb8ce290c0
Parents: 66e8c5b
Author: ancosen <anco...@gmail.com>
Authored: Sun Jul 6 11:44:10 2014 +0200
Committer: ancosen <anco...@gmail.com>
Committed: Sun Jul 6 11:44:10 2014 +0200

----------------------------------------------------------------------
 .../bindy/csv/BindyPatternLocaleTest.java       | 60 ++++++++++++++++++++
 .../dataformat/bindy/model/padding/Unity.java   | 35 ++++++++++++
 2 files changed, 95 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/8ffb77bb/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindyPatternLocaleTest.java
----------------------------------------------------------------------
diff --git 
a/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindyPatternLocaleTest.java
 
b/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindyPatternLocaleTest.java
new file mode 100644
index 0000000..d62ca2f
--- /dev/null
+++ 
b/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindyPatternLocaleTest.java
@@ -0,0 +1,60 @@
+/**
+ * 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 org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.dataformat.bindy.model.padding.Unity;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+/**
+ * @version
+ */
+public class BindyPatternLocaleTest extends CamelTestSupport {
+
+    @Test
+    public void testMarshalling() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:marshal");
+        mock.expectedMessageCount(1);
+        mock.expectedBodiesReceived("050,010\r\n");
+
+        Unity unity = new Unity();
+        unity.setMandant(50f);
+        unity.setReceiver(10f);
+        template.sendBody("direct:marshal", unity);
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                BindyCsvDataFormat bindy = new BindyCsvDataFormat(Unity.class);
+
+                // As recommended, when we use @Datafield Pattern we must 
specify the default locale
+                bindy.setLocale("default");
+                
+                from("direct:marshal")
+                        .marshal(bindy)
+                        .to("mock:marshal");
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/8ffb77bb/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/padding/Unity.java
----------------------------------------------------------------------
diff --git 
a/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/padding/Unity.java
 
b/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/padding/Unity.java
new file mode 100644
index 0000000..3cdefcb
--- /dev/null
+++ 
b/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/padding/Unity.java
@@ -0,0 +1,35 @@
+package org.apache.camel.dataformat.bindy.model.padding;
+
+import org.apache.camel.dataformat.bindy.annotation.CsvRecord;
+import org.apache.camel.dataformat.bindy.annotation.DataField;
+
+@CsvRecord(separator = ",")
+public class Unity {
+       @DataField(pos = 1, pattern = "000")
+       public float mandant;
+
+       @DataField(pos = 2, pattern = "000")
+       public float receiver;
+
+       public float getMandant() {
+               return mandant;
+       }
+
+       public void setMandant(float mandant) {
+               this.mandant = mandant;
+       }
+
+       public float getReceiver() {
+               return receiver;
+       }
+
+       public void setReceiver(float receiver) {
+               this.receiver = receiver;
+       }
+
+       @Override
+       public String toString() {
+               return "Unity [mandant=" + mandant + ", receiver=" + receiver + 
"]";
+       }
+
+}

Reply via email to