com.emarsys.ecommon.mail.mock
Class PopMockFolder

java.lang.Object
  extended by javax.mail.Folder
      extended by com.emarsys.ecommon.mail.mock.MockFolder
          extended by com.emarsys.ecommon.mail.mock.PopMockFolder

public class PopMockFolder
extends MockFolder

A MockFolder that mimics some behavior of POP3Folder (the default POP3 provider in javamail).

Author:
Michael "kULO" Kulovits

Field Summary
 
Fields inherited from class com.emarsys.ecommon.mail.mock.MockFolder
mailbox, name, open
 
Fields inherited from class javax.mail.Folder
HOLDS_FOLDERS, HOLDS_MESSAGES, mode, READ_ONLY, READ_WRITE, store
 
Constructor Summary
PopMockFolder(MockStore store, MockMailbox mailbox, java.lang.String name)
           
 
Method Summary
 void appendMessages(javax.mail.Message[] msgs)
          Always throws MethodNotSupportedException because the POP3 protocol doesn't support appending messages.
 boolean create(int type)
          Always returns false; the POP3 protocol doesn't support creating folders.
 boolean delete(boolean recurse)
          Always throws MethodNotSupportedException because the POP3 protocol doesn't allow the INBOX to be deleted.
 boolean exists()
           
 javax.mail.Message[] expunge()
          Always throws MethodNotSupportedException because the POP3 protocol doesn't support expunging messages without closing the folder; call the close method with the expunge argument set to true instead.
 javax.mail.Folder getFolder(java.lang.String name)
          Always throws MessagingException because no POP3 folders can contain subfolders.
 javax.mail.Flags getPermanentFlags()
          Always returns an empty Flags object because the POP3 protocol doesn't support any permanent flags.
 char getSeparator()
          Always returns a NUL character because POP3 doesn't support a hierarchy.
 int getType()
          Always returns Folder.HOLDS_MESSAGES.
 boolean hasNewMessages()
          Always returns false; the POP3 protocol provides no way to determine when a new message arrives.
 javax.mail.Folder[] list(java.lang.String pattern)
          Always throws MessagingException because no POP3 folders can contain subfolders.
 void open(int mode)
           
 boolean renameTo(javax.mail.Folder f)
          Always throws MethodNotSupportedException because the POP3 protocol doesn't support multiple folders.
 
Methods inherited from class com.emarsys.ecommon.mail.mock.MockFolder
close, doExpunge, getFullName, getInstance, getMailboxFolder, getMessage, getMessageCount, getName, getParent, isOpen
 
Methods inherited from class javax.mail.Folder
addConnectionListener, addFolderListener, addMessageChangedListener, addMessageCountListener, copyMessages, fetch, finalize, getDeletedMessageCount, getMessages, getMessages, getMessages, getMode, getNewMessageCount, getStore, getUnreadMessageCount, getURLName, isSubscribed, list, listSubscribed, listSubscribed, notifyConnectionListeners, notifyFolderListeners, notifyFolderRenamedListeners, notifyMessageAddedListeners, notifyMessageChangedListeners, notifyMessageRemovedListeners, removeConnectionListener, removeFolderListener, removeMessageChangedListener, removeMessageCountListener, search, search, setFlags, setFlags, setFlags, setSubscribed, toString
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PopMockFolder

public PopMockFolder(MockStore store,
                     MockMailbox mailbox,
                     java.lang.String name)
Parameters:
store -
mailbox -
name -
Method Detail

open

public void open(int mode)
          throws javax.mail.MessagingException
Overrides:
open in class MockFolder
Throws:
javax.mail.MessagingException
See Also:
MockFolder.open(int)

exists

public boolean exists()
               throws javax.mail.MessagingException
Overrides:
exists in class MockFolder
Throws:
javax.mail.MessagingException
See Also:
MockFolder.exists()

list

public javax.mail.Folder[] list(java.lang.String pattern)
                         throws javax.mail.MessagingException
Always throws MessagingException because no POP3 folders can contain subfolders.

Overrides:
list in class MockFolder
Throws:
javax.mail.MessagingException - always
See Also:
Folder.list(java.lang.String)

getSeparator

public char getSeparator()
Always returns a NUL character because POP3 doesn't support a hierarchy.

Overrides:
getSeparator in class MockFolder
Returns:
NUL
See Also:
Folder.getSeparator()

getType

public int getType()
Always returns Folder.HOLDS_MESSAGES.

Overrides:
getType in class MockFolder
Returns:
Folder.HOLDS_MESSAGES
See Also:
Folder.getType()

create

public boolean create(int type)
               throws javax.mail.MessagingException
Always returns false; the POP3 protocol doesn't support creating folders.

Overrides:
create in class MockFolder
Returns:
false
Throws:
javax.mail.MessagingException
See Also:
Folder.create(int)

hasNewMessages

public boolean hasNewMessages()
                       throws javax.mail.MessagingException
Always returns false; the POP3 protocol provides no way to determine when a new message arrives.

Overrides:
hasNewMessages in class MockFolder
Returns:
false
Throws:
javax.mail.MessagingException
See Also:
Folder.hasNewMessages()

getFolder

public javax.mail.Folder getFolder(java.lang.String name)
                            throws javax.mail.MessagingException
Always throws MessagingException because no POP3 folders can contain subfolders.

Overrides:
getFolder in class MockFolder
Throws:
javax.mail.MessagingException - always
See Also:
Folder.getFolder(java.lang.String)

delete

public boolean delete(boolean recurse)
               throws javax.mail.MessagingException
Always throws MethodNotSupportedException because the POP3 protocol doesn't allow the INBOX to be deleted.

Overrides:
delete in class MockFolder
Throws:
javax.mail.MethodNotSupportedException - always
javax.mail.MessagingException
See Also:
Folder.delete(boolean)

renameTo

public boolean renameTo(javax.mail.Folder f)
                 throws javax.mail.MessagingException
Always throws MethodNotSupportedException because the POP3 protocol doesn't support multiple folders.

Overrides:
renameTo in class MockFolder
Throws:
javax.mail.MethodNotSupportedException - always
javax.mail.MessagingException
See Also:
Folder.renameTo(javax.mail.Folder)

getPermanentFlags

public javax.mail.Flags getPermanentFlags()
Always returns an empty Flags object because the POP3 protocol doesn't support any permanent flags.

Overrides:
getPermanentFlags in class MockFolder
Returns:
empty Flags object
See Also:
Folder.getPermanentFlags()

appendMessages

public void appendMessages(javax.mail.Message[] msgs)
                    throws javax.mail.MessagingException
Always throws MethodNotSupportedException because the POP3 protocol doesn't support appending messages.

Overrides:
appendMessages in class MockFolder
Throws:
javax.mail.MethodNotSupportedException - always
javax.mail.MessagingException
See Also:
Folder.appendMessages(javax.mail.Message[])

expunge

public javax.mail.Message[] expunge()
                             throws javax.mail.MessagingException
Always throws MethodNotSupportedException because the POP3 protocol doesn't support expunging messages without closing the folder; call the close method with the expunge argument set to true instead.

Overrides:
expunge in class MockFolder
Throws:
javax.mail.MethodNotSupportedException - always
javax.mail.MessagingException
See Also:
Folder.expunge()


Copyright © 2010 emarsys AG. All Rights Reserved.