I am looking for a way to test my Dao classes.
One of my classes gets a datasource like this:
public class OrderEJB implements OrderEjbLocal{
@Resource(mappedName = "java:jboss/datasources/MyDS")
private DataSource dataSource;
@Inject
@DataAccessObject
private UserDAO userDAO;
@Override
public List<Activity> activityList() {
try (Connection connection = dataSource.getConnection();) {
return this.userDAO.findAllActivities(connection);
} catch (SQLException e) {
log.error("error");
throw new RuntimeException(e);
}
}
}
Then I have the class UserDAOImpl with the method
public List<Activity> activityList(Connection con)
How can I test the UserDAOImpl? Do I need something like mockito, jmock, easymock? Also, does the server need to be running when running my Junit test? or is there a way to do it without it?
Thanks