messages.put("headers", RestV2IT.addMessage(EMAIL_REGULAR, labelId));
messages.put("attach", RestV2IT.addMessage(EMAIL_LARGE_ATT, labelId));
// initialize POP3 client
POP3Client client = new POP3Client();
client.connect(POP3_HOST, POP3_PORT);
boolean loginSuccess = client.login(TEST_ACCOUNT, TEST_PASSWORD);
assertThat(loginSuccess, is(true));
// LIST all messages
POP3MessageInfo[] info = client.listMessages();
assertThat(info.length, equalTo(2));
assertThat((int) mailSizeAttach, equalTo(info[0].size));
assertThat((int) mailSizeRegular, equalTo(info[1].size));
assertThat(info[0].number, equalTo(1));
assertThat(info[1].number, equalTo(2));
// LIST one message
POP3MessageInfo msgInfo = client.listMessage(1);
assertThat((int) mailSizeAttach, equalTo(msgInfo.size));
assertThat(msgInfo.number, equalTo(1));
// LIST message that does not exist
msgInfo = client.listMessage(10);
assertThat(msgInfo, nullValue());
// UIDL all messages
info = client.listUniqueIdentifiers();
assertThat(info.length, equalTo(2));
assertThat(info[0].identifier,
equalTo(Base64UUIDUtils.encode(messages.get("attach"))));
assertThat(info[1].identifier,
equalTo(Base64UUIDUtils.encode(messages.get("headers"))));
assertThat(info[0].number, equalTo(1));
assertThat(info[1].number, equalTo(2));
// UIDL one message
msgInfo = client.listUniqueIdentifier(1);
assertThat(msgInfo.identifier,
equalTo(Base64UUIDUtils.encode(messages.get("attach"))));
assertThat(msgInfo.number, equalTo(1));
// UIDL message that does not exist
msgInfo = client.listUniqueIdentifier(10);
assertThat(msgInfo, nullValue());
boolean logoutSuccess = client.logout();
assertThat(logoutSuccess, is(true));
}