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/355becba Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/355becba Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/355becba Branch: refs/heads/master Commit: 355becba84321062c22223364fa56845e3e6391f Parents: 222f5fd Author: lburgazzoli <lburgazz...@gmail.com> Authored: Wed Dec 18 15:03:34 2013 +0100 Committer: Claus Ibsen <davscl...@apache.org> Committed: Fri Aug 7 11:05:47 2015 +0200 ---------------------------------------------------------------------- .../bindy/BindyAbstractDataFormat.java | 1 + .../dataformat/bindy/BindyAbstractFactory.java | 1 - .../bindy/BindyFixedLengthFactory.java | 52 +++++++++++++++++--- .../bindy/annotation/FixedLengthRecord.java | 14 +----- .../bindy/kvp/BindyKeyValuePairDataFormat.java | 1 - .../csv/BindyCarQuoteAndCommaDelimiterTest.java | 14 ++---- .../BindyInlinedQuotesCsvUnmarshallTest.java | 6 +-- .../bindy/csv/BindyPipeDelimiterTest.java | 11 ++--- .../csv/BindySimpleCsvAutospanLineTest.java | 18 +++---- .../BindySimpleCsvUnmarshallBadIntegerTest.java | 16 ++---- .../bindy/csv/BindySimpleCsvUnmarshallTest.java | 14 +++--- ...dySingleQuoteStartWordCsvUnmarshallTest.java | 6 +-- .../bindy/csv/BindyTabSeparatorTest.java | 18 +++---- .../csv2/BindyMarshalUnmarshalssueTest.java | 8 +-- .../csv2/BindyUnmarshalCommaIssueTest.java | 15 +++--- .../BindyComplexKeyValuePairStandaloneTest.java | 2 - ...plexOneToManyKeyValuePairUnMarshallTest.java | 17 ++++--- ...ySimpleKeyValuePairSortedUnmarshallTest.java | 14 +++--- ...indySimpleKeyValuePairTabUnmarshallTest.java | 13 ++--- ...indySimpleKeyValuePairUnmarshallDslTest.java | 12 +++-- .../BindySimpleKeyValuePairUnmarshallTest.java | 11 +++-- .../bindy/fixed/headerfooter/Order.java | 2 +- .../bindy/fixed/headerfooter/OrderFooter.java | 2 +- .../bindy/fixed/headerfooter/OrderHeader.java | 2 +- .../BindySimpleFixedLengthWithLinkTest.java | 26 ++-------- .../bindy/fixed/skipheader/Order.java | 2 +- .../bindy/fixed/skipheader/OrderFooter.java | 2 +- .../bindy/fixed/skipheader/OrderHeader.java | 2 +- .../BindySimpleFixedLengthUnmarshallTest.java | 5 +- ...impleFixedLengthUnmarshallTrimFieldTest.java | 6 +-- .../BindySimpleCsvUnmarshallDslTest-context.xml | 2 +- 31 files changed, 147 insertions(+), 168 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/355becba/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyAbstractDataFormat.java ---------------------------------------------------------------------- diff --git a/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyAbstractDataFormat.java b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyAbstractDataFormat.java index b790424..a4365e3 100644 --- a/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyAbstractDataFormat.java +++ b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyAbstractDataFormat.java @@ -29,6 +29,7 @@ public abstract class BindyAbstractDataFormat implements DataFormat { public BindyAbstractDataFormat() { } + protected BindyAbstractDataFormat(Class<?> classType) { this.classType = classType; } http://git-wip-us.apache.org/repos/asf/camel/blob/355becba/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyAbstractFactory.java ---------------------------------------------------------------------- diff --git a/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyAbstractFactory.java b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyAbstractFactory.java index a23383a..959e40c 100644 --- a/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyAbstractFactory.java +++ b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyAbstractFactory.java @@ -41,7 +41,6 @@ public abstract class BindyAbstractFactory implements BindyFactory { protected Set<String> modelClassNames; protected String crlf; - private String[] packageNames; private String locale; private Class<?> type; http://git-wip-us.apache.org/repos/asf/camel/blob/355becba/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyFixedLengthFactory.java ---------------------------------------------------------------------- diff --git a/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyFixedLengthFactory.java b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyFixedLengthFactory.java index ac3bfbc..08ca7b9 100644 --- a/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyFixedLengthFactory.java +++ b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyFixedLengthFactory.java @@ -62,10 +62,16 @@ public class BindyFixedLengthFactory extends BindyAbstractFactory implements Bin private char paddingChar; private int recordLength; private boolean ignoreTrailingChars; + + private Class<?> header; + private Class<?> footer; public BindyFixedLengthFactory(Class<?> type) throws Exception { super(type); + header = void.class; + footer = void.class; + // initialize specific parameters of the fixed length model initFixedLengthModel(); } @@ -83,6 +89,16 @@ public class BindyFixedLengthFactory extends BindyAbstractFactory implements Bin // initialize Fixed length parameter(s) // from @FixedLengthrecord annotation initFixedLengthRecordParameters(); + + if(header != void.class) { + models.add(header); + modelClassNames.add(header.getName()); + } + + if(footer != void.class) { + models.add(footer); + modelClassNames.add(footer.getName()); + } } public void initAnnotatedFields() { @@ -459,16 +475,20 @@ public class BindyFixedLengthFactory extends BindyAbstractFactory implements Bin crlf = record.crlf(); LOG.debug("Carriage return defined for the CSV: {}", crlf); - // Get hasHeader parameter - hasHeader = record.hasHeader(); + // Get header parameter + header = record.header(); + LOG.debug("Header: {}", header); + hasHeader = header != void.class; LOG.debug("Has Header: {}", hasHeader); - + // Get skipHeader parameter skipHeader = record.skipHeader(); LOG.debug("Skip Header: {}", skipHeader); - // Get hasFooter parameter - hasFooter = record.hasFooter(); + // Get footer parameter + footer = record.footer(); + LOG.debug("Footer: {}", footer); + hasFooter = record.footer() != void.class; LOG.debug("Has Footer: {}", hasFooter); // Get skipFooter parameter @@ -476,11 +496,11 @@ public class BindyFixedLengthFactory extends BindyAbstractFactory implements Bin LOG.debug("Skip Footer: {}", skipFooter); // Get isHeader parameter - isHeader = record.isHeader(); + isHeader = hasHeader ? cl.equals(header) : false; LOG.debug("Is Header: {}", isHeader); // Get isFooter parameter - isFooter = record.isFooter(); + isFooter = hasFooter ? cl.equals(footer) : false; LOG.debug("Is Footer: {}", isFooter); // Get padding character @@ -511,12 +531,28 @@ public class BindyFixedLengthFactory extends BindyAbstractFactory implements Bin } } - + + /** + * + * @return + */ + public Class<?> header() { + return header; + } + /** * Flag indicating if we have a header */ public boolean hasHeader() { return hasHeader; + } + + /** + * + * @return + */ + public Class<?> footer() { + return footer; } /** http://git-wip-us.apache.org/repos/asf/camel/blob/355becba/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/FixedLengthRecord.java ---------------------------------------------------------------------- diff --git a/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/FixedLengthRecord.java b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/FixedLengthRecord.java index cf88a2d..eca6fd1 100644 --- a/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/FixedLengthRecord.java +++ b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/annotation/FixedLengthRecord.java @@ -59,12 +59,12 @@ public @interface FixedLengthRecord { /** * Indicates that the record(s) of this type may be preceded by a single header record at the beginning of in the file */ - boolean hasHeader() default false; + Class<?> header() default void.class; /** * Indicates that the record(s) of this type may be followed by a single footer record at the end of the file */ - boolean hasFooter() default false; + Class<?> footer() default void.class; /** * Configures the data format to skip marshalling / unmarshalling of the header record @@ -77,16 +77,6 @@ public @interface FixedLengthRecord { boolean skipFooter() default false; /** - * Identifies this FixedLengthRecord as a header record, which may precede all other records in the file - */ - boolean isHeader() default false; - - /** - * Identifies this FixedLengthRecord as a footer record, which may be used as the last record in the file - */ - boolean isFooter() default false; - - /** * Indicates whether trailing characters beyond the last mapped field may be ignored */ boolean ignoreTrailingChars() default false; http://git-wip-us.apache.org/repos/asf/camel/blob/355becba/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/kvp/BindyKeyValuePairDataFormat.java ---------------------------------------------------------------------- diff --git a/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/kvp/BindyKeyValuePairDataFormat.java b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/kvp/BindyKeyValuePairDataFormat.java index 7c4a028..112330f 100644 --- a/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/kvp/BindyKeyValuePairDataFormat.java +++ b/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/kvp/BindyKeyValuePairDataFormat.java @@ -32,7 +32,6 @@ import org.apache.camel.dataformat.bindy.BindyAbstractFactory; import org.apache.camel.dataformat.bindy.BindyKeyValuePairFactory; import org.apache.camel.dataformat.bindy.util.ConverterUtils; import org.apache.camel.spi.DataFormat; -import org.apache.camel.spi.PackageScanClassResolver; import org.apache.camel.util.IOHelper; import org.apache.camel.util.ObjectHelper; import org.slf4j.Logger; http://git-wip-us.apache.org/repos/asf/camel/blob/355becba/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 87b67e6..a51fad9 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 @@ -16,9 +16,6 @@ */ package org.apache.camel.dataformat.bindy.csv; -import java.util.List; -import java.util.Map; - import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.dataformat.bindy.model.car.Car; @@ -51,10 +48,8 @@ public class BindyCarQuoteAndCommaDelimiterTest extends CamelTestSupport { template.sendBody("direct:out", HEADER + "\n" + ROW); assertMockEndpointsSatisfied(); - - Map<?, ?> map1 = (Map<?, ?>) mock.getReceivedExchanges().get(0).getIn().getBody(List.class).get(0); - - Car rec1 = (Car) map1.values().iterator().next(); + + Car rec1 = mock.getReceivedExchanges().get(0).getIn().getBody(Car.class); assertEquals("SS552", rec1.getStockid()); assertEquals("TOYOTA", rec1.getMake()); @@ -87,12 +82,13 @@ public class BindyCarQuoteAndCommaDelimiterTest extends CamelTestSupport { @Override public void configure() throws Exception { + Class<?> type = org.apache.camel.dataformat.bindy.model.car.Car.class; BindyCsvDataFormat dataFormat = new BindyCsvDataFormat(); - dataFormat.setClassType(org.apache.camel.dataformat.bindy.model.car.Car.class); + dataFormat.setClassType(type); dataFormat.setLocale("en"); from("direct:out") - .unmarshal().bindy(BindyType.Csv,org.apache.camel.dataformat.bindy.model.car.Car.class) + .unmarshal().bindy(BindyType.Csv,type) .to("mock:out"); from("direct:in") .marshal(dataFormat) http://git-wip-us.apache.org/repos/asf/camel/blob/355becba/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindyInlinedQuotesCsvUnmarshallTest.java ---------------------------------------------------------------------- diff --git a/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindyInlinedQuotesCsvUnmarshallTest.java b/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindyInlinedQuotesCsvUnmarshallTest.java index 0356209..a7339c8 100644 --- a/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindyInlinedQuotesCsvUnmarshallTest.java +++ b/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindyInlinedQuotesCsvUnmarshallTest.java @@ -16,9 +16,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.Produce; import org.apache.camel.ProducerTemplate; @@ -56,8 +53,7 @@ public class BindyInlinedQuotesCsvUnmarshallTest extends AbstractJUnit4SpringCon result.expectedMessageCount(1); result.assertIsSatisfied(); - Map<?, ?> map = (Map<?, ?>) result.getReceivedExchanges().get(0).getIn().getBody(List.class).get(0); - Order order = (Order) map.values().iterator().next(); + Order order = result.getReceivedExchanges().get(0).getIn().getBody(Order.class); Assert.assertEquals(10, order.getOrderNr()); Assert.assertEquals("Pauline", order.getFirstName()); Assert.assertEquals("O'Donald", order.getLastName()); http://git-wip-us.apache.org/repos/asf/camel/blob/355becba/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindyPipeDelimiterTest.java ---------------------------------------------------------------------- diff --git a/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindyPipeDelimiterTest.java b/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindyPipeDelimiterTest.java index 6202404..f6dabc8 100644 --- a/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindyPipeDelimiterTest.java +++ b/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindyPipeDelimiterTest.java @@ -17,7 +17,6 @@ package org.apache.camel.dataformat.bindy.csv; import java.util.List; -import java.util.Map; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; @@ -40,11 +39,11 @@ public class BindyPipeDelimiterTest extends CamelTestSupport { assertMockEndpointsSatisfied(); - Map<?, ?> map1 = (Map<?, ?>) mock.getReceivedExchanges().get(0).getIn().getBody(List.class).get(0); - Map<?, ?> map2 = (Map<?, ?>) mock.getReceivedExchanges().get(0).getIn().getBody(List.class).get(1); - - MyData rec1 = (MyData) map1.values().iterator().next(); - MyData rec2 = (MyData) map2.values().iterator().next(); + MyData rec1 = (MyData) mock.getReceivedExchanges().get(0).getIn().getBody(List.class).get(0); + MyData rec2 = (MyData) mock.getReceivedExchanges().get(0).getIn().getBody(List.class).get(1); + + //MyData rec1 = (MyData) map1.values().iterator().next(); + //MyData rec2 = (MyData) map2.values().iterator().next(); assertEquals("COL1", rec1.getCol1()); assertEquals("COL2", rec1.getCol2()); http://git-wip-us.apache.org/repos/asf/camel/blob/355becba/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 0df3f6d..1f6dc57 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 @@ -16,14 +16,10 @@ */ package org.apache.camel.dataformat.bindy.csv; -import java.util.List; -import java.util.Map; - import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.dataformat.bindy.model.simple.spanLastRecord.SpanLastRecord; import org.apache.camel.test.junit4.CamelTestSupport; -import org.apache.camel.util.CastUtils; import org.junit.Test; public class BindySimpleCsvAutospanLineTest extends CamelTestSupport { @@ -37,9 +33,11 @@ public class BindySimpleCsvAutospanLineTest extends CamelTestSupport { assertMockEndpointsSatisfied(); - final List<Map<?, SpanLastRecord>> rows = CastUtils.cast(mock.getReceivedExchanges().get(0).getIn().getBody(List.class)); - final SpanLastRecord order = rows.get(0).get(SpanLastRecord.class.getName()); + //final List<Map<?, SpanLastRecord>> rows = CastUtils.cast(mock.getReceivedExchanges().get(0).getIn().getBody(List.class)); + //final SpanLastRecord order = rows.get(0).get(SpanLastRecord.class.getName()); + final SpanLastRecord order = mock.getReceivedExchanges().get(0).getIn().getBody(SpanLastRecord.class); + assertEquals(1, order.getRecordId()); assertEquals("hei", order.getName()); assertEquals("kommentar", order.getComment()); @@ -54,9 +52,8 @@ public class BindySimpleCsvAutospanLineTest extends CamelTestSupport { assertMockEndpointsSatisfied(); - final List<Map<?, SpanLastRecord>> rows = CastUtils.cast(mock.getReceivedExchanges().get(0).getIn().getBody(List.class)); - final SpanLastRecord order = rows.get(0).get(SpanLastRecord.class.getName()); - + final SpanLastRecord order = mock.getReceivedExchanges().get(0).getIn().getBody(SpanLastRecord.class); + assertEquals(1, order.getRecordId()); assertEquals("hei", order.getName()); assertEquals("kommentar,test,noe,hei", order.getComment()); @@ -67,7 +64,8 @@ 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"); + final BindyCsvDataFormat bindy = new BindyCsvDataFormat( + org.apache.camel.dataformat.bindy.model.simple.spanLastRecord.SpanLastRecord.class); from("direct:unmarshal") .unmarshal(bindy) http://git-wip-us.apache.org/repos/asf/camel/blob/355becba/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 35c382d..71993d4 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,8 +16,7 @@ */ package org.apache.camel.dataformat.bindy.csv; -import java.util.List; -import java.util.Map; +import static org.junit.Assert.assertEquals; import org.apache.camel.EndpointInject; import org.apache.camel.Exchange; @@ -35,8 +34,6 @@ 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 { @@ -57,7 +54,6 @@ public class BindySimpleCsvUnmarshallBadIntegerTest extends AbstractJUnit4Spring @EndpointInject(uri = URI_MOCK_ERROR) private MockEndpoint error; - @SuppressWarnings("unchecked") @Test @DirtiesContext public void testIntegerMessage() throws Exception { @@ -68,12 +64,10 @@ public class BindySimpleCsvUnmarshallBadIntegerTest extends AbstractJUnit4Spring result.expectedMessageCount(1); result.assertIsSatisfied(); - - List<Map<String, org.apache.camel.dataformat.bindy.model.simple.oneclassmath.Math>> model = (List<Map<String, org.apache.camel.dataformat.bindy.model.simple.oneclassmath.Math>>)result - .getExchanges().get(0).getIn().getBody(); - - LOG.info(">>> Model generated : " + model.get(0).get("org.apache.camel.dataformat.bindy.model.simple.oneclassmath.Math").toString()); - + + Object data = result.getReceivedExchanges().get(0).getIn().getBody(); + + LOG.info(">>> Model generated : " + data.getClass().getName()); } @Test http://git-wip-us.apache.org/repos/asf/camel/blob/355becba/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 d42085e..52abc59 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,8 +16,11 @@ */ 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 java.util.Map; import org.apache.camel.EndpointInject; import org.apache.camel.Exchange; @@ -35,11 +38,6 @@ 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 { @@ -122,7 +120,7 @@ public class BindySimpleCsvUnmarshallTest extends AbstractJUnit4SpringContextTes template.sendBody(expected); - List<Map<String, Order>> orders = (List<Map<String, Order>>) result.getExchanges().get(0).getIn().getBody(); + List<Order> orders = (List<Order>) result.getExchanges().get(0).getIn().getBody(); result.expectedMessageCount(1); result.assertIsSatisfied(); @@ -130,7 +128,7 @@ public class BindySimpleCsvUnmarshallTest extends AbstractJUnit4SpringContextTes assertNotNull(orders); // As the @DataField defines a default value for the firstName, the // value might not be empty - assertFalse(orders.get(0).get(Order.class.getName()).getFirstName().isEmpty()); + assertFalse(orders.get(0).getFirstName().isEmpty()); } public static class ContextConfig extends RouteBuilder { http://git-wip-us.apache.org/repos/asf/camel/blob/355becba/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindySingleQuoteStartWordCsvUnmarshallTest.java ---------------------------------------------------------------------- diff --git a/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindySingleQuoteStartWordCsvUnmarshallTest.java b/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindySingleQuoteStartWordCsvUnmarshallTest.java index 8d28291..e58f49c 100644 --- a/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindySingleQuoteStartWordCsvUnmarshallTest.java +++ b/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindySingleQuoteStartWordCsvUnmarshallTest.java @@ -16,9 +16,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.Produce; import org.apache.camel.ProducerTemplate; @@ -56,8 +53,7 @@ public class BindySingleQuoteStartWordCsvUnmarshallTest extends AbstractJUnit4Sp result.expectedMessageCount(1); result.assertIsSatisfied(); - Map<?, ?> map = (Map<?, ?>) result.getReceivedExchanges().get(0).getIn().getBody(List.class).get(0); - Order order = (Order) map.values().iterator().next(); + Order order = result.getReceivedExchanges().get(0).getIn().getBody(Order.class); Assert.assertEquals(10, order.getOrderNr()); Assert.assertEquals("Patric", order.getFirstName()); Assert.assertEquals("'T jo", order.getLastName()); http://git-wip-us.apache.org/repos/asf/camel/blob/355becba/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindyTabSeparatorTest.java ---------------------------------------------------------------------- diff --git a/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindyTabSeparatorTest.java b/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindyTabSeparatorTest.java index 67abf4d..fb7bd77 100644 --- a/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindyTabSeparatorTest.java +++ b/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindyTabSeparatorTest.java @@ -16,15 +16,11 @@ */ package org.apache.camel.dataformat.bindy.csv; -import java.util.List; -import java.util.Map; - import org.apache.camel.Exchange; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.dataformat.bindy.model.tab.PurchaseOrder; import org.apache.camel.test.junit4.CamelTestSupport; -import org.apache.camel.util.CastUtils; import org.junit.Test; /** @@ -45,14 +41,15 @@ public class BindyTabSeparatorTest extends CamelTestSupport { /* List<Map<?, PurchaseOrder>> rows = CastUtils.cast(mock.getReceivedExchanges().get(0).getIn().getBody(List.class)); PurchaseOrder order = rows.get(0).get(PurchaseOrder.class.getName()); - + */ + PurchaseOrder order = mock.getReceivedExchanges().get(0).getIn().getBody(PurchaseOrder.class); + assertEquals(123, order.getId()); assertEquals("Camel in Action", order.getName()); assertEquals(2, order.getAmount()); assertEquals("Please hurry", order.getOrderText()); assertEquals("Jane Doe", order.getSalesRef()); assertEquals("John Doe", order.getCustomerRef()); - */ } @Test @@ -84,11 +81,12 @@ public class BindyTabSeparatorTest extends CamelTestSupport { assertMockEndpointsSatisfied(); - //TODO: check - /* - List<Map<?, PurchaseOrder>> rows = CastUtils.cast(mock.getReceivedExchanges().get(0).getIn().getBody(List.class)); - PurchaseOrder order = rows.get(0).get(PurchaseOrder.class.getName()); + //List<Map<?, PurchaseOrder>> rows = CastUtils.cast(mock.getReceivedExchanges().get(0).getIn().getBody(List.class)); + //PurchaseOrder order = rows.get(0).get(PurchaseOrder.class.getName()); + /*TODO: cjeck + PurchaseOrder order = mock.getReceivedExchanges().get(0).getIn().getBody(PurchaseOrder.class); + assertEquals(123, order.getId()); assertEquals("Camel in Action", order.getName()); assertEquals(2, order.getAmount()); http://git-wip-us.apache.org/repos/asf/camel/blob/355becba/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv2/BindyMarshalUnmarshalssueTest.java ---------------------------------------------------------------------- diff --git a/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv2/BindyMarshalUnmarshalssueTest.java b/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv2/BindyMarshalUnmarshalssueTest.java index 91df474..b5af2b7 100644 --- a/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv2/BindyMarshalUnmarshalssueTest.java +++ b/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv2/BindyMarshalUnmarshalssueTest.java @@ -16,9 +16,6 @@ */ package org.apache.camel.dataformat.bindy.csv2; -import java.util.List; -import java.util.Map; - import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.dataformat.bindy.csv.BindyCsvDataFormat; @@ -44,9 +41,8 @@ public class BindyMarshalUnmarshalssueTest extends CamelTestSupport { assertMockEndpointsSatisfied(); - Map<?, ?> map = (Map<?, ?>) mock.getReceivedExchanges().get(0).getIn().getBody(List.class).get(0); - WeatherModel model = (WeatherModel) map.values().iterator().next(); - + WeatherModel model = mock.getReceivedExchanges().get(0).getIn().getBody(WeatherModel.class); + assertEquals(123, model.getId()); assertEquals("Wednesday November 9 2011", model.getDate()); assertEquals("Central California", model.getPlace()); http://git-wip-us.apache.org/repos/asf/camel/blob/355becba/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv2/BindyUnmarshalCommaIssueTest.java ---------------------------------------------------------------------- diff --git a/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv2/BindyUnmarshalCommaIssueTest.java b/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv2/BindyUnmarshalCommaIssueTest.java index c63b711..7516313 100644 --- a/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv2/BindyUnmarshalCommaIssueTest.java +++ b/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv2/BindyUnmarshalCommaIssueTest.java @@ -40,10 +40,9 @@ public class BindyUnmarshalCommaIssueTest extends CamelTestSupport { template.sendBody("direct:start", body); assertMockEndpointsSatisfied(); - - Map<?, ?> map = (Map<?, ?>) mock.getReceivedExchanges().get(0).getIn().getBody(List.class).get(0); - WeatherModel model = (WeatherModel) map.values().iterator().next(); - + + WeatherModel model = mock.getReceivedExchanges().get(0).getIn().getBody(WeatherModel.class); + assertEquals(123, model.getId()); assertEquals("Wednesday November 9 2011", model.getDate()); assertEquals("Central California", model.getPlace()); @@ -59,8 +58,7 @@ public class BindyUnmarshalCommaIssueTest extends CamelTestSupport { assertMockEndpointsSatisfied(); - Map<?, ?> map = (Map<?, ?>) mock.getReceivedExchanges().get(0).getIn().getBody(List.class).get(0); - WeatherModel model = (WeatherModel) map.values().iterator().next(); + WeatherModel model = mock.getReceivedExchanges().get(0).getIn().getBody(WeatherModel.class); assertEquals(123, model.getId()); assertEquals("Wednesday, November 9, 2011", model.getDate()); @@ -77,9 +75,8 @@ public class BindyUnmarshalCommaIssueTest extends CamelTestSupport { assertMockEndpointsSatisfied(); - Map<?, ?> map = (Map<?, ?>) mock.getReceivedExchanges().get(0).getIn().getBody(List.class).get(0); - WeatherModel model = (WeatherModel) map.values().iterator().next(); - + WeatherModel model = mock.getReceivedExchanges().get(0).getIn().getBody(WeatherModel.class); + assertEquals(123, model.getId()); assertEquals("Wednesday, November 9, 2011", model.getDate()); assertEquals("Central California, United States", model.getPlace()); http://git-wip-us.apache.org/repos/asf/camel/blob/355becba/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fix/BindyComplexKeyValuePairStandaloneTest.java ---------------------------------------------------------------------- diff --git a/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fix/BindyComplexKeyValuePairStandaloneTest.java b/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fix/BindyComplexKeyValuePairStandaloneTest.java index f88b3f7..a6f826a 100644 --- a/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fix/BindyComplexKeyValuePairStandaloneTest.java +++ b/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fix/BindyComplexKeyValuePairStandaloneTest.java @@ -27,8 +27,6 @@ import org.apache.camel.dataformat.bindy.BindyKeyValuePairFactory; import org.apache.camel.dataformat.bindy.model.fix.complex.onetomany.Header; import org.apache.camel.dataformat.bindy.model.fix.complex.onetomany.Order; import org.apache.camel.dataformat.bindy.model.fix.complex.onetomany.Trailer; -import org.apache.camel.impl.DefaultPackageScanClassResolver; -import org.apache.camel.spi.PackageScanClassResolver; import org.junit.Assert; import org.junit.Before; import org.junit.Test; http://git-wip-us.apache.org/repos/asf/camel/blob/355becba/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fix/BindyComplexOneToManyKeyValuePairUnMarshallTest.java ---------------------------------------------------------------------- diff --git a/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fix/BindyComplexOneToManyKeyValuePairUnMarshallTest.java b/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fix/BindyComplexOneToManyKeyValuePairUnMarshallTest.java index b9c222c..36ab6f4 100644 --- a/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fix/BindyComplexOneToManyKeyValuePairUnMarshallTest.java +++ b/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fix/BindyComplexOneToManyKeyValuePairUnMarshallTest.java @@ -19,6 +19,7 @@ package org.apache.camel.dataformat.bindy.fix; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.dataformat.bindy.CommonBindyTest; import org.apache.camel.dataformat.bindy.kvp.BindyKeyValuePairDataFormat; +import org.apache.camel.dataformat.bindy.model.fix.complex.onetomany.Order; import org.junit.Assert; import org.junit.Test; import org.springframework.test.annotation.DirtiesContext; @@ -41,13 +42,15 @@ public class BindyComplexOneToManyKeyValuePairUnMarshallTest extends CommonBindy result.assertIsSatisfied(); - String body = result.getReceivedExchanges().get(0).getIn().getBody(String.class); - Assert.assertTrue(body.contains("BE.CHM.001, 11: CHM0001-01, 58: this is a camel - bindy test")); - Assert.assertTrue(body.contains("22: 4, 48: BE0001245678, 54: 1")); - Assert.assertTrue(body.contains("22: 5, 48: BE0009876543, 54: 2")); - Assert.assertTrue(body.contains("22: 6, 48: BE0009999999, 54: 3")); - Assert.assertTrue(body.contains("FIX 4.1, 9: 20, 34: 1 , 35: 0, 49: INVMGR, 56: BRKR")); - Assert.assertTrue(body.contains("10: 220")); + Order order1 = result.getReceivedExchanges().get(0).getIn().getBody(Order.class); + Order order2 = result.getReceivedExchanges().get(1).getIn().getBody(Order.class); + + Assert.assertTrue(order1.toString().contains("BE.CHM.001, 11: CHM0001-01, 58: this is a camel - bindy test")); + Assert.assertTrue(order1.getSecurities().get(0).toString().contains("22: 4, 48: BE0001245678, 54: 1")); + Assert.assertTrue(order1.getSecurities().get(1).toString().contains("22: 5, 48: BE0009876543, 54: 2")); + Assert.assertTrue(order1.getSecurities().get(2).toString().contains("22: 6, 48: BE0009999999, 54: 3")); + Assert.assertTrue(order2.getHeader().toString().contains("FIX 4.1, 9: 20, 34: 1 , 35: 0, 49: INVMGR, 56: BRKR")); + Assert.assertTrue(order2.getTrailer().toString().contains("10: 220")); } public static class ContextConfig extends RouteBuilder { http://git-wip-us.apache.org/repos/asf/camel/blob/355becba/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fix/BindySimpleKeyValuePairSortedUnmarshallTest.java ---------------------------------------------------------------------- diff --git a/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fix/BindySimpleKeyValuePairSortedUnmarshallTest.java b/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fix/BindySimpleKeyValuePairSortedUnmarshallTest.java index a9e640b..b93f1d0 100644 --- a/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fix/BindySimpleKeyValuePairSortedUnmarshallTest.java +++ b/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fix/BindySimpleKeyValuePairSortedUnmarshallTest.java @@ -19,6 +19,7 @@ package org.apache.camel.dataformat.bindy.fix; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.dataformat.bindy.CommonBindyTest; import org.apache.camel.dataformat.bindy.kvp.BindyKeyValuePairDataFormat; +import org.apache.camel.dataformat.bindy.model.fix.sorted.body.Order; import org.junit.Assert; import org.junit.Test; import org.springframework.test.annotation.DirtiesContext; @@ -26,22 +27,23 @@ import org.springframework.test.context.ContextConfiguration; @ContextConfiguration public class BindySimpleKeyValuePairSortedUnmarshallTest extends CommonBindyTest { - + + @Test @DirtiesContext public void testUnMarshallMessage() throws Exception { result.expectedMessageCount(1); result.assertIsSatisfied(); - String body = result.getReceivedExchanges().get(0).getIn().getBody(String.class); + Order order = result.getReceivedExchanges().get(0).getIn().getBody(Order.class); - Assert.assertTrue(body.contains("10: 220")); - Assert.assertTrue(body.contains("BE.CHM.001, 11: CHM0001-01, 22: 4, 48: BE0001245678, 54: 1, 58: this is a camel - bindy test")); - Assert.assertTrue(body.contains("FIX.4.1, 9: 20, 34: 1 , 35: 0, 49: INVMGR, 56: BRKR")); + Assert.assertTrue(order.getTrailer().toString().contains("10: 220")); + Assert.assertTrue(order.toString().contains("BE.CHM.001, 11: CHM0001-01, 22: 4, 48: BE0001245678, 54: 1, 58: this is a camel - bindy test")); + Assert.assertTrue(order.getHeader().toString().contains("FIX.4.1, 9: 20, 34: 1 , 35: 0, 49: INVMGR, 56: BRKR")); } public static class ContextConfig extends RouteBuilder { - BindyKeyValuePairDataFormat kvpBindyDataFormat = new BindyKeyValuePairDataFormat(org.apache.camel.dataformat.bindy.model.fix.sorted.body.Order.class); + BindyKeyValuePairDataFormat kvpBindyDataFormat = new BindyKeyValuePairDataFormat(Order.class); public void configure() { from(URI_FILE_FIX).unmarshal(kvpBindyDataFormat).to(URI_MOCK_RESULT); http://git-wip-us.apache.org/repos/asf/camel/blob/355becba/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fix/BindySimpleKeyValuePairTabUnmarshallTest.java ---------------------------------------------------------------------- diff --git a/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fix/BindySimpleKeyValuePairTabUnmarshallTest.java b/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fix/BindySimpleKeyValuePairTabUnmarshallTest.java index 3e1a637..b3689c6 100644 --- a/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fix/BindySimpleKeyValuePairTabUnmarshallTest.java +++ b/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fix/BindySimpleKeyValuePairTabUnmarshallTest.java @@ -19,6 +19,7 @@ package org.apache.camel.dataformat.bindy.fix; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.dataformat.bindy.CommonBindyTest; import org.apache.camel.dataformat.bindy.kvp.BindyKeyValuePairDataFormat; +import org.apache.camel.dataformat.bindy.model.fix.tab.Order; import org.junit.Assert; import org.junit.Test; import org.springframework.test.annotation.DirtiesContext; @@ -33,18 +34,18 @@ public class BindySimpleKeyValuePairTabUnmarshallTest extends CommonBindyTest { result.expectedMessageCount(1); result.assertIsSatisfied(); - String body = result.getReceivedExchanges().get(0).getIn().getBody(String.class); - Assert.assertTrue(body.contains("FIX.4.1, 9: 20, 34: 1 , 35: 0, 49: INVMGR, 56: BRKR")); - Assert.assertTrue(body.contains("BE.CHM.001, 11: CHM0001-01, 22: 4, 48: BE0001245678, 54: 1, 58: this is a camel - bindy test")); - Assert.assertTrue(body.contains("10: 220")); + Order order = result.getReceivedExchanges().get(0).getIn().getBody(Order.class); + + Assert.assertTrue(order.getHeader().toString().contains("FIX.4.1, 9: 20, 34: 1 , 35: 0, 49: INVMGR, 56: BRKR")); + Assert.assertTrue(order.toString().contains("BE.CHM.001, 11: CHM0001-01, 22: 4, 48: BE0001245678, 54: 1, 58: this is a camel - bindy test")); + Assert.assertTrue(order.getTrailer().toString().contains("10: 220")); } public static class ContextConfig extends RouteBuilder { - BindyKeyValuePairDataFormat kvpBindyDataFormat = new BindyKeyValuePairDataFormat(org.apache.camel.dataformat.bindy.model.fix.tab.Order.class); + BindyKeyValuePairDataFormat kvpBindyDataFormat = new BindyKeyValuePairDataFormat(Order.class); public void configure() { from(URI_FILE_FIX_TAB).unmarshal(kvpBindyDataFormat).to(URI_MOCK_RESULT); } - } } http://git-wip-us.apache.org/repos/asf/camel/blob/355becba/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 fa08c65..357ae9d 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 @@ -18,6 +18,7 @@ package org.apache.camel.dataformat.bindy.fix; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.dataformat.bindy.CommonBindyTest; +import org.apache.camel.dataformat.bindy.model.fix.simple.Order; import org.apache.camel.model.dataformat.BindyType; import org.junit.Assert; import org.junit.Test; @@ -33,17 +34,18 @@ public class BindySimpleKeyValuePairUnmarshallDslTest extends CommonBindyTest { result.expectedMessageCount(1); result.assertIsSatisfied(); - String body = result.getReceivedExchanges().get(0).getIn().getBody(String.class); - Assert.assertTrue(body.contains("10: 220")); - Assert.assertTrue(body.contains("FIX.4.1, 9: 20, 34: 1 , 35: 0, 49: INVMGR, 56: BRKR")); - Assert.assertTrue(body.contains("BE.CHM.001, 11: CHM0001-01, 22: 4, 48: BE0001245678, 54: 1, 58: this is a camel - bindy test")); + Order order = result.getReceivedExchanges().get(0).getIn().getBody(Order.class); + + Assert.assertTrue(order.getTrailer().toString().contains("10: 220")); + Assert.assertTrue(order.getHeader().toString().contains("FIX.4.1, 9: 20, 34: 1 , 35: 0, 49: INVMGR, 56: BRKR")); + Assert.assertTrue(order.toString().contains("BE.CHM.001, 11: CHM0001-01, 22: 4, 48: BE0001245678, 54: 1, 58: this is a camel - bindy test")); } public static class ContextConfig extends RouteBuilder { public void configure() { from(URI_FILE_FIX).unmarshal() - .bindy(BindyType.KeyValue, org.apache.camel.dataformat.bindy.model.fix.simple.Order.class) + .bindy(BindyType.KeyValue,Order.class) .to(URI_MOCK_RESULT); } http://git-wip-us.apache.org/repos/asf/camel/blob/355becba/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fix/BindySimpleKeyValuePairUnmarshallTest.java ---------------------------------------------------------------------- diff --git a/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fix/BindySimpleKeyValuePairUnmarshallTest.java b/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fix/BindySimpleKeyValuePairUnmarshallTest.java index df063de..732515b 100644 --- a/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fix/BindySimpleKeyValuePairUnmarshallTest.java +++ b/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fix/BindySimpleKeyValuePairUnmarshallTest.java @@ -19,6 +19,7 @@ package org.apache.camel.dataformat.bindy.fix; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.dataformat.bindy.CommonBindyTest; import org.apache.camel.dataformat.bindy.kvp.BindyKeyValuePairDataFormat; +import org.apache.camel.dataformat.bindy.model.fix.simple.Order; import org.junit.Assert; import org.junit.Test; import org.springframework.test.annotation.DirtiesContext; @@ -33,14 +34,14 @@ public class BindySimpleKeyValuePairUnmarshallTest extends CommonBindyTest { result.expectedMessageCount(1); result.assertIsSatisfied(); - String body = result.getReceivedExchanges().get(0).getIn().getBody(String.class); - Assert.assertTrue(body.contains("10: 220")); - Assert.assertTrue(body.contains("FIX.4.1, 9: 20, 34: 1 , 35: 0, 49: INVMGR, 56: BRKR")); - Assert.assertTrue(body.contains("BE.CHM.001, 11: CHM0001-01, 22: 4, 48: BE0001245678, 54: 1, 58: this is a camel - bindy test")); + Order order = result.getReceivedExchanges().get(0).getIn().getBody(Order.class); + Assert.assertTrue(order.getTrailer().toString().contains("10: 220")); + Assert.assertTrue(order.getHeader().toString().contains("FIX.4.1, 9: 20, 34: 1 , 35: 0, 49: INVMGR, 56: BRKR")); + Assert.assertTrue(order.toString().contains("BE.CHM.001, 11: CHM0001-01, 22: 4, 48: BE0001245678, 54: 1, 58: this is a camel - bindy test")); } public static class ContextConfig extends RouteBuilder { - BindyKeyValuePairDataFormat kvpBindyDataFormat = new BindyKeyValuePairDataFormat(org.apache.camel.dataformat.bindy.model.fix.simple.Order.class); + BindyKeyValuePairDataFormat kvpBindyDataFormat = new BindyKeyValuePairDataFormat(Order.class); public void configure() { from(URI_FILE_FIX).unmarshal(kvpBindyDataFormat).to(URI_MOCK_RESULT); http://git-wip-us.apache.org/repos/asf/camel/blob/355becba/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/headerfooter/Order.java ---------------------------------------------------------------------- diff --git a/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/headerfooter/Order.java b/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/headerfooter/Order.java index 1f8e0e7..b4cbbcb 100644 --- a/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/headerfooter/Order.java +++ b/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/headerfooter/Order.java @@ -22,7 +22,7 @@ import java.util.Date; import org.apache.camel.dataformat.bindy.annotation.DataField; import org.apache.camel.dataformat.bindy.annotation.FixedLengthRecord; -@FixedLengthRecord(hasHeader = true, hasFooter = true) +@FixedLengthRecord(header = OrderHeader.class, footer = OrderFooter.class) public class Order { @DataField(pos = 1, length = 2) http://git-wip-us.apache.org/repos/asf/camel/blob/355becba/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/headerfooter/OrderFooter.java ---------------------------------------------------------------------- diff --git a/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/headerfooter/OrderFooter.java b/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/headerfooter/OrderFooter.java index d025cb2..5b4b21f 100644 --- a/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/headerfooter/OrderFooter.java +++ b/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/headerfooter/OrderFooter.java @@ -19,7 +19,7 @@ package org.apache.camel.dataformat.bindy.fixed.headerfooter; import org.apache.camel.dataformat.bindy.annotation.DataField; import org.apache.camel.dataformat.bindy.annotation.FixedLengthRecord; -@FixedLengthRecord(isFooter = true) +@FixedLengthRecord public class OrderFooter { @DataField(pos = 1, length = 1) http://git-wip-us.apache.org/repos/asf/camel/blob/355becba/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/headerfooter/OrderHeader.java ---------------------------------------------------------------------- diff --git a/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/headerfooter/OrderHeader.java b/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/headerfooter/OrderHeader.java index 0ca3a6c..f364ef8 100644 --- a/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/headerfooter/OrderHeader.java +++ b/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/headerfooter/OrderHeader.java @@ -21,7 +21,7 @@ import java.util.Date; import org.apache.camel.dataformat.bindy.annotation.DataField; import org.apache.camel.dataformat.bindy.annotation.FixedLengthRecord; -@FixedLengthRecord(isHeader = true) +@FixedLengthRecord public class OrderHeader { @DataField(pos = 1, length = 1) private int recordType = 1; http://git-wip-us.apache.org/repos/asf/camel/blob/355becba/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/link/BindySimpleFixedLengthWithLinkTest.java ---------------------------------------------------------------------- diff --git a/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/link/BindySimpleFixedLengthWithLinkTest.java b/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/link/BindySimpleFixedLengthWithLinkTest.java index 0bc6fcc..323befd 100644 --- a/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/link/BindySimpleFixedLengthWithLinkTest.java +++ b/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/link/BindySimpleFixedLengthWithLinkTest.java @@ -16,10 +16,6 @@ */ package org.apache.camel.dataformat.bindy.fixed.link; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - import org.apache.camel.EndpointInject; import org.apache.camel.Exchange; import org.apache.camel.builder.RouteBuilder; @@ -62,23 +58,11 @@ public class BindySimpleFixedLengthWithLinkTest extends CamelTestSupport { // check the model Exchange exchange = unmarshallResult.getReceivedExchanges().get(0); - List<HashMap<String, Object>> results = (List) exchange.getIn().getBody(); - String orderKey = "org.apache.camel.dataformat.bindy.fixed.link.BindySimpleFixedLengthWithLinkTest$Order"; - - for (int i = 0; i < results.size(); i++) { - Map<String, Object> map = results.get(i); - for (String key : map.keySet()) { - if (key.equals(orderKey)) { - Order order = (Order) map.get(orderKey); - assertEquals("AAA", order.fieldA); - assertEquals("CCC", order.fieldC); - assertEquals("BBB", order.subRec.fieldB); - } - } - - } - - + Order order = exchange.getIn().getBody(Order.class); + + assertEquals("AAA", order.fieldA); + assertEquals("CCC", order.fieldC); + assertEquals("BBB", order.subRec.fieldB); } // ************************************************************************* http://git-wip-us.apache.org/repos/asf/camel/blob/355becba/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/skipheader/Order.java ---------------------------------------------------------------------- diff --git a/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/skipheader/Order.java b/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/skipheader/Order.java index 476db12..c8c67b8 100644 --- a/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/skipheader/Order.java +++ b/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/skipheader/Order.java @@ -22,7 +22,7 @@ import java.util.Date; import org.apache.camel.dataformat.bindy.annotation.DataField; import org.apache.camel.dataformat.bindy.annotation.FixedLengthRecord; -@FixedLengthRecord(hasHeader = true, hasFooter = true, skipHeader = true) +@FixedLengthRecord(header = OrderHeader.class, footer = OrderFooter.class, skipHeader = true) public class Order { @DataField(pos = 1, length = 2) http://git-wip-us.apache.org/repos/asf/camel/blob/355becba/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/skipheader/OrderFooter.java ---------------------------------------------------------------------- diff --git a/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/skipheader/OrderFooter.java b/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/skipheader/OrderFooter.java index cb638ac..c652943 100644 --- a/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/skipheader/OrderFooter.java +++ b/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/skipheader/OrderFooter.java @@ -19,7 +19,7 @@ package org.apache.camel.dataformat.bindy.fixed.skipheader; import org.apache.camel.dataformat.bindy.annotation.DataField; import org.apache.camel.dataformat.bindy.annotation.FixedLengthRecord; -@FixedLengthRecord(isFooter = true) +@FixedLengthRecord public class OrderFooter { @DataField(pos = 1, length = 1) http://git-wip-us.apache.org/repos/asf/camel/blob/355becba/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/skipheader/OrderHeader.java ---------------------------------------------------------------------- diff --git a/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/skipheader/OrderHeader.java b/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/skipheader/OrderHeader.java index 82209b0..ec60156 100644 --- a/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/skipheader/OrderHeader.java +++ b/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/skipheader/OrderHeader.java @@ -21,7 +21,7 @@ import java.util.Date; import org.apache.camel.dataformat.bindy.annotation.DataField; import org.apache.camel.dataformat.bindy.annotation.FixedLengthRecord; -@FixedLengthRecord(isHeader = true) +@FixedLengthRecord public class OrderHeader { @DataField(pos = 1, length = 1) private int recordType = 1; http://git-wip-us.apache.org/repos/asf/camel/blob/355becba/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/unmarshall/simple/trim/BindySimpleFixedLengthUnmarshallTest.java ---------------------------------------------------------------------- diff --git a/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/unmarshall/simple/trim/BindySimpleFixedLengthUnmarshallTest.java b/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/unmarshall/simple/trim/BindySimpleFixedLengthUnmarshallTest.java index b5f268b..d16b278 100644 --- a/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/unmarshall/simple/trim/BindySimpleFixedLengthUnmarshallTest.java +++ b/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/unmarshall/simple/trim/BindySimpleFixedLengthUnmarshallTest.java @@ -18,8 +18,6 @@ package org.apache.camel.dataformat.bindy.fixed.unmarshall.simple.trim; import java.math.BigDecimal; import java.util.Date; -import java.util.List; -import java.util.Map; import org.apache.camel.EndpointInject; import org.apache.camel.Produce; @@ -61,8 +59,7 @@ public class BindySimpleFixedLengthUnmarshallTest extends AbstractJUnit4SpringCo result.assertIsSatisfied(); // 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(); + BindySimpleFixedLengthUnmarshallTest.Order order = result.getReceivedExchanges().get(0).getIn().getBody(BindySimpleFixedLengthUnmarshallTest.Order.class); Assert.assertEquals(10, order.getOrderNr()); // the field is not trimmed Assert.assertEquals(" Pauline", order.getFirstName()); http://git-wip-us.apache.org/repos/asf/camel/blob/355becba/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/unmarshall/simple/trimfield/BindySimpleFixedLengthUnmarshallTrimFieldTest.java ---------------------------------------------------------------------- diff --git a/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/unmarshall/simple/trimfield/BindySimpleFixedLengthUnmarshallTrimFieldTest.java b/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/unmarshall/simple/trimfield/BindySimpleFixedLengthUnmarshallTrimFieldTest.java index f121a7a..e26dcae 100644 --- a/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/unmarshall/simple/trimfield/BindySimpleFixedLengthUnmarshallTrimFieldTest.java +++ b/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/fixed/unmarshall/simple/trimfield/BindySimpleFixedLengthUnmarshallTrimFieldTest.java @@ -18,8 +18,6 @@ package org.apache.camel.dataformat.bindy.fixed.unmarshall.simple.trimfield; import java.math.BigDecimal; import java.util.Date; -import java.util.List; -import java.util.Map; import org.apache.camel.EndpointInject; import org.apache.camel.Produce; @@ -61,8 +59,8 @@ public class BindySimpleFixedLengthUnmarshallTrimFieldTest extends AbstractJUnit result.assertIsSatisfied(); // check the model - Map<?, ?> map = (Map<?, ?>) result.getReceivedExchanges().get(0).getIn().getBody(List.class).get(0); - BindySimpleFixedLengthUnmarshallTrimFieldTest.Order order = (BindySimpleFixedLengthUnmarshallTrimFieldTest.Order) map.values().iterator().next(); + + BindySimpleFixedLengthUnmarshallTrimFieldTest.Order order = result.getReceivedExchanges().get(0).getIn().getBody(BindySimpleFixedLengthUnmarshallTrimFieldTest.Order.class); Assert.assertEquals(10, order.getOrderNr()); // the field is not trimmed Assert.assertEquals("Pauline", order.getFirstName()); http://git-wip-us.apache.org/repos/asf/camel/blob/355becba/components/camel-bindy/src/test/resources/org/apache/camel/dataformat/bindy/csv/BindySimpleCsvUnmarshallDslTest-context.xml ---------------------------------------------------------------------- diff --git a/components/camel-bindy/src/test/resources/org/apache/camel/dataformat/bindy/csv/BindySimpleCsvUnmarshallDslTest-context.xml b/components/camel-bindy/src/test/resources/org/apache/camel/dataformat/bindy/csv/BindySimpleCsvUnmarshallDslTest-context.xml index 8ac0b90..77ba6ad 100644 --- a/components/camel-bindy/src/test/resources/org/apache/camel/dataformat/bindy/csv/BindySimpleCsvUnmarshallDslTest-context.xml +++ b/components/camel-bindy/src/test/resources/org/apache/camel/dataformat/bindy/csv/BindySimpleCsvUnmarshallDslTest-context.xml @@ -32,7 +32,7 @@ </camelContext> <bean id="csvBindyDataformat" class="org.apache.camel.dataformat.bindy.csv.BindyCsvDataFormat"> - <constructor-arg value="org.apache.camel.dataformat.bindy.model.simple.oneclass" /> + <constructor-arg value="org.apache.camel.dataformat.bindy.model.simple.oneclass.Order" /> </bean> </beans> \ No newline at end of file