Search in sources :

Example 11 with Flags

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

the class TestImap method testOverflowNotAppend.

@Test
public void testOverflowNotAppend() throws Exception {
    int oldReadTimeout = connection.getConfig().getReadTimeout();
    try {
        connection.setReadTimeout(10);
        Flags flags = Flags.fromSpec("afs");
        Date date = new Date(System.currentTimeMillis());
        ImapRequest req = connection.newRequest(CAtom.FETCH, "1:*");
        req.addParam("{" + ((long) (Integer.MAX_VALUE) + 1) + "+}");
        ImapResponse resp = req.send();
        assertTrue(resp.isNO() || resp.isBAD());
    } finally {
        connection.setReadTimeout(oldReadTimeout);
    }
}
Also used : ImapRequest(com.zimbra.cs.mailclient.imap.ImapRequest) ImapResponse(com.zimbra.cs.mailclient.imap.ImapResponse) Flags(com.zimbra.cs.mailclient.imap.Flags) Date(java.sql.Date) Test(org.junit.Test)

Example 12 with Flags

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

the class TestImap method testAppendTagsDirty.

@Test
public void testAppendTagsDirty() throws Exception {
    Flags flags = Flags.fromSpec("afs");
    //new tag; does not exist in mbox
    final String tag1 = "NEWDIRTYTAG";
    MailboxInfo info = connection.select("INBOX");
    assertFalse("INBOX contains unexpected flag " + tag1, info.getFlags().isSet(tag1));
    flags.set(tag1);
    Date date = new Date(System.currentTimeMillis());
    Literal msg = message(10);
    try {
        ImapRequest req = connection.newRequest("APPEND", "INBOX", flags, date, msg);
        req.setResponseHandler(new ResponseHandler() {

            @Override
            public void handleResponse(ImapResponse res) throws Exception {
                if (res.isUntagged() && res.getCCode() == CAtom.FLAGS) {
                    Flags flags = (Flags) res.getData();
                    assertTrue(flags.isSet(tag1));
                }
            }
        });
        req.sendCheckStatus();
    } finally {
        msg.dispose();
    }
}
Also used : ResponseHandler(com.zimbra.cs.mailclient.imap.ResponseHandler) Literal(com.zimbra.cs.mailclient.imap.Literal) ImapRequest(com.zimbra.cs.mailclient.imap.ImapRequest) MailboxInfo(com.zimbra.cs.mailclient.imap.MailboxInfo) ImapResponse(com.zimbra.cs.mailclient.imap.ImapResponse) Flags(com.zimbra.cs.mailclient.imap.Flags) Date(java.sql.Date) ServiceException(com.zimbra.common.service.ServiceException) CommandFailedException(com.zimbra.cs.mailclient.CommandFailedException) IOException(java.io.IOException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) Test(org.junit.Test)

Example 13 with Flags

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

the class TestImap method testOverflowAppend.

@Test
public void testOverflowAppend() throws Exception {
    assertTrue(connection.hasCapability("UIDPLUS"));
    int oldReadTimeout = connection.getConfig().getReadTimeout();
    try {
        connection.setReadTimeout(10);
        Flags flags = Flags.fromSpec("afs");
        Date date = new Date(System.currentTimeMillis());
        ImapRequest req = connection.newRequest(CAtom.APPEND, new MailboxName("INBOX"));
        req.addParam("{" + ((long) (Integer.MAX_VALUE) + 1) + "+}");
        ImapResponse resp = req.send();
        assertTrue(resp.isNO() || resp.isBAD());
        req = connection.newRequest(CAtom.APPEND, new MailboxName("INBOX"));
        req.addParam("{" + ((long) (Integer.MAX_VALUE) + 1) + "}");
        resp = req.send();
        assertTrue(resp.isNO() || resp.isBAD());
    } finally {
        connection.setReadTimeout(oldReadTimeout);
    }
}
Also used : MailboxName(com.zimbra.cs.mailclient.imap.MailboxName) ImapRequest(com.zimbra.cs.mailclient.imap.ImapRequest) ImapResponse(com.zimbra.cs.mailclient.imap.ImapResponse) Flags(com.zimbra.cs.mailclient.imap.Flags) Date(java.sql.Date) Test(org.junit.Test)

