私は自分の DAO の単体テストをしようとしてきましたが、まだその方法を見つけられず、少し必死になっています。次のような小さなDAOがあります。
public interface ElectionsDao {
List<String> getDates();
}
私はSpringフレームワークを使用してDIを使用していSimpleJdbcTemplate
ます。私の実装は次のようになります。
public class ElectionsDaoImpl extends SimpleJdbcDaoSupport implements ElectionsDao {
public List<String> getDates() {
List<String> dates = new ArrayList<String>();
try {
dates = getSimpleJdbcTemplate().query("SELECT electiondate FROM electiondate", new StringRowMapper());
} catch (DataAccessException ex){
throw new RuntimeException(ex);
}
return dates;
}
protected static final class StringRowMapper implements ParameterizedRowMapper<String> {
public String mapRow(ResultSet rs, int line) throws SQLException {
String string = new String(rs.getString("electiondate"));
return string;
}
}
}
私がやりたいのは、getDates()
EasyMock を使用した単体テストですが、それを行う方法が見つかりません。私は困惑している。誰でも私を助けてもらえますか?