handler.add("valid", new MockMailbox(identifier, MESSAGE1, MESSAGE2));
server = new NettyServer(createProtocol(handler));
server.setListenAddresses(address);
server.bind();
POP3Client client = new POP3Client();
client.connect(address.getAddress().getHostAddress(), address.getPort());
assertTrue(client.login("valid", "valid"));
POP3MessageInfo[] info = client.listMessages();
assertEquals(2, info.length);
assertEquals((int) MESSAGE1.meta.getSize(), info[0].size);
assertEquals((int) MESSAGE2.meta.getSize(), info[1].size);
assertEquals(1, info[0].number);
assertEquals(2, info[1].number);
POP3MessageInfo mInfo = client.listMessage(1);
assertEquals((int) MESSAGE1.meta.getSize(), mInfo.size);
assertEquals(1, mInfo.number);
// try to retrieve message that not exist
mInfo = client.listMessage(10);
assertNull(mInfo);
info = client.listUniqueIdentifiers();
assertEquals(2, info.length);
assertEquals(identifier + "-" + MESSAGE1.meta.getUid(), info[0].identifier);
assertEquals(identifier + "-" + MESSAGE2.meta.getUid(), info[1].identifier);
assertEquals(1, info[0].number);
assertEquals(2, info[1].number);
mInfo = client.listUniqueIdentifier(1);
assertEquals(identifier + "-" + MESSAGE1.meta.getUid(), mInfo.identifier);
assertEquals(1, mInfo.number);
// try to retrieve message that not exist
mInfo = client.listUniqueIdentifier(10);
assertNull(mInfo);
assertTrue(client.logout());
} finally {
if (server != null) {
server.unbind();
}