public class DataSourceWrapper extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
protected Connection |
connection |
protected DatabaseConfiguration |
databaseConfiguration |
| 构造器和说明 |
|---|
DataSourceWrapper(DatabaseConfiguration databaseConfiguration,
Properties unitilsConfig,
UnitilsTransactionManager transactionmanager) |
DataSourceWrapper(DatabaseConfiguration databaseConfiguration,
UnitilsTransactionManager transactionManager) |
| 限定符和类型 | 方法和说明 |
|---|---|
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 <T extends DatabaseAccessing> |
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 |
restartSequences()
Sets all the sequences to the lowest acceptable value.
|
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
|
protected DatabaseConfiguration databaseConfiguration
protected Connection connection
public DataSourceWrapper(DatabaseConfiguration databaseConfiguration, UnitilsTransactionManager transactionManager)
public DataSourceWrapper(DatabaseConfiguration databaseConfiguration, Properties unitilsConfig, UnitilsTransactionManager transactionmanager)
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 DatabaseModule.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 nullDataSource (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 updatesDBMaintainerprotected 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()
public void restartSequences()
protected <T extends DatabaseAccessing> T getConfiguredDatabaseTaskInstance(Class<T> databaseTaskType)
databaseTaskType - The type of database task, not nullDatabaseAccessing of the given typepublic void generateDatasetDefinition()
public boolean isDataSourceLoaded()
public DatabaseConfiguration getDatabaseConfiguration()
public String getDatabaseName()
public void setTransactionManager(UnitilsTransactionManager transactionManager)
transactionManager - the transactionManager to setCopyright © 2008–2020 Matrix. All rights reserved.