11/*
2- * Copyright 2002-2019 the original author or authors.
2+ * Copyright 2002-2021 the original author or authors.
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
2626import java .util .concurrent .TimeUnit ;
2727import java .util .concurrent .atomic .AtomicBoolean ;
2828
29- import org .junit .After ;
30- import org .junit .Before ;
31- import org .junit .Test ;
29+ import org .junit .jupiter . api . AfterEach ;
30+ import org .junit .jupiter . api . BeforeEach ;
31+ import org .junit .jupiter . api . Test ;
3232import org .mockito .Mockito ;
3333
3434import org .springframework .beans .factory .BeanFactory ;
@@ -59,12 +59,12 @@ public class PollingLifecycleTests {
5959
6060 private final TestErrorHandler errorHandler = new TestErrorHandler ();
6161
62- @ Before
62+ @ BeforeEach
6363 public void init () {
6464 this .taskScheduler .afterPropertiesSet ();
6565 }
6666
67- @ After
67+ @ AfterEach
6868 public void tearDown () {
6969 this .taskScheduler .destroy ();
7070 }
@@ -91,7 +91,7 @@ public void handleMessage(Message<?> message) throws MessagingException {
9191 consumer .setBeanFactory (mock (BeanFactory .class ));
9292 consumer .afterPropertiesSet ();
9393 consumer .start ();
94- assertThat (latch .await (2 , TimeUnit .SECONDS )).isTrue ();
94+ assertThat (latch .await (10 , TimeUnit .SECONDS )).isTrue ();
9595 Mockito .verify (handler , times (1 )).handleMessage (Mockito .any (Message .class ));
9696 consumer .stop ();
9797 Mockito .reset (handler );
@@ -102,8 +102,7 @@ public void handleMessage(Message<?> message) throws MessagingException {
102102 }
103103
104104 @ Test
105- public void ensurePollerTaskStopsForAdapter () throws Exception {
106- final CountDownLatch latch = new CountDownLatch (1 );
105+ public void ensurePollerTaskStopsForAdapter () {
107106 QueueChannel channel = new QueueChannel ();
108107
109108 SourcePollingChannelAdapterFactoryBean adapterFactory = new SourcePollingChannelAdapterFactoryBean ();
@@ -116,7 +115,6 @@ public void ensurePollerTaskStopsForAdapter() throws Exception {
116115
117116 @ Override
118117 public Message <String > receive () {
119- latch .countDown ();
120118 return new GenericMessage <>("hello" );
121119 }
122120
@@ -128,8 +126,7 @@ public Message<String> receive() {
128126 adapter .setTaskScheduler (this .taskScheduler );
129127 adapter .afterPropertiesSet ();
130128 adapter .start ();
131- assertThat (latch .await (20 , TimeUnit .SECONDS )).isTrue ();
132- assertThat (channel .receive (100 )).isNotNull ();
129+ assertThat (channel .receive (10000 )).isNotNull ();
133130 adapter .stop ();
134131 assertThat (channel .receive (10 )).isNull ();
135132 Mockito .verify (source , times (1 )).receive ();
0 commit comments