use of com.zimbra.client.ZEmailAddress 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.ZEmailAddress in project zm-mailbox by Zimbra.
the class TestUtil method getOutgoingMessage.
public static ZOutgoingMessage getOutgoingMessage(String recipient, String subject, String body, String attachmentUploadId) throws ServiceException {
ZOutgoingMessage msg = new ZOutgoingMessage();
List<ZEmailAddress> addresses = new ArrayList<ZEmailAddress>();
addresses.add(new ZEmailAddress(addDomainIfNecessary(recipient), null, null, ZEmailAddress.EMAIL_TYPE_TO));
msg.setAddresses(addresses);
msg.setSubject(subject);
msg.setMessagePart(new MessagePart("text/plain", body));
msg.setAttachmentUploadId(attachmentUploadId);
return msg;
}
Aggregations