1 package com.ozacc.mail.mock;
2
3 import junit.framework.TestCase;
4
5 import org.apache.log4j.BasicConfigurator;
6
7 import com.ozacc.mail.fetch.ReceivedMail;
8
9 /***
10 * MockFetchMail¤Î¥Æ¥¹¥È¥±¡¼¥¹¡£
11 *
12 * @author Tomohiro Otsuka
13 * @version $Id: MockFetchMailTest.java,v 1.1.2.2 2005/02/05 09:28:58 otsuka Exp $
14 */
15 public class MockFetchMailTest extends TestCase {
16
17 MockFetchMail mockFetchMail;
18
19
20
21
22 protected void setUp() throws Exception {
23 super.setUp();
24 BasicConfigurator.configure();
25 mockFetchMail = new MockFetchMail();
26 }
27
28
29
30
31 protected void tearDown() throws Exception {
32 BasicConfigurator.resetConfiguration();
33 }
34
35 public final void testGetMailsReturnZero() {
36 ReceivedMail[] mails = mockFetchMail.getMails();
37 assertEquals(0, mails.length);
38 }
39
40 public final void testGetMails() {
41 ReceivedMail expectedMail = new ReceivedMail();
42 expectedMail.setFrom("from@example.net", "º¹½Ð¿Í");
43 expectedMail.addTo("to@example.com", "°¸Ì¾");
44 expectedMail.setSubject("MockFetchMailTest");
45 expectedMail.setText("ËÜʸ");
46
47 mockFetchMail.setupGetMails(expectedMail);
48
49 ReceivedMail[] mails = mockFetchMail.getMails();
50 assertEquals("1Ä̼õ¿®", 1, mails.length);
51
52 ReceivedMail mail = mails[0];
53 assertEquals("º¹½Ð¿Í", "º¹½Ð¿Í", mail.getFrom().getPersonal());
54 assertEquals("º¹½Ð¿Í¥¢¥É¥?¥¹", "from@example.net", mail.getFrom().getAddress());
55 assertEquals("°¸Àè¤Ï1¤Ä", 1, mail.getTo().length);
56 assertEquals("°¸Ì¾", "to@example.com", (mail.getTo()[0]).getAddress());
57 assertEquals("·?̾", "MockFetchMailTest", mail.getSubject());
58 assertEquals("ËÜʸ", "ËÜʸ", mail.getText());
59 }
60
61 }