File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed
spring-integration-core/src/test/java/org/springframework/integration/endpoint Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change 52
52
* @author Oleg Zhurakousky
53
53
* @author Gunnar Hillert
54
54
* @author Artem Bilan
55
+ * @author Gary Russell
55
56
*/
56
57
public class PollingLifecycleTests {
57
58
@@ -144,16 +145,18 @@ public void ensurePollerTaskStopsForAdapterWithInterruptible() throws Exception
144
145
pollerMetadata .setTrigger (new PeriodicTrigger (2000 ));
145
146
adapterFactory .setPollerMetadata (pollerMetadata );
146
147
final Runnable caughtInterrupted = mock (Runnable .class );
148
+ final CountDownLatch interruptedLatch = new CountDownLatch (1 );
147
149
MessageSource <String > source = () -> {
148
150
149
151
try {
150
152
for (int i = 0 ; i < 10 ; i ++) {
151
- Thread .sleep (10 );
153
+ Thread .sleep (latch . getCount () > 0 ? 10 : 1000 );
152
154
latch .countDown ();
153
155
}
154
156
}
155
157
catch (InterruptedException e ) {
156
158
caughtInterrupted .run ();
159
+ interruptedLatch .countDown ();
157
160
}
158
161
159
162
return new GenericMessage <>("hello" );
@@ -165,10 +168,10 @@ public void ensurePollerTaskStopsForAdapterWithInterruptible() throws Exception
165
168
adapter .setTaskScheduler (taskScheduler );
166
169
adapter .afterPropertiesSet ();
167
170
adapter .start ();
168
- assertTrue (latch .await (3000 , TimeUnit .SECONDS ));
171
+ assertTrue (latch .await (10_000 , TimeUnit .SECONDS ));
169
172
//
170
173
adapter .stop ();
171
- Thread . sleep ( 10 );
174
+ assertTrue ( interruptedLatch . await ( 10_000 , TimeUnit . SECONDS ) );
172
175
Mockito .verify (caughtInterrupted , times (1 )).run ();
173
176
}
174
177
You can’t perform that action at this time.
0 commit comments