Methods Summary |
---|
public abstract boolean | allowsPasswordlessUser()
|
public abstract boolean | canTestUserExists()while addUser() is part of MailServer interface, a user cannot be tested for afterwards
at the same time, James allows to do exactly this via isLocalUser(), other implementations
might vary.
|
public abstract MailServer | createMailServer()
|
public abstract boolean | isUserExisting(MailServer mailServerImpl, java.lang.String username)
|
public void | testAddUser()
// addUser acts on field localUsers for class org.apache.james.James
// thus, it is unrelated to getUserInbox() for the only known implementation of MailServer
// TODO clarify this
MailServer mailServer = createMailServer();
String userName = "testUserName";
if (canTestUserExists())
{
assertFalse("this is a fresh user", isUserExisting(mailServer, userName));
}
boolean allowsPasswordlessUser = allowsPasswordlessUser();
try {
boolean success = mailServer.addUser(userName, null);
if (!allowsPasswordlessUser) fail("null pwd was accepted unexpectedly");
if (!success) fail("null pwd was not accepted unexpectedly");
} catch (Exception e) {
if (allowsPasswordlessUser) fail("null pwd not accepted unexpectedly (with exception)");
}
userName = userName + "_next";
String password = "password";
boolean success = mailServer.addUser(userName, password);
if (!success) fail("user has not been added");
if (canTestUserExists())
{
assertTrue("user is present now", isUserExisting(mailServer, userName));
}
boolean successAgain = mailServer.addUser(userName, password);
if (successAgain) fail("user has been added two times");
|
public void | testGetExisitingUserInbox()
MailServer mailServer = createMailServer();
MailRepository userInbox = mailServer.getUserInbox(EXISTING_USER_NAME);
assertNotNull("existing user exists", userInbox);
|
public void | testGetNonexistingUserInbox()
MailServer mailServer = createMailServer();
String userName = "testNonexisitingUserName";
MailRepository userInbox = null;
userInbox = mailServer.getUserInbox(userName);
assertEquals("test user does not exist", null, userInbox);
|
public void | testId()
MailServer mailServer = createMailServer();
String id = mailServer.getId();
assertNotNull("mail id not null", id);
assertFalse("mail id not empty", "".equals(id));
|
public void | testIdIncrement()
MailServer mailServer = createMailServer();
String id1 = mailServer.getId();
String id2 = mailServer.getId();
assertFalse("next id is different", id1.equals(id2));
|