1 package com.ozacc.mail.mock;
2
3 import java.util.ArrayList;
4 import java.util.List;
5
6 import com.ozacc.mail.MailException;
7 import com.ozacc.mail.fetch.FetchMail;
8 import com.ozacc.mail.fetch.ReceivedMail;
9
10 /***
11 *
12 * @author Tomohiro Otsuka
13 * @version $Id: MockFetchMail.java,v 1.1.2.1 2004/10/24 10:18:41 otsuka Exp $
14 */
15 public class MockFetchMail implements FetchMail {
16
17 /*** デフォルトのSMTPサーバ。「localhost」 */
18 public static final String DEFAULT_HOST = "localhost";
19
20 /*** デフォルトのプロトコル。「pop3」 */
21 public static final String DEFAULT_PROTOCOL = "pop3";
22
23 /***
24 * デフォルトのポート。「-1」<br>
25 * -1はプロトコルに応じた適切なポートを設定する特別な値。
26 */
27 public static final int DEFAULT_PORT = -1;
28
29 private static final String INBOX_NAME = "INBOX";
30
31 private String host = DEFAULT_HOST;
32
33 private String protocol = DEFAULT_PROTOCOL;
34
35 private int port = DEFAULT_PORT;
36
37 private String username;
38
39 private String password;
40
41 private List expectedMails;
42
43 /***
44 * コンストラクタ。
45 */
46 public MockFetchMail() {
47 super();
48 expectedMails = new ArrayList();
49 }
50
51 public void addExcpectedReceivedMail(ReceivedMail expectedMail) {
52 expectedMails.add(expectedMail);
53 }
54
55 public void addExcpectedReceivedMails(ReceivedMail[] expectedMails) {
56 for (int i = 0; i < expectedMails.length; i++) {
57 ReceivedMail mail = expectedMails[i];
58 addExcpectedReceivedMail(mail);
59 }
60 }
61
62 /***
63 * @see com.ozacc.mail.fetch.FetchMail#getMails()
64 */
65 public ReceivedMail[] getMails() throws MailException {
66 return (ReceivedMail[])expectedMails.toArray(new ReceivedMail[expectedMails.size()]);
67 }
68
69 /***
70 * @see com.ozacc.mail.fetch.FetchMail#getMails(boolean)
71 */
72 public ReceivedMail[] getMails(boolean delete) throws MailException {
73 ReceivedMail[] result = getMails();
74 if (delete) {
75 expectedMails.clear();
76 }
77 return result;
78 }
79
80 /***
81 * @return Returns the host.
82 */
83 public String getHost() {
84 return host;
85 }
86
87 /***
88 * @param host The host to set.
89 */
90 public void setHost(String host) {
91 this.host = host;
92 }
93
94 /***
95 * @return Returns the password.
96 */
97 public String getPassword() {
98 return password;
99 }
100
101 /***
102 * @param password The password to set.
103 */
104 public void setPassword(String password) {
105 this.password = password;
106 }
107
108 /***
109 * @return Returns the port.
110 */
111 public int getPort() {
112 return port;
113 }
114
115 /***
116 * @param port The port to set.
117 */
118 public void setPort(int port) {
119 this.port = port;
120 }
121
122 /***
123 * @return Returns the protocol.
124 */
125 public String getProtocol() {
126 return protocol;
127 }
128
129 /***
130 * @param protocol The protocol to set.
131 */
132 public void setProtocol(String protocol) {
133 this.protocol = protocol;
134 }
135
136 /***
137 * @return Returns the username.
138 */
139 public String getUsername() {
140 return username;
141 }
142
143 /***
144 * @param username The username to set.
145 */
146 public void setUsername(String username) {
147 this.username = username;
148 }
149 }