2 package com.ozacc.mail.fetch.impl;
4 import javax.mail.Message.RecipientType;
5 import javax.mail.Session;
6 import javax.mail.internet.MimeMessage;
8 import junit.framework.TestCase;
10 import org.apache.log4j.BasicConfigurator;
11 import org.jvnet.mock_javamail.Mailbox;
13 import com.ozacc.mail.Mail;
14 import com.ozacc.mail.fetch.ReceivedMail;
17 * FetchMailImplクラスのテストケース。
22 public class FetchMailImplTest extends TestCase
24 protected void setUp() throws Exception
27 BasicConfigurator.configure();
31 * 受信したメールの返信を作成するテスト (#12279)
33 public void testReplyReceivedMail() throws Exception
35 String subject = "Test subject";
36 String recipient = "info@example.com";
37 Session session = Session.getInstance(System.getProperties());
38 MimeMessage msg = new MimeMessage(session);
39 msg.setRecipients(RecipientType.TO, recipient);
40 msg.setSubject(subject);
41 msg.setText("Test body");
42 msg.setHeader("Message-ID", "MSGID-123");
43 Mailbox inbox = Mailbox.get("info@example.com");
46 FetchMailImpl fetchMail = new FetchMailImpl();
47 fetchMail.setHost("example.com");
48 fetchMail.setUsername("info");
49 ReceivedMail[] mails = fetchMail.getMails();
50 assertEquals(1, mails.length);
51 ReceivedMail receivedMail = mails[0];
52 Mail reply = (Mail)(receivedMail.reply());
53 assertEquals(receivedMail.getReplySubjectPrefix() + subject, reply.getSubject());
56 protected void tearDown() throws Exception {
58 BasicConfigurator.resetConfiguration();