use of com.zimbra.client.ZMailbox in project zm-mailbox by Zimbra.
the class TestLmtp method testDiskStreamingMultipleRecipients.
/**
* Confirms that mail can successfully be delivered to multiple users when streaming to disk.
*/
@Test
public void testDiskStreamingMultipleRecipients() throws Exception {
TestUtil.createAccount(USER2_NAME);
TestUtil.setServerAttr(Provisioning.A_zimbraMailDiskStreamingThreshold, "0");
String[] recipients = { TestUtil.getAddress(USER_NAME), TestUtil.getAddress(USER2_NAME) };
String subject = NAME_PREFIX + " testDiskStreamingMultipleRecipients";
ZMailbox mbox1 = TestUtil.getZMailbox(USER_NAME);
ZMailbox mbox2 = TestUtil.getZMailbox(USER2_NAME);
TestUtil.addMessageLmtp(subject, recipients, TestUtil.getAddress(USER_NAME));
TestUtil.waitForMessage(mbox1, "in:inbox subject:\"" + subject + "\"");
ZMessage msg2 = TestUtil.waitForMessage(mbox2, "in:inbox subject:\"" + subject + "\"");
// Test bug 25484. Make sure that user1 can still read the message after user2
// deletes it.
mbox2.deleteMessage(msg2.getId());
mbox1 = TestUtil.getZMailbox(USER_NAME);
TestUtil.waitForMessage(mbox1, "in:inbox subject:\"" + subject + "\"");
}
use of com.zimbra.client.ZMailbox in project zm-mailbox by Zimbra.
the class TestLmtp method testDedupePref.
/**
* Verifies the behavior of {@code zimbraPrefMessageIdDedupingEnabled}.
*/
@Test
public void testDedupePref() throws Exception {
String subject = NAME_PREFIX + " testDedupePref";
ZMailbox mbox = TestUtil.getZMailbox(USER_NAME);
Account account = TestUtil.getAccount(USER_NAME);
String[] recipients = new String[] { USER_NAME };
// Deliver initial message.
String content = new MessageBuilder().withSubject(subject).withToRecipient(USER_NAME).withFrom(USER_NAME).withMessageIdHeader().create();
TestUtil.addMessageLmtp(recipients, USER_NAME, content);
String query = "in:inbox subject:\"" + subject + "\"";
// Redeliver with deduping enabled.
account.setPrefMessageIdDedupingEnabled(true);
TestUtil.addMessageLmtp(recipients, USER_NAME, content);
Assert.assertEquals(1, TestUtil.search(mbox, query).size());
// Redeliver with deduping disabled;
account.setPrefMessageIdDedupingEnabled(false);
TestUtil.addMessageLmtp(recipients, USER_NAME, content);
Assert.assertEquals(2, TestUtil.search(mbox, query).size());
}
use of com.zimbra.client.ZMailbox in project zm-mailbox by Zimbra.
the class TestLmtp method disableTestDedupeCacheTimeout.
/**
* Verifies the behavior of {@code zimbraMessageIdDedupeCacheTimeout}.
*/
// disable due to bug 76332
public void disableTestDedupeCacheTimeout() throws Exception {
ZMailbox mbox = TestUtil.getZMailbox(USER_NAME);
// Deliver initial message.
String subject = NAME_PREFIX + " testDedupeCacheTimeout";
String[] recipients = new String[] { USER_NAME };
String content = new MessageBuilder().withSubject(subject).withToRecipient(USER_NAME).withFrom(USER_NAME).withMessageIdHeader().create();
TestUtil.addMessageLmtp(recipients, USER_NAME, content);
String query = "in:inbox subject:\"" + subject + "\"";
Assert.assertEquals("message should have been delivered", 1, TestUtil.search(mbox, query).size());
// Set deduping cache timeout to 0.5 sec
TestUtil.setConfigAttr(Provisioning.A_zimbraMessageIdDedupeCacheTimeout, "500ms");
// Redeliver same message immediately
TestUtil.addMessageLmtp(recipients, USER_NAME, content);
Assert.assertEquals("deduping should have happened", 1, TestUtil.search(mbox, query).size());
// sleep for just over 0.5 sec
Thread.sleep(501);
// Redeliver
TestUtil.addMessageLmtp(recipients, USER_NAME, content);
Assert.assertEquals("dedupe cache entry should have timed out", 2, TestUtil.search(mbox, query).size());
}
use of com.zimbra.client.ZMailbox in project zm-mailbox by Zimbra.
the class TestLmtp method testStartTLSSuccess.
@Test
public void testStartTLSSuccess() throws Exception {
ZMailbox mbox = TestUtil.getZMailbox(USER_NAME);
LmtpClient lmtpClient = new LmtpClient("localhost", Provisioning.getInstance().getLocalServer().getIntAttr(Provisioning.A_zimbraLmtpBindPort, 7025));
Assert.assertTrue(lmtpClient.getResponse(), lmtpClient.replyOk());
lmtpClient.sendLine("LHLO " + LC.zimbra_server_hostname.value());
Assert.assertTrue(lmtpClient.getResponse(), lmtpClient.replyOk());
if (lmtpClient.getResponse().contains(STARTTLS)) {
lmtpClient.startTLS();
lmtpClient.sendLine("LHLO " + LC.zimbra_server_hostname.value());
Assert.assertTrue(lmtpClient.getResponse(), lmtpClient.replyOk());
}
lmtpClient.sendLine("MAIL FROM:<" + TestUtil.addDomainIfNecessary(USER_NAME) + ">");
Assert.assertTrue(lmtpClient.getResponse(), lmtpClient.replyOk());
lmtpClient.sendLine("RCPT TO:<" + TestUtil.addDomainIfNecessary(USER_NAME) + ">");
Assert.assertTrue(lmtpClient.getResponse(), lmtpClient.replyOk());
lmtpClient.sendLine("DATA");
Assert.assertTrue(lmtpClient.getResponse(), lmtpClient.replyOk());
String subject = NAME_PREFIX + " testFinalDotNotSent";
lmtpClient.sendLine("Subject: " + subject);
lmtpClient.abruptClose();
// wait for some time
Thread.sleep(1000);
List<ZMessage> msgs = TestUtil.search(mbox, "in:inbox " + subject);
Assert.assertTrue("msg got delivered via LMTP even though <CRLF>.<CRLF> was not received", msgs.isEmpty());
}
use of com.zimbra.client.ZMailbox in project zm-mailbox by Zimbra.
the class TestLmtp method testAllowReceiveButNotSendWhenOverQuota.
/**
* Verifies send/receive behavior for {@code zimbraMailAllowReceiveButNotSendWhenOverQuota}.
*/
@Test
public void testAllowReceiveButNotSendWhenOverQuota() throws Exception {
TestUtil.setAccountAttr(USER_NAME, Provisioning.A_zimbraMailAllowReceiveButNotSendWhenOverQuota, LdapConstants.LDAP_TRUE);
TestUtil.setAccountAttr(USER_NAME, Provisioning.A_zimbraMailQuota, "1");
String subject = NAME_PREFIX + " testAllowReceiveButNotSendWhenOverQuota";
// Verify that receive is allowed.
TestUtil.addMessageLmtp(subject, USER_NAME, USER_NAME);
ZMailbox mbox = TestUtil.getZMailbox(USER_NAME);
TestUtil.getMessage(mbox, "in:inbox subject:\"" + subject + "\"");
// Verify that send is disallowed.
try {
TestUtil.sendMessage(mbox, USER_NAME, subject);
Assert.fail("Send should have failed");
} catch (ServiceException e) {
Assert.assertEquals(MailServiceException.QUOTA_EXCEEDED, e.getCode());
}
// Verify that adding a document is disallowed.
try {
byte[] data = new byte[1024];
TestUtil.createDocument(mbox, Integer.toString(Mailbox.ID_FOLDER_BRIEFCASE), NAME_PREFIX + " receivenosend.bin", "application/content-stream", data);
Assert.fail("Document creation should have failed");
} catch (ServiceException e) {
Assert.assertEquals(MailServiceException.QUOTA_EXCEEDED, e.getCode());
}
// Verify that saving a draft is allowed (bug 51457).
String draftSubject1 = subject + " save draft 1";
String draftSubject2 = subject + " save draft 2 two";
ZOutgoingMessage outgoingDraft = TestUtil.getOutgoingMessage(USER_NAME, draftSubject1, draftSubject1, null);
// Add message
ZMessage draftMsg = mbox.saveDraft(outgoingDraft, null, Integer.toString(Mailbox.ID_FOLDER_DRAFTS));
outgoingDraft = TestUtil.getOutgoingMessage(USER_NAME, draftSubject2, draftSubject2, null);
// Set content of existing message
mbox.saveDraft(outgoingDraft, draftMsg.getId(), Integer.toString(Mailbox.ID_FOLDER_DRAFTS));
}
Aggregations