CAMEL-5958: Bindy ignores bean class type
Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/e1e5cac5 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/e1e5cac5 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/e1e5cac5 Branch: refs/heads/master Commit: e1e5cac598a4a842995e5805da26c1a87ef1148a Parents: b0e76ed Author: lburgazzoli <lburgazz...@gmail.com> Authored: Sat Sep 20 19:29:48 2014 +0200 Committer: Claus Ibsen <davscl...@apache.org> Committed: Fri Aug 7 11:05:48 2015 +0200 ---------------------------------------------------------------------- .../apache/camel/builder/DataFormatClause.java | 17 +-------- .../csv/BindyCarQuoteAndCommaDelimiterTest.java | 2 +- .../csv/BindySimpleCsvAutospanLineTest.java | 3 +- .../BindySimpleCsvBooleanFalseMarshallTest.java | 4 ++- .../BindySimpleCsvBooleanTrueMarshallTest.java | 4 ++- .../BindySimpleCsvBooleanUnmarshallTest.java | 38 ++++++++++---------- .../BindySimpleCsvUnmarshallBadIntegerTest.java | 3 +- .../bindy/csv/BindySimpleCsvUnmarshallTest.java | 8 ++--- ...indySimpleKeyValuePairUnmarshallDslTest.java | 2 +- 9 files changed, 35 insertions(+), 46 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/e1e5cac5/camel-core/src/main/java/org/apache/camel/builder/DataFormatClause.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/builder/DataFormatClause.java b/camel-core/src/main/java/org/apache/camel/builder/DataFormatClause.java index 6e915b6..be35d9f 100644 --- a/camel-core/src/main/java/org/apache/camel/builder/DataFormatClause.java +++ b/camel-core/src/main/java/org/apache/camel/builder/DataFormatClause.java @@ -149,22 +149,7 @@ public class DataFormatClause<T extends ProcessorDefinition<?>> { dataFormat.setIgnoreInvalidRecords(ignoreInvalidRecords); return dataFormat(dataFormat); } - - /** - * Uses the Bindy data format - * - * @param type the type of bindy data format to use - * @param packages packages to scan for Bindy annotated POJO classes - */ - /* - public T bindy(BindyType type, String... packages) { - BindyDataFormat bindy = new BindyDataFormat(); - bindy.setType(type); - bindy.setPackages(packages); - return dataFormat(bindy); - } - */ - + /** * Uses the Bindy data format * http://git-wip-us.apache.org/repos/asf/camel/blob/e1e5cac5/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindyCarQuoteAndCommaDelimiterTest.java ---------------------------------------------------------------------- diff --git a/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindyCarQuoteAndCommaDelimiterTest.java b/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindyCarQuoteAndCommaDelimiterTest.java index a51fad9..f06874e 100644 --- a/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindyCarQuoteAndCommaDelimiterTest.java +++ b/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindyCarQuoteAndCommaDelimiterTest.java @@ -88,7 +88,7 @@ public class BindyCarQuoteAndCommaDelimiterTest extends CamelTestSupport { dataFormat.setLocale("en"); from("direct:out") - .unmarshal().bindy(BindyType.Csv,type) + .unmarshal().bindy(BindyType.Csv, type) .to("mock:out"); from("direct:in") .marshal(dataFormat) http://git-wip-us.apache.org/repos/asf/camel/blob/e1e5cac5/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindySimpleCsvAutospanLineTest.java ---------------------------------------------------------------------- diff --git a/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindySimpleCsvAutospanLineTest.java b/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindySimpleCsvAutospanLineTest.java index 1f6dc57..1ef984e 100644 --- a/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindySimpleCsvAutospanLineTest.java +++ b/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindySimpleCsvAutospanLineTest.java @@ -64,8 +64,7 @@ public class BindySimpleCsvAutospanLineTest extends CamelTestSupport { return new RouteBuilder() { @Override public void configure() throws Exception { - final BindyCsvDataFormat bindy = new BindyCsvDataFormat( - org.apache.camel.dataformat.bindy.model.simple.spanLastRecord.SpanLastRecord.class); + final BindyCsvDataFormat bindy = new BindyCsvDataFormat(SpanLastRecord.class); from("direct:unmarshal") .unmarshal(bindy) http://git-wip-us.apache.org/repos/asf/camel/blob/e1e5cac5/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindySimpleCsvBooleanFalseMarshallTest.java ---------------------------------------------------------------------- diff --git a/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindySimpleCsvBooleanFalseMarshallTest.java b/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindySimpleCsvBooleanFalseMarshallTest.java index 11121a5..59af0e5 100644 --- a/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindySimpleCsvBooleanFalseMarshallTest.java +++ b/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindySimpleCsvBooleanFalseMarshallTest.java @@ -71,7 +71,9 @@ public class BindySimpleCsvBooleanFalseMarshallTest extends AbstractJUnit4Spring public static class ContextConfig extends RouteBuilder { public void configure() { - BindyCsvDataFormat camelDataFormat = new BindyCsvDataFormat("org.apache.camel.dataformat.bindy.model.simple.bool"); + BindyCsvDataFormat camelDataFormat = new BindyCsvDataFormat( + org.apache.camel.dataformat.bindy.model.simple.bool.BooleanExample.class); + camelDataFormat.setLocale("en"); from("direct:start").marshal(camelDataFormat).to("mock:result"); http://git-wip-us.apache.org/repos/asf/camel/blob/e1e5cac5/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindySimpleCsvBooleanTrueMarshallTest.java ---------------------------------------------------------------------- diff --git a/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindySimpleCsvBooleanTrueMarshallTest.java b/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindySimpleCsvBooleanTrueMarshallTest.java index 8b0fd9e..6633b72 100644 --- a/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindySimpleCsvBooleanTrueMarshallTest.java +++ b/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindySimpleCsvBooleanTrueMarshallTest.java @@ -71,7 +71,9 @@ public class BindySimpleCsvBooleanTrueMarshallTest extends AbstractJUnit4SpringC public static class ContextConfig extends RouteBuilder { public void configure() { - BindyCsvDataFormat camelDataFormat = new BindyCsvDataFormat("org.apache.camel.dataformat.bindy.model.simple.bool"); + BindyCsvDataFormat camelDataFormat = new BindyCsvDataFormat( + org.apache.camel.dataformat.bindy.model.simple.bool.BooleanExample.class); + camelDataFormat.setLocale("en"); from("direct:start").marshal(camelDataFormat).to("mock:result"); http://git-wip-us.apache.org/repos/asf/camel/blob/e1e5cac5/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindySimpleCsvBooleanUnmarshallTest.java ---------------------------------------------------------------------- diff --git a/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindySimpleCsvBooleanUnmarshallTest.java b/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindySimpleCsvBooleanUnmarshallTest.java index 57eea3b..9861e53 100755 --- a/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindySimpleCsvBooleanUnmarshallTest.java +++ b/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindySimpleCsvBooleanUnmarshallTest.java @@ -17,7 +17,6 @@ package org.apache.camel.dataformat.bindy.csv; import java.util.List; -import java.util.Map; import org.apache.camel.EndpointInject; import org.apache.camel.LoggingLevel; @@ -65,17 +64,17 @@ public class BindySimpleCsvBooleanUnmarshallTest extends AbstractJUnit4SpringCon template.sendBody(expected); - List<Map<String, BooleanExample>> examples = (List<Map<String, BooleanExample>>) result.getExchanges().get(0).getIn().getBody(); + List<BooleanExample> examples = (List<BooleanExample>)result.getExchanges().get(0).getIn().getBody(); result.expectedMessageCount(1); result.assertIsSatisfied(); - assertFalse(examples.get(0).get(BooleanExample.class.getName()).getName().isEmpty()); - assertEquals(examples.get(0).get(BooleanExample.class.getName()).getName(), "andrew"); - assertTrue(examples.get(0).get(BooleanExample.class.getName()).getExist()); - assertFalse(examples.get(1).get(BooleanExample.class.getName()).getName().isEmpty()); - assertEquals(examples.get(1).get(BooleanExample.class.getName()).getName(), "andrew"); - assertFalse(examples.get(1).get(BooleanExample.class.getName()).getExist()); + assertFalse(examples.get(0).getName().isEmpty()); + assertEquals(examples.get(0).getName(), "andrew"); + assertTrue(examples.get(0).getExist()); + assertFalse(examples.get(1).getName().isEmpty()); + assertEquals(examples.get(1).getName(), "andrew"); + assertFalse(examples.get(1).getExist()); assertNotNull(examples); } @@ -89,25 +88,26 @@ public class BindySimpleCsvBooleanUnmarshallTest extends AbstractJUnit4SpringCon template.sendBody(expected); - List<Map<String, BooleanExample>> examples = (List<Map<String, BooleanExample>>) result.getExchanges().get(0).getIn().getBody(); + List<BooleanExample> examples = (List<BooleanExample>)result.getExchanges().get(0).getIn().getBody(); result.expectedMessageCount(1); result.assertIsSatisfied(); - assertFalse(examples.get(0).get(BooleanExample.class.getName()).getName().isEmpty()); - assertEquals(examples.get(0).get(BooleanExample.class.getName()).getName(), "andrew"); - assertTrue(examples.get(0).get(BooleanExample.class.getName()).getExist()); - assertFalse(examples.get(1).get(BooleanExample.class.getName()).getName().isEmpty()); - assertEquals(examples.get(1).get(BooleanExample.class.getName()).getName(), "joseph"); - assertFalse(examples.get(1).get(BooleanExample.class.getName()).getExist()); - assertFalse(examples.get(2).get(BooleanExample.class.getName()).getName().isEmpty()); - assertEquals(examples.get(2).get(BooleanExample.class.getName()).getName(), "nicholas"); - assertTrue(examples.get(2).get(BooleanExample.class.getName()).getExist()); + assertFalse(examples.get(0).getName().isEmpty()); + assertEquals(examples.get(0).getName(), "andrew"); + assertTrue(examples.get(0).getExist()); + assertFalse(examples.get(1).getName().isEmpty()); + assertEquals(examples.get(1).getName(), "joseph"); + assertFalse(examples.get(1).getExist()); + assertFalse(examples.get(2).getName().isEmpty()); + assertEquals(examples.get(2).getName(), "nicholas"); + assertTrue(examples.get(2).getExist()); assertNotNull(examples); } public static class ContextConfig extends RouteBuilder { - BindyCsvDataFormat camelDataFormat = new BindyCsvDataFormat("org.apache.camel.dataformat.bindy.model.simple.bool"); + BindyCsvDataFormat camelDataFormat = new BindyCsvDataFormat( + org.apache.camel.dataformat.bindy.model.simple.bool.BooleanExample.class); public void configure() { // from("file://src/test/data?move=./target/done").unmarshal(camelDataFormat).to("mock:result"); http://git-wip-us.apache.org/repos/asf/camel/blob/e1e5cac5/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindySimpleCsvUnmarshallBadIntegerTest.java ---------------------------------------------------------------------- diff --git a/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindySimpleCsvUnmarshallBadIntegerTest.java b/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindySimpleCsvUnmarshallBadIntegerTest.java index 71993d4..b2e458c 100644 --- a/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindySimpleCsvUnmarshallBadIntegerTest.java +++ b/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindySimpleCsvUnmarshallBadIntegerTest.java @@ -16,7 +16,6 @@ */ package org.apache.camel.dataformat.bindy.csv; -import static org.junit.Assert.assertEquals; import org.apache.camel.EndpointInject; import org.apache.camel.Exchange; @@ -34,6 +33,8 @@ import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests; +import static org.junit.Assert.assertEquals; + @ContextConfiguration public class BindySimpleCsvUnmarshallBadIntegerTest extends AbstractJUnit4SpringContextTests { http://git-wip-us.apache.org/repos/asf/camel/blob/e1e5cac5/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindySimpleCsvUnmarshallTest.java ---------------------------------------------------------------------- diff --git a/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindySimpleCsvUnmarshallTest.java b/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindySimpleCsvUnmarshallTest.java index 52abc59..277c26c 100755 --- a/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindySimpleCsvUnmarshallTest.java +++ b/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindySimpleCsvUnmarshallTest.java @@ -16,10 +16,6 @@ */ package org.apache.camel.dataformat.bindy.csv; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; - import java.util.List; import org.apache.camel.EndpointInject; @@ -38,6 +34,10 @@ import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; + @ContextConfiguration public class BindySimpleCsvUnmarshallTest extends AbstractJUnit4SpringContextTests { http://git-wip-us.apache.org/repos/asf/camel/blob/e1e5cac5/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fix/BindySimpleKeyValuePairUnmarshallDslTest.java ---------------------------------------------------------------------- diff --git a/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fix/BindySimpleKeyValuePairUnmarshallDslTest.java b/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fix/BindySimpleKeyValuePairUnmarshallDslTest.java index 357ae9d..adec426 100644 --- a/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fix/BindySimpleKeyValuePairUnmarshallDslTest.java +++ b/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fix/BindySimpleKeyValuePairUnmarshallDslTest.java @@ -45,7 +45,7 @@ public class BindySimpleKeyValuePairUnmarshallDslTest extends CommonBindyTest { public void configure() { from(URI_FILE_FIX).unmarshal() - .bindy(BindyType.KeyValue,Order.class) + .bindy(BindyType.KeyValue, Order.class) .to(URI_MOCK_RESULT); }