public abstract class BaseEmailTestCase extends junit.framework.TestCase
| Modifier and Type | Field and Description |
|---|---|
static int |
BODY_END_PAD
Padding at end of body added by wiser/send
|
static int |
BODY_START_PAD
Padding at start of body added by wiser/send
|
protected org.subethamail.wiser.Wiser |
fakeMailServer
The fake Wiser email server
|
protected String |
strTestMailFrom
From address for the test email
|
protected String |
strTestMailServer
Mail server used for testing
|
protected String |
strTestMailTo
Destination address for the test email
|
protected String |
strTestPasswd
Mailserver strTestPasswd (set if needed)
|
protected String |
strTestURL
URL to used to test URL attachmetns (Must be valid)
|
protected String |
strTestUser
Mailserver username (set if needed)
|
protected String[] |
testCharsNotValid
Array of test strings
|
protected String[] |
testCharsValid
Test characters acceptable to email
|
| Constructor and Description |
|---|
BaseEmailTestCase(String name) |
| Modifier and Type | Method and Description |
|---|---|
protected URL |
createInvalidURL()
Create a mocked URL object which always throws an IOException
when the openStream() method is called.
|
void |
getMailServer()
Initializes the stub mail server.
|
protected int |
getMailServerPort()
Gets the mail server port.
|
String |
getMessageAsString(int intMsgNo) |
protected boolean |
isMailServerStopped(org.subethamail.wiser.Wiser fakeMailServer)
Checks if an email server is running at the address stored in the
fakeMailServer. |
protected void |
saveEmailToFile(org.subethamail.wiser.WiserMessage email)
Safe a mail to a file using a more or less unique file name.
|
protected void |
tearDown() |
protected org.subethamail.wiser.WiserMessage |
validateSend(org.subethamail.wiser.Wiser mailServer,
String strSubject,
InternetAddress fromAdd,
List<InternetAddress> toAdd,
List<InternetAddress> ccAdd,
List<InternetAddress> bccAdd,
boolean boolSaveToFile)
Validate the message was sent properly
|
protected void |
validateSend(org.subethamail.wiser.Wiser mailServer,
String strSubject,
Multipart content,
InternetAddress fromAdd,
List<InternetAddress> toAdd,
List<InternetAddress> ccAdd,
List<InternetAddress> bccAdd,
boolean boolSaveToFile)
Validate the message was sent properly
|
protected void |
validateSend(org.subethamail.wiser.Wiser mailServer,
String strSubject,
String strMessage,
InternetAddress fromAdd,
List<InternetAddress> toAdd,
List<InternetAddress> ccAdd,
List<InternetAddress> bccAdd,
boolean boolSaveToFile)
Validate the message was sent properly
|
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, countTestCases, createResult, fail, fail, failNotEquals, failNotSame, failSame, format, getName, run, run, runBare, runTest, setName, setUp, toStringpublic static final int BODY_END_PAD
public static final int BODY_START_PAD
protected org.subethamail.wiser.Wiser fakeMailServer
protected String strTestMailServer
protected String strTestMailFrom
protected String strTestMailTo
protected String strTestUser
protected String strTestPasswd
protected String strTestURL
protected String[] testCharsValid
protected String[] testCharsNotValid
public BaseEmailTestCase(String name)
name - nameprotected void tearDown()
tearDown in class junit.framework.TestCaseprotected int getMailServerPort()
protected void saveEmailToFile(org.subethamail.wiser.WiserMessage email) throws IOException, MessagingException
email - emailIOException - writing the email failedMessagingException - writing the email failedpublic String getMessageAsString(int intMsgNo)
intMsgNo - the message to retrievepublic void getMailServer()
protected org.subethamail.wiser.WiserMessage validateSend(org.subethamail.wiser.Wiser mailServer, String strSubject, InternetAddress fromAdd, List<InternetAddress> toAdd, List<InternetAddress> ccAdd, List<InternetAddress> bccAdd, boolean boolSaveToFile) throws IOException
mailServer - reference to the fake mail serverstrSubject - expected subjectfromAdd - expected from addresstoAdd - list of expected to addressesccAdd - list of expected cc addressesbccAdd - list of expected bcc addressesboolSaveToFile - true will output to file, false doesntIOException - Exceptionprotected void validateSend(org.subethamail.wiser.Wiser mailServer, String strSubject, Multipart content, InternetAddress fromAdd, List<InternetAddress> toAdd, List<InternetAddress> ccAdd, List<InternetAddress> bccAdd, boolean boolSaveToFile) throws IOException
mailServer - reference to the fake mail serverstrSubject - expected subjectcontent - the expected message contentfromAdd - expected from addresstoAdd - list of expected to addressesccAdd - list of expected cc addressesbccAdd - list of expected bcc addressesboolSaveToFile - true will output to file, false doesntIOException - Exceptionprotected void validateSend(org.subethamail.wiser.Wiser mailServer, String strSubject, String strMessage, InternetAddress fromAdd, List<InternetAddress> toAdd, List<InternetAddress> ccAdd, List<InternetAddress> bccAdd, boolean boolSaveToFile) throws IOException
mailServer - reference to the fake mail serverstrSubject - expected subjectstrMessage - the expected message as a stringfromAdd - expected from addresstoAdd - list of expected to addressesccAdd - list of expected cc addressesbccAdd - list of expected bcc addressesboolSaveToFile - true will output to file, false doesntIOException - Exceptionprotected boolean isMailServerStopped(org.subethamail.wiser.Wiser fakeMailServer)
fakeMailServer.fakeMailServer - The server from which the address is picked up.true if the server claims to be runningprotected URL createInvalidURL() throws Exception
Several ISPs do resolve invalid URLs like http://example.invalid
to some error page causing tests to fail otherwise.
ExceptionCopyright © 2001-2013 The Apache Software Foundation. All Rights Reserved.