Search in sources :

Example 16 with Literal

use of com.zimbra.cs.mailclient.imap.Literal in project zm-mailbox by Zimbra.

the class TestImapThrottle method append.

@Test
public void append() throws Exception {
    assertTrue(connection.hasCapability("UIDPLUS"));
    Date date = new Date(System.currentTimeMillis());
    Flags flags = Flags.fromSpec("afs");
    for (int i = 0; i < LOOP_LIMIT; i++) {
        Literal msg = message(100000);
        try {
            connection.append("INBOX", flags, date, msg);
        } finally {
            msg.dispose();
        }
    }
    Literal msg = message(100000);
    try {
        connection.append("INBOX", flags, date, msg);
        Assert.fail("expected exception here...");
    } catch (Exception e) {
        Assert.assertTrue(connection.isClosed());
    } finally {
        msg.dispose();
    }
}
Also used : Literal(com.zimbra.cs.mailclient.imap.Literal) Flags(com.zimbra.cs.mailclient.imap.Flags) Date(java.sql.Date) IOException(java.io.IOException) ServiceException(com.zimbra.common.service.ServiceException) CommandFailedException(com.zimbra.cs.mailclient.CommandFailedException) Test(org.junit.Test)

Example 17 with Literal

use of com.zimbra.cs.mailclient.imap.Literal in project zm-mailbox by Zimbra.

the class TestImap method testAppend.

@Test
public void testAppend() throws Exception {
    assertTrue(connection.hasCapability("UIDPLUS"));
    Flags flags = Flags.fromSpec("afs");
    Date date = new Date(System.currentTimeMillis());
    Literal msg = message(100000);
    try {
        AppendResult res = connection.append("INBOX", flags, date, msg);
        assertNotNull(res);
        byte[] b = fetchBody(res.getUid());
        assertArrayEquals("content mismatch", msg.getBytes(), b);
    } finally {
        msg.dispose();
    }
}
Also used : Literal(com.zimbra.cs.mailclient.imap.Literal) AppendResult(com.zimbra.cs.mailclient.imap.AppendResult) Flags(com.zimbra.cs.mailclient.imap.Flags) Date(java.sql.Date) Test(org.junit.Test)

Aggregations

Literal (com.zimbra.cs.mailclient.imap.Literal)17 Flags (com.zimbra.cs.mailclient.imap.Flags)12 Test (org.junit.Test)12 Date (java.sql.Date)11 CommandFailedException (com.zimbra.cs.mailclient.CommandFailedException)9 AppendResult (com.zimbra.cs.mailclient.imap.AppendResult)6 MailboxInfo (com.zimbra.cs.mailclient.imap.MailboxInfo)4 File (java.io.File)3 ServiceException (com.zimbra.common.service.ServiceException)2 MessageData (com.zimbra.cs.mailclient.imap.MessageData)2 FileWriter (java.io.FileWriter)2 IOException (java.io.IOException)2 Date (java.util.Date)2 MessagingException (javax.mail.MessagingException)2 ZFolder (com.zimbra.client.ZFolder)1 ZMailbox (com.zimbra.client.ZMailbox)1 ZTag (com.zimbra.client.ZTag)1 ZSharedFileInputStream (com.zimbra.common.zmime.ZSharedFileInputStream)1 MailException (com.zimbra.cs.mailclient.MailException)1 Body (com.zimbra.cs.mailclient.imap.Body)1