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 5252 * @author Oleg Zhurakousky
5353 * @author Gunnar Hillert
5454 * @author Artem Bilan
55+ * @author Gary Russell
5556 */
5657public class PollingLifecycleTests {
5758
@@ -144,16 +145,18 @@ public void ensurePollerTaskStopsForAdapterWithInterruptible() throws Exception
144145 pollerMetadata .setTrigger (new PeriodicTrigger (2000 ));
145146 adapterFactory .setPollerMetadata (pollerMetadata );
146147 final Runnable caughtInterrupted = mock (Runnable .class );
148+ final CountDownLatch interruptedLatch = new CountDownLatch (1 );
147149 MessageSource <String > source = () -> {
148150
149151 try {
150152 for (int i = 0 ; i < 10 ; i ++) {
151- Thread .sleep (10 );
153+ Thread .sleep (latch . getCount () > 0 ? 10 : 1000 );
152154 latch .countDown ();
153155 }
154156 }
155157 catch (InterruptedException e ) {
156158 caughtInterrupted .run ();
159+ interruptedLatch .countDown ();
157160 }
158161
159162 return new GenericMessage <>("hello" );
@@ -165,10 +168,10 @@ public void ensurePollerTaskStopsForAdapterWithInterruptible() throws Exception
165168 adapter .setTaskScheduler (taskScheduler );
166169 adapter .afterPropertiesSet ();
167170 adapter .start ();
168- assertTrue (latch .await (3000 , TimeUnit .SECONDS ));
171+ assertTrue (latch .await (10_000 , TimeUnit .SECONDS ));
169172 //
170173 adapter .stop ();
171- Thread . sleep ( 10 );
174+ assertTrue ( interruptedLatch . await ( 10_000 , TimeUnit . SECONDS ) );
172175 Mockito .verify (caughtInterrupted , times (1 )).run ();
173176 }
174177
You can’t perform that action at this time.
0 commit comments