com.emarsys.ecommon.mail.mock
Class MockMailbox

java.lang.Object
  extended by com.emarsys.ecommon.mail.mock.MockMailbox

public class MockMailbox
extends java.lang.Object

Inspired by org.jvnet.mock_javamail.Mailbox.

Author:
Michael "kULO" Kulovits

Constructor Summary
MockMailbox(javax.mail.Address address)
           
 
Method Summary
static void clearAll()
          Discards all the mailboxes and its data.
static MockMailbox get(javax.mail.Address a)
          Get the inbox for the given address.
static MockMailbox get(java.lang.String address)
           
 javax.mail.Address getAddress()
          Gets the e-mail address of this mailbox.
 java.util.List<javax.mail.Message> getFolder(java.lang.String name)
          Will create a new folder with the given name if not yet present.
 java.util.Set<java.lang.String> getFolderNames()
           
 boolean isError()
          Returns true if this mailbox is flagged as 'error'.
 void setError(boolean error)
          Sets if this mailbox should be flagged as 'error'.
 void throwOnError()
           
 void throwOnError(java.lang.String msg)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MockMailbox

public MockMailbox(javax.mail.Address address)
Method Detail

get

public static MockMailbox get(javax.mail.Address a)
Get the inbox for the given address.


get

public static MockMailbox get(java.lang.String address)
                       throws javax.mail.internet.AddressException
Throws:
javax.mail.internet.AddressException

clearAll

public static void clearAll()
Discards all the mailboxes and its data.


getAddress

public javax.mail.Address getAddress()
Gets the e-mail address of this mailbox.


isError

public boolean isError()
Returns true if this mailbox is flagged as 'error'.

See Also:
setError(boolean)

setError

public void setError(boolean error)
Sets if this mailbox should be flagged as 'error'. Any sending/receiving operation with an error mailbox will fail. This behavior can be used to test the error handling behavior of the application.


throwOnError

public void throwOnError()
                  throws javax.mail.MessagingException
Throws:
javax.mail.MessagingException

throwOnError

public void throwOnError(java.lang.String msg)
                  throws javax.mail.MessagingException
Throws:
javax.mail.MessagingException

getFolder

public java.util.List<javax.mail.Message> getFolder(java.lang.String name)
Will create a new folder with the given name if not yet present.

Parameters:
name -
Returns:
always a valid List instance representing a mail folder.

getFolderNames

public java.util.Set<java.lang.String> getFolderNames()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
See Also:
Object.toString()


Copyright © 2010 emarsys AG. All Rights Reserved.