FileDocCategorySizeDatePackage
MailTestAllImplementations.javaAPI DocApache James 2.3.13513Fri Jan 12 12:56:36 GMT 2007org.apache.james.core

MailTestAllImplementations

public abstract class MailTestAllImplementations extends TestCase
testing common behavior of Mail implementors. subclasses automatically get their Mail-behavior tested.

Fields Summary
Constructors Summary
Methods Summary
protected abstract org.apache.mailet.MailcreateMailImplementation()
provide the concrete implementation to test

protected voidhelperTestInitialState(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 voidhelperTestMessageSize(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 voidtestAttributes()

        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"));