01: package test;
02:
03: import junit.framework.TestCase;
04:
05: import javax.mail.Session;
06:
07: import dalma.endpoints.email.MimeMessageEx;
08:
09: public class MimeMessageExTest extends TestCase {
10: Session session = Session.getInstance(System.getProperties());
11:
12: public void testMainContent1() throws Exception {
13: // mail1.txt contains multipart/signed
14: MimeMessageEx msg = new MimeMessageEx(session, getClass()
15: .getResourceAsStream("mail1.txt"));
16: String mc = msg.getMainContent();
17: assertTrue(mc.startsWith("Christian Ullenboom wrote:"));
18: assertTrue(mc
19: .endsWith("Sun Microsystems kohsuke.kawaguchi@sun.com\r\n"));
20: }
21:
22: public void testMainContent2() throws Exception {
23: // mail2.txt contains multipart/report
24: MimeMessageEx msg = new MimeMessageEx(session, getClass()
25: .getResourceAsStream("mail2.txt"));
26: String mc = msg.getMainContent();
27: assertTrue(mc.startsWith("This is the Postfix program at"));
28: assertTrue(mc
29: .endsWith("User unknown (in reply to RCPT TO\r\n command)\r\n"));
30: }
31:
32: public void testMainContent3() throws Exception {
33: // mail3.txt contains multipart/mixed and multipart/signed
34: MimeMessageEx msg = new MimeMessageEx(session, getClass()
35: .getResourceAsStream("mail3.txt"));
36: String mc = msg.getMainContent();
37: System.out.println(mc);
38: assertEquals("this is the main part\r\n", mc);
39: }
40: }
|