com.webmethods.caf.faces.data.email
Class MockEmailTransport

java.lang.Object
  extended by Transport
      extended by com.webmethods.caf.faces.data.email.MockEmailTransport

public class MockEmailTransport
extends Transport

An email Transport implementation that doesn't send any messages, just queues them in its MockEmailTransport.getSentMessages() list (useful for message-sending functional tests).


Nested Class Summary
static class MockEmailTransport.SentMessage
          Container class for message sent through the mock transport.
 
Field Summary
protected  List sentMessages
           
 
Constructor Summary
MockEmailTransport()
          Default constructor using the session default instance and a default URLName.
MockEmailTransport(Session session)
          Constructor for using a specified session and a default URLName
MockEmailTransport(Session session, URLName name)
          Constructor for using a specified session and URLName.
 
Method Summary
static Transport getMockTransport()
          Mock transport for EmailDeliverer to use.
 List getSentMessages()
          Active list of sent messages.
static boolean isUseMockTransport()
          Determine if this Transport is using a mock transport.
protected  boolean protocolConnect(String host, int port, String user, String password)
          The method to perform the actual protocol-specific connection attempt.
 void sendMessage(Message message, Address[] addresses)
          Adds a sent message to the list of message sent through the mock transport.
static void setMockTransport(Transport transport)
          Mock transport for EmailDeliverer to use (null to not use a mock transport).
static void setUseMockTransport(boolean use)
          Set if this Transport is using a mock transport.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sentMessages

protected List sentMessages
Constructor Detail

MockEmailTransport

public MockEmailTransport()
Default constructor using the session default instance and a default URLName.


MockEmailTransport

public MockEmailTransport(Session session)
Constructor for using a specified session and a default URLName

Parameters:
session - Session object for this Transport.

MockEmailTransport

public MockEmailTransport(Session session,
                          URLName name)
Constructor for using a specified session and URLName.

Parameters:
session - Session object for this Transport.
name - URLName object to be used for this Transport.
Method Detail

isUseMockTransport

public static boolean isUseMockTransport()
Determine if this Transport is using a mock transport.

Returns:
True if EmailDeliverer is using a mock transport. Otherwise false.

setUseMockTransport

public static void setUseMockTransport(boolean use)
Set if this Transport is using a mock transport. If the Transport is already set then continue to use the same Transport. Set the use value to false to clear the Transport.

Parameters:
True - will set the Transport to use a mock transport. False will clear the Transport to use.

getMockTransport

public static Transport getMockTransport()
Mock transport for EmailDeliverer to use.

Returns:
The mock Transport used for this class.

setMockTransport

public static void setMockTransport(Transport transport)
Mock transport for EmailDeliverer to use (null to not use a mock transport).

Parameters:
transport - A Transport

sendMessage

public void sendMessage(Message message,
                        Address[] addresses)
                 throws MessagingException
Adds a sent message to the list of message sent through the mock transport.

Parameters:
message - The message sent.
addresses - The array of address contained in the message.
Throws:
MessagingException

protocolConnect

protected boolean protocolConnect(String host,
                                  int port,
                                  String user,
                                  String password)
                           throws MessagingException
The method to perform the actual protocol-specific connection attempt.

Parameters:
host - String ( ignored )
port - int ( ignored )
user - String ( ignored )
password - String ( ignored )
Returns:
Always returns true.
Throws:
MessagingException

getSentMessages

public List getSentMessages()
Active list of sent messages.

Returns:
A list of SentMessage.