Update of /cvsroot/junit/junit/src/org/junit/internal/runners
In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv512/src/org/junit/internal/runners
Modified Files:
MethodRoadie.java
Log Message:
Fixed bug 1745048: @After method not called after my test timeout in 4.3.1
Index: MethodRoadie.java
===================================================================
RCS file: /cvsroot/junit/junit/src/org/junit/internal/runners/MethodRoadie.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- MethodRoadie.java 2 Jul 2007 18:10:58 -0000 1.2
+++ MethodRoadie.java 2 Jul 2007 20:59:57 -0000 1.3
@@ -46,29 +46,37 @@
}
private void runWithTimeout(long timeout) {
- ExecutorService service= Executors.newSingleThreadExecutor();
- Callable<Object> callable= new Callable<Object>() {
- public Object call() throws Exception {
- runTest();
- return null;
- }
- };
- Future<Object> result= service.submit(callable);
- service.shutdown();
try {
- boolean terminated= service.awaitTermination(timeout,
- TimeUnit.MILLISECONDS);
- if (!terminated)
- service.shutdownNow();
- result.get(0, TimeUnit.MILLISECONDS); // throws the exception if one occurred during the invocation
- } catch (TimeoutException e) {
- addFailure(new Exception(String.format("test timed out after %d milliseconds", timeout)));
- } catch (Exception e) {
- addFailure(e);
- }
+ runBefores();
+ ExecutorService service= Executors.newSingleThreadExecutor();
+ Callable<Object> callable= new Callable<Object>() {
+ public Object call() throws Exception {
+ runTestMethod();
+ return null;
+ }
+ };
+ Future<Object> result= service.submit(callable);
+ service.shutdown();
+ try {
+ boolean terminated= service.awaitTermination(timeout,
+ TimeUnit.MILLISECONDS);
+ if (!terminated)
+ service.shutdownNow();
+ result.get(0, TimeUnit.MILLISECONDS); // throws the exception if one occurred during the invocation
+ } catch (TimeoutException e) {
+ addFailure(new Exception(String.format("test timed out after %d milliseconds", timeout)));
+ } catch (Exception e) {
+ addFailure(e);
+ }
+ } catch (FailedBefore e) {
+ } finally {
+ runAfters();
+ }
}
public void runTest() {
+ // TODO (Jul 2, 2007 4:54:13 PM): duplicated in timeout branch?
+
try {
runBefores();
runTestMethod();
|