17
17
package org .springframework .amqp .rabbit .listener ;
18
18
19
19
import static org .hamcrest .Matchers .greaterThanOrEqualTo ;
20
- import static org .hamcrest .Matchers .instanceOf ;
21
20
import static org .junit .Assert .assertArrayEquals ;
22
21
import static org .junit .Assert .assertEquals ;
23
22
import static org .junit .Assert .assertFalse ;
68
67
import org .springframework .amqp .support .converter .MessageConversionException ;
69
68
import org .springframework .amqp .utils .test .TestUtils ;
70
69
import org .springframework .context .ApplicationContext ;
71
- import org .springframework .context .ApplicationEvent ;
72
70
import org .springframework .context .event .ContextClosedEvent ;
73
71
import org .springframework .context .support .GenericApplicationContext ;
74
72
import org .springframework .scheduling .concurrent .ThreadPoolTaskExecutor ;
@@ -317,15 +315,13 @@ public void testEvents() throws Exception {
317
315
container .setQueueNames (EQ1 , EQ2 );
318
316
final List <Long > times = new ArrayList <>();
319
317
final CountDownLatch latch1 = new CountDownLatch (2 );
320
- final AtomicReference <ApplicationEvent > failEvent = new AtomicReference <>();
321
318
final CountDownLatch latch2 = new CountDownLatch (2 );
322
319
container .setApplicationEventPublisher (event -> {
323
320
if (event instanceof ListenerContainerIdleEvent ) {
324
321
times .add (System .currentTimeMillis ());
325
322
latch1 .countDown ();
326
323
}
327
- else {
328
- failEvent .set ((ApplicationEvent ) event );
324
+ else if (event instanceof ListenerContainerConsumerTerminatedEvent ) {
329
325
latch2 .countDown ();
330
326
}
331
327
});
@@ -339,8 +335,6 @@ public void testEvents() throws Exception {
339
335
assertThat (times .get (1 ) - times .get (0 ), greaterThanOrEqualTo (50L ));
340
336
brokerRunning .deleteQueues (EQ1 , EQ2 );
341
337
assertTrue (latch2 .await (10 , TimeUnit .SECONDS ));
342
- assertNotNull (failEvent .get ());
343
- assertThat (failEvent .get (), instanceOf (ListenerContainerConsumerTerminatedEvent .class ));
344
338
container .stop ();
345
339
cf .destroy ();
346
340
}
0 commit comments