Package org.dbunit.ant
Class DbUnitTask
java.lang.Object
org.apache.tools.ant.ProjectComponent
org.apache.tools.ant.Task
org.dbunit.ant.DbUnitTask
- All Implemented Interfaces:
Cloneable
public class DbUnitTask
extends org.apache.tools.ant.Task
DbUnitTask is the task definition for an Ant
interface to DbUnit. DbUnit is a JUnit extension
which sets your database to a known state before executing your
tasks.- Since:
- Jun 10, 2002
- Version:
- $Revision$
- Author:
- Timothy Ruppert, Ben Cox
- See Also:
-
Field Summary
Fields inherited from class org.apache.tools.ant.Task
target, taskName, taskType, wrapperFields inherited from class org.apache.tools.ant.ProjectComponent
description, location, project -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCompare(Compare compare) Adds a Compare to the steps List.voidaddDbConfig(DbConfig dbConfig) Sets the genericDatabaseConfigconfiguration child element.voidAdds an Export to the steps List.voidaddOperation(Operation operation) Adds an Operation.org.apache.tools.ant.types.PathCreate the classpath for loading the driver.protected IDatabaseConnectionLoads the JDBC driver and opens the configured database connection.protected IDatabaseConnectioncreateDatabaseConnection(Connection jdbcConnection, String dbSchema) Creates the dbunit connection using the two given arguments.voidexecute()Load the step and then execute it.Returns the size of batch inserts.Returns the genericDatabaseConfigconfiguration child element.Returns the JDBC fetch size used for result sets.getSteps()Gets the Steps.voidsetBatchSize(String batchSize) sets the size of batch inserts.voidsetClasspath(org.apache.tools.ant.types.Path classpath) Set the classpath for loading the driver.voidsetClasspathRef(org.apache.tools.ant.types.Reference r) Set the classpath for loading the driver using the classpath reference.voidsetDatatypeFactory(String datatypeFactory) Sets the fully qualified class name of theIDataTypeFactoryto use.voidsetDatatypeWarning(Boolean datatypeWarning) Sets the flag for logging a warning on unsupported data types.voidSet the JDBC driver to be used.voidsetEscapePattern(String escapePattern) Sets the pattern used to escape table and column names.voidsetFetchSize(String fetchSize) Sets the JDBC fetch size used for result sets.voidsetPassword(String password) Set the password for the DB connection.voidSet the schema for the DB connection.voidsetSkipOracleRecycleBinTables(Boolean skipOracleRecycleBinTables) Sets the flag for skipping Oracle recycle bin tables.voidsetSupportBatchStatement(Boolean supportBatchStatement) Set the flag for supporting batch statements.voidSet the DB connection url.voidsetUseQualifiedTableNames(Boolean useQualifiedTableNames) Set the flag for using the qualified table names.voidSet the user name for the DB connection.Methods inherited from class org.apache.tools.ant.Task
bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskTypeMethods inherited from class org.apache.tools.ant.ProjectComponent
clone, getDescription, getLocation, getProject, setDescription, setLocation, setProject
-
Constructor Details
-
DbUnitTask
public DbUnitTask()
-
-
Method Details
-
setDriver
Set the JDBC driver to be used.- Parameters:
driver- the fully qualified class name of the JDBC driver.
-
setUrl
Set the DB connection url.- Parameters:
url- the JDBC connection URL.
-
setUserid
Set the user name for the DB connection.- Parameters:
userId- the database user name.
-
setPassword
Set the password for the DB connection.- Parameters:
password- the database password.
-
setSchema
Set the schema for the DB connection.- Parameters:
schema- the database schema.
-
setUseQualifiedTableNames
Set the flag for using the qualified table names.- Parameters:
useQualifiedTableNames-trueto use qualified table names.
-
setSupportBatchStatement
Set the flag for supporting batch statements. NOTE: This property cannot be used to force the usage of batch statement if your database does not support it.- Parameters:
supportBatchStatement-trueto use batch statements.
-
setDatatypeWarning
Sets the flag for logging a warning on unsupported data types.- Parameters:
datatypeWarning-trueto log a warning on unsupported data types.
-
setDatatypeFactory
Sets the fully qualified class name of theIDataTypeFactoryto use.- Parameters:
datatypeFactory- the fully qualified class name of theIDataTypeFactoryto use.
-
setEscapePattern
Sets the pattern used to escape table and column names.- Parameters:
escapePattern- the pattern used to escape table and column names.
-
getDbConfig
Returns the genericDatabaseConfigconfiguration child element.- Returns:
- the generic
DatabaseConfigconfiguration child element.
-
addDbConfig
Sets the genericDatabaseConfigconfiguration child element.- Parameters:
dbConfig- the genericDatabaseConfigconfiguration child element.
-
setClasspath
public void setClasspath(org.apache.tools.ant.types.Path classpath) Set the classpath for loading the driver.- Parameters:
classpath- the classpath for loading the driver.
-
createClasspath
public org.apache.tools.ant.types.Path createClasspath()Create the classpath for loading the driver.- Returns:
- the classpath for loading the driver.
-
setClasspathRef
public void setClasspathRef(org.apache.tools.ant.types.Reference r) Set the classpath for loading the driver using the classpath reference.- Parameters:
r- the reference to the classpath for loading the driver.
-
getSteps
Gets the Steps.- Returns:
- the steps to execute.
-
addOperation
Adds an Operation.- Parameters:
operation- the operation step to add.
-
addCompare
Adds a Compare to the steps List.- Parameters:
compare- the compare step to add.
-
addExport
Adds an Export to the steps List.- Parameters:
export- the export step to add.
-
getBatchSize
Returns the size of batch inserts.- Returns:
- the size of batch inserts.
-
setBatchSize
sets the size of batch inserts.- Parameters:
batchSize- the size of batch inserts.
-
getFetchSize
Returns the JDBC fetch size used for result sets.- Returns:
- the JDBC fetch size used for result sets.
-
setFetchSize
Sets the JDBC fetch size used for result sets.- Parameters:
fetchSize- the JDBC fetch size used for result sets.
-
setSkipOracleRecycleBinTables
Sets the flag for skipping Oracle recycle bin tables.- Parameters:
skipOracleRecycleBinTables-trueto skip Oracle recycle bin tables.
-
execute
public void execute() throws org.apache.tools.ant.BuildExceptionLoad the step and then execute it.- Overrides:
executein classorg.apache.tools.ant.Task- Throws:
org.apache.tools.ant.BuildException
-
createConnection
Loads the JDBC driver and opens the configured database connection.- Returns:
- the opened database connection.
- Throws:
SQLException- if the connection cannot be opened.
-
createDatabaseConnection
Creates the dbunit connection using the two given arguments. The configuration properties of the dbunit connection are initialized using the fields of this class.- Parameters:
jdbcConnection- the JDBC connection to adapt.dbSchema- the database schema.- Returns:
- The dbunit connection
-