1
2
3
4
5
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 SmtpAttachmentsFunctionalTestCase extends AbstractEmailFunctionalTestCase
24 {
25
26 public SmtpAttachmentsFunctionalTestCase()
27 {
28 super(STRING_MESSAGE, "smtp", "smtp-functional-test-all-attachments.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(4, content.getCount());
42 verifyMessage((String) content.getBodyPart(0).getContent());
43 List<String> expectedTypes = Arrays.asList("text/plain", "application/xml", "application/text");
44 for (int i = 1; i < 4; 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 }