use of org.springframework.integration.mail.ImapIdleChannelAdapter.ImapIdleExceptionEvent in project spring-integration by spring-projects.
the class ImapMailReceiverTests method testConnectionException.
@Test
public void testConnectionException() throws Exception {
ImapMailReceiver mailReceiver = new ImapMailReceiver("imap:foo");
ImapIdleChannelAdapter adapter = new ImapIdleChannelAdapter(mailReceiver);
final AtomicReference<ImapIdleExceptionEvent> theEvent = new AtomicReference<ImapIdleExceptionEvent>();
final CountDownLatch latch = new CountDownLatch(1);
adapter.setApplicationEventPublisher(event -> {
assertNull("only one event expected", theEvent.get());
theEvent.set((ImapIdleExceptionEvent) event);
latch.countDown();
});
ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
taskScheduler.initialize();
adapter.setTaskScheduler(taskScheduler);
adapter.start();
assertTrue(latch.await(10, TimeUnit.SECONDS));
assertTrue(theEvent.get().toString().endsWith("cause=java.lang.IllegalStateException: Failure in 'idle' task. Will resubmit.]"));
}
Aggregations