camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cmuel...@apache.org
Subject svn commit: r1187859 - in /camel/branches/camel-2.7.x/components/camel-flatpack/src: main/java/org/apache/camel/component/flatpack/ test/java/org/apache/camel/component/flatpack/
Date Sun, 23 Oct 2011 10:23:01 GMT
Author: cmueller
Date: Sun Oct 23 10:23:01 2011
New Revision: 1187859

URL: http://svn.apache.org/viewvc?rev=1187859&view=rev
Log:
CAMEL-4510: Camel flatpack component drops all headers from the original message

Modified:
    camel/branches/camel-2.7.x/components/camel-flatpack/src/main/java/org/apache/camel/component/flatpack/FixedLengthEndpoint.java
    camel/branches/camel-2.7.x/components/camel-flatpack/src/main/java/org/apache/camel/component/flatpack/FlatpackProducer.java
    camel/branches/camel-2.7.x/components/camel-flatpack/src/test/java/org/apache/camel/component/flatpack/FlatpackFixedLengthWithHeaderAndTrailerDataFormatTest.java

Modified: camel/branches/camel-2.7.x/components/camel-flatpack/src/main/java/org/apache/camel/component/flatpack/FixedLengthEndpoint.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.7.x/components/camel-flatpack/src/main/java/org/apache/camel/component/flatpack/FixedLengthEndpoint.java?rev=1187859&r1=1187858&r2=1187859&view=diff
==============================================================================
--- camel/branches/camel-2.7.x/components/camel-flatpack/src/main/java/org/apache/camel/component/flatpack/FixedLengthEndpoint.java
(original)
+++ camel/branches/camel-2.7.x/components/camel-flatpack/src/main/java/org/apache/camel/component/flatpack/FixedLengthEndpoint.java
Sun Oct 23 10:23:01 2011
@@ -67,17 +67,12 @@ public class FixedLengthEndpoint extends
         return new LoadBalancerConsumer(this, processor, loadBalancer);
     }
 
-    public void processDataSet(DataSet dataSet, int counter) throws Exception {
-        Exchange exchange = createExchange(dataSet, counter);
-        loadBalancer.process(exchange);
-    }
-
-    public Exchange createExchange(DataSet dataSet, int counter) {
-        Exchange answer = createExchange();
-        Message in = answer.getIn();
+    public void processDataSet(Exchange originalExchange, DataSet dataSet, int counter) throws
Exception {
+        Exchange exchange = originalExchange.copy();
+        Message in = exchange.getIn();
         in.setBody(dataSet);
-        in.setHeader("camelFlatpackCounter", counter);
-        return answer;
+        in.setHeader("CamelFlatpackCounter", counter);
+        loadBalancer.process(exchange);
     }
 
     public Parser createParser(Exchange exchange) throws InvalidPayloadException, IOException
{

Modified: camel/branches/camel-2.7.x/components/camel-flatpack/src/main/java/org/apache/camel/component/flatpack/FlatpackProducer.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.7.x/components/camel-flatpack/src/main/java/org/apache/camel/component/flatpack/FlatpackProducer.java?rev=1187859&r1=1187858&r2=1187859&view=diff
==============================================================================
--- camel/branches/camel-2.7.x/components/camel-flatpack/src/main/java/org/apache/camel/component/flatpack/FlatpackProducer.java
(original)
+++ camel/branches/camel-2.7.x/components/camel-flatpack/src/main/java/org/apache/camel/component/flatpack/FlatpackProducer.java
Sun Oct 23 10:23:01 2011
@@ -39,10 +39,10 @@ class FlatpackProducer extends DefaultPr
         if (endpoint.isSplitRows()) {
             int counter = 0;
             while (dataSet.next()) {
-                endpoint.processDataSet(dataSet, counter++);
+                endpoint.processDataSet(exchange, dataSet, counter++);
             }
         } else {
-            endpoint.processDataSet(dataSet, dataSet.getRowCount());
+            endpoint.processDataSet(exchange, dataSet, dataSet.getRowCount());
         }
     }
 }

Modified: camel/branches/camel-2.7.x/components/camel-flatpack/src/test/java/org/apache/camel/component/flatpack/FlatpackFixedLengthWithHeaderAndTrailerDataFormatTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.7.x/components/camel-flatpack/src/test/java/org/apache/camel/component/flatpack/FlatpackFixedLengthWithHeaderAndTrailerDataFormatTest.java?rev=1187859&r1=1187858&r2=1187859&view=diff
==============================================================================
--- camel/branches/camel-2.7.x/components/camel-flatpack/src/test/java/org/apache/camel/component/flatpack/FlatpackFixedLengthWithHeaderAndTrailerDataFormatTest.java
(original)
+++ camel/branches/camel-2.7.x/components/camel-flatpack/src/test/java/org/apache/camel/component/flatpack/FlatpackFixedLengthWithHeaderAndTrailerDataFormatTest.java
Sun Oct 23 10:23:01 2011
@@ -38,6 +38,8 @@ public class FlatpackFixedLengthWithHead
         // by default we get on big message
         mock.expectedMessageCount(1);
         mock.message(0).body().isInstanceOf(DataSetList.class);
+        mock.message(0).header("MyFirstHeader").isEqualTo("1");
+        mock.message(0).header("MySecondHeader").isEqualTo("2");
 
         String data = IOConverter.toString(new File("src/test/data/headerandtrailer/PEOPLE-HeaderAndTrailer.txt").getAbsoluteFile(),
null);
 
@@ -74,7 +76,11 @@ public class FlatpackFixedLengthWithHead
                 df.setDefinition(new ClassPathResource("PEOPLE-HeaderAndTrailer.pzmap.xml"));
                 df.setFixed(true);
 
-                from("direct:unmarshal").unmarshal(df).to("mock:unmarshal");
+                from("direct:unmarshal")
+                    .setHeader("MyFirstHeader", constant("1"))
+                    .unmarshal(df)
+                    .setHeader("MySecondHeader", constant("2"))
+                    .to("mock:unmarshal");
 
                 // with the definition
                 from("direct:marshal").marshal(df).convertBodyTo(String.class).to("mock:marshal");



Mime
View raw message