Search in sources :

Example 1 with AppendMessage

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

the class ImapCommandThrottleTest method append.

@Test
public void append() throws IOException {
    String path = "testPath";
    AppendCommand append = new AppendCommand(new ImapPath(path, null), makeAppends());
    Assert.assertTrue("same obj", append.isDuplicate(append));
    AppendCommand append2 = new AppendCommand(new ImapPath(path, null), makeAppends());
    Assert.assertTrue("diff obj same params", append.isDuplicate(append2));
    AppendCommand append3 = new AppendCommand(new ImapPath(path + "foo", null), makeAppends());
    Assert.assertFalse("different path", append.isDuplicate(append3));
    List<AppendMessage> appends = makeAppends();
    appends.remove(0);
    AppendCommand append4 = new AppendCommand(new ImapPath(path, null), appends);
    Assert.assertFalse("different length appends", append.isDuplicate(append4));
    appends = makeAppends();
    AppendMessage appendMsg = appends.remove(0);
    List<Part> parts = new ArrayList<Part>();
    AppendMessage appendMsg2 = new AppendMessage(appendMsg.getPersistentFlagNames(), appendMsg.getDate(), parts);
    parts.add(makeAppendPart(appendMsg2, 215, (byte) 215));
    appends.add(0, appendMsg2);
    AppendCommand append5 = new AppendCommand(new ImapPath(path, null), appends);
    Assert.assertFalse("different append parts", append.isDuplicate(append5));
    parts = new ArrayList<Part>();
    appendMsg2 = new AppendMessage(appendMsg.getPersistentFlagNames(), new Date(), parts);
    parts.add(makeAppendPart(appendMsg2, 123, (byte) 99));
    appends.remove(0);
    appends.add(0, appendMsg2);
    AppendCommand append6 = new AppendCommand(new ImapPath(path, null), appends);
    Assert.assertFalse("different date", append.isDuplicate(append6));
    parts = new ArrayList<Part>();
    List<String> flagNames = new ArrayList<String>();
    flagNames.add("F1");
    flagNames.add("F3");
    appendMsg2 = new AppendMessage(flagNames, appendMsg.getDate(), parts);
    parts.add(makeAppendPart(appendMsg2, 123, (byte) 99));
    appends.remove(0);
    appends.add(0, appendMsg2);
    AppendCommand append7 = new AppendCommand(new ImapPath(path, null), appends);
    Assert.assertFalse("different flag names", append.isDuplicate(append7));
}
Also used : AppendCommand(com.zimbra.cs.imap.AppendCommand) Part(com.zimbra.cs.imap.AppendMessage.Part) AppendMessage(com.zimbra.cs.imap.AppendMessage) ArrayList(java.util.ArrayList) ImapPath(com.zimbra.cs.imap.ImapPath) Date(java.util.Date) Test(org.junit.Test)

Aggregations

AppendCommand (com.zimbra.cs.imap.AppendCommand)1 AppendMessage (com.zimbra.cs.imap.AppendMessage)1 Part (com.zimbra.cs.imap.AppendMessage.Part)1 ImapPath (com.zimbra.cs.imap.ImapPath)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 Test (org.junit.Test)1