public Statement apply(Statement base, Description description) { return new FailOnTimeout(base, fMillis); } }
/** * Builds a {@link FailOnTimeout} instance using the values in this builder, * wrapping the given statement. * * @param statement */ public FailOnTimeout build(Statement statement) { if (statement == null) { throw new NullPointerException("statement cannot be null"); } return new FailOnTimeout(this, statement); } }
/** * Returns a {@link Statement}: if {@code method}'s {@code @Test} annotation * has the {@code timeout} attribute, throw an exception if {@code next} * takes more than the specified number of milliseconds. * * @deprecated Will be private soon: use Rules instead */ @Deprecated protected Statement withPotentialTimeout(FrameworkMethod method, Object test, Statement next) { long timeout = getTimeout(method.getAnnotation(Test.class)); return timeout > 0 ? new FailOnTimeout(next, timeout) : next; }
public Statement apply(Statement base, Description description) { return new FailOnTimeout(base, fMillis); } }
/** * Returns a {@link Statement}: if {@code method}'s {@code @Test} annotation * has the {@code timeout} attribute, throw an exception if {@code next} * takes more than the specified number of milliseconds. * * @deprecated Will be private soon: use Rules instead */ @Deprecated protected Statement withPotentialTimeout(FrameworkMethod method, Object test, Statement next) { long timeout = getTimeout(method.getAnnotation(Test.class)); return timeout > 0 ? new FailOnTimeout(next, timeout) : next; }
public Statement apply(Statement base, Description description) { return new FailOnTimeout(base, fMillis); } }
/** * Builds a {@link FailOnTimeout} instance using the values in this builder, * wrapping the given statement. * * @param statement */ public FailOnTimeout build(final Statement statement) { return new FailOnTimeout(this, statement); } }
public Statement apply(Statement base, Description description) { return new FailOnTimeout(base, fMillis); } }
/** * Builds a {@link FailOnTimeout} instance using the values in this builder, * wrapping the given statement. * * @param statement */ public FailOnTimeout build(Statement statement) { if (statement == null) { throw new NullPointerException("statement cannot be null"); } return new FailOnTimeout(this, statement); } }
/** * Builds a {@link FailOnTimeout} instance using the values in this builder, * wrapping the given statement. * * @param statement */ public FailOnTimeout build(Statement statement) { if (statement == null) { throw new NullPointerException("statement cannot be null"); } return new FailOnTimeout(this, statement); } }
public class Q37355035 { private static final int MIN_TIMEOUT = 100; @Rule public Timeout timeout = new Timeout(MIN_TIMEOUT) { public Statement apply(Statement base, Description description) { return new FailOnTimeout(base, MIN_TIMEOUT) { @Override public void evaluate() throws Throwable { try { super.evaluate(); throw new TimeoutException(); } catch (Exception e) {} } }; } }; @Test(expected = TimeoutException.class) public void givesTimeout() throws InterruptedException { Thread.sleep(1000); } }
/** * Returns a {@link org.junit.runners.model.Statement}: if {@code method}'s {@code @Test} annotation * has the {@code timeout} attribute, throw an exception if {@code next} * takes more than the specified number of milliseconds. * * @deprecated Will be private soon: use Rules instead */ @Deprecated protected Statement withPotentialTimeout(FrameworkMethod method, Object test, Statement next) { long timeout = getTimeout(method.getAnnotation(Test.class)); return timeout > 0 ? new FailOnTimeout(next, timeout) : next; }
/** * Returns a {@link Statement}: if {@code method}'s {@code @Test} annotation * has the {@code timeout} attribute, throw an exception if {@code next} * takes more than the specified number of milliseconds. * * @deprecated Will be private soon: use Rules instead */ @Deprecated protected Statement withPotentialTimeout(FrameworkMethod method, Object test, Statement next) { long timeout = getTimeout(method.getAnnotation(Test.class)); return timeout > 0 ? new FailOnTimeout(next, timeout) : next; }
/** * Returns a {@link Statement}: if {@code method}'s {@code @Test} annotation * has the {@code timeout} attribute, throw an exception if {@code next} * takes more than the specified number of milliseconds. * * @deprecated Will be private soon: use Rules instead */ @Deprecated protected Statement withPotentialTimeout(FrameworkMethod method, Object test, Statement next) { long timeout = getTimeout(method.getAnnotation(Test.class)); return timeout > 0 ? new FailOnTimeout(next, timeout) : next; }
public Statement createStatement(final TestClass testClass, final FrameworkMethod method, final Object target, final Statement next, final Description description, final RunNotifier notifier) { final Test annotation = method.getAnnotation(Test.class); return annotation.timeout() <= 0 ? next : new FailOnTimeout(next, annotation.timeout()); } }
private static Throwable getTimeoutException() { final FailOnTimeout f = new FailOnTimeout(new Statement() { @Override public void evaluate() throws InterruptedException { Thread.sleep(1000); } }, 1); try { f.evaluate(); } catch(Throwable throwable) { return throwable; } return null; }
private static Throwable getTimeoutException() { final FailOnTimeout f = new FailOnTimeout(new Statement() { @Override public void evaluate() throws InterruptedException { Thread.sleep(1000); } }, 1); try { f.evaluate(); } catch(Throwable throwable) { return throwable; } return null; }