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.2.1 2005/01/23 06:51:56 otsuka Exp $ 15 */ 16 public class SendMailImplRealTest extends TestCase { 17 18 private MailBuilder builder; 19 20 private String email; 21 22 private String envelopeTo; 23 24 private SendMailImpl sendMail; 25 26 /* 27 * @see TestCase#setUp() 28 */ 29 protected void setUp() throws Exception { 30 super.setUp(); 31 32 BasicConfigurator.configure(); 33 34 email = "to@example.com"; 35 envelopeTo = "to@example.com"; 36 37 String host = "localhost"; 38 sendMail = new SendMailImpl(host); 39 sendMail.setMessageId("example.com"); 40 41 builder = new XMLMailBuilderImpl(); 42 } 43 44 /*** 45 * @see junit.framework.TestCase#tearDown() 46 */ 47 protected void tearDown() throws Exception { 48 BasicConfigurator.resetConfiguration(); 49 } 50 51 /* 52 public void testSendMailWithAttachmentInputStream() throws Exception { 53 String classPath = "/com/ozacc/mail/test-mail4.xml"; 54 Mail mail = builder.buildMail(classPath); 55 mail.addTo(email); 56 57 File image1 = new File("src/test/com/ozacc/mail/image1.jpg"); 58 FileInputStream fis = new FileInputStream(image1); 59 60 mail.addFile(fis, "ÌûÖÚ²èÁ?.jpg"); 61 mail.setSubject("źÉÕ¥Õ¥¡¥¤¥?¤ÎInputStreamÁ÷¿®¥Æ¥¹¥È"); 62 63 sendMail.send(mail); 64 } 65 66 67 public void testSendMailEnvelopeTo() throws Exception { 68 String classPath = "/com/ozacc/mail/test-mail4.xml"; 69 Mail mail = builder.buildMail(classPath); 70 mail.addTo(email); 71 mail.addEnvelopeTo(envelopeTo); 72 sendMail.send(mail); 73 } 74 75 public void testSendMailSimpl() throws Exception { 76 String classPath = "/com/ozacc/mail/test-mail4.xml"; 77 Mail mail = builder.buildMail(classPath); 78 mail.addTo(email); 79 80 sendMail.send(mail); 81 } 82 83 public void testSendMailWithAttachmentFile() throws Exception { 84 String classPath = "/com/ozacc/mail/test-mail4.xml"; 85 Mail mail = builder.buildMail(classPath); 86 mail.addTo(email); 87 88 File image1 = new File("src/test/com/ozacc/mail/image1.jpg"); 89 File image2 = new File("src/test/com/ozacc/mail/image2.png"); 90 91 mail.addFile(image1); 92 mail.addFile(image2, "ÌûÖÚ²èÁ?.png"); 93 mail.setSubject("źÉÕ¥Õ¥¡¥¤¥?Á÷¿®¥Æ¥¹¥È"); 94 95 sendMail.send(mail); 96 } 97 98 public void testSendMailHTML() throws Exception { 99 String classPath = "/com/ozacc/mail/test-mail5-html.xml"; 100 Mail mail = builder.buildMail(classPath); 101 mail.addTo(email); 102 mail.setHtmlText(mail.getText()); 103 mail.setText("¥×¥?¡¼¥ó¥Æ¥¥¹¥È"); 104 sendMail.send(mail); 105 } 106 107 public void testSendMailHTMLOnly() throws Exception { 108 String classPath = "/com/ozacc/mail/test-mail5-html.xml"; 109 Mail mail = builder.buildMail(classPath); 110 mail.addTo(email); 111 mail.setHtmlText(mail.getText()); 112 mail.setText(null); 113 mail.setSubject("HTML¥ª¥ó¥ê¡¼"); 114 sendMail.send(mail); 115 } 116 117 public void testSendMailHTMLWithAttachmentFile() throws Exception { 118 String classPath = "/com/ozacc/mail/test-mail5-html.xml"; 119 Mail mail = builder.buildMail(classPath); 120 mail.addTo(email); 121 mail.setHtmlText(mail.getText()); 122 mail.setText("¥×¥?¡¼¥ó¥Æ¥¥¹¥È"); 123 124 File image1 = new File("src/test/com/ozacc/mail/image1.jpg"); 125 mail.addFile(image1); 126 127 sendMail.send(mail); 128 } 129 */ 130 /*** 131 * ¥Æ¥¹¥È¥±¡¼¥¹¤¬¤Ò¤È¤Ä¤â¤Ê¤¤¤È¥¨¥é¡¼¤Ë¤Ê¤?¤Î¤Ç¡¢¥À¥ß¡¼¡£ 132 */ 133 public void testSendMailSuccess() { 134 Mail mail; 135 assertTrue(true); 136 } 137 138 }