com.xpn.xwiki.test.smtp
Class SimpleSmtpServer

java.lang.Object
  extended bycom.xpn.xwiki.test.smtp.SimpleSmtpServer
All Implemented Interfaces:
java.lang.Runnable

public class SimpleSmtpServer
extends java.lang.Object
implements java.lang.Runnable

Dummy SMTP server for testing purposes.


Field Summary
private  boolean doStop
          Indicates if a stop request has been sent to this server.
private  java.util.List receivedMail
          Stores all of the email received since this instance started up.
static int SMTP_PORT
          SMTP uses port 25.
private  boolean stopped
          Indicates whether this server is stopped or not.
 
Constructor Summary
SimpleSmtpServer()
          Constructor.
 
Method Summary
 int getReceievedEmailSize()
          Get the number of messages received.
 java.util.Iterator getReceivedEmail()
          Get email received by this instance since start up.
 boolean isStopped()
          Indicates whether this server is stopped or not.
 void run()
          Main loop of the SMTP server.
private  void sendResponse(java.io.PrintWriter out, SmtpResponse smtpResponse)
          Send response to client.
static SimpleSmtpServer start()
          Creates an instance of SimpleSmtpServer and starts it.
 void stop()
          Forces the server to stop after processing the current request.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

receivedMail

private java.util.List receivedMail
Stores all of the email received since this instance started up.


SMTP_PORT

public static final int SMTP_PORT
SMTP uses port 25.

See Also:
Constant Field Values

stopped

private volatile boolean stopped
Indicates whether this server is stopped or not.


doStop

private volatile boolean doStop
Indicates if a stop request has been sent to this server.

Constructor Detail

SimpleSmtpServer

public SimpleSmtpServer()
Constructor.

Method Detail

run

public void run()
Main loop of the SMTP server.

Specified by:
run in interface java.lang.Runnable

sendResponse

private void sendResponse(java.io.PrintWriter out,
                          SmtpResponse smtpResponse)
Send response to client.

Parameters:
out - socket output stream
smtpResponse - response object

getReceivedEmail

public java.util.Iterator getReceivedEmail()
Get email received by this instance since start up.

Returns:
List of String

getReceievedEmailSize

public int getReceievedEmailSize()
Get the number of messages received.

Returns:
size of received email list

stop

public void stop()
Forces the server to stop after processing the current request.


isStopped

public boolean isStopped()
Indicates whether this server is stopped or not.

Returns:
true iff this server is stopped

start

public static SimpleSmtpServer start()
Creates an instance of SimpleSmtpServer and starts it.

Returns:
a reference to the SMTP server


Copyright 2003 Ludovic Dubost