Modifier and Type | Class and Description |
---|---|
static class |
DbUnitAssert.ComparisonColumn
Represents a single column to be used for the comparison of table data.
|
Constructor and Description |
---|
DbUnitAssert()
Default constructor
|
Modifier and Type | Method and Description |
---|---|
void |
assertEquals(IDataSet expectedDataSet,
IDataSet actualDataSet)
Asserts that the two specified dataset are equals.
|
void |
assertEquals(IDataSet expectedDataSet,
IDataSet actualDataSet,
FailureHandler failureHandler)
Asserts that the two specified dataset are equals.
|
void |
assertEquals(ITable expectedTable,
ITable actualTable)
Asserts that the two specified tables are equals.
|
void |
assertEquals(ITable expectedTable,
ITable actualTable,
Column[] additionalColumnInfo)
Asserts that the two specified tables are equals.
|
void |
assertEquals(ITable expectedTable,
ITable actualTable,
FailureHandler failureHandler)
Asserts that the two specified tables are equals.
|
void |
assertEqualsByQuery(IDataSet expectedDataset,
IDatabaseConnection connection,
String sqlQuery,
String tableName,
String[] ignoreCols)
Compare a table from a dataset with a table generated from an sql query.
|
void |
assertEqualsByQuery(ITable expectedTable,
IDatabaseConnection connection,
String tableName,
String sqlQuery,
String[] ignoreCols)
Compare a table with a table generated from an sql query.
|
void |
assertEqualsIgnoreCols(IDataSet expectedDataset,
IDataSet actualDataset,
String tableName,
String[] ignoreCols)
Compare one table present in two datasets ignoring specified columns.
|
void |
assertEqualsIgnoreCols(ITable expectedTable,
ITable actualTable,
String[] ignoreCols)
Compare the given tables ignoring specified columns.
|
protected void |
compareData(ITable expectedTable,
ITable actualTable,
DbUnitAssert.ComparisonColumn[] comparisonCols,
FailureHandler failureHandler) |
protected DbUnitAssert.ComparisonColumn[] |
getComparisonColumns(String expectedTableName,
Column[] expectedColumns,
Column[] actualColumns,
FailureHandler failureHandler) |
protected FailureHandler |
getDefaultFailureHandler() |
protected FailureHandler |
getDefaultFailureHandler(Column[] additionalColumnInfo) |
protected String[] |
getSortedUpperTableNames(IDataSet dataSet) |
protected boolean |
skipCompare(String columnName,
Object expectedValue,
Object actualValue)
Method to last-minute intercept the comparison of a single
expected and actual value.
|
public void assertEqualsIgnoreCols(IDataSet expectedDataset, IDataSet actualDataset, String tableName, String[] ignoreCols) throws DatabaseUnitException
expectedDataset
- First dataset.actualDataset
- Second dataset.tableName
- Table name of the table to be compared.ignoreCols
- Columns to be ignored in comparison.DatabaseUnitException
- If an error occurs.public void assertEqualsIgnoreCols(ITable expectedTable, ITable actualTable, String[] ignoreCols) throws DatabaseUnitException
expectedTable
- First table.actualTable
- Second table.ignoreCols
- Columns to be ignored in comparison.DatabaseUnitException
- If an error occurs.public void assertEqualsByQuery(IDataSet expectedDataset, IDatabaseConnection connection, String sqlQuery, String tableName, String[] ignoreCols) throws DatabaseUnitException, SQLException
expectedDataset
- Dataset to retrieve the first table from.connection
- Connection to use for the SQL statement.sqlQuery
- SQL query that will build the data in returned second table rows.tableName
- Table name of the table to compareignoreCols
- Columns to be ignored in comparison.DatabaseUnitException
- If an error occurs while performing the comparison.SQLException
- If an SQL error occurs.public void assertEqualsByQuery(ITable expectedTable, IDatabaseConnection connection, String tableName, String sqlQuery, String[] ignoreCols) throws DatabaseUnitException, SQLException
expectedTable
- Table containing all expected results.connection
- Connection to use for the SQL statement.tableName
- The name of the table to query from the databasesqlQuery
- SQL query that will build the data in returned second table rows.ignoreCols
- Columns to be ignored in comparison.DatabaseUnitException
- If an error occurs while performing the comparison.SQLException
- If an SQL error occurs.public void assertEquals(IDataSet expectedDataSet, IDataSet actualDataSet) throws DatabaseUnitException
DatabaseUnitException
public void assertEquals(IDataSet expectedDataSet, IDataSet actualDataSet, FailureHandler failureHandler) throws DatabaseUnitException
DatabaseUnitException
public void assertEquals(ITable expectedTable, ITable actualTable) throws DatabaseUnitException
expectedTable
- Table containing all expected results.actualTable
- Table containing all actual results.DatabaseUnitException
public void assertEquals(ITable expectedTable, ITable actualTable, Column[] additionalColumnInfo) throws DatabaseUnitException
ITable actualTable = ...;
ITable expectedTable = ...;
ITableMetaData metaData = actualTable.getTableMetaData();
Column[] additionalInfoCols = Columns.getColumns(new String[] {"MY_PK_COLUMN"}, metaData.getColumns());
assertEquals(expectedTable, actualTable, additionalInfoCols);
expectedTable
- Table containing all expected results.actualTable
- Table containing all actual results.additionalColumnInfo
- The columns to be printed out if the assert fails because of a
data mismatch. Provides some additional column values that may be
useful to quickly identify the columns for which the mismatch
occurred (for example a primary key column). Can be
null
DatabaseUnitException
public void assertEquals(ITable expectedTable, ITable actualTable, FailureHandler failureHandler) throws DatabaseUnitException
ITable actualTable = ...;
ITable expectedTable = ...;
ITableMetaData metaData = actualTable.getTableMetaData();
FailureHandler failureHandler = new DefaultFailureHandler();
assertEquals(expectedTable, actualTable, failureHandler);
expectedTable
- Table containing all expected results.actualTable
- Table containing all actual results.failureHandler
- The failure handler used if the assert fails because of a data
mismatch. Provides some additional information that may be useful
to quickly identify the rows for which the mismatch occurred (for
example by printing an additional primary key column). Can be
null
DatabaseUnitException
protected FailureHandler getDefaultFailureHandler()
protected FailureHandler getDefaultFailureHandler(Column[] additionalColumnInfo)
protected void compareData(ITable expectedTable, ITable actualTable, DbUnitAssert.ComparisonColumn[] comparisonCols, FailureHandler failureHandler) throws DataSetException
expectedTable
- Table containing all expected results.actualTable
- Table containing all actual results.comparisonCols
- The columns to be compared, also including the correct
DataType
s for comparisonfailureHandler
- The failure handler used if the assert fails because of a data
mismatch. Provides some additional information that may be useful
to quickly identify the rows for which the mismatch occurred (for
example by printing an additional primary key column). Must not be
null
at this stageDataSetException
protected boolean skipCompare(String columnName, Object expectedValue, Object actualValue)
columnName
- The column being comparedexpectedValue
- The expected value to be comparedactualValue
- The actual value to be comparedfalse
always so that the comparison is never skippedprotected DbUnitAssert.ComparisonColumn[] getComparisonColumns(String expectedTableName, Column[] expectedColumns, Column[] actualColumns, FailureHandler failureHandler)
expectedTableName
- expectedColumns
- actualColumns
- failureHandler
- The FailureHandler
to be used when no datatype can be
determinedprotected String[] getSortedUpperTableNames(IDataSet dataSet) throws DataSetException
DataSetException
Copyright © 2002–2019. All rights reserved.