View Javadoc

1   /*
2    * $Id: SmtpAttachmentsFunctionalTestCase.java 20238 2010-11-18 05:43:38Z dirk.olmes $
3    * -------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.transport.email.transformers;
12  
13  import org.mule.transport.email.functional.AbstractEmailFunctionalTestCase;
14  
15  import java.util.Arrays;
16  import java.util.List;
17  
18  import javax.activation.MimeType;
19  import javax.mail.BodyPart;
20  import javax.mail.internet.MimeMultipart;
21  
22  public class SmtpAttachmentsFunctionalTestCase extends AbstractEmailFunctionalTestCase
23  {
24      public SmtpAttachmentsFunctionalTestCase()
25      {
26          super(STRING_MESSAGE, "smtp", "smtp-functional-test-all-attachments.xml");
27          setAddAttachments(true);
28      }
29  
30      public void testSend() throws Exception
31      {
32          doSend();
33      }
34  
35      @Override
36      protected void verifyMessage(MimeMultipart content) throws Exception
37      {
38          assertEquals(4, content.getCount());
39          verifyMessage((String) content.getBodyPart(0).getContent());
40          List<String> expectedTypes = Arrays.asList("text/plain", "application/xml", "application/text");
41          for (int i = 1; i < 4; i++)
42          {
43              BodyPart part = content.getBodyPart(i);
44              String type = part.getContentType();
45              MimeType mt = new MimeType(type);
46              assertTrue(expectedTypes.contains(mt.getPrimaryType() + "/" + mt.getSubType()));
47          }
48      }
49  }