@Test public void open_withoutInboxFolder_shouldNotTryAndCreateConnection() throws Exception { Pop3Folder folder = new Pop3Folder(mockStore, "TestFolder"); try { folder.open(Folder.OPEN_MODE_RW); } catch (Exception ignored) {} verify(mockStore, never()).createConnection(); }
@Override public synchronized void open(int mode) throws MessagingException { if (isOpen()) { return; } if (!name.equalsIgnoreCase(pop3Store.getConfig().getInboxFolderId())) { throw new MessagingException("Folder does not exist"); } connection = pop3Store.createConnection(); String response = connection.executeSimpleCommand(STAT_COMMAND); String[] parts = response.split(" "); messageCount = Integer.parseInt(parts[1]); uidToMsgMap.clear(); msgNumToMsgMap.clear(); uidToMsgNumMap.clear(); }
Pop3Folder extends Folder<Pop3Message> { @Override public synchronized void open(int mode) throws MessagingException { if (isOpen()) { return; } if (!name.equalsIgnoreCase(pop3Store.getConfig().getInboxFolderId())) { throw new MessagingException("Folder does not exist"); } connection = pop3Store.createConnection(); String response = connection.executeSimpleCommand(STAT_COMMAND); String[] parts = response.split(" "); messageCount = Integer.parseInt(parts[1]); uidToMsgMap.clear(); msgNumToMsgMap.clear(); uidToMsgNumMap.clear(); } }
Pop3Folder extends Folder<Pop3Message> { @Override public synchronized void open(int mode) throws MessagingException { if (isOpen()) { return; } if (!name.equalsIgnoreCase(pop3Store.getConfig().getInboxFolderId())) { throw new MessagingException("Folder does not exist"); } connection = pop3Store.createConnection(); String response = connection.executeSimpleCommand(STAT_COMMAND); String[] parts = response.split(" "); messageCount = Integer.parseInt(parts[1]); uidToMsgMap.clear(); msgNumToMsgMap.clear(); uidToMsgNumMap.clear(); } Pop3Folder(Pop3Store pop3Store, String name); }
Pop3Folder extends Folder<Pop3Message> { @Override public synchronized void open(int mode) throws MessagingException { if (isOpen()) { return; } if (!name.equalsIgnoreCase(pop3Store.getConfig().getInboxFolderId())) { throw new MessagingException("Folder does not exist"); } connection = pop3Store.createConnection(); String response = connection.executeSimpleCommand(STAT_COMMAND); String[] parts = response.split(" "); messageCount = Integer.parseInt(parts[1]); uidToMsgMap.clear(); msgNumToMsgMap.clear(); uidToMsgNumMap.clear(); } Pop3Folder(Pop3Store pop3Store, String name); @Override String getParentId(); @Override synchronized void open(int mode); @Override boolean isOpen(); @Override int getMode(); @Override void close(); @Override String getId(); @Override String getName(); @Override boolean create(FolderType type); @Override boolean exists(); @Override boolean canHaveSubFolders(); @Override int getMessageCount(); @Override int getUnreadMessageCount(); @Override int getFlaggedMessageCount(); @Override Pop3Message getMessage(String uid); @Override List<Pop3Message> getMessages(int start, int end, Date earliestDate, MessageRetrievalListener<Pop3Message> listener); @Override boolean areMoreMessagesAvailable(int indexOfOldestMessage, Date earliestDate); @Override void fetch(List<Pop3Message> messages, FetchProfile fp,
            MessageRetrievalListener<Pop3Message> listener); @Override Map<String, String> appendMessages(List<? extends Message> messages); @Override void delete(boolean recurse); @Override void delete(List<? extends Message> msgs, String trashFolderName); @Override String getUidFromMessageId(Message message); @Override void setFlags(final Set<Flag> flags, boolean value); @Override void setFlags(List<? extends Message> messages, final Set<Flag> flags, boolean value); @Override boolean isFlagSupported(Flag flag); @Override boolean supportsFetchingFlags(); @Override boolean equals(Object o); @Override int hashCode(); }
Pop3Folder extends Folder<Pop3Message> { @Override public synchronized void open(int mode) throws MessagingException { if (isOpen()) { return; } if (!name.equalsIgnoreCase(pop3Store.getConfig().getInboxFolderId())) { throw new MessagingException("Folder does not exist"); } connection = pop3Store.createConnection(); String response = connection.executeSimpleCommand(STAT_COMMAND); String[] parts = response.split(" "); messageCount = Integer.parseInt(parts[1]); uidToMsgMap.clear(); msgNumToMsgMap.clear(); uidToMsgNumMap.clear(); } Pop3Folder(Pop3Store pop3Store, String name); @Override String getParentId(); @Override synchronized void open(int mode); @Override boolean isOpen(); @Override int getMode(); @Override void close(); @Override String getId(); @Override String getName(); @Override boolean create(FolderType type); @Override boolean exists(); @Override boolean canHaveSubFolders(); @Override int getMessageCount(); @Override int getUnreadMessageCount(); @Override int getFlaggedMessageCount(); @Override Pop3Message getMessage(String uid); @Override List<Pop3Message> getMessages(int start, int end, Date earliestDate, MessageRetrievalListener<Pop3Message> listener); @Override boolean areMoreMessagesAvailable(int indexOfOldestMessage, Date earliestDate); @Override void fetch(List<Pop3Message> messages, FetchProfile fp,
            MessageRetrievalListener<Pop3Message> listener); @Override Map<String, String> appendMessages(List<? extends Message> messages); @Override void delete(boolean recurse); @Override void delete(List<? extends Message> msgs, String trashFolderName); @Override String getUidFromMessageId(Message message); @Override void setFlags(final Set<Flag> flags, boolean value); @Override void setFlags(List<? extends Message> messages, final Set<Flag> flags, boolean value); @Override boolean isFlagSupported(Flag flag); @Override boolean supportsFetchingFlags(); @Override boolean equals(Object o); @Override int hashCode();  }