1
2
3
4
5
6
7
8
9
10
11 package org.mule.transport.email.transformers;
12
13 import static org.junit.Assert.assertEquals;
14 import static org.junit.Assert.assertTrue;
15
16 import org.mule.transport.email.functional.AbstractEmailFunctionalTestCase;
17
18 import java.util.Arrays;
19 import java.util.Collection;
20 import java.util.List;
21
22 import javax.activation.MimeType;
23 import javax.mail.BodyPart;
24 import javax.mail.internet.MimeMultipart;
25
26 import org.junit.Test;
27 import org.junit.runners.Parameterized.Parameters;
28
29 public class SmtpAttachmentsFunctionalOutboundAttachmentsOnlyTestCase extends AbstractEmailFunctionalTestCase
30 {
31
32 public SmtpAttachmentsFunctionalOutboundAttachmentsOnlyTestCase(ConfigVariant variant, String configResources)
33 {
34 super(variant, STRING_MESSAGE, "smtp", configResources);
35 setAddAttachments(true);
36 }
37
38 @Parameters
39 public static Collection<Object[]> parameters()
40 {
41 return Arrays.asList(new Object[][]{
42 {ConfigVariant.SERVICE, "smtp-functional-test-outbound-attachments-only-service.xml"},
43 {ConfigVariant.FLOW, "smtp-functional-test-outbound-attachments-only-flow.xml"}
44 });
45 }
46
47 @Test
48 public void testSend() throws Exception
49 {
50 doSend();
51 }
52
53 @Override
54 protected void verifyMessage(MimeMultipart content) throws Exception
55 {
56 assertEquals(3, content.getCount());
57 verifyMessage((String) content.getBodyPart(0).getContent());
58 List<String> expectedTypes = Arrays.asList("application/text", "application/xml");
59 for (int i = 1; i < 2; i++)
60 {
61 BodyPart part = content.getBodyPart(i);
62 String type = part.getContentType();
63 MimeType mt = new MimeType(type);
64 assertTrue(expectedTypes.contains(mt.getPrimaryType() + "/" + mt.getSubType()));
65 }
66 }
67 }