DAOTest

public abstract class DAOTest<T extends DataSourceDAO> extends UnitTest<T>

The DAOTest is base class for testing DAO.

Author:

Twinsen Tsang

Parameters:
  • <T> – The class which implements DataSourceDAO.

See also: DataSourceDAO

Fields

CREATE_SQL_SUFFIX

public static final String CREATE_SQL_SUFFIX

DROP_SQL_SUFFIX

public static final String DROP_SQL_SUFFIX

INSERT_SQL_SUFFIX

public static final String INSERT_SQL_SUFFIX

MODULE_XML_DESCRIPTOR_SUFFIX

public static final String MODULE_XML_DESCRIPTOR_SUFFIX

container

protected Module container

containerLogger

protected Logger containerLogger

daoFactory

protected DAOFactory daoFactory

Constructors

DAOTest

public DAOTest()

Create an instance of DAOTest. By default, it disable JMOCK features for reducing dependency.

DAOTest

public DAOTest(boolean noMocking)

Create an instance of DAOTest.

Parameters:
  • noMocking – the flag representing the test requires object mocking or not ?

Methods

commitSQL

protected void commitSQL(String fixtureName)

This is a helper function for commit SQL from Fixture.

createDAOContainer

public Module createDAOContainer()

This is the factory to create the DAO container (typically it is a common module). Sub-class may override this to customize the DAO container.

dropTable

public synchronized void dropTable()

Drop the table for next test-case.

getTableName

public abstract String getTableName()

Return the DB table name accessed by this DAO.

Returns:the DB table name accessed by this DAO.

getTestContainer

public Module getTestContainer()

initTestTarget

public synchronized void initTestTarget()

Initialize the test target for this test-case. A Special piazza common module is constructed during this initialization. We will call the module as a container of our test-case because the DAO can only be constructed through DAOFactory. Moreover, we have to create the database table and insert some SQL for testing because of non-persistence database has been adopted for performing unit-testing.

tearDown

public void tearDown()