jSyncManager Simple Java Server

org.jSyncManager.SJS.Tests
Class MailDeliveryTest

java.lang.Object
  extended by java.lang.Thread
      extended by org.jSyncManager.SJS.API.AbstractAdapter
          extended by org.jSyncManager.SJS.API.AbstractRequestResponseAdapter
              extended by org.jSyncManager.SJS.Adapters.SMTPServer.AbstractSMTPServer
                  extended by org.jSyncManager.SJS.Adapters.SMTPServer.SMTPServer
                      extended by org.jSyncManager.SJS.Tests.MailDeliveryTest
All Implemented Interfaces:
java.lang.Runnable

public class MailDeliveryTest
extends SMTPServer

Description of the type...

Version:
$Revision$
Author:
campbelm

Nested Class Summary
 
Nested classes/interfaces inherited from class org.jSyncManager.SJS.Adapters.SMTPServer.AbstractSMTPServer
AbstractSMTPServer.CommandData, AbstractSMTPServer.CommandEhlo, AbstractSMTPServer.CommandExpn, AbstractSMTPServer.CommandHelo, AbstractSMTPServer.CommandHelp, AbstractSMTPServer.CommandMail, AbstractSMTPServer.CommandNoop, AbstractSMTPServer.CommandQuit, AbstractSMTPServer.CommandRcpt, AbstractSMTPServer.CommandRset, AbstractSMTPServer.CommandVrfy, AbstractSMTPServer.SmtpCommand, AbstractSMTPServer.State
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
 int DATA_BAD_SEQ_ERROR
          The code for bad sequence.
 int DATA_FINNISHED
          The code for successful data ending with a "."
 int DATA_SUCCESS
          The code for a successful call to the DATA command
 java.lang.String[] domains
          An array of strings that are the specified domains
 int SENDER_ERROR
          The code for a failed DATA call due to an unavailable RCPT TO field
 int SENDER_SUCCESS
          Variable definition...
 java.lang.String[] users
          An array of strings that are the specified users
 
Fields inherited from class org.jSyncManager.SJS.Adapters.SMTPServer.SMTPServer
domain, server
 
Fields inherited from class org.jSyncManager.SJS.Adapters.SMTPServer.AbstractSMTPServer
atDomainRegex, commands, currentMask, domainRegex, INVALID_ADDR_SYNTAX, INVALID_SEQUENCE, INVALID_SYNTAX, mailAddrExpr, PARAM_NOT_IMPLEMENTED, rcptAddrExpr, relayPattern, state, validEmailChars
 
Fields inherited from class org.jSyncManager.SJS.API.AbstractAdapter
props
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
MailDeliveryTest()
           
 
Method Summary
static void beginClass()
          General summary
 void beginMethod()
          The method executed before the main tests are run.
 void cleanMboxes()
          Clear the mailboxes of the users.
static void endClass()
          Tear down method.
 void endMethod()
          Tear down method.
 java.lang.String generateNewDomain()
          Generates a random domain name.
 java.lang.String generateNewUser()
          Generates a random username.
 java.lang.String generateRandomLowerString()
          Generates random lower strings.
 java.lang.String generateRandomUpperString()
          Generates random upper strings.
static void main(java.lang.String[] args)
          Main method.
 java.lang.String readMbox(java.lang.String fromUser)
          Reads the mailbox for a particular user and returns it as one string.
 void testMailReturns()
          This is the main SMPTServer tester.
 void testMBoxes()
          This tests the MBox implementation
 
Methods inherited from class org.jSyncManager.SJS.Adapters.SMTPServer.SMTPServer
getAddress, getDomains, getMboxForUser, getUsers, init, processData, processEhlo, processExpn, processHelo, processHelp, processMail, processMessageFinished, processMessagePart, processNoop, processQuit, processRcpt, processRset, processVrfy
 
Methods inherited from class org.jSyncManager.SJS.Adapters.SMTPServer.AbstractSMTPServer
getCommands, getConnectionHeaderString, getCurrentMask, getMailAddrExpr, getRcptAddrExpr, getStateLong, initCommands, processRequest
 
Methods inherited from class org.jSyncManager.SJS.API.AbstractRequestResponseAdapter
disconnect, getTimeoutMessage, processConnection
 
Methods inherited from class org.jSyncManager.SJS.API.AbstractAdapter
connectionPermitted, getConnectionManagerInterface, getInetAddress, getLogManager, getProperty, processConnection, run, setLogManager, setThreadGroup
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

domains

public java.lang.String[] domains
An array of strings that are the specified domains


users

public java.lang.String[] users
An array of strings that are the specified users


DATA_BAD_SEQ_ERROR

public final int DATA_BAD_SEQ_ERROR
The code for bad sequence. This happens when the RCPT TO command is invalid

See Also:
Constant Field Values

DATA_FINNISHED

public final int DATA_FINNISHED
The code for successful data ending with a "."

See Also:
Constant Field Values

DATA_SUCCESS

public final int DATA_SUCCESS
The code for a successful call to the DATA command

See Also:
Constant Field Values

SENDER_ERROR

public final int SENDER_ERROR
The code for a failed DATA call due to an unavailable RCPT TO field

See Also:
Constant Field Values

SENDER_SUCCESS

public final int SENDER_SUCCESS
Variable definition...

See Also:
Constant Field Values
Constructor Detail

MailDeliveryTest

public MailDeliveryTest()
Method Detail

beginClass

public static void beginClass()
                       throws java.lang.Exception
General summary

Throws:
java.lang.Exception - exception

beginMethod

public void beginMethod()
The method executed before the main tests are run. It creates a new LogManager and gets the users and domains from the SMTPServer.


testMailReturns

public void testMailReturns()
This is the main SMPTServer tester. It checks if the server correctly - returns DATA_BAD_SEQ_ERROR in the case of out of sequence commands - correctly returns DATA_FINNISHED when the data is finished. - shows DATA_SUCCESS if the data is sent successfully. - returns SENDER_ERROR if the sender does not exist. - returns SENDER_SUCCESS if the sender exists.


testMBoxes

public void testMBoxes()
This tests the MBox implementation


endMethod

public void endMethod()
Tear down method. Runs after each test method.


endClass

public static void endClass()
Tear down method. Runs once after the class.


readMbox

public java.lang.String readMbox(java.lang.String fromUser)
                          throws java.lang.Exception
Reads the mailbox for a particular user and returns it as one string.

Parameters:
fromUser - the user to read the mailbox for.
Returns:
the user mailbox in string format.
Throws:
java.lang.Exception - exception

cleanMboxes

public void cleanMboxes()
Clear the mailboxes of the users.


generateRandomLowerString

public java.lang.String generateRandomLowerString()
Generates random lower strings.

Returns:
randomly generated string.

generateRandomUpperString

public java.lang.String generateRandomUpperString()
Generates random upper strings.

Returns:
randomly generated string.

generateNewUser

public java.lang.String generateNewUser()
Generates a random username.

Returns:
randomly generated username that is not in users[] and always at least one char long

generateNewDomain

public java.lang.String generateNewDomain()
Generates a random domain name.

Returns:
randomly generated domain that is not in domains[], always ends in .com and always at least one char long

main

public static void main(java.lang.String[] args)
Main method. Initialises the JUnit tests. This is so we can just run the class and do the tests without using the build file.

note that doing this requires the change of one variables in SMTPServer but is merely a debug tool

Parameters:
args - runtime arguments (ignored).

jSyncManager Simple Java Server

Copyright (c) 2004 Brad BARCLAY. All Rights Reserved.