m_usersRepository.addUser("foo2", "bar2");
MockMailRepository mailRep2 = new MockMailRepository();
//do not setupTestMails, this is done later
m_mailServer.setUserInbox("foo2", mailRep2);
POP3Client pop3Protocol2 = null;
try {
// open two connections
m_pop3Protocol = new POP3Client();
m_pop3Protocol.connect("127.0.0.1", m_pop3ListenerPort);
pop3Protocol2 = new POP3Client();
pop3Protocol2.connect("127.0.0.1", m_pop3ListenerPort);
assertEquals("first connection taken", 0, m_pop3Protocol.getState());
assertEquals("second connection taken", 0, pop3Protocol2.getState());
// open two accounts
m_pop3Protocol.login("foo1", "bar1");
pop3Protocol2.login("foo2", "bar2");
POP3MessageInfo[] entries = m_pop3Protocol.listMessages();
assertEquals("foo1 has mails", 2, entries.length);
entries = pop3Protocol2.listMessages();
assertEquals("foo2 has no mails", 0, entries.length);
} finally {
// put both to rest, field var is handled by tearDown()
if (pop3Protocol2 != null) {
pop3Protocol2.sendCommand("quit");
pop3Protocol2.disconnect();
}
}
}