Hi
Is there a flaw in MockEndpoint with sleep for empty tests?
For instance if I have this code I would expect it to wait 10 sec
before stopping, but it doesn't.
public void testManually() throws Exception {
deleteDirectory("./target/exclusiveread");
MockEndpoint mock = getMockEndpoint("mock:result");
mock.setSleepForEmptyTest(10000);
mock.expectedMessageCount(0);
mock.assertIsSatisfied();
}
Fixing the code in MockEndpoint to this seems to fix it, and it's a
bit more readable, what it does
public void assertIsSatisfied(long timeoutForEmptyEndpoints)
throws InterruptedException {
LOG.info("Asserting: " + this + " is satisfied");
if (expectedCount == 0) {
if (timeoutForEmptyEndpoints > 0) {
LOG.debug("Sleeping for: " + timeoutForEmptyEndpoints
+ " millis to check there really are no messages received");
Thread.sleep(timeoutForEmptyEndpoints);
} else {
waitForCompleteLatch();
}
assertEquals("Received message count", expectedCount,
getReceivedCounter());
} else if (expectedCount > 0) {
if (expectedCount != getReceivedCounter()) {
waitForCompleteLatch();
}
assertEquals("Received message count", expectedCount,
getReceivedCounter());
} else if (expectedMinimumCount > 0 && getReceivedCounter() <
expectedMinimumCount) {
waitForCompleteLatch();
}
Feedback from other riders is welcome ;)
--
/Claus Ibsen
Apache Camel Committer
Blog: http://davsclaus.blogspot.com/