Skip to content

Commit 3c27241

Browse files
authored
Improve IMAP IDLE tests
This forces the race condition that was fixed in #3535 consistently. Before the `IdleCanceler` was used to cancel the `idle()` call in addition to the normal flow. That should not be necessary any more.
1 parent d8c7ae7 commit 3c27241

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

spring-integration-mail/src/test/java/org/springframework/integration/mail/ImapMailReceiverTests.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,13 +185,10 @@ public void testIdleWithServerGuts(ImapMailReceiver receiver, boolean mapped, bo
185185
receiver.setMaxFetchSize(1);
186186
receiver.setShouldDeleteMessages(false);
187187
receiver.setShouldMarkMessagesAsRead(true);
188-
receiver.setCancelIdleInterval(1);
189188
ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
190189
setUpScheduler(receiver, taskScheduler);
191190
receiver.setUserFlag("testSIUserFlag");
192191
receiver.afterPropertiesSet();
193-
LogAccessor logger = spy(TestUtils.getPropertyValue(receiver, "logger", LogAccessor.class));
194-
new DirectFieldAccessor(receiver).setPropertyValue("logger", logger);
195192
ImapIdleChannelAdapter adapter = new ImapIdleChannelAdapter(receiver);
196193
QueueChannel channel = new QueueChannel();
197194
adapter.setOutputChannel(channel);
@@ -237,7 +234,6 @@ public void testIdleWithServerGuts(ImapMailReceiver receiver, boolean mapped, bo
237234
}
238235
assertThat(channel.receive(20000)).isNotNull(); // new message after idle
239236
assertThat(channel.receive(100)).isNull(); // no new message after second and third idle
240-
verify(logger).debug("Canceling IDLE");
241237

242238
adapter.stop();
243239
taskScheduler.shutdown();

spring-integration-test-support/src/main/java/org/springframework/integration/test/mail/TestMailServer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2019 the original author or authors.
2+
* Copyright 2014-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.
@@ -254,7 +254,7 @@ class ImapHandler extends MailHandler {
254254
/**
255255
* Time to wait while IDLE before returning a result.
256256
*/
257-
private static final int IDLE_WAIT_TIME = 1000;
257+
private static final int IDLE_WAIT_TIME = 500;
258258

259259
ImapHandler(Socket socket) {
260260
super(socket);

0 commit comments

Comments
 (0)