Package org.dbunit
Class Assertion
java.lang.Object
org.dbunit.Assertion
Provides static methods for the most common DbUnit assertion needs.
Although the methods are static, they rely on a
DbUnitAssert instance
to do the work. So, if you need to customize this class behavior, you can
create your own DbUnitAssert extension.- Since:
- 1.3 (Mar 22, 2002)
- Version:
- $Revision$ $Date$
- Author:
- Manuel Laflamme, Felipe Leme (dbunit@felipeal.net), Last changed by: $Author$
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidassertEquals(IDataSet expectedDataSet, IDataSet actualDataSet) Asserts that the two specified datasets are equal.static voidassertEquals(IDataSet expectedDataSet, IDataSet actualDataSet, FailureHandler failureHandler) Asserts that the two specified datasets are equal.static voidassertEquals(ITable expectedTable, ITable actualTable) Asserts that the two specified tables are equal.static voidassertEquals(ITable expectedTable, ITable actualTable, FailureHandler failureHandler) Asserts that the two specified tables are equal.static voidassertEquals(ITable expectedTable, ITable actualTable, Column[] additionalColumnInfo) Asserts that the two specified tables are equal.static voidassertEqualsByQuery(IDataSet expectedDataset, IDatabaseConnection connection, String sqlQuery, String tableName, String[] ignoreCols) Asserts that the specified dataset table matches the given query's result, ignoring the given columns.static voidassertEqualsByQuery(ITable expectedTable, IDatabaseConnection connection, String tableName, String sqlQuery, String[] ignoreCols) Asserts that the specified table matches the given query's result, ignoring the given columns.static voidassertEqualsIgnoreCols(IDataSet expectedDataset, IDataSet actualDataset, String tableName, String[] ignoreCols) Asserts that the two specified datasets' tables are equal, ignoring the given columns.static voidassertEqualsIgnoreCols(ITable expectedTable, ITable actualTable, String[] ignoreCols) Asserts that the two specified tables are equal, ignoring the given columns.static voidassertWithValueComparer(IDataSet expectedDataSet, IDataSet actualDataSet, ValueComparer defaultValueComparer, Map<String, Map<String, ValueComparer>> tableColumnValueComparers) Asserts that the two specified datasets are equal, using the given value comparers.static voidassertWithValueComparer(IDataSet expectedDataSet, IDataSet actualDataSet, FailureHandler failureHandler, ValueComparer defaultValueComparer, Map<String, Map<String, ValueComparer>> tableColumnValueComparers) Asserts that the two specified datasets are equal, using the given value comparers.static voidassertWithValueComparer(ITable expectedTable, ITable actualTable, ValueComparer defaultValueComparer, Map<String, ValueComparer> columnValueComparers) Asserts that the two specified tables are equal, using the given value comparers.static voidassertWithValueComparer(ITable expectedTable, ITable actualTable, FailureHandler failureHandler, ValueComparer defaultValueComparer, Map<String, ValueComparer> columnValueComparers) Asserts that the two specified tables are equal, using the given value comparers.static voidassertWithValueComparer(ITable expectedTable, ITable actualTable, Column[] additionalColumnInfo, ValueComparer defaultValueComparer, Map<String, ValueComparer> columnValueComparers) Asserts that the two specified tables are equal, using the given value comparers.static DbUnitAssertReturns the sharedDbUnitAssertinstance used for equals-based comparisons.static DbUnitValueComparerAssertReturns the sharedDbUnitValueComparerAssertinstance used for value-comparer-based comparisons.
-
Method Details
-
assertEqualsIgnoreCols
public static void assertEqualsIgnoreCols(IDataSet expectedDataset, IDataSet actualDataset, String tableName, String[] ignoreCols) throws DatabaseUnitException Asserts that the two specified datasets' tables are equal, ignoring the given columns.- Parameters:
expectedDataset- dataset containing the expected results.actualDataset- dataset containing the actual results.tableName- name of the table to compare.ignoreCols- columns to ignore during comparison.- Throws:
DatabaseUnitException- if an error occurs during comparison.- See Also:
-
assertEqualsIgnoreCols
public static void assertEqualsIgnoreCols(ITable expectedTable, ITable actualTable, String[] ignoreCols) throws DatabaseUnitException Asserts that the two specified tables are equal, ignoring the given columns.- Parameters:
expectedTable- table containing the expected results.actualTable- table containing the actual results.ignoreCols- columns to ignore during comparison.- Throws:
DatabaseUnitException- if an error occurs during comparison.- See Also:
-
assertEqualsByQuery
public static void assertEqualsByQuery(IDataSet expectedDataset, IDatabaseConnection connection, String sqlQuery, String tableName, String[] ignoreCols) throws DatabaseUnitException, SQLException Asserts that the specified dataset table matches the given query's result, ignoring the given columns.- Parameters:
expectedDataset- dataset containing the expected results.connection- connection used to query the actual results.sqlQuery- SQL query used to obtain the actual results.tableName- name of the table being compared.ignoreCols- columns to ignore during comparison.- Throws:
DatabaseUnitException- if an error occurs during comparison.SQLException- if an error occurs while executing the query.- See Also:
-
assertEqualsByQuery
public static void assertEqualsByQuery(ITable expectedTable, IDatabaseConnection connection, String tableName, String sqlQuery, String[] ignoreCols) throws DatabaseUnitException, SQLException Asserts that the specified table matches the given query's result, ignoring the given columns.- Parameters:
expectedTable- table containing the expected results.connection- connection used to query the actual results.tableName- name of the table being compared.sqlQuery- SQL query used to obtain the actual results.ignoreCols- columns to ignore during comparison.- Throws:
DatabaseUnitException- if an error occurs during comparison.SQLException- if an error occurs while executing the query.- See Also:
-
assertEquals
public static void assertEquals(IDataSet expectedDataSet, IDataSet actualDataSet) throws DatabaseUnitException Asserts that the two specified datasets are equal.- Parameters:
expectedDataSet- dataset containing the expected results.actualDataSet- dataset containing the actual results.- Throws:
DatabaseUnitException- if an error occurs during comparison.- See Also:
-
assertEquals
public static void assertEquals(IDataSet expectedDataSet, IDataSet actualDataSet, FailureHandler failureHandler) throws DatabaseUnitException Asserts that the two specified datasets are equal.- Parameters:
expectedDataSet- dataset containing the expected results.actualDataSet- dataset containing the actual results.failureHandler- the failure handler used to report mismatches.- Throws:
DatabaseUnitException- if an error occurs during comparison.- Since:
- 2.4
- See Also:
-
assertEquals
public static void assertEquals(ITable expectedTable, ITable actualTable) throws DatabaseUnitException Asserts that the two specified tables are equal.- Parameters:
expectedTable- table containing the expected results.actualTable- table containing the actual results.- Throws:
DatabaseUnitException- if an error occurs during comparison.- See Also:
-
assertEquals
public static void assertEquals(ITable expectedTable, ITable actualTable, Column[] additionalColumnInfo) throws DatabaseUnitException Asserts that the two specified tables are equal.- Parameters:
expectedTable- table containing the expected results.actualTable- table containing the actual results.additionalColumnInfo- additional columns to include in failure messages.- Throws:
DatabaseUnitException- if an error occurs during comparison.- See Also:
-
assertEquals
public static void assertEquals(ITable expectedTable, ITable actualTable, FailureHandler failureHandler) throws DatabaseUnitException Asserts that the two specified tables are equal.- Parameters:
expectedTable- table containing the expected results.actualTable- table containing the actual results.failureHandler- the failure handler used to report mismatches.- Throws:
DatabaseUnitException- if an error occurs during comparison.- Since:
- 2.4
- See Also:
-
assertWithValueComparer
public static void assertWithValueComparer(IDataSet expectedDataSet, IDataSet actualDataSet, ValueComparer defaultValueComparer, Map<String, Map<String, throws DatabaseUnitExceptionValueComparer>> tableColumnValueComparers) Asserts that the two specified datasets are equal, using the given value comparers.- Parameters:
expectedDataSet- dataset containing the expected results.actualDataSet- dataset containing the actual results.defaultValueComparer- the value comparer used when no more specific comparer is configured.tableColumnValueComparers- the per-table, per-column value comparers to use.- Throws:
DatabaseUnitException- if an error occurs during comparison.- Since:
- 2.6.0
- See Also:
-
assertWithValueComparer
public static void assertWithValueComparer(ITable expectedTable, ITable actualTable, ValueComparer defaultValueComparer, Map<String, ValueComparer> columnValueComparers) throws DatabaseUnitExceptionAsserts that the two specified tables are equal, using the given value comparers.- Parameters:
expectedTable- table containing the expected results.actualTable- table containing the actual results.defaultValueComparer- the value comparer used when no more specific comparer is configured.columnValueComparers- the per-column value comparers to use.- Throws:
DatabaseUnitException- if an error occurs during comparison.- Since:
- 2.6.0
- See Also:
-
assertWithValueComparer
public static void assertWithValueComparer(IDataSet expectedDataSet, IDataSet actualDataSet, FailureHandler failureHandler, ValueComparer defaultValueComparer, Map<String, Map<String, throws DatabaseUnitExceptionValueComparer>> tableColumnValueComparers) Asserts that the two specified datasets are equal, using the given value comparers.- Parameters:
expectedDataSet- dataset containing the expected results.actualDataSet- dataset containing the actual results.failureHandler- the failure handler used to report mismatches.defaultValueComparer- the value comparer used when no more specific comparer is configured.tableColumnValueComparers- the per-table, per-column value comparers to use.- Throws:
DatabaseUnitException- if an error occurs during comparison.- Since:
- 2.6.0
- See Also:
-
assertWithValueComparer
public static void assertWithValueComparer(ITable expectedTable, ITable actualTable, Column[] additionalColumnInfo, ValueComparer defaultValueComparer, Map<String, ValueComparer> columnValueComparers) throws DatabaseUnitExceptionAsserts that the two specified tables are equal, using the given value comparers.- Parameters:
expectedTable- table containing the expected results.actualTable- table containing the actual results.additionalColumnInfo- additional columns to include in failure messages.defaultValueComparer- the value comparer used when no more specific comparer is configured.columnValueComparers- the per-column value comparers to use.- Throws:
DatabaseUnitException- if an error occurs during comparison.- Since:
- 2.6.0
- See Also:
-
assertWithValueComparer
public static void assertWithValueComparer(ITable expectedTable, ITable actualTable, FailureHandler failureHandler, ValueComparer defaultValueComparer, Map<String, ValueComparer> columnValueComparers) throws DatabaseUnitExceptionAsserts that the two specified tables are equal, using the given value comparers.- Parameters:
expectedTable- table containing the expected results.actualTable- table containing the actual results.failureHandler- the failure handler used to report mismatches.defaultValueComparer- the value comparer used when no more specific comparer is configured.columnValueComparers- the per-column value comparers to use.- Throws:
DatabaseUnitException- if an error occurs during comparison.- Since:
- 2.6.0
- See Also:
-
getEqualsInstance
Returns the sharedDbUnitAssertinstance used for equals-based comparisons.- Returns:
- the shared
DbUnitAssertinstance.
-
getValueCompareInstance
Returns the sharedDbUnitValueComparerAssertinstance used for value-comparer-based comparisons.- Returns:
- the shared
DbUnitValueComparerAssertinstance.
-