Search in sources :

Example 16 with ZEmailAddress

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());
}
Also used : ZMessage(com.zimbra.client.ZMessage) ZOutgoingMessage(com.zimbra.client.ZMailbox.ZOutgoingMessage) ZMailbox(com.zimbra.client.ZMailbox) ZEmailAddress(com.zimbra.client.ZEmailAddress) MessagePart(com.zimbra.client.ZMailbox.ZOutgoingMessage.MessagePart) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 17 with ZEmailAddress

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;
}
Also used : ZOutgoingMessage(com.zimbra.client.ZMailbox.ZOutgoingMessage) ZEmailAddress(com.zimbra.client.ZEmailAddress) AttachedMessagePart(com.zimbra.client.ZMailbox.ZOutgoingMessage.AttachedMessagePart) MessagePart(com.zimbra.client.ZMailbox.ZOutgoingMessage.MessagePart) ArrayList(java.util.ArrayList)

Aggregations

ZEmailAddress (com.zimbra.client.ZEmailAddress)17 ZOutgoingMessage (com.zimbra.client.ZMailbox.ZOutgoingMessage)11 ZMessage (com.zimbra.client.ZMessage)11 Test (org.junit.Test)11 ZMailbox (com.zimbra.client.ZMailbox)9 ArrayList (java.util.ArrayList)9 MessagePart (com.zimbra.client.ZMailbox.ZOutgoingMessage.MessagePart)8 AttachedMessagePart (com.zimbra.client.ZMailbox.ZOutgoingMessage.AttachedMessagePart)4 LinkedList (java.util.LinkedList)3 ToZJSONObject (com.zimbra.client.ToZJSONObject)2 ZJSONObject (com.zimbra.client.ZJSONObject)2 ZMimePart (com.zimbra.client.ZMessage.ZMimePart)2 ServiceException (com.zimbra.common.service.ServiceException)2 JSONException (org.json.JSONException)2 ZFilterAction (com.zimbra.client.ZFilterAction)1 ZFilterCondition (com.zimbra.client.ZFilterCondition)1 ZFilterRule (com.zimbra.client.ZFilterRule)1 ZFilterRules (com.zimbra.client.ZFilterRules)1 SoapFaultException (com.zimbra.common.soap.SoapFaultException)1 Account (com.zimbra.cs.account.Account)1