@Test(timeout = 10000) @Transactional(propagation = Propagation.NOT_SUPPORTED) @Repeat(5) public void notTransactionalWithJUnitTimeout() { assertInTransaction(false); }
/** * Get the repeat count configured via the {@link Repeat @Repeat} * annotation on the supplied {@code method}. * <p>Non-negative configured values will be converted to {@code 1}. * @return the configured repeat count, or {@code 1} if the method is * not annotated with {@code @Repeat} */ public static int getRepeatCount(Method method) { Repeat repeat = AnnotatedElementUtils.findMergedAnnotation(method, Repeat.class); if (repeat == null) { return 1; } return Math.max(1, repeat.value()); }
@Repeat(5) @Retention(RetentionPolicy.RUNTIME) private static @interface RepeatedFiveTimes {
return base; final int repeats = repeat.value(); if (concurrency <= 0) { return new Statement() {
@Test @Repeat(5) public void repeatedFiveTimes() throws Exception { incrementInvocationCount(); } }
/** * Get the repeat count configured via the {@link Repeat @Repeat} * annotation on the supplied {@code method}. * <p>Non-negative configured values will be converted to {@code 1}. * @return the configured repeat count, or {@code 1} if the method is * not annotated with {@code @Repeat} */ public static int getRepeatCount(Method method) { Repeat repeat = AnnotatedElementUtils.findMergedAnnotation(method, Repeat.class); if (repeat == null) { return 1; } return Math.max(1, repeat.value()); }
/** * Overridden since Spring's Rule-based JUnit support cannot properly * integrate with timed execution that is controlled by a third-party runner. */ @Test(timeout = 10000) @Repeat(5) @Override public void transactionalWithJUnitTimeout() { assertInTransaction(false); }
/** * Get the repeat count configured via the {@link Repeat @Repeat} * annotation on the supplied {@code method}. * <p>Non-negative configured values will be converted to {@code 1}. * @return the configured repeat count, or {@code 1} if the method is * not annotated with {@code @Repeat} */ public static int getRepeatCount(Method method) { Repeat repeat = AnnotatedElementUtils.findMergedAnnotation(method, Repeat.class); if (repeat == null) { return 1; } return Math.max(1, repeat.value()); }
@Test @Repeat(5) public void repeatedFiveTimes() throws Exception { incrementInvocationCount(); } }
final int repeats = repeat.value(); if (repeats <= 1) { return base;
@Test(timeout = 10000) @Repeat(5) public void transactionalWithJUnitTimeout() { assertInTransaction(true); }
@Test @Timed(millis = 100) @Repeat(10) public void collectiveRepetitionsExceedTimeout() throws Exception { incrementInvocationCount(); Thread.sleep(11); } }
@Test @Timed(millis = 20) @Repeat(4) public void firstRepetitionOfManyExceedsTimeout() throws Exception { incrementInvocationCount(); Thread.sleep(25); }
@Test @Transactional(propagation = Propagation.NOT_SUPPORTED) @Timed(millis = 10000) @Repeat(5) public void notTransactionalWithSpringTimeout() { assertInTransaction(false); }
@Test @Timed(millis = 10) @Repeat(1) public void singleRepetitionExceedsTimeout() throws Exception { incrementInvocationCount(); Thread.sleep(15); }
@Test @Timed(millis = 20) @Repeat(4) public void firstRepetitionOfManyExceedsTimeout() throws Exception { incrementInvocationCount(); Thread.sleep(25); }
@Test @Timed(millis = 10) @Repeat(1) public void singleRepetitionExceedsTimeout() throws Exception { incrementInvocationCount(); Thread.sleep(15); }
@Test @Timed(millis = 100) @Repeat(10) public void collectiveRepetitionsExceedTimeout() throws Exception { incrementInvocationCount(); Thread.sleep(11); } }
@Test @Timed(millis = 1000) @Repeat(5) public void repeatedFiveTimesButDoesNotExceedTimeout() throws Exception { incrementInvocationCount(); }
@Test @Repeat @Timed(millis = 10000) public void defaultRepeatValue() throws Exception { incrementInvocationCount(); } }