1   package com.ozacc.mail.impl;
2   
3   import junit.framework.TestCase;
4   
5   import org.apache.log4j.BasicConfigurator;
6   
7   import com.ozacc.mail.Mail;
8   import com.ozacc.mail.MailBuilder;
9   
10  /***
11   * SendMailImpl¥¯¥é¥¹¤Î¥Æ¥¹¥È¥±¡¼¥¹¡£¼ÂºÝ¤ËÁ÷¿®¤·¡¢¥á¡¼¥é¡¼¤Ç¼õ¿®¤·¤Æ³Îǧ¤¹¤?¥Æ¥¹¥È¤Ç¤¹¡£
12   * 
13   * @author Tomohiro Otsuka
14   * @version $Id: SendMailImplRealTest.java,v 1.6 2004/09/20 21:44:01 otsuka Exp $
15   */
16  public class SendMailImplRealTest extends TestCase {
17  
18  	private MailBuilder builder;
19  
20  	private String email;
21  
22  	private SendMailImpl sendMail;
23  
24  	/*
25  	 * @see TestCase#setUp()
26  	 */
27  	protected void setUp() throws Exception {
28  		super.setUp();
29  
30  		BasicConfigurator.configure();
31  
32  		email = "to@example.com";
33  
34  		String host = "192.168.0.10";
35  		sendMail = new SendMailImpl(host);
36  		sendMail.setMessageId("example.com");
37  
38  		builder = new XMLMailBuilderImpl();
39  	}
40  
41  	/***
42  	 * @see junit.framework.TestCase#tearDown()
43  	 */
44  	protected void tearDown() throws Exception {
45  		BasicConfigurator.resetConfiguration();
46  	}
47  
48  	/*	public void testSendMailWithAttachmentInputStream() throws Exception {
49  	 String classPath = "/com/ozacc/mail/test-mail4.xml";
50  	 Mail mail = builder.buildMail(classPath);
51  	 mail.addTo(email);
52  
53  	 File image1 = new File("src/test/com/ozacc/mail/image1.jpg");
54  	 FileInputStream fis = new FileInputStream(image1);
55  
56  	 mail.addFile(fis, "ÌûÖÚ²èÁ?.jpg");
57  	 mail.setSubject("źÉÕ¥Õ¥¡¥¤¥?¤ÎInputStreamÁ÷¿®¥Æ¥¹¥È");
58  
59  	 sendMail.send(mail);
60  	 }
61  
62  	 public void testSendMailSimpl() throws Exception {
63  	 String classPath = "/com/ozacc/mail/test-mail4.xml";
64  	 Mail mail = builder.buildMail(classPath);
65  	 mail.addTo(email);
66  
67  	 sendMail.send(mail);
68  	 }
69  
70  	 public void testSendMailWithAttachmentFile() throws Exception {
71  	 String classPath = "/com/ozacc/mail/test-mail4.xml";
72  	 Mail mail = builder.buildMail(classPath);
73  	 mail.addTo(email);
74  
75  	 File image1 = new File("src/test/com/ozacc/mail/image1.jpg");
76  	 File image2 = new File("src/test/com/ozacc/mail/image2.png");
77  
78  	 mail.addFile(image1);
79  	 mail.addFile(image2, "ÌûÖÚ²èÁ?.png");
80  	 mail.setSubject("źÉÕ¥Õ¥¡¥¤¥?Á÷¿®¥Æ¥¹¥È");
81  
82  	 sendMail.send(mail);
83  	 }
84  
85  	 public void testSendMailHTML() throws Exception {
86  	 String classPath = "/com/ozacc/mail/test-mail5-html.xml";
87  	 Mail mail = builder.buildMail(classPath);
88  	 mail.addTo(email);
89  	 mail.setHtmlText(mail.getText());
90  	 mail.setText("¥×¥?¡¼¥ó¥Æ¥­¥¹¥È");
91  	 sendMail.send(mail);
92  	 }
93  	 
94  	 public void testSendMailHTMLOnly() throws Exception {
95  	 String classPath = "/com/ozacc/mail/test-mail5-html.xml";
96  	 Mail mail = builder.buildMail(classPath);
97  	 mail.addTo(email);
98  	 mail.setHtmlText(mail.getText());
99  	 mail.setText(null);
100 	 mail.setSubject("HTML¥ª¥ó¥ê¡¼");
101 	 sendMail.send(mail);
102 	 }
103 
104 	 public void testSendMailHTMLWithAttachmentFile() throws Exception {
105 	 String classPath = "/com/ozacc/mail/test-mail5-html.xml";
106 	 Mail mail = builder.buildMail(classPath);
107 	 mail.addTo(email);
108 	 mail.setHtmlText(mail.getText());
109 	 mail.setText("¥×¥?¡¼¥ó¥Æ¥­¥¹¥È");
110 
111 	 File image1 = new File("src/test/com/ozacc/mail/image1.jpg");
112 	 mail.addFile(image1);
113 
114 	 sendMail.send(mail);
115 	 }
116 	 */
117 	/***
118 	 * ¥Æ¥¹¥È¥±¡¼¥¹¤¬¤Ò¤È¤Ä¤â¤Ê¤¤¤È¥¨¥é¡¼¤Ë¤Ê¤?¤Î¤Ç¡¢¥À¥ß¡¼¡£
119 	 */
120 	public void testSendMailSuccess() {
121 		Mail mail;
122 		assertTrue(true);
123 	}
124 
125 }