Coverage report

  %line %branch
com.ozacc.mail.mock.MockFetchMail
42% 
84% 

 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.