camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [2/6] git commit: Test @Datafield pattern with Locale
Date Fri, 11 Jul 2014 06:46:24 GMT
Test @Datafield pattern with Locale


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

Branch: refs/heads/master
Commit: 9743c50cee8e086f808da6b6d700fa38f098fe8e
Parents: 8ffb77b
Author: ancosen <ancosen@gmail.com>
Authored: Sun Jul 6 14:57:39 2014 +0200
Committer: ancosen <ancosen@gmail.com>
Committed: Sun Jul 6 14:57:39 2014 +0200

----------------------------------------------------------------------
 .../bindy/csv/BindyPatternLocaleTest.java       | 120 ++++++++++++++-----
 1 file changed, 89 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/9743c50c/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
index d62ca2f..58bbe24 100644
--- 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
@@ -16,45 +16,103 @@
  */
 package org.apache.camel.dataformat.bindy.csv;
 
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Locale;
+
+import org.apache.camel.builder.AdviceWithRouteBuilder;
 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;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
 
 /**
- * @version
+ * @version 
  */
+@RunWith(Parameterized.class)
 public class BindyPatternLocaleTest extends CamelTestSupport {
+	
+	private String locale;
+	
+	public BindyPatternLocaleTest(String locale) {
+			this.locale = locale;
+   }
+
+	@Parameters
+	public static Collection<String[]> localeList() {
+		return Arrays.asList(new String[][] { 
+				{Locale.CANADA.getCountry()}, 
+				{Locale.CANADA_FRENCH.getCountry()},
+				{Locale.CHINA.getCountry()},
+				{Locale.CHINESE.getLanguage()},
+				{Locale.ENGLISH.getLanguage()},
+				{Locale.FRANCE.getCountry()},
+				{Locale.FRENCH.getLanguage()},
+				{Locale.GERMAN.getLanguage()},
+				{Locale.GERMANY.getCountry()},
+				{Locale.ITALIAN.getLanguage()},
+				{Locale.ITALY.getCountry()},
+				{Locale.JAPAN.getCountry()},
+				{Locale.JAPANESE.getLanguage()},
+				{Locale.KOREA.getCountry()},
+				{Locale.KOREAN.getLanguage()},
+				{Locale.PRC.getCountry()},
+				{Locale.SIMPLIFIED_CHINESE.getLanguage()},
+				{Locale.TAIWAN.getCountry()},
+				{Locale.TRADITIONAL_CHINESE.getLanguage()},
+				{Locale.UK.getCountry()},
+				{Locale.US.getCountry()},
+		});
+	}
+
+	@Test
+	public void testMarshalling() throws Exception {
+		context.getRouteDefinitions().get(0)
+				.adviceWith(context, new AdviceWithRouteBuilder() {
+					@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(locale);
+
+						// weave the node in the route which has id = marshaller
+						// and replace it with the following route path
+						weaveById("marshaller").replace().marshal(bindy);
+					}
+				});
+		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");
 
-    @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");
-            }
-        };
-    }
+				from("direct:marshal").marshal(bindy).id("marshaller")
+						.to("mock:marshal");
+			}
+		};
+	}
 }


Mime
View raw message