Author: davsclaus
Date: Sun Apr 1 13:46:38 2012
New Revision: 1308116
URL: http://svn.apache.org/viewvc?rev=1308116&view=rev
Log:
CAMEL-4160: Added retainFirst and retainLast option to mock component.
Modified:
camel/trunk/camel-core/src/main/java/org/apache/camel/component/mock/MockEndpoint.java
Modified:
camel/trunk/camel-core/src/main/java/org/apache/camel/component/mock/MockEndpoint.java
URL:
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/mock/MockEndpoint.java?rev=1308116&r1=1308115&r2=1308116&view=diff
==============================================================================
---
camel/trunk/camel-core/src/main/java/org/apache/camel/component/mock/MockEndpoint.java
(original)
+++
camel/trunk/camel-core/src/main/java/org/apache/camel/component/mock/MockEndpoint.java
Sun Apr 1 13:46:38 2012
@@ -1176,11 +1176,14 @@ public class MockEndpoint extends Defaul
}
LOG.debug(msg);
}
- ++counter;
// record timestamp when exchange was received
copy.setProperty(Exchange.RECEIVED_TIMESTAMP, new Date());
+
+ // add a copy of the received exchange
addReceivedExchange(copy);
+ // and then increment counter after adding received exchange
+ ++counter;
Processor processor = processors.get(getReceivedCounter()) != null
? processors.get(getReceivedCounter()) : defaultProcessor;
@@ -1210,7 +1213,7 @@ public class MockEndpoint extends Defaul
receivedExchanges.add(copy);
} else {
// okay there is some sort of limitations, so figure out what to
retain
- if (retainFirst > 0 && counter <= retainFirst) {
+ if (retainFirst > 0 && counter < retainFirst) {
// store a copy as its within the retain first limitation
receivedExchanges.add(copy);
} else if (retainLast > 0) {