I have the following method:
public List<Author> getNewsAuthors() throws ServiceException, ConnectionException {
try {
logger.debug("Getting the NewsDAO instance");
NewsDAO newsDAO = daoFactory.getNewsDAO(scopingDataSource);
logger.debug("Getting news authors from the database");
List<Author> authorList = newsDAO.getNewsAuthors();
logger.debug("Returning all news authors");
return authorList;
}
catch (SQLException e) {
logger.error("Error in retrieving all news authors");
if (isConnectionException(e.getLocalizedMessage())) {
throw new ConnectionException(e.getLocalizedMessage());
}
else {
throw new ServiceException(e.getLocalizedMessage());
}
}
}
Can I mock the DAO instance inside the method call? Notice that the dao instance receives a data source in the constructor.
I am using EasyMock.
Aucun commentaire:
Enregistrer un commentaire