You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2014/06/24 01:43:39 UTC
git commit: Added unit tests to verify the sedaBlockWhenFull feature
Repository: camel
Updated Branches:
refs/heads/master 1103fe038 -> 0c6db0c90
Added unit tests to verify the sedaBlockWhenFull feature
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/0c6db0c9
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/0c6db0c9
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/0c6db0c9
Branch: refs/heads/master
Commit: 0c6db0c907bc0de5132a4a78f9d6e0c3b98b311c
Parents: 1103fe0
Author: Willem Jiang <wi...@gmail.com>
Authored: Tue Jun 24 07:41:55 2014 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Tue Jun 24 07:42:50 2014 +0800
----------------------------------------------------------------------
.../component/seda/SedaBlockWhenFullTest.java | 24 +++++++++++++++++---
1 file changed, 21 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/0c6db0c9/camel-core/src/test/java/org/apache/camel/component/seda/SedaBlockWhenFullTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/component/seda/SedaBlockWhenFullTest.java b/camel-core/src/test/java/org/apache/camel/component/seda/SedaBlockWhenFullTest.java
index 18290ea..29eae02 100644
--- a/camel-core/src/test/java/org/apache/camel/component/seda/SedaBlockWhenFullTest.java
+++ b/camel-core/src/test/java/org/apache/camel/component/seda/SedaBlockWhenFullTest.java
@@ -27,9 +27,10 @@ import org.apache.camel.builder.RouteBuilder;
public class SedaBlockWhenFullTest extends ContextTestSupport {
private static final int QUEUE_SIZE = 1;
private static final int DELAY = 10;
+ private static final int DELAY_LONG = 100;
private static final String MOCK_URI = "mock:blockWhenFullOutput";
private static final String SIZE_PARAM = "?size=%d";
- private static final String BLOCK_WHEN_FULL_URI = "seda:blockingFoo" + String.format(SIZE_PARAM, QUEUE_SIZE) + "&blockWhenFull=true";
+ private static final String BLOCK_WHEN_FULL_URI = "seda:blockingFoo" + String.format(SIZE_PARAM, QUEUE_SIZE) + "&blockWhenFull=true&timeout=0";
private static final String DEFAULT_URI = "seda:foo" + String.format(SIZE_PARAM, QUEUE_SIZE);
@Override
@@ -37,7 +38,7 @@ public class SedaBlockWhenFullTest extends ContextTestSupport {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
- from(BLOCK_WHEN_FULL_URI).delay(DELAY).to(MOCK_URI);
+ from(BLOCK_WHEN_FULL_URI).delay(DELAY_LONG).to(MOCK_URI);
// use same delay as above on purpose
from(DEFAULT_URI).delay(DELAY).to("mock:whatever");
@@ -60,13 +61,24 @@ public class SedaBlockWhenFullTest extends ContextTestSupport {
public void testSedaBlockingWhenFull() throws Exception {
getMockEndpoint(MOCK_URI).setExpectedMessageCount(QUEUE_SIZE + 2);
-
+
SedaEndpoint seda = context.getEndpoint(BLOCK_WHEN_FULL_URI, SedaEndpoint.class);
assertEquals(QUEUE_SIZE, seda.getQueue().remainingCapacity());
sendTwoOverCapacity(BLOCK_WHEN_FULL_URI, QUEUE_SIZE);
assertMockEndpointsSatisfied();
}
+
+ public void testAsyncSedaBlockingWhenFull() throws Exception {
+ getMockEndpoint(MOCK_URI).setExpectedMessageCount(QUEUE_SIZE + 1);
+ getMockEndpoint(MOCK_URI).setResultWaitTime(DELAY_LONG * 3);
+
+ SedaEndpoint seda = context.getEndpoint(BLOCK_WHEN_FULL_URI, SedaEndpoint.class);
+ assertEquals(QUEUE_SIZE, seda.getQueue().remainingCapacity());
+
+ asyncSendTwoOverCapacity(BLOCK_WHEN_FULL_URI, QUEUE_SIZE + 4);
+ assertMockEndpointsSatisfied();
+ }
/**
* This method make sure that we hit the limit by sending two msg over the
@@ -78,5 +90,11 @@ public class SedaBlockWhenFullTest extends ContextTestSupport {
template.sendBody(uri, "Message " + i);
}
}
+
+ private void asyncSendTwoOverCapacity(String uri, int capacity) {
+ for (int i = 0; i < (capacity + 2); i++) {
+ template.asyncSendBody(uri, "Message " + i);
+ }
+ }
}