@Test public void testImapNoMessages() throws Exception { BaleenCollectionReader bcr = getCollectionReader( EmailReader.PARAM_PROTOCOL, "imap", EmailReader.PARAM_WAIT, 5, EmailReader.PARAM_SERVER, greenMail.getImap().getBindTo(), EmailReader.PARAM_PORT, greenMail.getImap().getPort(), EmailReader.PARAM_USER, "to@localhost.com", EmailReader.PARAM_PASS, "password"); bcr.initialize(); assertFalse(bcr.doHasNext()); bcr.close(); }
@Override public boolean doHasNext() throws IOException, CollectionException { try { reopenConnection(); } catch (MessagingException me) { throw new IOException("Unable to reconnect to mail server", me); } if (!attachmentQueue.isEmpty() || !messageQueue.isEmpty()) { return true; } try { tryExpunge(); } catch (MessagingException me) { throw new IOException("Unable to expunge (delete) messages", me); } if (lastCheck + wait * 1000 > System.currentTimeMillis()) { return false; } lastCheck = System.currentTimeMillis(); try { for (Message msg : inboxFolder.getMessages()) { String uid = generateUniqueId(msg); if (!alreadyProcessed.add(uid)) { continue; } if (!ATTACHMENTS.equalsIgnoreCase(process) || hasAttachments(msg)) { messageQueue.add(msg); } } } catch (MessagingException me) { throw new IOException("Unable to check for messages", me); } return !messageQueue.isEmpty(); }
EmailReader extends BaleenCollectionReader { @Override public boolean doHasNext() throws IOException, CollectionException { try { reopenConnection(); } catch (MessagingException me) { throw new IOException("Unable to reconnect to mail server", me); } if (!attachmentQueue.isEmpty() || !messageQueue.isEmpty()) { return true; } try { tryExpunge(); } catch (MessagingException me) { throw new IOException("Unable to expunge (delete) messages", me); } if (lastCheck + wait * 1000 > System.currentTimeMillis()) { return false; } lastCheck = System.currentTimeMillis(); try { for (Message msg : inboxFolder.getMessages()) { String uid = generateUniqueId(msg); if (!alreadyProcessed.add(uid)) { continue; } if (!ATTACHMENTS.equalsIgnoreCase(process) || hasAttachments(msg)) { messageQueue.add(msg); } } } catch (MessagingException me) { throw new IOException("Unable to check for messages", me); } return !messageQueue.isEmpty(); } }
EmailReader extends BaleenCollectionReader { @Override public boolean doHasNext() throws IOException, CollectionException { try { reopenConnection(); } catch (MessagingException me) { throw new IOException("Unable to reconnect to mail server", me); } if (!attachmentQueue.isEmpty() || !messageQueue.isEmpty()) { return true; } try { tryExpunge(); } catch (MessagingException me) { throw new IOException("Unable to expunge (delete) messages", me); } if (lastCheck + wait * 1000 > System.currentTimeMillis()) { return false; } lastCheck = System.currentTimeMillis(); try { for (Message msg : inboxFolder.getMessages()) { String uid = generateUniqueId(msg); if (!alreadyProcessed.add(uid)) { continue; } if (!ATTACHMENTS.equalsIgnoreCase(process) || hasAttachments(msg)) { messageQueue.add(msg); } } } catch (MessagingException me) { throw new IOException("Unable to check for messages", me); } return !messageQueue.isEmpty(); }  }
EmailReader extends BaleenCollectionReader { @Override public boolean doHasNext() throws IOException, CollectionException { try { reopenConnection(); } catch (MessagingException me) { throw new IOException("Unable to reconnect to mail server", me); } if (!attachmentQueue.isEmpty() || !messageQueue.isEmpty()) { return true; } try { tryExpunge(); } catch (MessagingException me) { throw new IOException("Unable to expunge (delete) messages", me); } if (lastCheck + wait * 1000 > System.currentTimeMillis()) { return false; } lastCheck = System.currentTimeMillis(); try { for (Message msg : inboxFolder.getMessages()) { String uid = generateUniqueId(msg); if (!alreadyProcessed.add(uid)) { continue; } if (!ATTACHMENTS.equalsIgnoreCase(process) || hasAttachments(msg)) { messageQueue.add(msg); } } } catch (MessagingException me) { throw new IOException("Unable to check for messages", me); } return !messageQueue.isEmpty(); }  @Override boolean doHasNext(); }
EmailReader extends BaleenCollectionReader { @Override public boolean doHasNext() throws IOException, CollectionException { try { reopenConnection(); } catch (MessagingException me) { throw new IOException("Unable to reconnect to mail server", me); } if (!attachmentQueue.isEmpty() || !messageQueue.isEmpty()) { return true; } try { tryExpunge(); } catch (MessagingException me) { throw new IOException("Unable to expunge (delete) messages", me); } if (lastCheck + wait * 1000 > System.currentTimeMillis()) { return false; } lastCheck = System.currentTimeMillis(); try { for (Message msg : inboxFolder.getMessages()) { String uid = generateUniqueId(msg); if (!alreadyProcessed.add(uid)) { continue; } if (!ATTACHMENTS.equalsIgnoreCase(process) || hasAttachments(msg)) { messageQueue.add(msg); } } } catch (MessagingException me) { throw new IOException("Unable to check for messages", me); } return !messageQueue.isEmpty(); }  @Override boolean doHasNext(); static final String PARAM_SERVER; static final String PARAM_PORT; static final String PARAM_USER; static final String PARAM_PASS; static final String PARAM_PROTOCOL; static final String PARAM_INBOX; static final String PARAM_WAIT; static final String PARAM_DELETE_EMAIL; static final String PARAM_DELETE_ATTACHMENT; static final String PARAM_FOLDER; static final String PARAM_PROCESS; static final String BOTH; static final String CONTENT; static final String ATTACHMENTS; }