Fish & Chips Club 4.10.0.0

hirondelle.fish.test.doubles
Class FakeDAOBehavior

Object
  extended by hirondelle.fish.test.doubles.FakeDAOBehavior

public final class FakeDAOBehavior
extends Object

Change the exception behavior of fake DAOs. One of the advantages of using fake DAOs is that they can be made to throw specific exceptions when desired. By default, fake DAO operations will always succeed, in the sense of not throwing an explicit exception.

You control the behavior of a fake DAO using these methods :

For an illustration, see MemberDAOFake and TESTMemberDAO.

Implementation Note
This class uses simple System properties to store the desired behavior. Such an implementation is suitable only for a single threaded environment.


Nested Class Summary
static class FakeDAOBehavior.DbOperation
          Enumeration of the basic DAO operations.
static class FakeDAOBehavior.DbOperationResult
          Enumeration of how a basic DAO operation may succeed or fail.
 
Field Summary
static String USE_FAKE_DAOS
          Name of a System property used to swap implementations between real and fake DAOs.
 
Constructor Summary
FakeDAOBehavior()
           
 
Method Summary
static void possiblyThrowExceptionFor(FakeDAOBehavior.DbOperation aOperation)
          Possibly throw an exception for the given operation.
static void setBehavior(FakeDAOBehavior.DbOperation aDbOperation, FakeDAOBehavior.DbOperationResult aDbOperationResult)
          Set the desired behavior of a fake DAO operation.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

USE_FAKE_DAOS

public static final String USE_FAKE_DAOS
Name of a System property used to swap implementations between real and fake DAOs. When the property has the value true, then fake DAOs are used. See MemberDAOFake for an illustration. Value - "useFakeDAOs".

See Also:
Constant Field Values
Constructor Detail

FakeDAOBehavior

public FakeDAOBehavior()
Method Detail

possiblyThrowExceptionFor

public static void possiblyThrowExceptionFor(FakeDAOBehavior.DbOperation aOperation)
                                      throws DAOException,
                                             DuplicateException
Possibly throw an exception for the given operation.

An exception is thrown only if it has been indicated by calling setBehavior(DbOperation, DbOperationResult).

Throws:
DAOException
DuplicateException

setBehavior

public static void setBehavior(FakeDAOBehavior.DbOperation aDbOperation,
                               FakeDAOBehavior.DbOperationResult aDbOperationResult)
Set the desired behavior of a fake DAO operation.


Fish & Chips Club 4.10.0.0

Copyright Hirondelle Systems - Generated 2013Oct19.12.26