Search in sources :

Example 1 with ImapAppender

use of com.zimbra.cs.datasource.imap.ImapAppender in project zm-mailbox by Zimbra.

the class TestImapClient method testGMailAppend.

@Ignore("deprecated")
public void testGMailAppend() throws Exception {
    ImapConfig config = new ImapConfig();
    config.getLogger().setLevel(Log.Level.trace);
    config.setHost("imap.gmail.com");
    config.setSecurity(MailConfig.Security.SSL);
    config.setSSLSocketFactory(SSLUtil.getDummySSLContext().getSocketFactory());
    config.setAuthenticationId("dacztest");
    config.setMaxLiteralTraceSize(999999);
    connection = new ImapConnection(config);
    connection.connect();
    connection.login("test1234");
    MimeMessage mm = newTestMessage(new Random().nextInt());
    // Append and find unique message
    ImapAppender appender = new ImapAppender(connection, "INBOX");
    long uid1 = appender.appendMessage(getBytes(mm), null);
    System.out.println("XXX uid1 = " + uid1);
    assertTrue("uid1 not found", uid1 > 0);
    // Now append message again and make sure we can find the de-duped copy
    long uid2 = appender.appendMessage(getBytes(mm), null);
    assertTrue("uid2 not found", uid2 > 0);
    assertEquals(uid1, uid2);
    connection.close();
}
Also used : ImapConfig(com.zimbra.cs.mailclient.imap.ImapConfig) Random(java.util.Random) ZMimeMessage(com.zimbra.common.zmime.ZMimeMessage) MimeMessage(javax.mail.internet.MimeMessage) ImapConnection(com.zimbra.cs.mailclient.imap.ImapConnection) ImapAppender(com.zimbra.cs.datasource.imap.ImapAppender) Ignore(org.junit.Ignore)

Aggregations

ZMimeMessage (com.zimbra.common.zmime.ZMimeMessage)1 ImapAppender (com.zimbra.cs.datasource.imap.ImapAppender)1 ImapConfig (com.zimbra.cs.mailclient.imap.ImapConfig)1 ImapConnection (com.zimbra.cs.mailclient.imap.ImapConnection)1 Random (java.util.Random)1 MimeMessage (javax.mail.internet.MimeMessage)1 Ignore (org.junit.Ignore)1