use of com.zimbra.cs.mailclient.imap.Literal 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();
}
}
use of com.zimbra.cs.mailclient.imap.Literal 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());
}
}
use of com.zimbra.cs.mailclient.imap.Literal 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());
}
}
use of com.zimbra.cs.mailclient.imap.Literal in project zm-mailbox by Zimbra.
the class TestImapThrottle method message.
private static Literal message(int size) throws IOException {
File file = File.createTempFile("msg", null);
file.deleteOnExit();
FileWriter out = new FileWriter(file);
try {
out.write(simpleMessage("test message"));
for (int i = 0; i < size; i++) {
out.write('X');
if (i % 72 == 0) {
out.write("\r\n");
}
}
} finally {
out.close();
}
return new Literal(file, true);
}
use of com.zimbra.cs.mailclient.imap.Literal in project zm-mailbox by Zimbra.
the class TestImapThrottle method search.
@Test
public void search() 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.search((Object[]) new String[] { "TEXT", "\"XXXXX\"" });
}
try {
connection.search((Object[]) new String[] { "TEXT", "\"XXXXX\"" });
Assert.fail("should have been rejected");
} catch (CommandFailedException e) {
Assert.assertTrue(connection.isClosed());
}
}
Aggregations