* Tests moving of message(s) to [Gmail]/Trash
*/
@Test
public void testMoveToTrash() {
final ImapGmailClient client = new ImapGmailClient(ImapGmailLabel.SENT_MAIL);
final ImapGmailConnection connection = new ImapGmailConnection();
try {
connection.setLoginCredentials(conf.getGmailCredentials());
if (conf.useProxy()) {
connection.setProxy(conf.getProxyHost(), conf.getProxyPort());
connection.setProxyCredentials(conf.getProxyCredentials());
}
client.setConnection(connection);
final List<GmailMessage> messages = client.getUnreadMessages();
log.debug("Starting to move message(s) to trash folder.");
// moving single GmailMessage to trash folder
//GmailMessage[] jmgms = new JavaMailGmailMessage[1];
//jmgms[0] = messages.get(0);
//client.moveToTrash(jmgms);
client.moveToTrash(messages.toArray(new JavaMailGmailMessage[0]));
log.debug("Finished moving all selected message(s) to trash.");
assertTrue("All unread messages are moved to trash.",
client.getUnreadMessages().isEmpty());
} catch (final Exception e) {
log.error("Test Failed", e);
fail("Caught exception: " + e.getMessage());
} finally {
if (connection.isConnected()) {
connection.disconnect();
}
}
}