OSDN Git Service

CVS最新版の全ファイルを追加
[spring-ext/ozacc-mail.git] / src / test / com / ozacc / mail / impl / SendMailImplRealTest.java
1 package com.ozacc.mail.impl;\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.Mail;\r
8 import com.ozacc.mail.MailBuilder;\r
9 \r
10 /**\r
11  * SendMailImplクラスのテストケース。実際に送信し、メーラーで受信して確認するテストです。\r
12  * \r
13  * @author Tomohiro Otsuka\r
14  * @version $Id: SendMailImplRealTest.java,v 1.6.2.1 2005/01/23 06:51:56 otsuka Exp $\r
15  */\r
16 public class SendMailImplRealTest extends TestCase {\r
17 \r
18         private MailBuilder builder;\r
19 \r
20         private String email;\r
21 \r
22         private String envelopeTo;\r
23 \r
24         private SendMailImpl sendMail;\r
25 \r
26         /*\r
27          * @see TestCase#setUp()\r
28          */\r
29         protected void setUp() throws Exception {\r
30                 super.setUp();\r
31 \r
32                 BasicConfigurator.configure();\r
33 \r
34                 email = "to@example.com";\r
35                 envelopeTo = "to@example.com";\r
36 \r
37                 String host = "localhost";\r
38                 sendMail = new SendMailImpl(host);\r
39                 sendMail.setMessageId("example.com");\r
40 \r
41                 builder = new XMLMailBuilderImpl();\r
42         }\r
43 \r
44         /**\r
45          * @see junit.framework.TestCase#tearDown()\r
46          */\r
47         protected void tearDown() throws Exception {\r
48                 BasicConfigurator.resetConfiguration();\r
49         }\r
50 \r
51         /*\r
52          public void testSendMailWithAttachmentInputStream() throws Exception {\r
53          String classPath = "/com/ozacc/mail/test-mail4.xml";\r
54          Mail mail = builder.buildMail(classPath);\r
55          mail.addTo(email);\r
56 \r
57          File image1 = new File("src/test/com/ozacc/mail/image1.jpg");\r
58          FileInputStream fis = new FileInputStream(image1);\r
59 \r
60          mail.addFile(fis, "野菜画像.jpg");\r
61          mail.setSubject("添付ファイルのInputStream送信テスト");\r
62 \r
63          sendMail.send(mail);\r
64          }\r
65 \r
66          \r
67          public void testSendMailEnvelopeTo() throws Exception {\r
68          String classPath = "/com/ozacc/mail/test-mail4.xml";\r
69          Mail mail = builder.buildMail(classPath);\r
70          mail.addTo(email);\r
71          mail.addEnvelopeTo(envelopeTo);\r
72          sendMail.send(mail);\r
73          }\r
74 \r
75          public void testSendMailSimpl() throws Exception {\r
76          String classPath = "/com/ozacc/mail/test-mail4.xml";\r
77          Mail mail = builder.buildMail(classPath);\r
78          mail.addTo(email);\r
79 \r
80          sendMail.send(mail);\r
81          }\r
82 \r
83          public void testSendMailWithAttachmentFile() throws Exception {\r
84          String classPath = "/com/ozacc/mail/test-mail4.xml";\r
85          Mail mail = builder.buildMail(classPath);\r
86          mail.addTo(email);\r
87 \r
88          File image1 = new File("src/test/com/ozacc/mail/image1.jpg");\r
89          File image2 = new File("src/test/com/ozacc/mail/image2.png");\r
90 \r
91          mail.addFile(image1);\r
92          mail.addFile(image2, "野菜画像.png");\r
93          mail.setSubject("添付ファイル送信テスト");\r
94 \r
95          sendMail.send(mail);\r
96          }\r
97 \r
98          public void testSendMailHTML() throws Exception {\r
99          String classPath = "/com/ozacc/mail/test-mail5-html.xml";\r
100          Mail mail = builder.buildMail(classPath);\r
101          mail.addTo(email);\r
102          mail.setHtmlText(mail.getText());\r
103          mail.setText("プレーンテキスト");\r
104          sendMail.send(mail);\r
105          }\r
106          \r
107          public void testSendMailHTMLOnly() throws Exception {\r
108          String classPath = "/com/ozacc/mail/test-mail5-html.xml";\r
109          Mail mail = builder.buildMail(classPath);\r
110          mail.addTo(email);\r
111          mail.setHtmlText(mail.getText());\r
112          mail.setText(null);\r
113          mail.setSubject("HTMLオンリー");\r
114          sendMail.send(mail);\r
115          }\r
116 \r
117          public void testSendMailHTMLWithAttachmentFile() throws Exception {\r
118          String classPath = "/com/ozacc/mail/test-mail5-html.xml";\r
119          Mail mail = builder.buildMail(classPath);\r
120          mail.addTo(email);\r
121          mail.setHtmlText(mail.getText());\r
122          mail.setText("プレーンテキスト");\r
123 \r
124          File image1 = new File("src/test/com/ozacc/mail/image1.jpg");\r
125          mail.addFile(image1);\r
126 \r
127          sendMail.send(mail);\r
128          }\r
129          */\r
130         /**\r
131          * テストケースがひとつもないとエラーになるので、ダミー。\r
132          */\r
133         public void testSendMailSuccess() {\r
134                 Mail mail;\r
135                 assertTrue(true);\r
136         }\r
137 \r
138 }