|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.osesb.scheduledjobs.databasepoller.test.DatabasePollerTestDriver
public class DatabasePollerTestDriver
Helper class for DatabasePollerTest, which is a JUnit Test for the org.osesb.scheduledjobs.databasepoller package.
Tests a database poller that is configured by the ScheduledJobConfiguration file specified by the 'testConfiguration' property Test.properties. Tests can be configured to run against different database applications using the</scheduled-job/job-configuration/database-poller-configuration/tableset-configuration/jdbc-configuration>
element in the ScheduledJobConfiguration file and the 'databasePollerTestDriverConfiguration'
property in Test.properties.
The target database application must be up and available for the tests to
run. The JDBCTEST test tables must be created in the target database application.
See org.osesb.utilities.jdbc.test.testdata for .sql files that create the
test database.
The test DatabasePollerConfiguration(s) in the example folders (example1, example2,...)
are configured to use the Customer table in the JDBC test database.
DatabasePollerTest uses a test driver, DatabasePollerTestDriver, which runs
in a Thread that periodically inserts a random number of rows into the
table(s) which are being scanned by the database poller. The update period
is a random interval between (1 times) and (5 times) the repeatInterval
that is configured for the database poller and the maximum number of rows
that are inserted during each run is given by MAX_ROWS_TO_INSERT.
DatabasePollerTestDriver is configured using the DataSetConfiguration file
specified by the 'databasePollerTestDriverConfiguration' property in Test.properties.
The DataSetConfiguration includes at least a SQLStatement that is used to update
the database table(s) configured for the database poller that is being tested.
DatabasePollerTestDriver gets its database connection using the JDBCConfiguration that
is configured for the TableSet that the database poller uses. The SQL statement
configured for DatabasePollerTestDriver must update the databse table(s) configured
for the database poller that is being tested. The tester should make sure that the
DataSetConfiguration for the DatabasePollerTestDriver is consistent with the
<jdbc-configuration> element in the ScheduledJobConfiguration file.
The test succeeds if the number of rows processed by the database poller is equal to
'the number of rows initially in the target table(s)' + 'the number of rows added by DatabasePollerTestDriver'.
The number of rows initially in the target table(s) is given by the 'initialNumberOfTestRows'
property in Test.properties.
| Field Summary | |
|---|---|
protected DataSetConfiguration |
dataSetConfiguration
The DataSetConfiguration for this DatabasePollerTestDriver, which is set by the DatabasePollerTest that instantiates this class. |
protected java.sql.Connection |
dbConn
JDBC Connections used by testThread. |
protected static org.apache.commons.logging.Log |
log
The logging implementation for this class. |
protected static int |
MAX_ROWS_TO_INSERT
The DatabasePollerTestDriver thread periodically inserts a random number of rows into the table(s) which are being scanned by the database poller. |
protected ScheduledJobConfiguration |
scheduledJobConfiguration
The DatabasePollerConfiguration passed to the Constructor. |
protected java.lang.Thread |
testThread
The DatabasePollerTestDriver thread periodically inserts a random number of rows into the table(s) which are being scanned by the database poller. |
protected boolean |
testThreadStopping
run() flag for testThread. |
protected java.lang.String |
thisClassName
The full name of this class. |
protected java.util.Date |
threadStartedTimestamp
Timestamp for when testThread started. |
protected int |
totalNumberOfRowsInserted
The DatabasePollerTestDriver thread periodically inserts a random number of rows into the table(s) which are being scanned by the database poller. |
| Constructor Summary | |
|---|---|
DatabasePollerTestDriver(ScheduledJobConfiguration scheduledJobConfiguration)
Invoked by DatabasePollerTest to create a new instance of DatabasePollerTestDriver. |
|
| Method Summary | |
|---|---|
DataSetConfiguration |
getDataSetConfiguration()
Returns the DataSetConfiguration for this DatabasePollerTestDriver, which is set by the DatabasePollerTest that instantiates this class. |
ScheduledJobConfiguration |
getScheduledJobConfiguration()
Returns the ScheduledJobConfiguration for this DatabasePollerTestDriver. |
int |
getTotalNumberOfRowsInserted()
Get the totalNumberOfRowsInserted is the total number of rows inserted by testThread. |
void |
joinTestThread()
Wait for testThread to die. |
static void |
main(java.lang.String[] args)
main() For testing. |
void |
run()
Run the DatabasePollerTestDriver thread, periodically inserts a random number of rows into the table(s) which are being scanned by the database poller. |
void |
setDataSetConfiguration(DataSetConfiguration dataSetConfiguration)
Sets the DataSetConfiguration for this DatabasePollerTestDriver, which is set by the DatabasePollerTest that instantiates this class. |
void |
start()
Start testThread, which periodically inserts a random number of rows into the table(s) which are being scanned by the database poller. |
void |
stop()
Stop testThread, which periodically inserts a random number of rows into the table(s) which are being scanned by the database poller. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected java.lang.String thisClassName
protected ScheduledJobConfiguration scheduledJobConfiguration
protected DataSetConfiguration dataSetConfiguration
setDataSetConfiguration(DataSetConfiguration dataSetConfiguration)protected java.lang.Thread testThread
start(),
stop(),
run()protected java.util.Date threadStartedTimestamp
start(),
run()protected boolean testThreadStopping
start(),
stop(),
run()protected java.sql.Connection dbConn
start(),
run()protected static final int MAX_ROWS_TO_INSERT
run(),
Constant Field Valuesprotected int totalNumberOfRowsInserted
run()protected static org.apache.commons.logging.Log log
| Constructor Detail |
|---|
public DatabasePollerTestDriver(ScheduledJobConfiguration scheduledJobConfiguration)
throws java.lang.Exception
scheduledJobConfiguration - The ScheduledJobConfiguration for the database poller being tested.
java.lang.Exception - if constructed with a null scheduledJobConfiguration.| Method Detail |
|---|
public void start()
throws java.lang.Exception
java.lang.Exceptionpublic void stop()
public void joinTestThread()
public void run()
run in interface java.lang.Runnablestart(),
stop()public ScheduledJobConfiguration getScheduledJobConfiguration()
public DataSetConfiguration getDataSetConfiguration()
public void setDataSetConfiguration(DataSetConfiguration dataSetConfiguration)
dataSetConfiguration - The DataSetConfiguration for this DatabasePollerTestDriver.public int getTotalNumberOfRowsInserted()
run()public static void main(java.lang.String[] args)
args - commandline arguments
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||