|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--junit.framework.Assert | +--com.netriser.xmltestsuite.TestResource | +--com.netriser.xmltestsuite.DBResource
This class provides database resources to test objects. It also monitors designated database tables for insertions and deletions to verify for each test or step that only specified database tables are affected.
It is configured via the optional database element in the xml configuration file parsed by ConfigurationResource.
The monitoring uses nested selects, so that many tables can be efficiently monitored at the same time. This requires a database which supports nested selects. Most databases support this, the most notable exception being MS Access.
This class acts as a facade which hides the complexity of the database from the test objects. It is instantiated as a singleton using a factory To obtain a instance use
DBResource ResourceFactory.getDBResource();
Constructor Summary | |
DBResource()
|
Method Summary | |
void |
addError(junit.framework.Test test,
java.lang.Throwable t)
|
void |
addFailure(junit.framework.Test test,
junit.framework.AssertionFailedError t)
|
void |
displayQuery(java.lang.String query)
|
void |
endTest(junit.framework.Test test)
Verifies the database tables at the end of a test or step. |
void |
exec(java.lang.String query)
Executes a given query string. |
java.lang.String |
execR1C1(java.lang.String query)
Returns the first column of the first row of a given query string. |
java.sql.Connection |
getDBConnection()
|
void |
listdbInsertedRows()
Prints a list of inserted rows. |
void |
setUp()
Opens a connection to the database. |
void |
startTest(junit.framework.Test test)
|
void |
tearDown()
Closes the database connection and prints a list of inserted rows. |
void |
useTestResult(junit.framework.TestResult resultCollector)
Called when testing starts ie by Main::RunTest Provides opportunity to calll TestResult::addListener addListener requires class to implement TestListener interface |
Methods inherited from class com.netriser.xmltestsuite.TestResource |
debug, getDebugMode, getVerboseMode, setDebug, setVerbose, verbose |
Methods inherited from class junit.framework.Assert |
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public DBResource()
Method Detail |
public java.sql.Connection getDBConnection()
public void setUp()
setUp
in interface TestResourceInterface
setUp
in class TestResource
TestResource.setUp()
public void tearDown()
tearDown
in interface TestResourceInterface
tearDown
in class TestResource
TestResource.tearDown()
public void exec(java.lang.String query) throws java.sql.SQLException
java.sql.SQLException
public java.lang.String execR1C1(java.lang.String query) throws java.sql.SQLException
java.sql.SQLException
public void listdbInsertedRows()
public void useTestResult(junit.framework.TestResult resultCollector)
TestResourceInterface
useTestResult
in interface TestResourceInterface
useTestResult
in class TestResource
TestResourceInterface.useTestResult(TestResult)
public void addError(junit.framework.Test test, java.lang.Throwable t)
addError
in interface junit.framework.TestListener
TestListener.addError(Test, Throwable)
public void addFailure(junit.framework.Test test, junit.framework.AssertionFailedError t)
addFailure
in interface junit.framework.TestListener
TestListener.addFailure(Test, AssertionFailedError)
public void endTest(junit.framework.Test test)
endTest
in interface junit.framework.TestListener
TestListener.endTest(Test)
public void startTest(junit.framework.Test test)
startTest
in interface junit.framework.TestListener
TestListener.startTest(Test)
public void displayQuery(java.lang.String query) throws java.sql.SQLException
java.sql.SQLException
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |