|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.opensubsystems.patterns.listdata.persist.db.ListDatabaseTestUtils
public abstract class ListDatabaseTestUtils
Class used by JUnit tests derived from ListDatabaseFactoryTest class. Each such class should derive its own class from this class and implement all required methods. The functionality provided by the implemented methods it used to execute the generic tests for list pattern functionality. The idea is that the derived class specifies how to constructs the in memory tested data objects using two specified string values (here called column one and column two) and then specifies how to insert them to the database and how to delete them from the database. Then the generic tests using these specific methods as well as other utility methods from this class test list pattern implementation and behavior of the tested data object.
| Field Summary | |
|---|---|
protected int[] |
m_arrAllColumnCodes
Array with codes for all columns that stores data for the tested data object. |
protected java.lang.Class |
m_clsListDatabaseSchemaClass
Class that implements ListDatabaseSchema interface for the tested data object. |
protected java.lang.Class |
m_clsListFactoryClass
Class representing database specific ListFactory interface implementation for the tested data object. |
protected int |
m_iColumnOneCode
Code that represents column storing the first value used to generate the tested data object. |
protected int |
m_iColumnTwoCode
Code that represents column storing the second value used to generate the tested data object. |
static java.lang.String |
NO_PARENT
Constant used to return test data which were created without any parent. |
| Constructor Summary | |
|---|---|
ListDatabaseTestUtils(java.lang.Class clsListFactoryClass,
java.lang.Class clsListDatabaseSchemaClass,
int[] arrAllColumnCodes,
int iColumnOneCode,
int iColumnTwoCode)
Constructor |
|
| Method Summary | |
|---|---|
void |
analyzeDatabase()
Update database statistics with expectation to improve performance of queries (usually after a large number of data were inserted or deleted) by analyzing the modified tables. |
protected abstract org.opensubsystems.core.data.DataObject |
constructData(java.lang.Object parent,
int iDomainId,
java.lang.String str1,
java.lang.String str2)
Construct instance of tested data object that can be later inserted to the database using the specifiend values. |
protected org.opensubsystems.core.data.DataObject |
createDataObject(org.opensubsystems.core.data.DataObject data)
Create data object. |
protected void |
createDataObjects(java.util.List lstDataObjects)
Create list of data objects efficiently if possible. |
protected abstract void |
deleteData(java.lang.Object parent,
int iDomainId,
java.lang.String strPrefix1,
java.lang.String strPrefix2)
Delete all instances of tested data object that were previously constructed for a specified parent using the specified prefixes for values used to populate column one and two. |
protected void |
deleteData(java.lang.Object parent,
int iDomainId,
java.lang.String strPrefix1,
java.lang.String strPrefix2,
java.lang.String strDeleteByListTestPrefixesQuery,
boolean bSubstitueValues)
Convenience method to delete all instances of tested data object that were previously constructed for a specified parent using the specified prefixes for values used to populate column one and two. |
protected void |
deleteDataObject(org.opensubsystems.core.data.DataObject data,
int iDomainId)
Delete data object. |
protected void |
deleteDataObjects(java.util.List lstDataObjects,
int iDomainId)
Deletes list of data objects efficiently if possible. |
void |
deleteLoadTestData(javax.transaction.UserTransaction transaction,
java.lang.Object[] insertedData)
Delete all data inserted for the load tests using the insertLoadTestData method. |
protected void |
deleteLoadTestData(javax.transaction.UserTransaction transaction,
java.lang.Object[] insertedData,
int iDomainId)
Delete all data inserted for the load tests using the insertLoadTestData method. |
protected abstract void |
deleteParent(java.lang.Object parent,
int iDomainId)
If the insertParent created any parent object then these needs to be deleted to cleanup the database. |
void |
deleteTestData(javax.transaction.UserTransaction transaction,
java.lang.Object[] insertedData)
Delete all test data inserted by insertTestData method. |
int[] |
getAllColumnCodes()
Get codes for all columns that stores data for the tested data object. |
int |
getColumnOneCode()
Get code that represents column storing the first value used to generate the tested data object. |
abstract java.lang.String |
getColumnOneValue(org.opensubsystems.core.data.DataObject data)
Get value of the attribute represented by the first column code specified in the constructor. |
int |
getColumnTwoCode()
Get code that represents column storing the second value used to generate the tested data object. |
abstract java.lang.String |
getColumnTwoValue(org.opensubsystems.core.data.DataObject data)
Get value of the attribute represented by the second column code specified in the constructor. |
org.opensubsystems.patterns.listdata.data.ListOptions |
getDefaultListOptions(java.lang.Object parent)
Ge list options initialized to default values that will be used during list pattern tests. |
java.lang.String[] |
getDefaultResultListColumnTwo()
Get expected results for columns 2 if the list is sorted using this column. |
java.lang.String[] |
getExpectedResultListColumnOne()
Get expected results for columns 1 if the list is sorted using this column. |
org.opensubsystems.patterns.listdata.persist.db.ListDatabaseSchema |
getListDatabaseSchema()
Get instance of ListDatabaseSchema able to retrieve the tested data provide and execute database specific operations. |
java.lang.Class |
getListDatabaseSchemaClass()
Get class that implements ListDatabaseSchema interface. |
org.opensubsystems.patterns.listdata.persist.ListFactory |
getListFactory()
Get instance of ListFactory able to retrieve the tested data object from the database. |
java.lang.Class |
getListFactoryClass()
Get class representing database specific ListFactory interface implementation for the tested data object. |
protected org.opensubsystems.core.data.DataObject |
insertData(java.lang.Object parent,
int iDomainId,
java.lang.String str1,
java.lang.String str2)
Insert to the database record representing tested data object that is generated using the values specified for two columns of the data object. |
java.lang.Object[] |
insertLoadTestData(javax.transaction.UserTransaction transaction,
int iLoadTestListSize)
Insert data records for load tests if they were not inserted yet. |
protected java.lang.Object[] |
insertLoadTestData(javax.transaction.UserTransaction transaction,
int iLoadTestListSize,
int iDomainId,
int iStartNumber,
boolean bAditionalData)
Insert data records for load tests if they were not inserted yet. |
protected java.util.List |
insertMultipleData(java.lang.Object parent,
int iDomainId,
int iCount,
int iStartNumber,
boolean bAditionalData)
Insert efficiently to the database multiple records representing tested data object that are generated using the specified values |
protected abstract java.lang.Object |
insertParent(int iDomainId,
java.lang.String str1,
java.lang.String str2)
If the tested data object requires any kind of "parent" records, it should create them in this method using the two passed string values and return it. |
java.lang.Object[] |
insertTestData(javax.transaction.UserTransaction transaction)
Insert small set of data records to conduct tests with. |
void |
printDebug(java.util.List dataList)
Print debug infor for specified data |
void |
printDebug(org.opensubsystems.patterns.listdata.data.ListOptions options)
Print debug info for ListOptions |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String NO_PARENT
protected java.lang.Class m_clsListFactoryClass
protected java.lang.Class m_clsListDatabaseSchemaClass
protected int[] m_arrAllColumnCodes
protected int m_iColumnOneCode
protected int m_iColumnTwoCode
| Constructor Detail |
|---|
public ListDatabaseTestUtils(java.lang.Class clsListFactoryClass,
java.lang.Class clsListDatabaseSchemaClass,
int[] arrAllColumnCodes,
int iColumnOneCode,
int iColumnTwoCode)
clsListFactoryClass - - class representing database specific
ListFactory interface implementation for the
tested data objectclsListDatabaseSchemaClass - - class representing database specific
ListDatabaseSchema implementation for
the tested data objectarrAllColumnCodes - - array with codes for all columns that stores
data for the tested data objectiColumnOneCode - - Code that represents column storing the first
value used to generate the tested data object. It
is assumed that this code is part of
arrAllColumnCodes.iColumnTwoCode - - Code that represents column storing the second
value used to generate the tested data object. It
is assumed that this code is part of
arrAllColumnCodes.| Method Detail |
|---|
protected abstract java.lang.Object insertParent(int iDomainId,
java.lang.String str1,
java.lang.String str2)
throws java.lang.Exception
iDomainId - - domain id where the the particular data object will
belong to. This is applicable only if data object exist
in domain. Otherwise this can be ignored.str1 - - column one value to create the parent recordsstr2 - - column two value to create the parent records
java.lang.Exception - - an error has occured
protected abstract void deleteParent(java.lang.Object parent,
int iDomainId)
throws java.lang.Exception
parent - - value returned by insertParent method that represents the
parent object that needs to be deletediDomainId - - domain id where the the particular data is supposed to
belong to. This is applicable only if data object exist
in domain. Otherwise this can be ignored.
java.lang.Exception - - an error has occured
protected abstract org.opensubsystems.core.data.DataObject constructData(java.lang.Object parent,
int iDomainId,
java.lang.String str1,
java.lang.String str2)
throws java.lang.Exception
parent - - if this data type supports parents then this provides
parent object created by insertParent method to insert
the new data items into. Otherwise it is null.iDomainId - - domain id where the the particular data object will
belong to. This is applicable only if data object exist
in domain. Otherwise this can be ignored.str1 - - column one value to create the tested data objectstr2 - - column two value to create the tested data object
java.lang.Exception - - an error has occured
protected abstract void deleteData(java.lang.Object parent,
int iDomainId,
java.lang.String strPrefix1,
java.lang.String strPrefix2)
throws java.lang.Exception
parent - - if this data type supports parents then this provides
parent object created by insertParent method to insert
the new data items into. Otherwise it is null.iDomainId - - domain id where the the particular data object belongs
to. This is applicable only if data object exist
in domain. Otherwise this can be ignored.strPrefix1 - - prefix used to construct column one values whe the
tested data objects were created. There is multiple
data objects with this prefix and all of the affected
data objects must be deleted.strPrefix2 - - prefix used to construct column two values whe the
tested data objects were created. There is multiple
data objects with this prefix and all of the affected
data objects must be deleted.
java.lang.Exception - - an error has occuredpublic abstract java.lang.String getColumnOneValue(org.opensubsystems.core.data.DataObject data)
data - - tested data object
public abstract java.lang.String getColumnTwoValue(org.opensubsystems.core.data.DataObject data)
data - - tested data object
public final int[] getAllColumnCodes()
public final int getColumnOneCode()
public final int getColumnTwoCode()
public final java.lang.Class getListFactoryClass()
throws org.opensubsystems.core.error.OSSException
org.opensubsystems.core.error.OSSException - - an error has occured
public final org.opensubsystems.patterns.listdata.persist.ListFactory getListFactory()
throws org.opensubsystems.core.error.OSSException
org.opensubsystems.core.error.OSSException - - an error has occured
public final java.lang.Class getListDatabaseSchemaClass()
throws org.opensubsystems.core.error.OSSException
org.opensubsystems.core.error.OSSException - - an error has occured
public final org.opensubsystems.patterns.listdata.persist.db.ListDatabaseSchema getListDatabaseSchema()
throws org.opensubsystems.core.error.OSSException
org.opensubsystems.core.error.OSSException - - an error has occuredpublic java.lang.String[] getExpectedResultListColumnOne()
public java.lang.String[] getDefaultResultListColumnTwo()
public final java.lang.Object[] insertTestData(javax.transaction.UserTransaction transaction)
throws java.lang.Exception
transaction - - transaction to use to insert data
java.lang.Exception - - an error has occured
public final void deleteTestData(javax.transaction.UserTransaction transaction,
java.lang.Object[] insertedData)
throws java.lang.Exception
transaction - - transaction to use when deleting datainsertedData - - data inserted by the insertTestData method that
needs to be deleted
java.lang.Exception - - an error has occured
public final java.lang.Object[] insertLoadTestData(javax.transaction.UserTransaction transaction,
int iLoadTestListSize)
throws java.lang.Exception
transaction - - transaction to use to insert data or null if no
transaction should be used since the caller will
control the transactioniLoadTestListSize - - number of tested data objects to insert
java.lang.Exception - - an error has occured
public final void deleteLoadTestData(javax.transaction.UserTransaction transaction,
java.lang.Object[] insertedData)
throws java.lang.Exception
transaction - - transactioninsertedData - - data inserted by the insertLoadTestData method that
needs to be deleted
java.lang.Exception - - an error has occured
public final void analyzeDatabase()
throws java.lang.Exception
java.lang.Exception - - an error has occured
public org.opensubsystems.patterns.listdata.data.ListOptions getDefaultListOptions(java.lang.Object parent)
throws org.opensubsystems.core.error.OSSException
parent - - if this class supports parent then the return object is
the parent to which test data were inserted. If it doesn't
support parents, then it is null.
org.opensubsystems.core.error.OSSException - - an error has occuredpublic void printDebug(org.opensubsystems.patterns.listdata.data.ListOptions options)
options - - ListOptions to printpublic void printDebug(java.util.List dataList)
dataList - - List to print
protected org.opensubsystems.core.data.DataObject insertData(java.lang.Object parent,
int iDomainId,
java.lang.String str1,
java.lang.String str2)
throws java.lang.Exception
parent - - if this data type supports parents then this provides
parent object created by insertParent method to insert
the new data items into. Otherwise it is null.iDomainId - - domain id where the the particular data object will
belong to. This is applicabe only if data object exist
in domain. Otherwise this can be infored.str1 - - column one value to create the tested data objectstr2 - - column two value to create the tested data object
java.lang.Exception - - an error has occured
protected java.util.List insertMultipleData(java.lang.Object parent,
int iDomainId,
int iCount,
int iStartNumber,
boolean bAditionalData)
throws java.lang.Exception
parent - - if this data type supports parents then this provides
parent object created by insertParent method to insert
the new data items into. Otherwise it is null.iDomainId - - domain id where the the particular data object will
belong to. This is applicabe only if data object exist
in domain. Otherwise this can be infored.iCount - - number of tested data objects to insertiStartNumber - - starting number for generating unique values for the
columnsbAditionalData - - flag if there will be added additional data for
particular data object
java.lang.Exception - - an error has occured
protected final java.lang.Object[] insertLoadTestData(javax.transaction.UserTransaction transaction,
int iLoadTestListSize,
int iDomainId,
int iStartNumber,
boolean bAditionalData)
throws java.lang.Exception
transaction - - transaction to use to insert data or null if no
transaction should be used since the caller will
control the transactioniLoadTestListSize - - number of tested data objects to insertiDomainId - - if of domain where to insert the extra dataiStartNumber - - starting number for generating unique values for the
columnsbAditionalData - - flag if there will be added additional data for
particular data object
java.lang.Exception - - an error has occured
protected final void deleteLoadTestData(javax.transaction.UserTransaction transaction,
java.lang.Object[] insertedData,
int iDomainId)
throws java.lang.Exception
transaction - - transaction to use to delete data or null if no
transaction should be used since the caller will
control the transactioninsertedData - - data inserted by the insertLoadTestData method that
needs to be deletediDomainId - - domain id where to delete the inserted data
java.lang.Exception - - an error has occured
protected org.opensubsystems.core.data.DataObject createDataObject(org.opensubsystems.core.data.DataObject data)
throws org.opensubsystems.core.error.OSSException
data - - data object that will be created
org.opensubsystems.core.error.OSSException - - exception occured during create
protected void deleteDataObject(org.opensubsystems.core.data.DataObject data,
int iDomainId)
throws org.opensubsystems.core.error.OSSException
data - - data object that will be deletediDomainId - - this is the domain id in which we expect the data object
to exist (if the data object contains domain id, it
should be the same as the one we specify as an argument)
org.opensubsystems.core.error.OSSException - - an error has occured
protected void createDataObjects(java.util.List lstDataObjects)
throws org.opensubsystems.core.error.OSSException
lstDataObjects - - list of data object that will be created
org.opensubsystems.core.error.OSSException - - exception occured during create
protected void deleteDataObjects(java.util.List lstDataObjects,
int iDomainId)
throws org.opensubsystems.core.error.OSSException
lstDataObjects - - list of data object that will be deletediDomainId - - if of domain where we expect all the specified data
objects to exist (in case they exist in the domain)
org.opensubsystems.core.error.OSSException - - an error has occured
protected void deleteData(java.lang.Object parent,
int iDomainId,
java.lang.String strPrefix1,
java.lang.String strPrefix2,
java.lang.String strDeleteByListTestPrefixesQuery,
boolean bSubstitueValues)
throws java.lang.Exception
parent - - if this data type supports parents then this provides
parent object created by insertParent method to insert
the new data items into. Otherwise it is null.iDomainId - - domain id where the the particular data object belongs
to. This is applicable only if data object exist
in domain. Otherwise this can be ignored.strPrefix1 - - prefix used to construct column one values whe the
tested data objects were created. There is multiple
data objects with this prefix and all of the affected
data objects must be deleted.strPrefix2 - - prefix used to construct column two values whe the
tested data objects were created. There is multiple
data objects with this prefix and all of the affected
data objects must be deleted.strDeleteByListTestPrefixesQuery - - query that deletes all the data
using the specified prefixes
in specified domain (if the
tested data object exists in
domain). If bSubstitueValues is
true then the query need to take
prefix 1 as first argument,
prefix 2 as second argument
and optional domain id as the
last argumentbSubstitueValues - - if true then the prefix 1, 2 and domain id will
be substitued to the passed in query when a
prepared statement is created otherwise if it is
false then assumption is that the query doesn't
contain any variables that needs substitution.
java.lang.Exception - - an error has occured
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||