org.dbunit.assertion
Class DefaultFailureHandler

java.lang.Object
  extended by org.dbunit.assertion.DefaultFailureHandler
All Implemented Interfaces:
DifferenceListener, FailureFactory, FailureHandler
Direct Known Subclasses:
DiffCollectingFailureHandler

public class DefaultFailureHandler
extends Object
implements FailureHandler

Default implementation of the FailureHandler.

Since:
2.4.0
Version:
$Revision: 872 $ $Date: 2008-11-08 16:45:52 +0100 (Sat, 08 Nov 2008) $
Author:
gommma (gommma AT users.sourceforge.net), Last changed by: $Author: gommma $

Nested Class Summary
static class DefaultFailureHandler.DefaultFailureFactory
          Default failure factory which returns DBUnits own assertion error instances.
 
Constructor Summary
DefaultFailureHandler()
          Default constructor which does not provide any additional column information.
DefaultFailureHandler(Column[] additionalColumnInfo)
          Create a default failure handler
DefaultFailureHandler(String[] additionalColumnInfo)
          Create a default failure handler
 
Method Summary
protected  String buildMessage(Difference diff)
           
 Error createFailure(String message)
           
 Error 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.
 String getAdditionalInfo(ITable expectedTable, ITable actualTable, int row, String columnName)
          Returns a string to be appended to the assertion failure message.
 void handle(Difference diff)
          Is invoked by the DbUnitAssert when a data cell difference has been found.
 void setFailureFactory(FailureFactory failureFactory)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DefaultFailureHandler

public DefaultFailureHandler()
Default constructor which does not provide any additional column information.


DefaultFailureHandler

public DefaultFailureHandler(Column[] additionalColumnInfo)
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

public DefaultFailureHandler(String[] additionalColumnInfo)
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 Detail

setFailureFactory

public void setFailureFactory(FailureFactory failureFactory)
Parameters:
failureFactory - The DefaultFailureHandler.DefaultFailureFactory to be used for creating assertion errors.

createFailure

public Error createFailure(String message,
                           String expected,
                           String actual)
Description copied from interface: FailureFactory
Creates a new failure object which can have different types, depending on the testing framework you are currently using (e.g. JUnit, TestNG, ...)

Specified by:
createFailure in interface FailureFactory
Parameters:
message - The reason for the failure
expected - The expected result
actual - 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

public Error createFailure(String message)
Specified by:
createFailure in interface FailureFactory
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: FailureHandler
Returns 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:
getAdditionalInfo in interface FailureHandler
row - The row for which the assertion failed
columnName - The column for which the assertion failed
Returns:
A string that is appended to the assertion failure message

handle

public void handle(Difference diff)
Description copied from interface: DifferenceListener
Is invoked by the DbUnitAssert when a data cell difference has been found.

Specified by:
handle in interface DifferenceListener
Parameters:
diff - The difference that has been found

buildMessage

protected String buildMessage(Difference diff)

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2002-2012. All Rights Reserved.