|
Fish & Chips Club 4.10.0.0 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
Objecthirondelle.fish.main.member.MemberDAO
hirondelle.fish.main.member.MemberDAOFake
public class MemberDAOFake
Test double for MemberDAO.
This is a 'fake' class is intended for unit testing only. This implementation stores its data in memory, using a static member of this class. This class is safe for access from multiple threads.
Note: this class uses synchronized to ensure thread safety. However, this may not really be necessary in many cases. It's only really necessary when your testing involves more than a single thread of execution. When running stand-alone unit tests, there is usually only one such thread. When using tools such as HttpUnit, however, which throw multiple HTTP requests at your app, then 'synchronized' is required.
This class goes to some lengths to mimic the real behavior as closely as possible.
For example, the items returned by list() are sorted correctly using a specific
Comparator. In addition, there is a mechanism for forcing particular
exceptions to occur (important for exercising all branches.)
| Constructor Summary | |
|---|---|
MemberDAOFake()
|
|
| Method Summary | |
|---|---|
(package private) Id |
add(Member aMember)
Add a new Member to the database. |
(package private) boolean |
change(Member aMember)
Update an existing Member. |
(package private) int |
delete(Id aMemberId)
Delete a single Member. |
Member |
fetch(Id aMemberId)
Return a single Member identified by its id. |
(package private) Integer |
getNumActiveMembers()
Return the number of currently active members. |
(package private) List<Member> |
list()
Return a List of all Member objects, sorted by Member Name. |
| Methods inherited from class hirondelle.fish.main.member.MemberDAO |
|---|
deleteMany, getInstance |
| Methods inherited from class Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public MemberDAOFake()
| Method Detail |
|---|
List<Member> list()
throws DAOException
MemberDAOMember objects, sorted by Member Name.
list in class MemberDAODAOException
public Member fetch(Id aMemberId)
throws DAOException
MemberDAOMember identified by its id.
fetch in class MemberDAODAOException
Id add(Member aMember)
throws DAOException,
DuplicateException
MemberDAOMember to the database.
The name of the Member must be unique. If there is a name
conflict, then a DuplicateException is thrown.
add in class MemberDAODAOException
DuplicateException
boolean change(Member aMember)
throws DAOException,
DuplicateException
MemberDAOMember.
The name of the Member must be unique. If there is a name
conflict, then a DuplicateException is thrown.
change in class MemberDAODAOException
DuplicateException
int delete(Id aMemberId)
throws DAOException
MemberDAOMember.
If an item is linked to this Member, then deletion will fail, and a
DAOException is thrown.
delete in class MemberDAODAOException
Integer getNumActiveMembers()
throws DAOException
MemberDAO
getNumActiveMembers in class MemberDAODAOException
|
Fish & Chips Club 4.10.0.0 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||