Methods Summary |
---|
private void | connect()
p.connect(InetAddress.getByName(mailhost));
assertTrue(p.isConnected());
assertEquals(POP3.AUTHORIZATION_STATE, p.getState());
|
private void | login()
assertTrue(p.login(user, password));
assertEquals(POP3.TRANSACTION_STATE, p.getState());
|
private void | reset()
//Case where this is the first time reset is called
if (p == null)
{
//Do nothing
}
else if (p.isConnected())
{
p.disconnect();
}
p = null;
p = new POP3Client();
|
public static junit.framework.TestSuite | suite()Method suite.
return (new TestSuite(POP3ClientTest.class));
|
public void | testInvalidLoginWithBadName()
reset();
connect();
//Try with an invalid user that doesn't exist
assertFalse(p.login("badusername", password));
|
public void | testInvalidLoginWithBadPassword()
reset();
connect();
//Try with a bad password
assertFalse(p.login(user, "badpassword"));
|
public void | testLoginFromWrongState()Test to try to run the login method from the
disconnected, transaction and update states
reset();
//Not currently connected, not in authorization state
//Try to login with good name/password
assertFalse(p.login(user, password));
//Now connect and set the state to 'transaction' and try again
connect();
p.setState(POP3.TRANSACTION_STATE);
assertFalse(p.login(user, password));
p.disconnect();
//Now connect and set the state to 'update' and try again
connect();
p.setState(POP3.UPDATE_STATE);
assertFalse(p.login(user, password));
p.disconnect();
|
public void | testLogoutFromAllStates()
//From 'transaction' state
reset();
connect();
login();
assertTrue(p.logout());
assertEquals(POP3.UPDATE_STATE, p.getState());
//From 'update' state
reset();
connect();
login();
p.setState(POP3.UPDATE_STATE);
assertTrue(p.logout());
|
public void | testValidLoginWithNameAndPassword()Simple test to logon to a valid server using a valid
user name and password.
reset();
connect();
//Try with a valid user
login();
|