/** * Creates an instance wrapping the given statement with the given timeout in milliseconds. * * @param statement the statement to wrap * @param timeoutMillis the timeout in milliseconds * @deprecated use {@link #builder()} instead. */ @Deprecated public FailOnTimeout(Statement statement, long timeoutMillis) { this(builder().withTimeout(timeoutMillis, TimeUnit.MILLISECONDS), statement); }
statement = FailOnTimeout.builder().withTimeout(junitTimeout, TimeUnit.MILLISECONDS).build(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 */ @Deprecated protected Statement withPotentialTimeout(FrameworkMethod method, Object test, Statement next) { long timeout = getTimeout(method.getAnnotation(Test.class)); if (timeout <= 0) { return next; } return FailOnTimeout.builder() .withTimeout(timeout, TimeUnit.MILLISECONDS) .build(next); }
statement = FailOnTimeout.builder().withTimeout(junitTimeout, TimeUnit.MILLISECONDS).build(next);
statement = FailOnTimeout.builder().withTimeout(junitTimeout, TimeUnit.MILLISECONDS).build(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 protected Statement withPotentialTimeout(FrameworkMethod method, Object test, Statement next) { long timeout = getTimeout(method.getAnnotation(Test.class)); if (timeout <= 0) { return next; } return FailOnTimeout.builder() .withTimeout(timeout, TimeUnit.MILLISECONDS) .build(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 protected Statement withPotentialTimeout(FrameworkMethod method, Object test, Statement next) { long timeout = getTimeout(method.getAnnotation(Test.class)); if (timeout <= 0) { return next; } return FailOnTimeout.builder() .withTimeout(timeout, TimeUnit.MILLISECONDS) .build(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 protected Statement withPotentialTimeout(FrameworkMethod method, Object test, Statement next) { long timeout = getTimeout(method.getAnnotation(Test.class)); if (timeout <= 0) { return next; } return FailOnTimeout.builder() .withTimeout(timeout, TimeUnit.MILLISECONDS) .build(next); }
/** * Creates a {@link Statement} that will run the given * {@code statement}, and timeout the operation based * on the values configured in this rule. Subclasses * can override this method for different behavior. * * @since 4.12 */ protected Statement createFailOnTimeoutStatement( Statement statement) throws Exception { return FailOnTimeout.builder() .withTimeout(timeout, timeUnit) .withLookingForStuckThread(lookForStuckThread) .build(statement); }
/** * Creates a {@link Statement} that will run the given * {@code statement}, and timeout the operation based * on the values configured in this rule. Subclasses * can override this method for different behavior. * * @since 4.12 */ protected Statement createFailOnTimeoutStatement( Statement statement) throws Exception { return FailOnTimeout.builder() .withTimeout(timeout, timeUnit) .withLookingForStuckThread(lookForStuckThread) .build(statement); }
static Statement newStatement(Example example) { Statement statement = new ExampleStatement(example); if (example.isExpectedToThrowAnException()) { statement = new ExpectException(statement, example.expected()); } if (example.shouldFailOnTimeout()) { statement = FailOnTimeout.builder() .withTimeout(example.timeout(), example.timeoutUnit()) .build(statement); } return statement; }
/** * Creates an instance wrapping the given statement with the given timeout in milliseconds. * * @param statement the statement to wrap * @param timeoutMillis the timeout in milliseconds * @deprecated use {@link #builder()} instead. */ @Deprecated public FailOnTimeout(Statement statement, long timeoutMillis) { this(builder().withTimeout(timeoutMillis, TimeUnit.MILLISECONDS), statement); }
/** * Creates an instance wrapping the given statement with the given timeout in milliseconds. * * @param statement the statement to wrap * @param timeoutMillis the timeout in milliseconds * @deprecated use {@link #builder()} instead. */ @Deprecated public FailOnTimeout(Statement statement, long timeoutMillis) { this(builder().withTimeout(timeoutMillis, TimeUnit.MILLISECONDS), statement); }
/** * Apply a timeout expressed as a duration to a builder of a {@link FailOnTimeout} object. * @param builder to modify * @param timeout duration of the timeout * @return the builder input - for fluent use. */ static FailOnTimeout.Builder withAppliedTimeout(FailOnTimeout.Builder builder, Duration timeout) { builder.withTimeout(timeout.toNanos(), TimeUnit.NANOSECONDS); return builder; } }
static Statement newStatement(Example example) { Statement statement = new ExampleStatement(example); if (example.isExpectedToThrowAnException()) { statement = new ExpectException(statement, example.expected()); } if (example.shouldFailOnTimeout()) { statement = FailOnTimeout.builder() .withTimeout(example.timeout(), example.timeoutUnit()) .build(statement); } return statement; }
/** * Creates an instance wrapping the given statement with the given timeout in milliseconds. * * @param statement the statement to wrap * @param timeoutMillis the timeout in milliseconds * @deprecated use {@link #builder()} instead. */ @Deprecated public FailOnTimeout(final Statement statement, final long timeoutMillis) { this(builder().withTimeout(timeoutMillis, TimeUnit.MILLISECONDS), statement); }
/** * Creates a {@link Statement} that will run the given * {@code statement}, and timeout the operation based * on the values configured in this rule. Subclasses * can override this method for different behavior. * * @since 4.12 */ protected Statement createFailOnTimeoutStatement( Statement statement) throws Exception { return FailOnTimeout.builder() .withTimeout(timeout, timeUnit) .withLookingForStuckThread(lookForStuckThread) .build(statement); }