We are testing part of a login service using the jMock framework. We are using a combination of stub and mock classes.
We will be mocking the UserDAO
class. A DAO (Data
Access Object) is a class that fetches some data from a store (such
as a database) and converts into one or more objects in our application.
We provide an implementation of LoginService
but there is no implementation of
UserDAO
. \
As we're doing TDD, there are two tests, neither of which pass.
You need to change the
login
method in LoginService
to do the following:
- hash the password,
- call the
loadByUsernameAndPassword
method onuserDAO
, then - return
true
if the user name and password match the hard-coded values.
Finally, complete the second test case testLoginFailsIfUserNotKnown
.