You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by bv...@apache.org on 2012/03/01 17:01:57 UTC
svn commit: r1295644 -
/camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailProducerConcurrentTest.java
Author: bvahdat
Date: Thu Mar 1 16:01:56 2012
New Revision: 1295644
URL: http://svn.apache.org/viewvc?rev=1295644&view=rev
Log:
Fixed the failed test on the CI-Server.
Modified:
camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailProducerConcurrentTest.java
Modified: camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailProducerConcurrentTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailProducerConcurrentTest.java?rev=1295644&r1=1295643&r2=1295644&view=diff
==============================================================================
--- camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailProducerConcurrentTest.java (original)
+++ camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailProducerConcurrentTest.java Thu Mar 1 16:01:56 2012
@@ -19,8 +19,10 @@ package org.apache.camel.component.mail;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.Callable;
+import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.test.junit4.CamelTestSupport;
@@ -50,17 +52,22 @@ public class MailProducerConcurrentTest
getMockEndpoint("mock:result").expectedMessageCount(files);
getMockEndpoint("mock:result").expectsNoDuplicates(body());
+ final CountDownLatch latch = new CountDownLatch(files);
ExecutorService executor = Executors.newFixedThreadPool(poolSize);
for (int i = 0; i < files; i++) {
final int index = i;
executor.submit(new Callable<Object>() {
public Object call() throws Exception {
template.sendBodyAndHeader("direct:start", "Message " + index, "To", "someone@localhost");
+ latch.countDown();
return null;
}
});
}
+ // wait first for all the exchanges above to be thoroughly sent asynchronously
+ assertTrue(latch.await(2, TimeUnit.SECONDS));
+
assertMockEndpointsSatisfied();
Mailbox box = Mailbox.get("someone@localhost");