1
2
3
4
5
6
7
8
9
10
11 package org.mule.transport.email;
12
13 import org.mule.api.MuleException;
14 import org.mule.api.MuleMessage;
15 import org.mule.module.client.MuleClient;
16 import org.mule.tck.FunctionalTestCase;
17
18 import javax.mail.internet.MimeMessage;
19
20
21
22
23
24
25
26
27
28
29 public class EmailRoundTripTestCase extends FunctionalTestCase
30 {
31
32 public static final long WAIT_MS = 3000L;
33
34
35 private AbstractGreenMailSupport greenMailSupport = new FixedPortGreenMailSupport(62000);
36
37 protected String getConfigResources()
38 {
39 return "email-round-trip-test.xml";
40 }
41
42 public void testRoundTrip() throws MuleException, InterruptedException
43 {
44
45
46 MuleClient client = new MuleClient();
47 MuleMessage message = client.request("vm://rfc822?connector=queue", WAIT_MS);
48 assertTrue(message.getPayload() instanceof byte[]);
49
50
51 greenMailSupport.getServers().waitForIncomingEmail(WAIT_MS, 1);
52 MimeMessage[] messages = greenMailSupport.getServers().getReceivedMessages();
53 assertNotNull("did not receive any messages", messages);
54 assertEquals("did not receive 1 mail", 1, messages.length);
55 }
56
57
58
59
60
61
62 protected void suitePreSetUp() throws Exception
63 {
64 greenMailSupport.startServers();
65 greenMailSupport.createBobAndStoreEmail(greenMailSupport.getValidMessage(AbstractGreenMailSupport.ALICE_EMAIL));
66 }
67
68
69
70
71
72
73 protected void suitePostTearDown() throws Exception
74 {
75 greenMailSupport.stopServers();
76 }
77
78 }