Source:
<code>public void testIdleWithServer() throws Exception { Properties mailProps = new Properties(); mailProps.put("mail.debug", "true"); mailProps.put("mail.imap.connectionpool.debug", "true"); ImapMailReceiver receiver = new ImapMailReceiver("imap://user:pw@localhost:" + imapIdlePort + "/INBOX"); receiver.setJavaMailProperties(mailProps); receiver.setMaxFetchSize(1); receiver.setShouldDeleteMessages(false); receiver.setShouldMarkMessagesAsRead(true); receiver.setSearchTermStrategy(new SearchTermStrategy() { @Override public SearchTerm generateSearchTerm(Flags supportedFlags, Folder folder) { try { FromTerm fromTerm = new FromTerm(new InternetAddress("bar@baz")); AndTerm andTerm = new AndTerm(fromTerm, new FlagTerm(new Flags(Flags.Flag.SEEN), false)); return andTerm; } catch (AddressException e) { throw new RuntimeException(e); } } }); ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler(); setUpScheduler(receiver, taskScheduler); receiver.afterPropertiesSet(); Log logger = spy(TestUtils.getPropertyValue(receiver, "logger", Log.class)); new DirectFieldAccessor(receiver).setPropertyValue("logger", logger); <START> doAnswer(new CallsRealMethods()).when(logger).debug("Canceling IDLE"); <END> ImapIdleChannelAdapter adapter = new ImapIdleChannelAdapter(receiver); QueueChannel channel = new QueueChannel(); adapter.setOutputChannel(channel); adapter.setTaskScheduler(taskScheduler); adapter.setCancelIdleInterval(8); adapter.start(); assertNotNull(channel.receive(6000)); assertNotNull(channel.receive(6000)); assertNull(channel.receive(10000)); verify(logger).debug("Canceling IDLE"); taskScheduler.shutdown(); }</code><technical_language>Redundant</technical_language>

Target:
public void testIdleWithServer() throws Exception { Properties mailProps = new Properties(); mailProps.put("mail.debug", "true"); mailProps.put("mail.imap.connectionpool.debug", "true"); ImapMailReceiver receiver = new ImapMailReceiver("imap://user:pw@localhost:" + imapIdlePort + "/INBOX"); receiver.setJavaMailProperties(mailProps); receiver.setMaxFetchSize(1); receiver.setShouldDeleteMessages(false); receiver.setShouldMarkMessagesAsRead(true); receiver.setSearchTermStrategy(new SearchTermStrategy() { @Override public SearchTerm generateSearchTerm(Flags supportedFlags, Folder folder) { try { FromTerm fromTerm = new FromTerm(new InternetAddress("bar@baz")); AndTerm andTerm = new AndTerm(fromTerm, new FlagTerm(new Flags(Flags.Flag.SEEN), false)); return andTerm; } catch (AddressException e) { throw new RuntimeException(e); } } }); receiver.setCancelIdleInterval(8); ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler(); setUpScheduler(receiver, taskScheduler); receiver.afterPropertiesSet(); Log logger = spy(TestUtils.getPropertyValue(receiver, "logger", Log.class)); new DirectFieldAccessor(receiver).setPropertyValue("logger", logger); ImapIdleChannelAdapter adapter = new ImapIdleChannelAdapter(receiver); QueueChannel channel = new QueueChannel(); adapter.setOutputChannel(channel); adapter.setTaskScheduler(taskScheduler); adapter.start(); assertNotNull(channel.receive(6000)); assertNotNull(channel.receive(6000)); assertNull(channel.receive(10000)); verify(logger).debug("Canceling IDLE"); taskScheduler.shutdown(); }