Author: markt Date: Fri Apr 23 13:48:16 2010 New Revision: 937298 URL: http://svn.apache.org/viewvc?rev=937298&view=rev Log: Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=49164 Improve unit tests by propagating failures from spawned threads to main thread. Patch provided by Felix Schumacher.
Modified: tomcat/trunk/test/org/apache/catalina/tribes/test/interceptors/TestOrderInterceptor.java Modified: tomcat/trunk/test/org/apache/catalina/tribes/test/interceptors/TestOrderInterceptor.java URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/tribes/test/interceptors/TestOrderInterceptor.java?rev=937298&r1=937297&r2=937298&view=diff ============================================================================== --- tomcat/trunk/test/org/apache/catalina/tribes/test/interceptors/TestOrderInterceptor.java (original) +++ tomcat/trunk/test/org/apache/catalina/tribes/test/interceptors/TestOrderInterceptor.java Fri Apr 23 13:48:16 2010 @@ -29,6 +29,9 @@ import org.apache.catalina.tribes.group. import org.apache.catalina.tribes.ChannelMessage; import org.apache.catalina.tribes.group.InterceptorPayload; import org.apache.catalina.tribes.ChannelException; + +import java.util.Queue; +import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.atomic.AtomicInteger; public class TestOrderInterceptor extends TestCase { @@ -91,6 +94,7 @@ public class TestOrderInterceptor extend public void testOrder2() throws Exception { final Member[] dest = channels[0].getMembers(); final AtomicInteger value = new AtomicInteger(0); + final Queue<Exception> exceptionQueue = new ConcurrentLinkedQueue<Exception>(); Runnable run = new Runnable() { public void run() { for (int i = 0; i < 100; i++) { @@ -99,8 +103,7 @@ public class TestOrderInterceptor extend channels[0].send(dest, new Integer(value.getAndAdd(1)), 0); } }catch ( Exception x ) { - x.printStackTrace(); - assertEquals(true,false); + exceptionQueue.add(x); } } } @@ -115,6 +118,10 @@ public class TestOrderInterceptor extend for (int i=0;i<threads.length;i++) { threads[i].join(); } + if (!exceptionQueue.isEmpty()) { + fail("Exception while sending in threads: " + + exceptionQueue.remove().toString()); + } Thread.sleep(5000); for ( int i=0; i<test.length; i++ ) { assertEquals(false,test[i].fail); --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org