%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
com.ozacc.mail.mock.MockFetchMail |
|
|
1 | package com.ozacc.mail.mock; |
|
2 | ||
3 | import java.util.ArrayList; |
|
4 | import java.util.List; |
|
5 | ||
6 | import org.apache.commons.logging.Log; |
|
7 | import org.apache.commons.logging.LogFactory; |
|
8 | ||
9 | import com.ozacc.mail.MailException; |
|
10 | import com.ozacc.mail.fetch.FetchMail; |
|
11 | import com.ozacc.mail.fetch.ReceivedMail; |
|
12 | ||
13 | /** |
|
14 | * FetchMailImpl¥¯¥é¥¹¤ÎMock¡£<br> |
|
15 | * <code>setupGetMails()</code>¥á¥½¥Ã¥É¤Ç<code>ReceivedMail</code>¥¤¥ó¥¹¥¿¥ó¥¹¤ò¥»¥Ã¥È¤¹¤?¤È¡¢<code>getMails()</code>¥á¥½¥Ã¥É¤¬¤½¤Î¥¤¥ó¥¹¥¿¥ó¥¹¤òÊÖ¤·¤Þ¤¹¡£ |
|
16 | * |
|
17 | * @since 1.2 |
|
18 | * @author Tomohiro Otsuka |
|
19 | * @version $Id: MockFetchMail.java,v 1.1.2.2 2005/01/29 22:33:27 otsuka Exp $ |
|
20 | */ |
|
21 | 1 | public class MockFetchMail implements FetchMail { |
22 | ||
23 | 1 | private static Log log = LogFactory.getLog(MockFetchMail.class); |
24 | ||
25 | /** ¥Ç¥Õ¥©¥?¥È¤ÎSMTP¥µ¡¼¥Ð¡£¡Ölocalhost¡× */ |
|
26 | public static final String DEFAULT_HOST = "localhost"; |
|
27 | ||
28 | /** ¥Ç¥Õ¥©¥?¥È¤Î¥×¥úÁÈ¥³¥?¡£¡Öpop3¡× */ |
|
29 | public static final String DEFAULT_PROTOCOL = "pop3"; |
|
30 | ||
31 | /** |
|
32 | * ¥Ç¥Õ¥©¥?¥È¤Î¥Ý¡¼¥È¡£¡Ö-1¡×<br> |
|
33 | * -1¤Ï¥×¥úÁÈ¥³¥?¤Ë±?¤¸¤¿Å¬Àڤʥݡ¼¥È¤òÀßÄꤹ¤?ÆÃÊ̤ÊÃÍ¡£ |
|
34 | */ |
|
35 | public static final int DEFAULT_PORT = -1; |
|
36 | ||
37 | private static final String INBOX_NAME = "INBOX"; |
|
38 | ||
39 | 1 | private String host = DEFAULT_HOST; |
40 | ||
41 | 1 | private String protocol = DEFAULT_PROTOCOL; |
42 | ||
43 | 1 | private int port = DEFAULT_PORT; |
44 | ||
45 | private String username; |
|
46 | ||
47 | private String password; |
|
48 | ||
49 | private List receivedMails; |
|
50 | ||
51 | /** |
|
52 | * ¥³¥ó¥¹¥È¥é¥¯¥¿¡£ |
|
53 | */ |
|
54 | public MockFetchMail() { |
|
55 | 1 | super(); |
56 | 1 | receivedMails = new ArrayList(); |
57 | 1 | } |
58 | ||
59 | /** |
|
60 | * <code>MockFetchMail</code>¤Î<code>getMails()</code>¥á¥½¥Ã¥É¤¬ÊÖ¤¹ |
|
61 | * <code>ReceivedMail</code>¥¤¥ó¥¹¥¿¥ó¥¹¤ò¥»¥Ã¥È¤·¤Þ¤¹¡£ |
|
62 | * |
|
63 | * @param mails <code>getMails()</code>¥á¥½¥Ã¥É¤¬ÊÖ¤¹<code>ReceivedMail</code>¥¤¥ó¥¹¥¿¥ó¥¹ |
|
64 | */ |
|
65 | public void setupGetMails(ReceivedMail mail) { |
|
66 | 1 | receivedMails.add(mail); |
67 | 1 | } |
68 | ||
69 | /** |
|
70 | * <code>MockFetchMail</code>¤Î<code>getMails()</code>¥á¥½¥Ã¥É¤¬ÊÖ¤¹ |
|
71 | * <code>ReceivedMail</code>¥¤¥ó¥¹¥¿¥ó¥¹¤ò¥»¥Ã¥È¤·¤Þ¤¹¡£ |
|
72 | * |
|
73 | * @param mails <code>getMails()</code>¥á¥½¥Ã¥É¤¬ÊÖ¤¹<code>ReceivedMail</code>¥¤¥ó¥¹¥¿¥ó¥¹ÇÛÎ? |
|
74 | */ |
|
75 | public void setupGetMails(ReceivedMail[] mails) { |
|
76 | 0 | for (int i = 0; i < mails.length; i++) { |
77 | 0 | ReceivedMail mail = mails[i]; |
78 | 0 | setupGetMails(mail); |
79 | } |
|
80 | 0 | } |
81 | ||
82 | /** |
|
83 | * @see com.ozacc.mail.fetch.FetchMail#getMails() |
|
84 | */ |
|
85 | public ReceivedMail[] getMails() throws MailException { |
|
86 | 1 | log.debug(protocol.toUpperCase() + "¥µ¡¼¥Ð[" + host + "]¤ËÀܳ¤·¤?¥Õ¥ê¡£"); |
87 | 1 | log.debug(protocol.toUpperCase() + "¥µ¡¼¥Ð[" + host + "]¤ËÀܳ¤·¤¿¥Õ¥ê¡£"); |
88 | ||
89 | 1 | if (receivedMails.size() > 0) { |
90 | 1 | log.debug(receivedMails.size() + "Ä̤Υ᡼¥?¤ò¼õ¿®¤¹¤?¥Õ¥ê¡£"); |
91 | } else { |
|
92 | 0 | log.debug("¼õ¿®¤¹¤?¥Õ¥ê¤ò¤¹¤?¥á¡¼¥?¤Ï¤¢¤ê¤Þ¤»¤ó¡£"); |
93 | } |
|
94 | try { |
|
95 | 1 | return (ReceivedMail[])receivedMails.toArray(new ReceivedMail[receivedMails.size()]); |
96 | 0 | } finally { |
97 | 1 | log.debug(protocol.toUpperCase() + "¥µ¡¼¥Ð[" + host + "]¤È¤ÎÀܳ¤òÀÚÃǤ¹¤?¥Õ¥ê¡£"); |
98 | 1 | log.debug(protocol.toUpperCase() + "¥µ¡¼¥Ð[" + host + "]¤È¤ÎÀܳ¤òÀÚÃǤ·¤¿¥Õ¥ê¡£"); |
99 | 1 | } |
100 | } |
|
101 | ||
102 | /** |
|
103 | * @see com.ozacc.mail.fetch.FetchMail#getMails(boolean) |
|
104 | */ |
|
105 | public ReceivedMail[] getMails(boolean delete) throws MailException { |
|
106 | 0 | ReceivedMail[] result = getMails(); |
107 | 0 | if (delete) { |
108 | 0 | receivedMails.clear(); |
109 | } |
|
110 | 0 | return result; |
111 | } |
|
112 | ||
113 | /** |
|
114 | * @return Returns the host. |
|
115 | */ |
|
116 | public String getHost() { |
|
117 | 0 | return host; |
118 | } |
|
119 | ||
120 | /** |
|
121 | * @param host The host to set. |
|
122 | */ |
|
123 | public void setHost(String host) { |
|
124 | 0 | this.host = host; |
125 | 0 | } |
126 | ||
127 | /** |
|
128 | * @return Returns the password. |
|
129 | */ |
|
130 | public String getPassword() { |
|
131 | 0 | return password; |
132 | } |
|
133 | ||
134 | /** |
|
135 | * @param password The password to set. |
|
136 | */ |
|
137 | public void setPassword(String password) { |
|
138 | 0 | this.password = password; |
139 | 0 | } |
140 | ||
141 | /** |
|
142 | * @return Returns the port. |
|
143 | */ |
|
144 | public int getPort() { |
|
145 | 0 | return port; |
146 | } |
|
147 | ||
148 | /** |
|
149 | * @param port The port to set. |
|
150 | */ |
|
151 | public void setPort(int port) { |
|
152 | 0 | this.port = port; |
153 | 0 | } |
154 | ||
155 | /** |
|
156 | * @return Returns the protocol. |
|
157 | */ |
|
158 | public String getProtocol() { |
|
159 | 0 | return protocol; |
160 | } |
|
161 | ||
162 | /** |
|
163 | * @param protocol The protocol to set. |
|
164 | */ |
|
165 | public void setProtocol(String protocol) { |
|
166 | 0 | this.protocol = protocol; |
167 | 0 | } |
168 | ||
169 | /** |
|
170 | * @return Returns the username. |
|
171 | */ |
|
172 | public String getUsername() { |
|
173 | 0 | return username; |
174 | } |
|
175 | ||
176 | /** |
|
177 | * @param username The username to set. |
|
178 | */ |
|
179 | public void setUsername(String username) { |
|
180 | 0 | this.username = username; |
181 | 0 | } |
182 | } |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |