Author: davsclaus
Date: Sat Apr 16 13:54:09 2011
New Revision: 1093999
URL: http://svn.apache.org/viewvc?rev=1093999&view=rev
Log:
CAMEL-3872: Added test based on user forum issue.
Added:
camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindyCarQuoteAndCommaDelimiterTest.java
(with props)
camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/car/
camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/car/Car.java
(with props)
Added:
camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindyCarQuoteAndCommaDelimiterTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindyCarQuoteAndCommaDelimiterTest.java?rev=1093999&view=auto
==============================================================================
---
camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindyCarQuoteAndCommaDelimiterTest.java
(added)
+++
camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindyCarQuoteAndCommaDelimiterTest.java
Sat Apr 16 13:54:09 2011
@@ -0,0 +1,79 @@
+/**
+ * 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 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;
+import org.apache.camel.model.dataformat.BindyType;
+import org.apache.camel.test.CamelTestSupport;
+import org.junit.Test;
+
+/**
+ * @version
+ */
+public class BindyCarQuoteAndCommaDelimiterTest extends CamelTestSupport {
+
+ @Test
+ public void testBindyQuoteAndCommaDelimiter() throws Exception {
+ MockEndpoint mock = getMockEndpoint("mock:result");
+ mock.expectedMessageCount(1);
+
+ String header =
"\"stockid\";\"make\";\"model\";\"deriv\";\"series\";\"registration\";\"chassis\";\"engine\";\"year\""
+ +
";\"klms\";\"body\";\"colour\";\"enginesize\";\"trans\";\"fuel\";\"options\";\"desc\";\"status\";\"Reserve_price\";\"nvic\"";
+ String row = "\"SS552\";\"TOYOTA\";\"KLUGER\";\"CV 4X4\";\"MCU28R
UPGRADE\";\"TBA\";\"\";\"\";\"2005\";\"155000\";\"4D WAGON\""
+ + ";\"BLACK\";\"3.3 LTR\";\"5 Sp Auto\";\"MULTI POINT
FINJ\";\"POWER MIRRORS, POWER STEERING, POWER WINDOWS, CRUISE CONTROL,"
+ + " ENGINE IMMOBILISER, BRAKE ASSIST, DUAL AIRBAG PACKAGE,
ANTI-LOCK BRAKING, CENTRAL LOCKING REMOTE CONTROL, ALARM SYSTEM/REMOTE"
+ + " ANTI THEFT, AUTOMATIC AIR CON / CLIMATE CONTROL,
ELECTRONIC BRAKE FORCE DISTRIBUTION, CLOTH TRIM, LIMITED SLIP DIFFERENTIAL,"
+ + " RADIO CD WITH 6 SPEAKERS\";\"Dual Airbag Package,
Anti-lock Braking, Automatic Air Con / Climate Control, Alarm System/Remote"
+ + " Anti Theft, Brake Assist, Cruise Control, Central Locking
Remote Control, Cloth Trim, Electronic Brake Force Distribution,"
+ + " Engine Immobiliser, Limited Slip Differential, Power
Mirrors, Power Steering, Power Windows, Radio CD with 6 Speakers"
+ + " CV GOOD KLMS AUTO POWER OPTIONS GOOD KLMS
\";\"Used\";\"\";\"EZR05I\" ";
+
+ template.sendBody("direct:start", header + "\n" + row);
+
+ assertMockEndpointsSatisfied();
+
+ Map map1 = (Map)
mock.getReceivedExchanges().get(0).getIn().getBody(List.class).get(0);
+
+ Car rec1 = (Car) map1.values().iterator().next();
+
+ assertEquals("SS552", rec1.getStockid());
+ assertEquals("TOYOTA", rec1.getMake());
+ assertEquals("KLUGER", rec1.getModel());
+ assertEquals(2005, rec1.getYear());
+ assertEquals(Double.valueOf("155000.0"), rec1.getKlms());
+ assertEquals("EZR05I", rec1.getNvic());
+ assertEquals("Used", rec1.getStatus());
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("direct:start")
+ .unmarshal().bindy(BindyType.Csv,
"org.apache.camel.dataformat.bindy.model.car")
+ .to("mock:result");
+ }
+ };
+ }
+
+}
Propchange:
camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindyCarQuoteAndCommaDelimiterTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindyCarQuoteAndCommaDelimiterTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added:
camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/car/Car.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/car/Car.java?rev=1093999&view=auto
==============================================================================
---
camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/car/Car.java
(added)
+++
camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/car/Car.java
Sat Apr 16 13:54:09 2011
@@ -0,0 +1,228 @@
+/**
+ * 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.model.car;
+
+import org.apache.camel.dataformat.bindy.annotation.CsvRecord;
+import org.apache.camel.dataformat.bindy.annotation.DataField;
+
+/**
+ *
+ */
+@CsvRecord(separator = "\";\"", skipFirstLine = true)
+public class Car {
+
+ @DataField(pos = 1)
+ private String stockid;
+ @DataField(pos = 2)
+ private String make;
+ @DataField(pos = 3)
+ private String model;
+ @DataField(pos = 4)
+ private String deriv;
+ @DataField(pos = 5)
+ private String series;
+ @DataField(pos = 6)
+ private String registration;
+ @DataField(pos = 7)
+ private String chassis;
+ @DataField(pos = 8)
+ private String engine;
+ @DataField(pos = 9)
+ private int year;
+ @DataField(pos = 10, precision = 1)
+ private double klms;
+ @DataField(pos = 11)
+ private String body;
+ @DataField(pos = 12)
+ private String colour;
+ @DataField(pos = 13)
+ private String enginesize;
+ @DataField(pos = 14)
+ private String trans;
+ @DataField(pos = 15)
+ private String fuel;
+ @DataField(pos = 16)
+ private String options;
+ @DataField(pos = 17)
+ private String desc;
+ @DataField(pos = 18)
+ private String status;
+ @DataField(pos = 19, precision = 1)
+ private double price;
+ @DataField(pos = 20)
+ private String nvic;
+
+ public String getStockid() {
+ return stockid;
+ }
+
+ public void setStockid(String stockid) {
+ this.stockid = stockid;
+ }
+
+ public String getMake() {
+ return make;
+ }
+
+ public void setMake(String make) {
+ this.make = make;
+ }
+
+ public String getModel() {
+ return model;
+ }
+
+ public void setModel(String model) {
+ this.model = model;
+ }
+
+ public String getDeriv() {
+ return deriv;
+ }
+
+ public void setDeriv(String deriv) {
+ this.deriv = deriv;
+ }
+
+ public String getSeries() {
+ return series;
+ }
+
+ public void setSeries(String series) {
+ this.series = series;
+ }
+
+ public String getRegistration() {
+ return registration;
+ }
+
+ public void setRegistration(String registration) {
+ this.registration = registration;
+ }
+
+ public String getChassis() {
+ return chassis;
+ }
+
+ public void setChassis(String chassis) {
+ this.chassis = chassis;
+ }
+
+ public String getEngine() {
+ return engine;
+ }
+
+ public void setEngine(String engine) {
+ this.engine = engine;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+
+ public double getKlms() {
+ return klms;
+ }
+
+ public void setKlms(double klms) {
+ this.klms = klms;
+ }
+
+ public String getBody() {
+ return body;
+ }
+
+ public void setBody(String body) {
+ this.body = body;
+ }
+
+ public String getColour() {
+ return colour;
+ }
+
+ public void setColour(String colour) {
+ this.colour = colour;
+ }
+
+ public String getEnginesize() {
+ return enginesize;
+ }
+
+ public void setEnginesize(String enginesize) {
+ this.enginesize = enginesize;
+ }
+
+ public String getTrans() {
+ return trans;
+ }
+
+ public void setTrans(String trans) {
+ this.trans = trans;
+ }
+
+ public String getFuel() {
+ return fuel;
+ }
+
+ public void setFuel(String fuel) {
+ this.fuel = fuel;
+ }
+
+ public String getOptions() {
+ return options;
+ }
+
+ public void setOptions(String options) {
+ this.options = options;
+ }
+
+ public String getDesc() {
+ return desc;
+ }
+
+ public void setDesc(String desc) {
+ this.desc = desc;
+ }
+
+ public String getStatus() {
+ return status;
+ }
+
+ public void setStatus(String status) {
+ this.status = status;
+ }
+
+ public double getPrice() {
+ return price;
+ }
+
+ public void setPrice(double price) {
+ this.price = price;
+ }
+
+ public String getNvic() {
+ return nvic;
+ }
+
+ public void setNvic(String nvic) {
+ this.nvic = nvic;
+ }
+}
Propchange:
camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/car/Car.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/car/Car.java
------------------------------------------------------------------------------
svn:keywords = Rev Date