org.unitils.dbunit.util
Class DataSetAssert

java.lang.Object
  extended by org.unitils.dbunit.util.DataSetAssert

public class DataSetAssert
extends Object

Assert class that offers assert methods for testing things that are specific to DbUnit.

Author:
Tim Ducheyne, Filip Neven

Constructor Summary
DataSetAssert()
           
 
Method Summary
protected  void appendBestRowDifferences(TableDifference tableDifference, StringBuilder result)
          Appends the best matching row differences of the given table difference to the result
protected  void appendColumnNames(Row row, StringBuilder result)
          Appends the column names of the given row to the result
protected  void appendMissingRowDifferences(TableDifference tableDifference, StringBuilder result)
          Appends the missing rows of the given table difference to the result
protected  void appendMissingTableDifferences(SchemaDifference schemaDifference, StringBuilder result)
          Appends the missing tables of the given schema difference to the result
protected  void appendRow(Row row, StringBuilder result)
          Appends the values of the given row to the result
protected  void appendSchemaContent(Schema schema, Schema actualSchema, StringBuilder result)
          Appends all rows and tables of the actual schema to the result.
protected  void appendTableDifferences(SchemaDifference schemaDifference, StringBuilder result)
          Appends the table differences of the given schema difference to the result
protected  void appendTableName(Schema schema, Table table, StringBuilder result)
          Appends the schema and table name to the result
 void assertEqualDbUnitDataSets(String schemaName, org.dbunit.dataset.IDataSet expectedDataSet, org.dbunit.dataset.IDataSet actualDataSet)
          Asserts that the given expected DbUnit data set is equal to the actual DbUnit data set.
 void assertEqualSchemas(Schema expectedSchema, Schema actualSchema)
          Asserts that the given expected schema is equal to the actual schema.
protected  String generateErrorMessage(SchemaDifference schemaDifference)
          Formats the assertion failed message for the given difference.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataSetAssert

public DataSetAssert()
Method Detail

assertEqualSchemas

public void assertEqualSchemas(Schema expectedSchema,
                               Schema actualSchema)
                        throws AssertionError
Asserts that the given expected schema is equal to the actual schema. Tables, rows or columns that are not specified in the expected schema will be ignored. If an empty table is specified in the expected schema, it will check that the actual table is also be empty.

Parameters:
expectedSchema - The expected schema, not null
actualSchema - The actual schema, not null
Throws:
AssertionError - When the assertion fails.

assertEqualDbUnitDataSets

public void assertEqualDbUnitDataSets(String schemaName,
                                      org.dbunit.dataset.IDataSet expectedDataSet,
                                      org.dbunit.dataset.IDataSet actualDataSet)
Asserts that the given expected DbUnit data set is equal to the actual DbUnit data set. Tables, rows or columns that are not specified in the expected data set will be ignored. If an empty table is specified in the expected data set, it will check that the actual table is also be empty.

Parameters:
schemaName - The name of the schema that these data sets belong to, not null
expectedDataSet - The expected data set, not null
actualDataSet - The actual data set, not null
Throws:
AssertionError - When the assertion fails.

generateErrorMessage

protected String generateErrorMessage(SchemaDifference schemaDifference)
Formats the assertion failed message for the given difference.

Parameters:
schemaDifference - The difference, not null
Returns:
The message, not null

appendMissingTableDifferences

protected void appendMissingTableDifferences(SchemaDifference schemaDifference,
                                             StringBuilder result)
Appends the missing tables of the given schema difference to the result

Parameters:
schemaDifference - The difference, not null
result - The result to append to, not null

appendTableDifferences

protected void appendTableDifferences(SchemaDifference schemaDifference,
                                      StringBuilder result)
Appends the table differences of the given schema difference to the result

Parameters:
schemaDifference - The difference, not null
result - The result to append to, not null

appendMissingRowDifferences

protected void appendMissingRowDifferences(TableDifference tableDifference,
                                           StringBuilder result)
Appends the missing rows of the given table difference to the result

Parameters:
tableDifference - The difference, not null
result - The result to append to, not null

appendBestRowDifferences

protected void appendBestRowDifferences(TableDifference tableDifference,
                                        StringBuilder result)
Appends the best matching row differences of the given table difference to the result

Parameters:
tableDifference - The difference, not null
result - The result to append to, not null

appendColumnNames

protected void appendColumnNames(Row row,
                                 StringBuilder result)
Appends the column names of the given row to the result

Parameters:
row - The row, not null
result - The result to append to, not null

appendRow

protected void appendRow(Row row,
                         StringBuilder result)
Appends the values of the given row to the result

Parameters:
row - The row, not null
result - The result to append to, not null

appendSchemaContent

protected void appendSchemaContent(Schema schema,
                                   Schema actualSchema,
                                   StringBuilder result)
Appends all rows and tables of the actual schema to the result. Only tables that are in the expected schema will be appended.

Parameters:
schema - The expected schema, not null
actualSchema - The actual schema, not null
result - The result to append to, not null

appendTableName

protected void appendTableName(Schema schema,
                               Table table,
                               StringBuilder result)
Appends the schema and table name to the result

Parameters:
schema - The schema name, not null
table - The table name, not null
result - The result to append to, not null


Copyright © 2011. All Rights Reserved.