org.apache.commons.latka.validators
Class GoldenFileValidator

java.lang.Object
  extended byorg.apache.commons.latka.validators.BaseValidator
      extended byorg.apache.commons.latka.validators.GoldenFileValidator
All Implemented Interfaces:
Validator

public class GoldenFileValidator
extends BaseValidator
implements Validator

Compare the response with a golden file. Right now this is a proof of concept class; we should extend it to support more than just files, I think. Also, maybe golden files should be more than just text.


Field Summary
protected  java.io.File _goldFile
           
protected  boolean _ignoreWhitespace
           
protected  java.lang.StringBuffer _matchLog
           
protected static java.lang.String TRUE_MESSAGE
           
 
Fields inherited from class org.apache.commons.latka.validators.BaseValidator
_label, _log
 
Constructor Summary
GoldenFileValidator(java.io.File goldenFile)
           
GoldenFileValidator(java.lang.String label, java.io.File goldenFile)
           
 
Method Summary
protected  boolean compare(byte[] array1, byte[] array2)
           
protected  boolean compareWeak(java.lang.String str1, java.lang.String str2)
           
protected  void log(java.lang.String message)
           
 void setIgnoreWhitespace(boolean ignoreWhitespace)
           
 void validate(Response response)
          Run custom validation.
 
Methods inherited from class org.apache.commons.latka.validators.BaseValidator
fail, getLabel, setLabel
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_goldFile

protected java.io.File _goldFile

_ignoreWhitespace

protected boolean _ignoreWhitespace

TRUE_MESSAGE

protected static java.lang.String TRUE_MESSAGE

_matchLog

protected java.lang.StringBuffer _matchLog
Constructor Detail

GoldenFileValidator

public GoldenFileValidator(java.io.File goldenFile)

GoldenFileValidator

public GoldenFileValidator(java.lang.String label,
                           java.io.File goldenFile)
Method Detail

setIgnoreWhitespace

public void setIgnoreWhitespace(boolean ignoreWhitespace)

validate

public void validate(Response response)
              throws ValidationException
Description copied from interface: Validator
Run custom validation. Latka will provide the HTTP response to this method. The implementer should throw a ValidationException if the Response fails to meet the validation criteria.

Specified by:
validate in interface Validator
Specified by:
validate in class BaseValidator
Parameters:
response - the response to validate
Throws:
ValidationException

compare

protected boolean compare(byte[] array1,
                          byte[] array2)

compareWeak

protected boolean compareWeak(java.lang.String str1,
                              java.lang.String str2)

log

protected void log(java.lang.String message)


Copyright © 2002-2007 The Apache Software Foundation. All Rights Reserved.