OSDN Git Service

CVS最新版の全ファイルを追加
[spring-ext/ozacc-mail.git] / src / test / com / ozacc / mail / spring / XMLMailFactoryBeanTest.java
1 package com.ozacc.mail.spring;\r
2 \r
3 import junit.framework.TestCase;\r
4 \r
5 import org.apache.log4j.BasicConfigurator;\r
6 import org.springframework.context.ApplicationContext;\r
7 import org.springframework.context.support.FileSystemXmlApplicationContext;\r
8 \r
9 import com.ozacc.mail.Mail;\r
10 import com.ozacc.mail.mock.EqualityCheck;\r
11 \r
12 /**\r
13  * XMLMailFactoryBeanのTestCase。\r
14  * \r
15  * @author Tomohiro Otsuka\r
16  * @version $Id: XMLMailFactoryBeanTest.java,v 1.5 2004/09/17 20:34:31 otsuka Exp $\r
17  */\r
18 public class XMLMailFactoryBeanTest extends TestCase {\r
19 \r
20         Mail mail;\r
21 \r
22         /**\r
23          * @see junit.framework.TestCase#setUp()\r
24          */\r
25         public void setUp() throws Exception {\r
26                 super.setUp();\r
27 \r
28                 BasicConfigurator.configure();\r
29 \r
30                 mail = new Mail();\r
31                 mail.setSubject("XMLMailBuilderのテストケース");\r
32                 mail.setText("改行します。\n改行しました。\nテストは成功。");\r
33                 mail.setFrom("from@example.com", "差出人");\r
34                 mail.setReturnPath("return@example.com");\r
35                 mail.setReplyTo("reply@example.com");\r
36                 mail.addTo("to1@example.com", "宛先1");\r
37                 mail.addTo("to2@example.com");\r
38                 mail.addCc("cc1@example.com", "CC1");\r
39                 mail.addCc("cc2@example.com");\r
40                 mail.addBcc("bcc@example.com");\r
41         }\r
42 \r
43         /**\r
44          * @see junit.framework.TestCase#tearDown()\r
45          */\r
46         protected void tearDown() throws Exception {\r
47                 BasicConfigurator.resetConfiguration();\r
48         }\r
49 \r
50         public void testMailFactoryBeanClassPathFail() throws Exception {\r
51                 mail.addBcc("ccb@example.com");\r
52 \r
53                 ApplicationContext context = new FileSystemXmlApplicationContext(\r
54                                 "src/test/com/ozacc/mail/spring/testContext.xml");\r
55                 Mail result = (Mail)context.getBean("mail");\r
56 \r
57                 assertFalse(EqualityCheck.equals(mail, result));\r
58 \r
59         }\r
60 \r
61         public void testMailFactoryBeanClassPath() throws Exception {\r
62                 ApplicationContext context = new FileSystemXmlApplicationContext(\r
63                                 "src/test/com/ozacc/mail/spring/testContext.xml");\r
64                 Mail result = (Mail)context.getBean("mail");\r
65 \r
66                 assertTrue(EqualityCheck.equals(mail, result));\r
67         }\r
68 \r
69         public void testMailFactoryBeanFilePath() throws Exception {\r
70                 ApplicationContext context = new FileSystemXmlApplicationContext(\r
71                                 "src/test/com/ozacc/mail/spring/testContext.xml");\r
72                 Mail result = (Mail)context.getBean("mail2");\r
73 \r
74                 assertTrue(EqualityCheck.equals(mail, result));\r
75         }\r
76 \r
77         public void testMailFactoryBeanLocation() throws Exception {\r
78                 ApplicationContext context = new FileSystemXmlApplicationContext(\r
79                                 "src/test/com/ozacc/mail/spring/testContext.xml");\r
80                 Mail result = (Mail)context.getBean("mail3");\r
81 \r
82                 assertTrue(EqualityCheck.equals(mail, result));\r
83         }\r
84 \r
85         public void testMailFactoryBeanLocationClasspath() throws Exception {\r
86                 ApplicationContext context = new FileSystemXmlApplicationContext(\r
87                                 "src/test/com/ozacc/mail/spring/testContext.xml");\r
88                 Mail result = (Mail)context.getBean("mail4");\r
89 \r
90                 assertTrue(EqualityCheck.equals(mail, result));\r
91         }\r
92 \r
93 }