1 package com.ozacc.mail.impl;
\r
3 import junit.framework.TestCase;
\r
5 import org.apache.log4j.BasicConfigurator;
\r
7 import com.ozacc.mail.Mail;
\r
8 import com.ozacc.mail.MailBuilder;
\r
11 * SendMailImplクラスのテストケース。実際に送信し、メーラーで受信して確認するテストです。
\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
16 public class SendMailImplRealTest extends TestCase {
\r
18 private MailBuilder builder;
\r
20 private String email;
\r
22 private String envelopeTo;
\r
24 private SendMailImpl sendMail;
\r
27 * @see TestCase#setUp()
\r
29 protected void setUp() throws Exception {
\r
32 BasicConfigurator.configure();
\r
34 email = "to@example.com";
\r
35 envelopeTo = "to@example.com";
\r
37 String host = "localhost";
\r
38 sendMail = new SendMailImpl(host);
\r
39 sendMail.setMessageId("example.com");
\r
41 builder = new XMLMailBuilderImpl();
\r
45 * @see junit.framework.TestCase#tearDown()
\r
47 protected void tearDown() throws Exception {
\r
48 BasicConfigurator.resetConfiguration();
\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
57 File image1 = new File("src/test/com/ozacc/mail/image1.jpg");
\r
58 FileInputStream fis = new FileInputStream(image1);
\r
60 mail.addFile(fis, "野菜画像.jpg");
\r
61 mail.setSubject("添付ファイルのInputStream送信テスト");
\r
63 sendMail.send(mail);
\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
71 mail.addEnvelopeTo(envelopeTo);
\r
72 sendMail.send(mail);
\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
80 sendMail.send(mail);
\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
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
91 mail.addFile(image1);
\r
92 mail.addFile(image2, "野菜画像.png");
\r
93 mail.setSubject("添付ファイル送信テスト");
\r
95 sendMail.send(mail);
\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
102 mail.setHtmlText(mail.getText());
\r
103 mail.setText("プレーンテキスト");
\r
104 sendMail.send(mail);
\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
111 mail.setHtmlText(mail.getText());
\r
112 mail.setText(null);
\r
113 mail.setSubject("HTMLオンリー");
\r
114 sendMail.send(mail);
\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
121 mail.setHtmlText(mail.getText());
\r
122 mail.setText("プレーンテキスト");
\r
124 File image1 = new File("src/test/com/ozacc/mail/image1.jpg");
\r
125 mail.addFile(image1);
\r
127 sendMail.send(mail);
\r
131 * テストケースがひとつもないとエラーになるので、ダミー。
\r
133 public void testSendMailSuccess() {
\r