MailTestAllImplementationspublic abstract class MailTestAllImplementations extends TestCase testing common behavior of Mail implementors. subclasses automatically get their Mail-behavior tested. |
Methods Summary |
---|
protected abstract org.apache.mailet.Mail | createMailImplementation()provide the concrete implementation to test
| protected void | helperTestInitialState(org.apache.mailet.Mail mail)
assertFalse("no initial attributes", mail.hasAttributes());
assertNull("no initial error", mail.getErrorMessage());
assertNotNull("initial last update set", mail.getLastUpdated());
try {
assertTrue("no initial recipient", mail.getRecipients().isEmpty());
} catch (NullPointerException e) {
// current behavior. *BUT*, shouldn't this method better return with an empty list?!
}
assertEquals("initial remote address is localhost ip", "127.0.0.1", mail.getRemoteAddr());
assertEquals("initial remote host is localhost", "localhost", mail.getRemoteHost());
assertEquals("default initial state", Mail.DEFAULT, mail.getState());
| protected void | helperTestMessageSize(org.apache.mailet.Mail mail, int expectedMsgSize)
try {
assertEquals("initial message size == " + expectedMsgSize, expectedMsgSize, mail.getMessageSize());
} catch (NullPointerException e) {
// current behavior. *BUT*, shouldn't this method return more gracefully?!
}
| public void | testAttributes()
Mail mail = createMailImplementation();
assertFalse("no initial attributes", mail.hasAttributes());
assertFalse("attributes initially empty", mail.getAttributeNames().hasNext());
assertNull("not found on emtpy list", mail.getAttribute("test"));
assertNull("no previous item with key", mail.setAttribute("testKey", "testValue"));
assertEquals("item found", "testValue", mail.getAttribute("testKey"));
assertTrue("has attribute", mail.hasAttributes());
assertEquals("item removed", "testValue", mail.removeAttribute("testKey"));
assertNull("item no longer found", mail.getAttribute("testKey"));
|
|