[hornetq-commits] JBoss hornetq SVN: r9131 - trunk/tests/src/org/hornetq/tests/integration/cluster/failover.
do-not-reply at jboss.org
do-not-reply at jboss.org
Fri Apr 16 00:13:50 EDT 2010
Author: clebert.suconic at jboss.com
Date: 2010-04-16 00:13:49 -0400 (Fri, 16 Apr 2010)
New Revision: 9131
Modified:
trunk/tests/src/org/hornetq/tests/integration/cluster/failover/AsynchronousFailoverTest.java
Log:
Fixing test as it was swallowing failures
Modified: trunk/tests/src/org/hornetq/tests/integration/cluster/failover/AsynchronousFailoverTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/cluster/failover/AsynchronousFailoverTest.java 2010-04-15 16:36:54 UTC (rev 9130)
+++ trunk/tests/src/org/hornetq/tests/integration/cluster/failover/AsynchronousFailoverTest.java 2010-04-16 04:13:49 UTC (rev 9131)
@@ -64,7 +64,7 @@
}
}
- public void testNonTransactional() throws Exception
+ public void testNonTransactional() throws Throwable
{
runTest(new TestRunner()
{
@@ -74,15 +74,16 @@
{
doTestNonTransactional(this);
}
- catch (Exception e)
+ catch (Throwable e)
{
AsynchronousFailoverTest.log.error("Test failed", e);
+ addException(e);
}
}
});
}
- public void testTransactional() throws Exception
+ public void testTransactional() throws Throwable
{
runTest(new TestRunner()
{
@@ -92,9 +93,10 @@
{
doTestTransactional(this);
}
- catch (Exception e)
+ catch (Throwable e)
{
AsynchronousFailoverTest.log.error("Test failed", e);
+ addException(e);
}
}
});
@@ -104,6 +106,8 @@
{
volatile boolean failed;
+ ArrayList<Throwable> errors = new ArrayList<Throwable>();
+
boolean isFailed()
{
return failed;
@@ -118,9 +122,33 @@
{
failed = false;
}
+
+ synchronized void addException(Throwable e)
+ {
+ errors.add(e);
+ }
+
+ void checkForExceptions() throws Throwable
+ {
+ if (errors.size() > 0)
+ {
+ log.warn("Exceptions on test:");
+ for (Throwable e: errors)
+ {
+ log.warn(e.getMessage(), e);
+ }
+ // throwing the first error that happened on the Runnable
+ throw errors.get(0);
+ }
+
+
+
+ }
+
+
}
- private void runTest(final TestRunner runnable) throws Exception
+ private void runTest(final TestRunner runnable) throws Throwable
{
final int numIts = 1;
@@ -172,6 +200,8 @@
AsynchronousFailoverTest.log.info("Fail complete");
t.join();
+
+ runnable.checkForExceptions();
createSession.close();
@@ -187,6 +217,7 @@
if (i != numIts - 1)
{
tearDown();
+ runnable.checkForExceptions();
runnable.reset();
setUp();
}
@@ -211,7 +242,7 @@
session.addFailureListener(listener);
this.listener = listener;
-
+
ClientProducer producer = session.createProducer(FailoverTestBase.ADDRESS);
final int numMessages = 1000;
More information about the hornetq-commits
mailing list