Package org.dbunit.assertion
Class DefaultFailureHandler
java.lang.Object
org.dbunit.assertion.DefaultFailureHandler
- All Implemented Interfaces:
DifferenceListener,FailureFactory,FailureHandler
- Direct Known Subclasses:
DiffCollectingFailureHandler
Default implementation of the
FailureHandler.- Since:
- 2.4.0
- Author:
- gommma (gommma AT users.sourceforge.net)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classDefault failure factory which returns DBUnits own assertion error instances. -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor which does not provide any additional column information.DefaultFailureHandler(String[] additionalColumnInfo) Create a default failure handlerDefaultFailureHandler(Column[] additionalColumnInfo) Create a default failure handler -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddFailMessage(Difference diff, StringBuilder builder) protected StringbuildMessage(Difference diff) createFailure(String message) createFailure(String message, String expected, String actual) Creates a new failure object which can have different types, depending on the testing framework you are currently using (e.g.getAdditionalInfo(ITable expectedTable, ITable actualTable, int row, String columnName) Returns a string to be appended to the assertion failure message.protected ObjectgetColumnValue(ITable table, int rowIndex, String columnName) voidhandle(Difference diff) Is invoked by theDbUnitAssertwhen a data cell difference has been found.protected booleanisFailMessage(String failMessage) protected StringmakeAdditionalColumnInfoErrorMessage(String columnName, DataSetException e) voidsetFailureFactory(FailureFactory failureFactory) toString()
-
Constructor Details
-
DefaultFailureHandler
public DefaultFailureHandler()Default constructor which does not provide any additional column information. -
DefaultFailureHandler
Create a default failure handler- Parameters:
additionalColumnInfo- the column names of the columns for which additional information should be printed when an assertion failed.
-
DefaultFailureHandler
Create a default failure handler- Parameters:
additionalColumnInfo- the column names of the columns for which additional information should be printed when an assertion failed.
-
-
Method Details
-
setFailureFactory
- Parameters:
failureFactory- TheFailureFactoryto be used for creating assertion errors.
-
createFailure
Description copied from interface:FailureFactoryCreates a new failure object which can have different types, depending on the testing framework you are currently using (e.g. JUnit, TestNG, ...)- Specified by:
createFailurein interfaceFailureFactory- Parameters:
message- The reason for the failureexpected- The expected resultactual- The actual result- Returns:
- The comparison failure object for this handler (can be JUnit or some other) which can be thrown on an assertion failure
-
createFailure
- Specified by:
createFailurein interfaceFailureFactory- Parameters:
message- The reason for the failure- Returns:
- The assertion failure object for this handler (can be JUnit or some other) which can be thrown on an assertion failure
-
getAdditionalInfo
public String getAdditionalInfo(ITable expectedTable, ITable actualTable, int row, String columnName) Description copied from interface:FailureHandlerReturns a string to be appended to the assertion failure message. Is used to provide some more information about a failure (for example to print out some PK columns for identifying the failed rows in the DB).- Specified by:
getAdditionalInfoin interfaceFailureHandler- Parameters:
expectedTable-actualTable-row- The row for which the assertion failedcolumnName- The column for which the assertion failed- Returns:
- A string that is appended to the assertion failure message
-
getColumnValue
-
makeAdditionalColumnInfoErrorMessage
-
handle
Description copied from interface:DifferenceListenerIs invoked by theDbUnitAssertwhen a data cell difference has been found.- Specified by:
handlein interfaceDifferenceListener- Parameters:
diff- The difference that has been found
-
buildMessage
-
addFailMessage
-
isFailMessage
-
toString
-