From d96f592d18e80cab8f73c740b6cb14d612befe36 Mon Sep 17 00:00:00 2001 From: Martin Ritchie Date: Mon, 12 Apr 2010 15:43:36 +0000 Subject: QPID-2421 : Fixed preFill when numConsumers > 1. This requried the introduction of a new phase in TestThreadAware : postThreadSetup. This ensures that all the threads have correctly setup their clients and so registered their topic subscribers. We can then preFill in the postThreadSetup and reliably receive the data from each of the client's publishers. Added new sendOnly parameter to allow send only testing with topics where numConsumers must be set. Merged from 0.5.x-dev rev 920389 git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@933286 13f79535-47bb-0310-9956-ffa450edef68 --- .../qpid/junit/extensions/ScaledTestDecorator.java | 16 ++++++++++++++++ .../apache/qpid/junit/extensions/TestThreadAware.java | 5 +++++ 2 files changed, 21 insertions(+) (limited to 'qpid/java/junit-toolkit/src') diff --git a/qpid/java/junit-toolkit/src/main/org/apache/qpid/junit/extensions/ScaledTestDecorator.java b/qpid/java/junit-toolkit/src/main/org/apache/qpid/junit/extensions/ScaledTestDecorator.java index e0af22cfb7..93e2a3c855 100644 --- a/qpid/java/junit-toolkit/src/main/org/apache/qpid/junit/extensions/ScaledTestDecorator.java +++ b/qpid/java/junit-toolkit/src/main/org/apache/qpid/junit/extensions/ScaledTestDecorator.java @@ -323,6 +323,22 @@ public class ScaledTestDecorator extends WrappedSuiteTestDecorator implements Sh // Wait until all test threads have completed their setups. barrier.await(); + + // Call setup on all underlying tests in the suite that are thread aware. + for (Test childTest : test.getAllUnderlyingTests()) + { + // Check that the test is concurrency aware, so provides a setup method to call. + if (childTest instanceof TestThreadAware) + { + // Call the tests post thread setup. + TestThreadAware setupTest = (TestThreadAware) childTest; + setupTest.postThreadSetUp(); + } + } + + // Wait until all test threads have completed their prefill. + barrier.await(); + // Start timing the test batch, only after thread setups have completed. if (testResult instanceof TKTestResult) { diff --git a/qpid/java/junit-toolkit/src/main/org/apache/qpid/junit/extensions/TestThreadAware.java b/qpid/java/junit-toolkit/src/main/org/apache/qpid/junit/extensions/TestThreadAware.java index d7de2822a2..94dcf5499b 100644 --- a/qpid/java/junit-toolkit/src/main/org/apache/qpid/junit/extensions/TestThreadAware.java +++ b/qpid/java/junit-toolkit/src/main/org/apache/qpid/junit/extensions/TestThreadAware.java @@ -42,6 +42,11 @@ public interface TestThreadAware */ public void threadSetUp(); + /** + * Called after all threads have completed their setup. + */ + public void postThreadSetUp(); + /** * Called when a test thread is destroyed. */ -- cgit v1.2.1