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  	 * @see TestCase#setUp()
21  	 */
22  	protected void setUp() throws Exception {
23  		super.setUp();
24  		BasicConfigurator.configure();
25  		mockFetchMail = new MockFetchMail();
26  	}
27  
28  	/*
29  	 * @see junit.framework.TestCase#tearDown()
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  }