diff options
| author | Rafael H. Schloming <rhs@apache.org> | 2008-08-15 03:40:49 +0000 |
|---|---|---|
| committer | Rafael H. Schloming <rhs@apache.org> | 2008-08-15 03:40:49 +0000 |
| commit | b6a376a4797e4988cdae48e0e5395a9b1f4e9f85 (patch) | |
| tree | dc41b190202b592d35579af35cc8b18bb1f1b702 /java/junit-toolkit | |
| parent | c521097d6d6f44e437e2ce67f5a8ae66706e4476 (diff) | |
| download | qpid-python-b6a376a4797e4988cdae48e0e5395a9b1f4e9f85.tar.gz | |
updated qpid.0-10/java to match trunk/qpid/java@686097
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/branches/qpid.0-10@686136 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/junit-toolkit')
4 files changed, 99 insertions, 67 deletions
diff --git a/java/junit-toolkit/pom.xml b/java/junit-toolkit/pom.xml index 2b57c26a13..c5f0d75a74 100644 --- a/java/junit-toolkit/pom.xml +++ b/java/junit-toolkit/pom.xml @@ -52,6 +52,18 @@ <version>1.2.12</version> </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + <version>1.4.0</version> + </dependency> + + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-log4j12</artifactId> + <version>1.4.0</version> + </dependency> + </dependencies> </dependencyManagement> @@ -65,6 +77,19 @@ <groupId>log4j</groupId> <artifactId>log4j</artifactId> </dependency> + + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + <version>1.4.0</version> + </dependency> + + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-log4j12</artifactId> + <version>1.4.0</version> + </dependency> + </dependencies> <build> diff --git a/java/junit-toolkit/src/main/org/apache/qpid/junit/concurrency/ThreadTestCoordinator.java b/java/junit-toolkit/src/main/org/apache/qpid/junit/concurrency/ThreadTestCoordinator.java index 605c35feed..3cf8543656 100644 --- a/java/junit-toolkit/src/main/org/apache/qpid/junit/concurrency/ThreadTestCoordinator.java +++ b/java/junit-toolkit/src/main/org/apache/qpid/junit/concurrency/ThreadTestCoordinator.java @@ -20,7 +20,8 @@ */ package org.apache.qpid.junit.concurrency; -import org.apache.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.ArrayList; import java.util.Collection; @@ -68,7 +69,7 @@ import java.util.concurrent.ThreadFactory; public class ThreadTestCoordinator { /** Used for logging. */ - private static final Logger log = Logger.getLogger(ThreadTestCoordinator.class); + private static final Logger log = LoggerFactory.getLogger(ThreadTestCoordinator.class); /** Keeps track of the test threads by their ids. */ private TestRunnable[] testThreads; // = new TestRunnable[2]; diff --git a/java/junit-toolkit/src/main/org/apache/qpid/junit/extensions/DurationTestDecorator.java b/java/junit-toolkit/src/main/org/apache/qpid/junit/extensions/DurationTestDecorator.java index 1c1c146361..e99fcce752 100644 --- a/java/junit-toolkit/src/main/org/apache/qpid/junit/extensions/DurationTestDecorator.java +++ b/java/junit-toolkit/src/main/org/apache/qpid/junit/extensions/DurationTestDecorator.java @@ -95,30 +95,36 @@ public class DurationTestDecorator extends WrappedSuiteTestDecorator implements { log.debug("public void run(TestResult testResult): called"); - // Cast the test result to expose it as a TKTestResult if the test is running under the TKTestRunner. - TKTestResult tkTestResult = null; +// Removing the durationTimer as this addition prevents this TestDecorator being wrapped with a Scaled Test Decorator. + // This change will cause the tests to run for at least the specified duration + // If we need the test to stop much closer to the specified duration then we need to + // ensure that the solution doesn't prevent this Decorator being wrapped with other Decorators. + +// // Cast the test result to expose it as a TKTestResult if the test is running under the TKTestRunner. +// TKTestResult tkTestResult = null; +// +// if (testResult instanceof TKTestResult) +// { +// tkTestResult = (TKTestResult) testResult; +// } +// +// // If running under the TKTestRunner, set up a timer to notify the test framework when the test reaches its +// // completion time. +// Timer durationTimer = null; +// +// if (tkTestResult != null) +// { +// log.debug("Creating duration timer."); +// +// durationTimer = new Timer(); +// durationTimer.schedule(new DurationTimerTask((TKTestResult) testResult), duration); +// } - if (testResult instanceof TKTestResult) - { - tkTestResult = (TKTestResult) testResult; - } // Work out when the test should end. long now = System.nanoTime(); long end = (duration * 1000000) + now; - // If running under the TKTestRunner, set up a timer to notify the test framework when the test reaches its - // completion time. - Timer durationTimer = null; - - if (tkTestResult != null) - { - log.debug("Creating duration timer."); - - durationTimer = new Timer(); - durationTimer.schedule(new DurationTimerTask((TKTestResult) testResult), duration); - } - // Run the test until the duration times out or the shutdown flag is set. The test method may not exit until // interrupted in some cases, in which case the timer will do the interrupting. while ((now < end) && !shutdown) @@ -128,13 +134,13 @@ public class DurationTestDecorator extends WrappedSuiteTestDecorator implements now = System.nanoTime(); } - // Clean up any timer that was used. - if (durationTimer != null) - { - log.debug("Cancelling duration timer."); - - durationTimer.cancel(); - } +// // Clean up any timer that was used. +// if (durationTimer != null) +// { +// log.debug("Cancelling duration timer."); +// +// durationTimer.cancel(); +// } } /** @@ -157,43 +163,43 @@ public class DurationTestDecorator extends WrappedSuiteTestDecorator implements }); } - /** - * DurationTimerTask is a timer task that is configured, upon expiry of its timer, to invoke - * {@link TKTestResult#shutdownNow()}, for the test result object on which it is set. It also sets - * the {@link DurationTestDecorator#shutdown} flag to indicate that no new tests should be run. - * - * <p/>The test loop implemented by DurationTestDecorator checks that the duration has not expired, on each - * test case that it runs. However, it is possible to write test cases that never return until explicitly - * interrupted by the test framework. This timer task exists to notify the test framework - */ - private class DurationTimerTask extends TimerTask - { - /** Used for debugging purposes. */ - private final Logger log = Logger.getLogger(DurationTimerTask.class); - - /** Holds the test result for the test to which a duration limit is being applied. */ - TKTestResult testResult; - - /** - * Creates a duration limit timer which will notify the specified test result when the duration has - * expired. - * - * @param testResult The test result to notify upon expiry of the test duration. - */ - public DurationTimerTask(TKTestResult testResult) - { - this.testResult = testResult; - } - - /** - * The action to be performed by this timer task. - */ - public void run() - { - log.debug("public void run(): called"); - - shutdown = true; - testResult.shutdownNow(); - } - } +// /** +// * DurationTimerTask is a timer task that is configured, upon expiry of its timer, to invoke +// * {@link TKTestResult#shutdownNow()}, for the test result object on which it is set. It also sets +// * the {@link DurationTestDecorator#shutdown} flag to indicate that no new tests should be run. +// * +// * <p/>The test loop implemented by DurationTestDecorator checks that the duration has not expired, on each +// * test case that it runs. However, it is possible to write test cases that never return until explicitly +// * interrupted by the test framework. This timer task exists to notify the test framework +// */ +// private class DurationTimerTask extends TimerTask +// { +// /** Used for debugging purposes. */ +// private final Logger log = Logger.getLogger(DurationTimerTask.class); +// +// /** Holds the test result for the test to which a duration limit is being applied. */ +// TKTestResult testResult; +// +// /** +// * Creates a duration limit timer which will notify the specified test result when the duration has +// * expired. +// * +// * @param testResult The test result to notify upon expiry of the test duration. +// */ +// public DurationTimerTask(TKTestResult testResult) +// { +// this.testResult = testResult; +// } +// +// /** +// * The action to be performed by this timer task. +// */ +// public void run() +// { +// log.debug("public void run(): called"); +// +// shutdown = true; +// testResult.shutdownNow(); +// } +// } } diff --git a/java/junit-toolkit/src/main/org/apache/qpid/junit/extensions/TestRunnerImprovedErrorHandling.java b/java/junit-toolkit/src/main/org/apache/qpid/junit/extensions/TestRunnerImprovedErrorHandling.java index edd79b3697..c68405bd06 100644 --- a/java/junit-toolkit/src/main/org/apache/qpid/junit/extensions/TestRunnerImprovedErrorHandling.java +++ b/java/junit-toolkit/src/main/org/apache/qpid/junit/extensions/TestRunnerImprovedErrorHandling.java @@ -86,7 +86,7 @@ public class TestRunnerImprovedErrorHandling extends TestRunner * * @throws Exception Any exceptions falling through the tests are wrapped in Exception and rethrown. */ - protected TestResult start(String[] args) throws Exception + public TestResult start(String[] args) throws Exception { String testCase = ""; boolean wait = false; |
