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