net.sourceforge.sqlunit.matchers
Class ForgivingNullMatcher

java.lang.Object
  extended by net.sourceforge.sqlunit.matchers.ForgivingNullMatcher
All Implemented Interfaces:
IMatcher

public class ForgivingNullMatcher
extends java.lang.Object
implements IMatcher

The ForgivingNullMatcher is an implementation of the IMatcher interface used to compare values you know are either supposed to be NULL (but might be textually represented differently) or are actually equal. Basically searches for the word NULL (case insensitive) or for blank elements or for elements that are equal Strings. Especially useful when you're generating your test script by copying and pasting out of a SQL query tool that displays NULLs differently than SQLUnit pulls back from the database. For example, all of these values are treated as equal: <col id="14" name="benchcode" type="INTEGER">[NULL]</col> <col id="14" name="benchcode" type="INTEGER">NULL</col> <col id="14" name="benchcode" type="INTEGER"></col> <col id="14" name="benchcode" type="INTEGER">null</col> Example configuration: <match resultset-id="1" row-id="*" col-id="14" matcher="net.sourceforge.sqlunit.matchers.ForgivingNullMatcher"> </match>

Version:
$Revision: 1.2 $
Author:
Tim Cull (trcull@yahoo.com)

Field Summary
static java.lang.String NULL_STRING
           
 
Constructor Summary
ForgivingNullMatcher()
          Default constructor as per contract with IMatcher
 
Method Summary
 boolean isEqual(java.lang.String source, java.lang.String target, java.util.Map args)
          Returns true if the value of the target and the source are equivalent to NULL (either by being empty or by containing the word NULL) or are actually equal to each other
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NULL_STRING

public static final java.lang.String NULL_STRING
See Also:
Constant Field Values
Constructor Detail

ForgivingNullMatcher

public ForgivingNullMatcher()
Default constructor as per contract with IMatcher

Method Detail

isEqual

public boolean isEqual(java.lang.String source,
                       java.lang.String target,
                       java.util.Map args)
                throws SQLUnitException
Returns true if the value of the target and the source are equivalent to NULL (either by being empty or by containing the word NULL) or are actually equal to each other

Specified by:
isEqual in interface IMatcher
Parameters:
source - the String representing the source to be matched.
target - the String representing the target to be matched.
args - a Map of name value pairs of arguments passed in.
Returns:
true if the matching strategy resulted in success.
Throws:
SQLUnitException - if there was a problem with matching.