You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by dk...@apache.org on 2011/09/19 22:50:05 UTC
svn commit: r1172811 - in /camel/branches/camel-2.8.x: ./
camel-core/src/main/java/org/apache/camel/processor/Splitter.java
camel-core/src/test/java/org/apache/camel/processor/SplitterTest.java
Author: dkulp
Date: Mon Sep 19 20:50:04 2011
New Revision: 1172811
URL: http://svn.apache.org/viewvc?rev=1172811&view=rev
Log:
Merged revisions 1158140 via svnmerge from
https://svn.apache.org/repos/asf/camel/trunk
........
r1158140 | davsclaus | 2011-08-16 03:49:07 -0400 (Tue, 16 Aug 2011) | 1 line
CAMEL-4310: Splitter in streaming mode set split size header on the completed exchange. Thanks to Sebastien Petrucci for the patch.
........
Modified:
camel/branches/camel-2.8.x/ (props changed)
camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/processor/Splitter.java
camel/branches/camel-2.8.x/camel-core/src/test/java/org/apache/camel/processor/SplitterTest.java
Propchange: camel/branches/camel-2.8.x/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.
Modified: camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/processor/Splitter.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/processor/Splitter.java?rev=1172811&r1=1172810&r2=1172811&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/processor/Splitter.java (original)
+++ camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/processor/Splitter.java Mon Sep 19 20:50:04 2011
@@ -188,12 +188,15 @@ public class Splitter extends MulticastP
exchange.setProperty(Exchange.SPLIT_INDEX, index);
if (allPairs instanceof Collection) {
+ // non streaming mode, so we know the total size already
exchange.setProperty(Exchange.SPLIT_SIZE, ((Collection<?>) allPairs).size());
}
if (it.hasNext()) {
exchange.setProperty(Exchange.SPLIT_COMPLETE, Boolean.FALSE);
} else {
exchange.setProperty(Exchange.SPLIT_COMPLETE, Boolean.TRUE);
+ // streaming mode, so set total size when we are complete based on the index
+ exchange.setProperty(Exchange.SPLIT_SIZE, index + 1);
}
}
Modified: camel/branches/camel-2.8.x/camel-core/src/test/java/org/apache/camel/processor/SplitterTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/camel-core/src/test/java/org/apache/camel/processor/SplitterTest.java?rev=1172811&r1=1172810&r2=1172811&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/camel-core/src/test/java/org/apache/camel/processor/SplitterTest.java (original)
+++ camel/branches/camel-2.8.x/camel-core/src/test/java/org/apache/camel/processor/SplitterTest.java Mon Sep 19 20:50:04 2011
@@ -176,10 +176,21 @@ public class SplitterTest extends Contex
});
assertMockEndpointsSatisfied();
- for (Exchange exchange : resultEndpoint.getReceivedExchanges()) {
- assertNotNull(exchange.getProperty(Exchange.SPLIT_INDEX));
- //this header cannot be set when streaming is used
- assertNull(exchange.getProperty(Exchange.SPLIT_SIZE));
+
+ // check properties with split details is correct
+ int size = resultEndpoint.getReceivedExchanges().size();
+ for (int i = 0; i < size; i++) {
+ Exchange exchange = resultEndpoint.getReceivedExchanges().get(i);
+ assertEquals(i, exchange.getProperty(Exchange.SPLIT_INDEX));
+ if (i < (size - 1)) {
+ assertEquals(Boolean.FALSE, exchange.getProperty(Exchange.SPLIT_COMPLETE));
+ //this header cannot be set when streaming is used, except for the last exchange
+ assertNull(exchange.getProperty(Exchange.SPLIT_SIZE));
+ } else {
+ assertEquals(Boolean.TRUE, exchange.getProperty(Exchange.SPLIT_COMPLETE));
+ // when we are complete the size is set
+ assertEquals(size, exchange.getProperty(Exchange.SPLIT_SIZE));
+ }
}
}