Search in sources :

Example 6 with ZMimePart

use of com.zimbra.client.ZMessage.ZMimePart in project zm-mailbox by Zimbra.

the class TestMessageIntercept method verifyInterceptMessage.

/**
     * Verifies the structure of the intercept message.
     */
private void verifyInterceptMessage(ZMessage interceptMsg, String operation, String folderName, String folderId) throws Exception {
    // Check structure
    ZMimePart part = interceptMsg.getMimeStructure();
    assertEquals(MimeConstants.CT_MULTIPART_MIXED, part.getContentType());
    List<ZMimePart> children = part.getChildren();
    assertEquals(2, children.size());
    // Check body
    ZMimePart bodyPart = children.get(0);
    assertEquals(MimeConstants.CT_TEXT_PLAIN, bodyPart.getContentType());
    String body = bodyPart.getContent();
    String context = "Unexpected body: \n" + body;
    assertTrue(context, body.contains("Intercepted message for " + RECIPIENT_NAME));
    assertTrue(context, body.contains("Operation=" + operation));
    assertTrue(context, body.contains("folder=" + folderName));
    assertTrue(context, body.contains("folder ID=" + folderId));
    // Compare to original message
    ZMimePart interceptedPart = children.get(1);
    assertEquals(MimeConstants.CT_MESSAGE_RFC822, interceptedPart.getContentType());
}
Also used : ZMimePart(com.zimbra.client.ZMessage.ZMimePart)

Aggregations

ZMimePart (com.zimbra.client.ZMessage.ZMimePart)6 ZMessage (com.zimbra.client.ZMessage)5 ZMailbox (com.zimbra.client.ZMailbox)3 Test (org.junit.Test)3 ZEmailAddress (com.zimbra.client.ZEmailAddress)2 ZOutgoingMessage (com.zimbra.client.ZMailbox.ZOutgoingMessage)2 AttachedMessagePart (com.zimbra.client.ZMailbox.ZOutgoingMessage.AttachedMessagePart)2 MessagePart (com.zimbra.client.ZMailbox.ZOutgoingMessage.MessagePart)2 ZGetMessageParams (com.zimbra.client.ZGetMessageParams)1 BufferedReader (java.io.BufferedReader)1 File (java.io.File)1 StringReader (java.io.StringReader)1 ArrayList (java.util.ArrayList)1