use of com.zimbra.client.ZMessage in project zm-mailbox by Zimbra.
the class TestLmtp method testTransparency.
@Test
public void testTransparency() throws Exception {
String subject = NAME_PREFIX + " LMTPTransparency1";
String body = "line1\r\n.line2\r\n..line3\r\n...line4\r\n";
Assert.assertTrue(TestUtil.addMessageLmtp(subject, new String[] { USER_NAME }, USER_NAME, body));
ZMailbox mbox = TestUtil.getZMailbox(USER_NAME);
ZMessage msg = TestUtil.getMessage(mbox, "in:inbox subject:\"" + subject + "\"");
String currentBody = msg.getMimeStructure().getContent();
TestUtil.assertMessageContains(currentBody, body);
}
use of com.zimbra.client.ZMessage in project zm-mailbox by Zimbra.
the class TestLmtp method testAttachedMessage.
/**
* Sends a message with another message attached and confirms that the subject
* of the attached message is indexed.
* @see MessageRFC822Handler
*/
@Test
public void testAttachedMessage() throws Exception {
String outerSubject = NAME_PREFIX + " testAttachedMessage outer";
String innerSubject = NAME_PREFIX + " testAttachedMessage inner";
ZMailbox mbox = TestUtil.getZMailbox(USER_NAME);
// Assemble outer message
ZOutgoingMessage msg = new ZOutgoingMessage();
List<ZEmailAddress> addresses = new ArrayList<ZEmailAddress>();
addresses.add(new ZEmailAddress(TestUtil.getAddress(USER_NAME), null, null, ZEmailAddress.EMAIL_TYPE_TO));
msg.setAddresses(addresses);
msg.setSubject(outerSubject);
// Assemble body and inner message
String attachedMessageString = TestUtil.getTestMessage(innerSubject, USER_NAME, USER_NAME, null);
MessagePart attachedMessage = new MessagePart("message/rfc822", attachedMessageString);
MessagePart body = new MessagePart("text/plain", "This is the outer message");
msg.setMessagePart(new MessagePart("multipart/mixed", body, attachedMessage));
// Send and wait for it to arrive
mbox.sendMessage(msg, null, false);
TestUtil.waitForMessage(mbox, "in:inbox " + outerSubject);
// Test search for message subject
List<ZMessage> msgs = TestUtil.search(mbox, "in:inbox " + innerSubject);
Assert.assertEquals(1, msgs.size());
msgs = TestUtil.search(mbox, "in:sent " + innerSubject);
Assert.assertEquals(1, msgs.size());
// Test search for message body
msgs = TestUtil.search(mbox, "in:inbox " + NAME_PREFIX + " waves");
Assert.assertEquals(1, msgs.size());
msgs = TestUtil.search(mbox, "in:sent " + NAME_PREFIX + " waves");
Assert.assertEquals(1, msgs.size());
}
use of com.zimbra.client.ZMessage in project zm-mailbox by Zimbra.
the class TestLmtp method testFinalDotNotSent.
// bug 53058
@Test
public void testFinalDotNotSent() 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.ZMessage in project zm-mailbox by Zimbra.
the class TestLmtp method testConcurrentDedupe.
/**
* Tests the LMTP deduping code. Attempts to deliver multiple copies of the
* same message to the same message to the same mailbox simultaneously. Confirms
* that only one copy got delivered. Bug 38898.
*/
@Test
public void testConcurrentDedupe() throws Exception {
String subject = NAME_PREFIX + " testConcurrentDedupe";
String content = TestUtil.getTestMessage(subject, USER_NAME, USER_NAME, null);
content = "Message-ID: " + System.currentTimeMillis() + "\r\n" + content;
Thread[] threads = new Thread[5];
for (int i = 0; i < threads.length; i++) {
threads[i] = new Thread(new LmtpClientThread(USER_NAME, content));
}
for (Thread thread : threads) {
thread.start();
}
for (Thread thread : threads) {
thread.join();
}
ZMailbox mbox = TestUtil.getZMailbox(USER_NAME);
List<ZMessage> messages = TestUtil.search(mbox, "in:inbox subject:\"" + subject + "\"");
Assert.assertEquals(1, messages.size());
}
use of com.zimbra.client.ZMessage in project zm-mailbox by Zimbra.
the class TestUtil method search.
public static List<ZMessage> search(ZMailbox mbox, ZSearchParams params) throws ServiceException {
List<ZMessage> msgs = new ArrayList<ZMessage>();
for (ZSearchHit hit : mbox.search(params).getHits()) {
ZGetMessageParams msgParams = new ZGetMessageParams();
msgParams.setId(hit.getId());
msgs.add(mbox.getMessage(msgParams));
}
return msgs;
}
Aggregations