|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.unitils.database.DataSourceWrapper
public class DataSourceWrapper
DataSourceWrapper.
| Field Summary | |
|---|---|
protected DatabaseConfiguration |
databaseConfiguration
|
| Constructor Summary | |
|---|---|
DataSourceWrapper(DatabaseConfiguration databaseConfiguration,
Properties unitilsConfig,
UnitilsTransactionManager transactionmanager)
|
|
DataSourceWrapper(DatabaseConfiguration databaseConfiguration,
UnitilsTransactionManager transactionManager)
|
|
| Method Summary | ||
|---|---|---|
void |
activateTransactionIfNeeded()
|
|
void |
cleanSchemas()
Cleans all configured schema's. |
|
void |
clearSchemas()
Clears all configured schema's. |
|
DataSource |
createDataSource()
Creates a datasource by using the factory that is defined by the dataSourceFactory.className property |
|
void |
disableConstraints()
Disables all foreigh key and not-null constraints on the configured schema's. |
|
void |
generateDatasetDefinition()
Generates a definition file that defines the structure of dataset's, i.e. a XSD of DTD that describes the structure of the database. |
|
protected
|
getConfiguredDatabaseTaskInstance(Class<T> databaseTaskType)
|
|
Connection |
getConnection()
|
|
DatabaseConfiguration |
getDatabaseConfiguration()
|
|
String |
getDatabaseName()
|
|
DataSource |
getDataSource()
|
|
DataSource |
getDataSourceAndActivateTransactionIfNeeded()
Returns the DataSource that provides connection to the unit test database. |
|
protected SQLHandler |
getDefaultSqlHandler()
|
|
protected Object |
getTestObject()
|
|
DataSource |
getTransactionalDataSourceAndActivateTransactionIfNeeded(Object testObject)
Returns the DataSource that provides connection to the unit test database. |
|
boolean |
isDataSourceLoaded()
|
|
void |
setTransactionManager(UnitilsTransactionManager transactionManager)
|
|
void |
updateDatabase()
Determines whether the test database is outdated and, if this is the case, updates the database with the latest changes. |
|
void |
updateDatabase(SQLHandler sqlHandler)
Determines whether the test database is outdated and, if that is the case, updates the database with the latest changes. |
|
void |
updateSequences()
Updates all sequences that have a value below a certain configurable treshold to become equal to this treshold |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected DatabaseConfiguration databaseConfiguration
| Constructor Detail |
|---|
public DataSourceWrapper(DatabaseConfiguration databaseConfiguration,
UnitilsTransactionManager transactionManager)
public DataSourceWrapper(DatabaseConfiguration databaseConfiguration,
Properties unitilsConfig,
UnitilsTransactionManager transactionmanager)
| Method Detail |
|---|
public Connection getConnection()
public DataSource getTransactionalDataSourceAndActivateTransactionIfNeeded(Object testObject)
DataSource that provides connection to the unit test database. When invoked the first
time, the DBMaintainer is invoked to make sure the test database is up-to-date (if database updating is enabled)
If the property #PROPERTY_WRAP_DATASOURCE_IN_TRANSACTIONAL_PROXY has been set to true, the DataSource
returned will make sure that, for the duration of a transaction, the same java.sql.Connection is returned,
and that invocations of the close() method of these connections are suppressed.
testObject - The test instance, not nullwrapDataSourceInTransactionalProxy -
DataSource (default database).public DataSource createDataSource()
public void updateDatabase()
DBMaintainer for more information.
public void updateDatabase(SQLHandler sqlHandler)
sqlHandler - SQLHandler that needs to be used for the database updatesDBMaintainer}protected SQLHandler getDefaultSqlHandler()
public DataSource getDataSourceAndActivateTransactionIfNeeded()
DataSource that provides connection to the unit test database. When invoked the first
time, the DBMaintainer is invoked to make sure the test database is up-to-date (if database updating is enabled)
DataSourcepublic void activateTransactionIfNeeded()
protected Object getTestObject()
public DataSource getDataSource()
public void clearSchemas()
public void cleanSchemas()
public void disableConstraints()
public void updateSequences()
protected <T extends DatabaseAccessing> T getConfiguredDatabaseTaskInstance(Class<T> databaseTaskType)
databaseTaskType - The type of database task, not null
DatabaseAccessing of the given typepublic void generateDatasetDefinition()
public boolean isDataSourceLoaded()
public DatabaseConfiguration getDatabaseConfiguration()
public String getDatabaseName()
public void setTransactionManager(UnitilsTransactionManager transactionManager)
transactionManager - the transactionManager to set
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||