You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2012/03/31 14:23:22 UTC
svn commit: r1307788 -
/camel/trunk/camel-core/src/main/java/org/apache/camel/component/mock/MockEndpoint.java
Author: davsclaus
Date: Sat Mar 31 12:23:22 2012
New Revision: 1307788
URL: http://svn.apache.org/viewvc?rev=1307788&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=1307788&r1=1307787&r2=1307788&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 Sat Mar 31 12:23:22 2012
@@ -486,7 +486,7 @@ public class MockEndpoint extends Defaul
expects(new Runnable() {
public void run() {
for (int i = 0; i < getReceivedExchanges().size(); i++) {
- Exchange exchange = getReceivedExchanges().get(i);
+ Exchange exchange = getReceivedExchange(i);
for (Map.Entry<String, Object> entry : expectedHeaderValues.entrySet()) {
String key = entry.getKey();
Object expectedValue = entry.getValue();
@@ -526,7 +526,7 @@ public class MockEndpoint extends Defaul
expects(new Runnable() {
public void run() {
for (int i = 0; i < getReceivedExchanges().size(); i++) {
- Exchange exchange = getReceivedExchanges().get(i);
+ Exchange exchange = getReceivedExchange(i);
for (Map.Entry<String, Object> entry : expectedPropertyValues.entrySet()) {
String key = entry.getKey();
Object expectedValue = entry.getValue();
@@ -560,7 +560,7 @@ public class MockEndpoint extends Defaul
expects(new Runnable() {
public void run() {
for (int i = 0; i < expectedBodyValues.size(); i++) {
- Exchange exchange = getReceivedExchanges().get(i);
+ Exchange exchange = getReceivedExchange(i);
assertTrue("No exchange received for counter: " + i, exchange != null);
Object expectedBody = expectedBodyValues.get(i);
@@ -627,7 +627,7 @@ public class MockEndpoint extends Defaul
expectedMessageCount(1);
final AssertionClause clause = new AssertionClause(this) {
public void run() {
- Exchange exchange = getReceivedExchanges().get(0);
+ Exchange exchange = getReceivedExchange(0);
assertTrue("No exchange received for counter: " + 0, exchange != null);
Object actualBody = exchange.getIn().getBody();
@@ -654,7 +654,7 @@ public class MockEndpoint extends Defaul
public void run() {
Set<Object> actualBodyValuesSet = new HashSet<Object>(actualBodyValues);
for (int i = 0; i < expectedBodyValues.size(); i++) {
- Exchange exchange = getReceivedExchanges().get(i);
+ Exchange exchange = getReceivedExchange(i);
assertTrue("No exchange received for counter: " + i, exchange != null);
Object expectedBody = expectedBodyValues.get(i);
@@ -918,7 +918,7 @@ public class MockEndpoint extends Defaul
public Exchange assertExchangeReceived(int index) {
int count = getReceivedCounter();
assertTrue("Not enough messages received. Was: " + count, count > index);
- return getReceivedExchanges().get(index);
+ return getReceivedExchange(index);
}
// Properties
@@ -1034,7 +1034,7 @@ public class MockEndpoint extends Defaul
* but there is only the first 10 {@link Exchange}s in the {@link #getExchanges()} and
* {@link #getReceivedExchanges()} methods.
* <p/>
- * When using this method, then some of the other expecation methods is not supported,
+ * When using this method, then some of the other expectation methods is not supported,
* for example the {@link #expectedBodiesReceived(Object...)} sets a expectation on the first
* number of bodies received.
* <p/>
@@ -1062,7 +1062,7 @@ public class MockEndpoint extends Defaul
* but there is only the last 20 {@link Exchange}s in the {@link #getExchanges()} and
* {@link #getReceivedExchanges()} methods.
* <p/>
- * When using this method, then some of the other expecation methods is not supported,
+ * When using this method, then some of the other expectation methods is not supported,
* for example the {@link #expectedBodiesReceived(Object...)} sets a expectation on the first
* number of bodies received.
* <p/>
@@ -1301,4 +1301,13 @@ public class MockEndpoint extends Defaul
public boolean isLenientProperties() {
return true;
}
+
+ private Exchange getReceivedExchange(int index) {
+ if (index <= receivedExchanges.size() - 1) {
+ return receivedExchanges.get(index);
+ } else {
+ return null;
+ }
+ }
+
}