camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hadr...@apache.org
Subject svn commit: r1463772 - in /camel/trunk/components/camel-bindy/src: main/java/org/apache/camel/dataformat/bindy/ main/java/org/apache/camel/dataformat/bindy/fixed/ test/java/org/apache/camel/dataformat/bindy/csv/ test/java/org/apache/camel/dataformat/bi...
Date Tue, 02 Apr 2013 21:56:47 GMT
Author: hadrian
Date: Tue Apr  2 21:56:46 2013
New Revision: 1463772

URL: http://svn.apache.org/r1463772
Log:
CAMEL-6234. Add validation for multple models in the same package

Added:
    camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindyCsvFieldEndingWithSeparatorIssueTest.java
  (contents, props changed)
      - copied, changed from r1463377, camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindyCVSFieldEndingWithSeparatorIssueTest.java
    camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/csv/
    camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/csv/MyCsvRecord.java
  (contents, props changed)
      - copied, changed from r1463377, camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/MyCsvRecord.java
    camel/trunk/components/camel-bindy/src/test/resources/org/apache/camel/dataformat/bindy/csv/BindyCsvUnmarshallTest-context.xml
  (contents, props changed)
      - copied, changed from r1463377, camel/trunk/components/camel-bindy/src/test/resources/org/apache/camel/dataformat/bindy/csv/BindyCSVUnmarshallTest-context.xml
Removed:
    camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindyCVSFieldEndingWithSeparatorIssueTest.java
    camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/MyCsvRecord.java
    camel/trunk/components/camel-bindy/src/test/resources/org/apache/camel/dataformat/bindy/csv/BindyCSVUnmarshallTest-context.xml
Modified:
    camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyCsvFactory.java
    camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/fixed/BindyFixedLengthDataFormat.java

Modified: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyCsvFactory.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyCsvFactory.java?rev=1463772&r1=1463771&r2=1463772&view=diff
==============================================================================
--- camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyCsvFactory.java
(original)
+++ camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/BindyCsvFactory.java
Tue Apr  2 21:56:46 2013
@@ -102,8 +102,8 @@ public class BindyCsvFactory extends Bin
 
     public void initAnnotatedFields() {
 
+    	int maxpos = 0;
         for (Class<?> cl : models) {
-
             List<Field> linkFields = new ArrayList<Field>();
 
             if (LOG.isDebugEnabled()) {
@@ -124,8 +124,14 @@ public class BindyCsvFactory extends Bin
                         ++numberOptionalFields;
                     }
 
-                    dataFields.put(dataField.pos(), dataField);
-                    annotatedFields.put(dataField.pos(), field);
+                    int pos = dataField.pos();
+                    if (annotatedFields.containsKey(pos)) {
+                    	Field f = annotatedFields.get(pos);
+                    	LOG.warn("Potentially invalid model: existing @DataField '{}' replaced
by '{}'", f.getName(), field.getName());
+                    }
+                    dataFields.put(pos, dataField);
+                    annotatedFields.put(pos, field);
+                    maxpos = Math.max(maxpos, pos);
                 }
 
                 Link linkField = field.getAnnotation(Link.class);
@@ -136,7 +142,6 @@ public class BindyCsvFactory extends Bin
                     }
                     linkFields.add(field);
                 }
-
             }
 
             if (!linkFields.isEmpty()) {
@@ -151,6 +156,10 @@ public class BindyCsvFactory extends Bin
                 LOG.debug("Total: {}", totalFields);
             }
         }
+
+        if (annotatedFields.size() < maxpos) {
+        	LOG.info("Potentially incomplete model: some csv fields may not be mapped to @DataField
members");
+        }
     }
 
     public void bind(List<String> tokens, Map<String, Object> model, int line)
