1
2
3
4
5
6
7
8
9
10
11 package org.mule.providers.email;
12
13 import org.mule.extras.client.MuleClient;
14 import org.mule.tck.FunctionalTestCase;
15 import org.mule.umo.UMOMessage;
16 import org.mule.umo.UMOException;
17
18 import javax.mail.internet.MimeMessage;
19
20
21
22
23
24
25
26
27
28
29 public class RoundTripTestCase 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 "round-trip-test.xml";
40 }
41
42 public void testRoundTrip() throws UMOException, InterruptedException
43 {
44
45
46 MuleClient client = new MuleClient();
47 UMOMessage message = client.receive("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 protected void doPreFunctionalSetUp() throws Exception
62 {
63 greenMailSupport.startServers();
64 greenMailSupport.createBobAndStoreEmail(greenMailSupport.getValidMessage(AbstractGreenMailSupport.ALICE_EMAIL));
65 }
66
67
68
69
70
71 protected void doFunctionalTearDown() throws Exception
72 {
73 greenMailSupport.stopServers();
74 }
75
76 }