Package org.dbunit.ant
Class AbstractStep
java.lang.Object
org.apache.tools.ant.ProjectComponent
org.dbunit.ant.AbstractStep
- All Implemented Interfaces:
Cloneable,DbUnitTaskStep
public abstract class AbstractStep
extends org.apache.tools.ant.ProjectComponent
implements DbUnitTaskStep
Abstract base implementation of a
DbUnitTaskStep executed by the DbUnit Ant task.- Since:
- 2.1 (Apr 3, 2004)
- Version:
- $Revision$ $Date$
- Author:
- Manuel Laflamme, Last changed by: $Author$
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringCSV data format identifier.static final StringDTD (metadata-only) format identifier.static final StringFlat XML data format identifier.static final StringJSON data format identifier.static final StringExcel data format identifier.static final StringXML data format identifier.static final StringYAML data format identifier.Fields inherited from class org.apache.tools.ant.ProjectComponent
description, location, project -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcheckDataFormat(String format) Checks if the given data format is a valid one according to the methodisDataFormat(String).protected IDataSetgetDatabaseDataSet(IDatabaseConnection connection, List tables) Builds a dataset from the given connection, restricted to the given tables and queries.static InputSourcegetInputSource(File file) Creates and returns anInputSourceprotected IDataSetgetSrcDataSet(File src, String format, boolean forwardonly) Loads a dataset from the given source file in the given format.booleanisDataFormat(String format) Checks if the given format is a format which contains tabular data.booleanReturns whether the resulting dataset's tables must be ordered.voidsetOrdered(boolean ordered) Sets whether the resulting dataset's tables must be ordered.toString()Methods inherited from class org.apache.tools.ant.ProjectComponent
clone, getDescription, getLocation, getProject, log, log, setDescription, setLocation, setProjectMethods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.dbunit.ant.DbUnitTaskStep
execute, getLogMessage
-
Field Details
-
FORMAT_FLAT
Flat XML data format identifier.- See Also:
-
FORMAT_XML
XML data format identifier.- See Also:
-
FORMAT_DTD
DTD (metadata-only) format identifier.- See Also:
-
FORMAT_CSV
CSV data format identifier.- See Also:
-
FORMAT_XLS
Excel data format identifier.- See Also:
-
FORMAT_YML
YAML data format identifier.- See Also:
-
FORMAT_JSON
JSON data format identifier.- See Also:
-
-
Constructor Details
-
AbstractStep
public AbstractStep()
-
-
Method Details
-
getDatabaseDataSet
protected IDataSet getDatabaseDataSet(IDatabaseConnection connection, List tables) throws DatabaseUnitException Builds a dataset from the given connection, restricted to the given tables and queries.- Parameters:
connection- the database connection.tables- the list ofTable,Query, andQuerySetelements configuring which tables/queries to include; the whole database is used if empty.- Returns:
- the assembled dataset.
- Throws:
DatabaseUnitException- if building the dataset fails.
-
getSrcDataSet
protected IDataSet getSrcDataSet(File src, String format, boolean forwardonly) throws DatabaseUnitException Loads a dataset from the given source file in the given format.- Parameters:
src- the source file.format- the data format, one of theFORMAT_*constants.forwardonly-trueto stream the dataset forward-only instead of caching it.- Returns:
- the loaded dataset.
- Throws:
DatabaseUnitException- if loading the dataset fails.
-
isDataFormat
Checks if the given format is a format which contains tabular data.- Parameters:
format- The format to check- Returns:
trueif the given format is a data format. A data format is a format which holds tabular data that can be loaded via dbunit. An example for a data format is "xml" or "flat". A non-data format is "dtd" which holds only metadata information.- Since:
- 2.4
-
checkDataFormat
Checks if the given data format is a valid one according to the methodisDataFormat(String). If it is not anIllegalArgumentExceptionis thrown.- Parameters:
format- The format to check- Throws:
IllegalArgumentException- If the given format is not a valid data format- Since:
- 2.4
-
getInputSource
Creates and returns anInputSource- Parameters:
file- The file for which anInputSourceshould be created- Returns:
- The input source for the given file
- Throws:
MalformedURLException- if the file's path cannot be converted to a URL.
-
isOrdered
public boolean isOrdered()Returns whether the resulting dataset's tables must be ordered.- Returns:
trueif the resulting dataset's tables must be ordered.
-
setOrdered
public void setOrdered(boolean ordered) Sets whether the resulting dataset's tables must be ordered.- Parameters:
ordered-trueif the resulting dataset's tables must be ordered.
-
toString
-