throws Exception {
@@ -512,7 +521,7 @@ public class BindyCsvFactory extends Bin
     }
 
     /**
-     * Get parameters defined in @Csvrecord annotation
+     * Get parameters defined in @CsvRecord annotation
      */
     private void initCsvRecordParameters() {
         if (separator == null) {

Modified: camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/fixed/BindyFixedLengthDataFormat.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/fixed/BindyFixedLengthDataFormat.java?rev=1463772&r1=1463771&r2=1463772&view=diff
==============================================================================
--- camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/fixed/BindyFixedLengthDataFormat.java
(original)
+++ camel/trunk/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/fixed/BindyFixedLengthDataFormat.java
Tue Apr  2 21:56:46 2013
@@ -118,7 +118,7 @@ public class BindyFixedLengthDataFormat 
                 // only use the header factory if the row is the header
                 if (headerFactory.supportsModel(modelClassNames)) {
                     if (factory.skipHeader())  {
-                        LOG.warn("Skipping marshal of header row; 'skipHeader=true'");
+                        LOG.info("Skipping marshal of header row; 'skipHeader=true'");
                         continue;
                     } else {
                         result = headerFactory.unbind(model);
@@ -130,7 +130,7 @@ public class BindyFixedLengthDataFormat 
                 // only use the header factory if the row is the header
                 if (footerFactory.supportsModel(modelClassNames)) {
                     if (factory.skipFooter()) {
-                        LOG.warn("Skipping marshal of footer row; 'skipFooter=true'");
+                        LOG.info("Skipping marshal of footer row; 'skipFooter=true'");
                         continue;
                     } else {
                         result = footerFactory.unbind(model);

Copied: camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindyCsvFieldEndingWithSeparatorIssueTest.java
(from r1463377, camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindyCVSFieldEndingWithSeparatorIssueTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindyCsvFieldEndingWithSeparatorIssueTest.java?p2=camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindyCsvFieldEndingWithSeparatorIssueTest.java&p1=camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindyCVSFieldEndingWithSeparatorIssueTest.java&r1=1463377&r2=1463772&rev=1463772&view=diff
==============================================================================
--- camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindyCVSFieldEndingWithSeparatorIssueTest.java
(original)
+++ camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindyCsvFieldEndingWithSeparatorIssueTest.java
Tue Apr  2 21:56:46 2013
@@ -20,8 +20,10 @@ import org.apache.camel.CamelContext;
 import org.apache.camel.ProducerTemplate;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.dataformat.bindy.model.csv.MyCsvRecord;
 import org.apache.camel.impl.DefaultCamelContext;
 import org.apache.camel.model.dataformat.BindyType;
+
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.junit.Ignore;
 import org.junit.Test;
@@ -34,7 +36,7 @@ import org.junit.Test;
  * !!! The separator in the beginning of the quoted field is still not handled.
  *
  */
-public class BindyCVSFieldEndingWithSeparatorIssueTest extends CamelTestSupport {
+public class BindyCsvFieldEndingWithSeparatorIssueTest extends CamelTestSupport {
 
     @Test
     public void testBindy() throws Exception {

Propchange: camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/BindyCsvFieldEndingWithSeparatorIssueTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/csv/MyCsvRecord.java
(from r1463377, camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/MyCsvRecord.java)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/csv/MyCsvRecord.java?p2=camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/csv/MyCsvRecord.java&p1=camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/MyCsvRecord.java&r1=1463377&r2=1463772&rev=1463772&view=diff
==============================================================================
--- camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/csv/MyCsvRecord.java
(original)
+++ camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/csv/MyCsvRecord.java
Tue Apr  2 21:56:46 2013
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.camel.dataformat.bindy.csv;
+package org.apache.camel.dataformat.bindy.model.csv;
 
 import java.io.Serializable;
 

Propchange: camel/trunk/components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/csv/MyCsvRecord.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: camel/trunk/components/camel-bindy/src/test/resources/org/apache/camel/dataformat/bindy/csv/BindyCsvUnmarshallTest-context.xml
(from r1463377, camel/trunk/components/camel-bindy/src/test/resources/org/apache/camel/dataformat/bindy/csv/BindyCSVUnmarshallTest-context.xml)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bindy/src/test/resources/org/apache/camel/dataformat/bindy/csv/BindyCsvUnmarshallTest-context.xml?p2=camel/trunk/components/camel-bindy/src/test/resources/org/apache/camel/dataformat/bindy/csv/BindyCsvUnmarshallTest-context.xml&p1=camel/trunk/components/camel-bindy/src/test/resources/org/apache/camel/dataformat/bindy/csv/BindyCSVUnmarshallTest-context.xml&r1=1463377&r2=1463772&rev=1463772&view=diff
==============================================================================
    (empty)

Propchange: camel/trunk/components/camel-bindy/src/test/resources/org/apache/camel/dataformat/bindy/csv/BindyCsvUnmarshallTest-context.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-bindy/src/test/resources/org/apache/camel/dataformat/bindy/csv/BindyCsvUnmarshallTest-context.xml
------------------------------------------------------------------------------
    svn:executable = *

Propchange: camel/trunk/components/camel-bindy/src/test/resources/org/apache/camel/dataformat/bindy/csv/BindyCsvUnmarshallTest-context.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: camel/trunk/components/camel-bindy/src/test/resources/org/apache/camel/dataformat/bindy/csv/BindyCsvUnmarshallTest-context.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml



Mime
View raw message