Package org.dbunit.assertion
Class DbUnitAssert
java.lang.Object
org.dbunit.assertion.DbUnitAssertBase
org.dbunit.assertion.DbUnitAssert
Default implementation of DbUnit assertions, based on the original methods
present at
Assertion.
All are equality comparisons.- Since:
- 2.4.0
- Version:
- $Revision$ $Date$
- Author:
- Felipe Leme (dbunit@felipeal.net), gommma (gommma AT users.sourceforge.net)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classRepresents a single column to be used for the comparison of table data. -
Field Summary
Fields inherited from class org.dbunit.assertion.DbUnitAssertBase
valueComparerDefaults -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidassertEquals(IDataSet expectedDataSet, IDataSet actualDataSet) Asserts that the two specified dataset are equals.voidassertEquals(IDataSet expectedDataSet, IDataSet actualDataSet, FailureHandler failureHandler) Asserts that the two specified dataset are equals.voidassertEquals(ITable expectedTable, ITable actualTable) Asserts that the two specified tables are equals.voidassertEquals(ITable expectedTable, ITable actualTable, FailureHandler failureHandler) Asserts that the two specified tables are equals.voidassertEquals(ITable expectedTable, ITable actualTable, Column[] additionalColumnInfo) Asserts that the two specified tables are equals.voidassertEqualsByQuery(IDataSet expectedDataset, IDatabaseConnection connection, String sqlQuery, String tableName, String[] ignoreCols) Compare a table from a dataset with a table generated from an sql query.voidassertEqualsByQuery(ITable expectedTable, IDatabaseConnection connection, String tableName, String sqlQuery, String[] ignoreCols) Compare a table with a table generated from an sql query.voidassertEqualsIgnoreCols(IDataSet expectedDataset, IDataSet actualDataset, String tableName, String[] ignoreCols) Compare one table present in two datasets ignoring specified columns.voidassertEqualsIgnoreCols(ITable expectedTable, ITable actualTable, String[] ignoreCols) Compare the given tables ignoring specified columns.protected voidcompareTables(IDataSet expectedDataSet, IDataSet actualDataSet, String[] expectedNames, FailureHandler failureHandler) Methods inherited from class org.dbunit.assertion.DbUnitAssertBase
assertWithValueComparer, assertWithValueComparer, compareColumns, compareData, compareData, compareData, compareRowCounts, compareTableCounts, compareTableNames, compareTables, determineFailureHandler, determineValidColumnValueComparers, determineValidDefaultValueComparer, determineValidTableColumnValueComparers, determineValueComparer, failIfNecessary, getComparisonColumns, getDefaultFailureHandler, getDefaultFailureHandler, getSortedTableNames, setValueComparerDefaults, skipCompare
-
Constructor Details
-
DbUnitAssert
public DbUnitAssert()
-
-
Method Details
-
assertEqualsIgnoreCols
public void assertEqualsIgnoreCols(IDataSet expectedDataset, IDataSet actualDataset, String tableName, String[] ignoreCols) throws DatabaseUnitException Compare one table present in two datasets ignoring specified columns.- Parameters:
expectedDataset- First dataset.actualDataset- Second dataset.tableName- Table name of the table to be compared.ignoreCols- Columns to be ignored in comparison.- Throws:
DatabaseUnitException- If an error occurs.
-
assertEqualsIgnoreCols
public void assertEqualsIgnoreCols(ITable expectedTable, ITable actualTable, String[] ignoreCols) throws DatabaseUnitException Compare the given tables ignoring specified columns.- Parameters:
expectedTable- First table.actualTable- Second table.ignoreCols- Columns to be ignored in comparison.- Throws:
DatabaseUnitException- If an error occurs.
-
assertEqualsByQuery
public void assertEqualsByQuery(IDataSet expectedDataset, IDatabaseConnection connection, String sqlQuery, String tableName, String[] ignoreCols) throws DatabaseUnitException, SQLException Compare a table from a dataset with a table generated from an sql query.- Parameters:
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 compare.ignoreCols- Columns to be ignored in comparison.- Throws:
DatabaseUnitException- If an error occurs while performing the comparison.SQLException- If an SQL error occurs.
-
assertEqualsByQuery
public void assertEqualsByQuery(ITable expectedTable, IDatabaseConnection connection, String tableName, String sqlQuery, String[] ignoreCols) throws DatabaseUnitException, SQLException Compare a table with a table generated from an sql query.- Parameters:
expectedTable- Table containing all expected results.connection- Connection to use for the SQL statement.tableName- The name of the table to query from the database.sqlQuery- SQL query that will build the data in returned second table rows.ignoreCols- Columns to be ignored in comparison.- Throws:
DatabaseUnitException- If an error occurs while performing the comparison.SQLException- If an SQL error occurs.
-
assertEquals
public void assertEquals(IDataSet expectedDataSet, IDataSet actualDataSet) throws DatabaseUnitException Asserts that the two specified dataset are equals. This method ignore the tables order.- Throws:
DatabaseUnitException
-
assertEquals
public void assertEquals(IDataSet expectedDataSet, IDataSet actualDataSet, FailureHandler failureHandler) throws DatabaseUnitException Asserts that the two specified dataset are equals. This method ignore the tables order.- Throws:
DatabaseUnitException- Since:
- 2.4
-
compareTables
protected void compareTables(IDataSet expectedDataSet, IDataSet actualDataSet, String[] expectedNames, FailureHandler failureHandler) throws DatabaseUnitException - Throws:
DatabaseUnitException
-
assertEquals
Asserts that the two specified tables are equals. This method ignores the table names, the columns order, the columns data type and which columns are composing the primary keys.- Parameters:
expectedTable- Table containing all expected results.actualTable- Table containing all actual results.- Throws:
DatabaseUnitException
-
assertEquals
public void assertEquals(ITable expectedTable, ITable actualTable, Column[] additionalColumnInfo) throws DatabaseUnitException Asserts that the two specified tables are equals. This method ignores the table names, the columns order, the columns data type and which columns are composing the primary keys.
Example:ITable actualTable = ...; ITable expectedTable = ...; ITableMetaData metaData = actualTable.getTableMetaData(); Column[] additionalInfoCols = Columns.getColumns(new String[] {"MY_PK_COLUMN"}, metaData.getColumns()); assertEquals(expectedTable, actualTable, additionalInfoCols);- Parameters:
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 benull.- Throws:
DatabaseUnitException
-
assertEquals
public void assertEquals(ITable expectedTable, ITable actualTable, FailureHandler failureHandler) throws DatabaseUnitException Asserts that the two specified tables are equals. This method ignores the table names, the columns order, the columns data type and which columns are composing the primary keys.
Example:ITable actualTable = ...; ITable expectedTable = ...; ITableMetaData metaData = actualTable.getTableMetaData(); FailureHandler failureHandler = new DefaultFailureHandler(); assertEquals(expectedTable, actualTable, failureHandler);
- Parameters:
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 benull.- Throws:
DatabaseUnitException- Since:
- 2.4
-