Example 14 with Flags

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

the class TestImapThrottle method sort.

@Test
public void sort() throws IOException {
    Flags flags = Flags.fromSpec("afs");
    for (int i = 0; i < 3; i++) {
        Date date = new Date(System.currentTimeMillis());
        Literal msg = message(1000 + i * 1000);
        try {
            connection.append("INBOX", flags, date, msg);
        } finally {
            msg.dispose();
        }
    }
    for (int i = 0; i < LOOP_LIMIT; i++) {
        connection.newRequest("SORT (DATE REVERSE SUBJECT) UTF-8 ALL").sendCheckStatus();
    }
    try {
        connection.newRequest("SORT (DATE REVERSE SUBJECT) UTF-8 ALL").sendCheckStatus();
        Assert.fail("should have been rejected");
    } catch (CommandFailedException e) {
        Assert.assertTrue(connection.isClosed());
    }
}
Also used : Literal(com.zimbra.cs.mailclient.imap.Literal) Flags(com.zimbra.cs.mailclient.imap.Flags) Date(java.sql.Date) CommandFailedException(com.zimbra.cs.mailclient.CommandFailedException) Test(org.junit.Test)

Example 15 with Flags

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

the class TestImapThrottle method copy.

@Test
public void copy() throws IOException {
    Flags flags = Flags.fromSpec("afs");
    for (int i = 0; i < 3; i++) {
        Date date = new Date(System.currentTimeMillis());
        Literal msg = message(1000 + i * 1000);
        try {
            connection.append("INBOX", flags, date, msg);
        } finally {
            msg.dispose();
        }
    }
    connection.create("FOO");
    for (int i = 0; i < LOOP_LIMIT; i++) {
        connection.copy("1:3", "FOO");
    }
    try {
        connection.copy("1:3", "FOO");
        Assert.fail("should have been rejected");
    } catch (CommandFailedException e) {
        Assert.assertTrue(connection.isClosed());
    }
}
Also used : Literal(com.zimbra.cs.mailclient.imap.Literal) Flags(com.zimbra.cs.mailclient.imap.Flags) Date(java.sql.Date) CommandFailedException(com.zimbra.cs.mailclient.CommandFailedException) Test(org.junit.Test)

Aggregations

Flags (com.zimbra.cs.mailclient.imap.Flags)21 Test (org.junit.Test)14 Date (java.sql.Date)13 Literal (com.zimbra.cs.mailclient.imap.Literal)12 CommandFailedException (com.zimbra.cs.mailclient.CommandFailedException)10 MessageData (com.zimbra.cs.mailclient.imap.MessageData)5 AppendResult (com.zimbra.cs.mailclient.imap.AppendResult)4 ImapRequest (com.zimbra.cs.mailclient.imap.ImapRequest)4 ImapResponse (com.zimbra.cs.mailclient.imap.ImapResponse)4 MailboxInfo (com.zimbra.cs.mailclient.imap.MailboxInfo)4 ServiceException (com.zimbra.common.service.ServiceException)3 IOException (java.io.IOException)3 ZFolder (com.zimbra.client.ZFolder)2 ZMailbox (com.zimbra.client.ZMailbox)2 ZTag (com.zimbra.client.ZTag)2 ResponseHandler (com.zimbra.cs.mailclient.imap.ResponseHandler)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 Body (com.zimbra.cs.mailclient.imap.Body)1 FetchResponseHandler (com.zimbra.cs.mailclient.imap.FetchResponseHandler)1 MailboxName (com.zimbra.cs.mailclient.imap.MailboxName)1