OSDN Git Service

CVS最新版の全ファイルを追加
[spring-ext/ozacc-mail.git] / src / test / com / ozacc / mail / mock / MockFetchMailTest.java
1 package com.ozacc.mail.mock;\r
2 \r
3 import junit.framework.TestCase;\r
4 \r
5 import org.apache.log4j.BasicConfigurator;\r
6 \r
7 import com.ozacc.mail.fetch.ReceivedMail;\r
8 \r
9 /**\r
10  * MockFetchMailのテストケース。\r
11  * \r
12  * @author Tomohiro Otsuka\r
13  * @version $Id: MockFetchMailTest.java,v 1.1.2.2 2005/02/05 09:28:58 otsuka Exp $\r
14  */\r
15 public class MockFetchMailTest extends TestCase {\r
16 \r
17         MockFetchMail mockFetchMail;\r
18 \r
19         /*\r
20          * @see TestCase#setUp()\r
21          */\r
22         protected void setUp() throws Exception {\r
23                 super.setUp();\r
24                 BasicConfigurator.configure();\r
25                 mockFetchMail = new MockFetchMail();\r
26         }\r
27 \r
28         /*\r
29          * @see junit.framework.TestCase#tearDown()\r
30          */\r
31         protected void tearDown() throws Exception {\r
32                 BasicConfigurator.resetConfiguration();\r
33         }\r
34 \r
35         public final void testGetMailsReturnZero() {\r
36                 ReceivedMail[] mails = mockFetchMail.getMails();\r
37                 assertEquals(0, mails.length);\r
38         }\r
39 \r
40         public final void testGetMails() {\r
41                 ReceivedMail expectedMail = new ReceivedMail();\r
42                 expectedMail.setFrom("from@example.net", "差出人");\r
43                 expectedMail.addTo("to@example.com", "宛名");\r
44                 expectedMail.setSubject("MockFetchMailTest");\r
45                 expectedMail.setText("本文");\r
46 \r
47                 mockFetchMail.setupGetMails(expectedMail);\r
48 \r
49                 ReceivedMail[] mails = mockFetchMail.getMails();\r
50                 assertEquals("1通受信", 1, mails.length);\r
51 \r
52                 ReceivedMail mail = mails[0];\r
53                 assertEquals("差出人", "差出人", mail.getFrom().getPersonal());\r
54                 assertEquals("差出人アドレス", "from@example.net", mail.getFrom().getAddress());\r
55                 assertEquals("宛先は1つ", 1, mail.getTo().length);\r
56                 assertEquals("宛名", "to@example.com", (mail.getTo()[0]).getAddress());\r
57                 assertEquals("件名", "MockFetchMailTest", mail.getSubject());\r
58                 assertEquals("本文", "本文", mail.getText());\r
59         }\r
60 \r
61 }