3030import org .junit .runners .Parameterized .Parameters ;
3131import org .springframework .test .annotation .Repeat ;
3232import org .springframework .test .annotation .Timed ;
33- import org .springframework .test .context .ContextConfiguration ;
3433import org .springframework .test .context .TestExecutionListeners ;
3534
3635/**
@@ -76,7 +75,8 @@ public static Collection<Object[]> repetitionData() {
7675 { NonAnnotatedRepeatedTestCase .class , 0 , 1 , 1 , 1 },//
7776 { DefaultRepeatValueRepeatedTestCase .class , 0 , 1 , 1 , 1 },//
7877 { NegativeRepeatValueRepeatedTestCase .class , 0 , 1 , 1 , 1 },//
79- { RepeatedFiveTimesRepeatedTestCase .class , 0 , 1 , 1 , 5 } //
78+ { RepeatedFiveTimesRepeatedTestCase .class , 0 , 1 , 1 , 5 },//
79+ { TimedRepeatedTestCase .class , 3 , 4 , 4 , (5 + 1 + 4 + 10 ) } //
8080 });
8181 }
8282
@@ -101,7 +101,6 @@ public void assertRepetitions() throws Exception {
101101
102102 @ RunWith (SpringJUnit4ClassRunner .class )
103103 @ TestExecutionListeners ( {})
104- @ ContextConfiguration (locations = {})
105104 public abstract static class AbstractRepeatedTestCase {
106105
107106 protected void incrementInvocationCount () throws IOException {
@@ -113,7 +112,7 @@ public static final class NonAnnotatedRepeatedTestCase extends AbstractRepeatedT
113112
114113 @ Test
115114 @ Timed (millis = 10000 )
116- public void testNonAnnotated () throws Exception {
115+ public void nonAnnotated () throws Exception {
117116 incrementInvocationCount ();
118117 }
119118 }
@@ -123,7 +122,7 @@ public static final class DefaultRepeatValueRepeatedTestCase extends AbstractRep
123122 @ Test
124123 @ Repeat
125124 @ Timed (millis = 10000 )
126- public void testDefaultRepeatValue () throws Exception {
125+ public void defaultRepeatValue () throws Exception {
127126 incrementInvocationCount ();
128127 }
129128 }
@@ -133,7 +132,7 @@ public static final class NegativeRepeatValueRepeatedTestCase extends AbstractRe
133132 @ Test
134133 @ Repeat (-5 )
135134 @ Timed (millis = 10000 )
136- public void testNegativeRepeatValue () throws Exception {
135+ public void negativeRepeatValue () throws Exception {
137136 incrementInvocationCount ();
138137 }
139138 }
@@ -142,9 +141,47 @@ public static final class RepeatedFiveTimesRepeatedTestCase extends AbstractRepe
142141
143142 @ Test
144143 @ Repeat (5 )
144+ public void repeatedFiveTimes () throws Exception {
145+ incrementInvocationCount ();
146+ }
147+ }
148+
149+ /**
150+ * Unit tests for claims raised in <a
151+ * href="http://jira.springframework.org/browse/SPR-6011"
152+ * target="_blank">SPR-6011</a>.
153+ */
154+ public static final class TimedRepeatedTestCase extends AbstractRepeatedTestCase {
155+
156+ @ Test
145157 @ Timed (millis = 10000 )
146- public void testRepeatedFiveTimes () throws Exception {
158+ @ Repeat (5 )
159+ public void repeatedFiveTimesButDoesNotExceedTimeout () throws Exception {
160+ incrementInvocationCount ();
161+ }
162+
163+ @ Test
164+ @ Timed (millis = 100 )
165+ @ Repeat (1 )
166+ public void singleRepetitionExceedsTimeout () throws Exception {
167+ incrementInvocationCount ();
168+ Thread .sleep (250 );
169+ }
170+
171+ @ Test
172+ @ Timed (millis = 200 )
173+ @ Repeat (4 )
174+ public void firstRepetitionOfManyExceedsTimeout () throws Exception {
175+ incrementInvocationCount ();
176+ Thread .sleep (250 );
177+ }
178+
179+ @ Test
180+ @ Timed (millis = 1000 )
181+ @ Repeat (10 )
182+ public void collectiveRepetitionsExceedTimeout () throws Exception {
147183 incrementInvocationCount ();
184+ Thread .sleep (150 );
148185 }
149186 }
150187
0 commit comments