org.junit.internal.runners.MethodRoadie Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of virtdata-lib-realer Show documentation
Show all versions of virtdata-lib-realer Show documentation
With inspiration from other libraries
package org.junit.internal.runners;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import org.junit.internal.AssumptionViolatedException;
import org.junit.runner.Description;
import org.junit.runner.notification.Failure;
import org.junit.runner.notification.RunNotifier;
import org.junit.runners.BlockJUnit4ClassRunner;
import org.junit.runners.model.TestTimedOutException;
/**
* @deprecated Included for backwards compatibility with JUnit 4.4. Will be
* removed in the next major release. Please use
* {@link BlockJUnit4ClassRunner} in place of {@link JUnit4ClassRunner}.
*/
@Deprecated
public class MethodRoadie {
private final Object test;
private final RunNotifier notifier;
private final Description description;
private TestMethod testMethod;
public MethodRoadie(Object test, TestMethod method, RunNotifier notifier, Description description) {
this.test = test;
this.notifier = notifier;
this.description = description;
testMethod = method;
}
public void run() {
if (testMethod.isIgnored()) {
notifier.fireTestIgnored(description);
return;
}
notifier.fireTestStarted(description);
try {
long timeout = testMethod.getTimeout();
if (timeout > 0) {
runWithTimeout(timeout);
} else {
runTest();
}
} finally {
notifier.fireTestFinished(description);
}
}
private void runWithTimeout(final long timeout) {
runBeforesThenTestThenAfters(new Runnable() {
public void run() {
ExecutorService service = Executors.newSingleThreadExecutor();
Callable