Previously, if an IMAP server supports IDLE, but not
RECENT, no existing messages were retrieved until a new
message arrived.
INT-2821 Polishing - Fix Race Condition
Use searchForMessages() when server doesn't support RECENT.
Simply skipping the first idle() doesn't work
because receive() closes the folder, there was a race condition
where a new message could arrive between the previous receive()
and folder.open() in waitForMessages().
Updated mock test so that first call to waitForMessages() finds
messages and does not idle(), and subsequent calls does not
find messages and goes to idle().
Also tested in the debugger against gmail which (at the time of
writing) does not support RECENT.