You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by cu...@apache.org on 2001/11/02 16:04:03 UTC

cvs commit: xml-xalan/test/java/src/org/apache/qetest/xsl XHTComparator.java XHTFileCheckService.java

curcuru     01/11/02 07:04:03

  Modified:    test/java/src/org/apache/qetest CheckService.java
                        SimpleFileCheckService.java
               test/java/src/org/apache/qetest/xsl XHTComparator.java
                        XHTFileCheckService.java
  Log:
  Use new Configurable interface to pass setAttribute calls to XHTComparator's parser
  
  Revision  Changes    Path
  1.4       +31 -26    xml-xalan/test/java/src/org/apache/qetest/CheckService.java
  
  Index: CheckService.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/test/java/src/org/apache/qetest/CheckService.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- CheckService.java	2001/02/09 00:35:00	1.3
  +++ CheckService.java	2001/11/02 15:04:02	1.4
  @@ -55,29 +55,35 @@
    * <http://www.apache.org/>.
    */
   
  -/*
  - *
  - * CheckService.java
  - *
  - */
   package org.apache.qetest;
   
   /**
    * Interface for 'check'ing (validating) equivalence of two items.
  + *
    * Implementers provide their own algorithims for determining
  - * equivalence.
  + * equivalence, including custom algorithims for complex objects. 
  + * CheckServices should log out both any pertinent information about 
  + * the checking they've performed, then log out a checkPass or 
  + * checkFail (or Ambg, etc.) record, as well as returning the 
  + * appropriate result constant to the caller.
  + *
  + * The Configurable interface also allows callers to attempt to 
  + * set attributes on either the CheckService or on any 
  + * underlying validation algorithims.
  + *
    * @author Shane_Curcuru@lotus.com
  - * @version $Id: CheckService.java,v 1.3 2001/02/09 00:35:00 curcuru Exp $
  + * @version $Id: CheckService.java,v 1.4 2001/11/02 15:04:02 curcuru Exp $
    */
  -public interface CheckService
  +public interface CheckService extends Configurable
   {
   
       /**
        * Compare two objects for equivalence, and return appropriate result.
        * Implementers should provide the details of their "equals"
  -     * algorithim in getCheckMethod().  They must also call the 
  +     * algorithim in getDescription().  They must also call the 
        * appropriate checkPass()/checkFail()/etc. method on the 
        * supplied Logger.
  +     * 
        * Note that the order of actual, reference is usually 
        * important in determining the result.
        * <li>Typically:
  @@ -93,11 +99,11 @@
        * @param reference (gold, or expected) Object to check against
        * @param description of what you're checking
        * @param msg comment to log out with this test point
  -     * @return Reporter.*_RESULT code denoting status; each method may define
  -     * it's own meanings for pass, fail, ambiguous, etc.
  +     * @return Logger.*_RESULT code denoting status; each method may 
  +     * define it's own meanings for pass, fail, ambiguous, etc.
        */
  -    public abstract int check(Logger logger, Object actual,
  -                              Object reference, String msg);
  +    public int check(Logger logger, Object actual,
  +                     Object reference, String msg);
   
       /**
        * Compare two objects for equivalence, and return appropriate result.
  @@ -108,25 +114,24 @@
        * @param description of what you're checking
        * @param msg comment to log out with this test point
        * @param id ID tag to log out with this test point
  -     * @return Reporter.*_RESULT code denoting status; each method may define
  -     * it's own meanings for pass, fail, ambiguous, etc.
  +     * @return Logger.*_RESULT code denoting status; each method may 
  +     * define it's own meanings for pass, fail, ambiguous, etc.
        */
  -    public abstract int check(Logger logger, Object actual,
  -                              Object reference, String msg, String id);
  +    public int check(Logger logger, Object actual,
  +                     Object reference, String msg, String id);
   
       /**
  -     * Description of algorithim used to check equivalence.  
  -     *
  -     * @return String describing algorithim
  -     */
  -    public abstract String getDescription();
  -
  -    /**
        * Gets extended information about the last check call.
  +     * 
  +     * This is somewhat optional, and may be removed.  CheckServices 
  +     * should probably log out any additional info themselves to 
  +     * their logger before calling checkPass, etc., thus removing 
  +     * the need for callers to explicitly ask for this info.
        *
        * @return String describing any additional info about the last
  -     * two Objects that were checked
  +     * two Objects that were checked, or null if none available
        */
  -    public abstract String getExtendedInfo();
  +    public String getExtendedInfo();
  +
   }  // end of class CheckService
   
  
  
  
  1.5       +48 -71    xml-xalan/test/java/src/org/apache/qetest/SimpleFileCheckService.java
  
  Index: SimpleFileCheckService.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/test/java/src/org/apache/qetest/SimpleFileCheckService.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- SimpleFileCheckService.java	2001/02/09 00:35:03	1.4
  +++ SimpleFileCheckService.java	2001/11/02 15:04:02	1.5
  @@ -55,11 +55,6 @@
    * <http://www.apache.org/>.
    */
   
  -/*
  - *
  - * SimpleFileCheckService.java
  - *
  - */
   package org.apache.qetest;
   
   import java.io.BufferedReader;
  @@ -69,7 +64,7 @@
   /**
    * Simply does .readLine of each file into string buffers and then String.equals().
    * @author Shane_Curcuru@lotus.com
  - * @version $Id: SimpleFileCheckService.java,v 1.4 2001/02/09 00:35:03 curcuru Exp $
  + * @version $Id: SimpleFileCheckService.java,v 1.5 2001/11/02 15:04:02 curcuru Exp $
    */
   public class SimpleFileCheckService implements CheckService
   {
  @@ -83,8 +78,8 @@
        * @param description of what you're checking
        * @param msg comment to log out with this test point
        * @param id ID tag to log out with this test point
  -     * @return Logger.*_RESULT code denoting status; each method may define
  -     * it's own meanings for pass, fail, ambiguous, etc.
  +     * @return Logger.*_RESULT code denoting status; each method may 
  +     * define it's own meanings for pass, fail, ambiguous, etc.
        */
       public int check(Logger logger, Object actual, Object reference,
                        String msg, String id)
  @@ -94,8 +89,7 @@
           {
   
               // Must have File objects to continue
  -            logger.checkErr(
  -                "SimpleFileCheckService only takes files, with: " + msg, id);
  +            logger.checkErr(msg + " :check() objects were not Files", id);
   
               return Logger.ERRR_RESULT;
           }
  @@ -105,7 +99,7 @@
           // Fail if Actual file doesn't exist
           if (fVal1 == null)
           {
  -            logger.checkFail(msg, id);
  +            logger.checkFail(msg + " :Actual file null", id);
   
               return Logger.FAIL_RESULT;
           }
  @@ -115,7 +109,7 @@
           // Ambiguous if gold or reference file doesn't exist
           if (fVal2 == null)
           {
  -            logger.checkAmbiguous(msg, id);
  +            logger.checkAmbiguous(msg + " :Gold file null", id);
   
               return Logger.AMBG_RESULT;
           }
  @@ -143,8 +137,8 @@
        * @param reference (gold, or expected) File to check against
        * @param description of what you're checking
        * @param msg comment to log out with this test point
  -     * @return Logger.*_RESULT code denoting status; each method may define
  -     * it's own meanings for pass, fail, ambiguous, etc.
  +     * @return Logger.*_RESULT code denoting status; each method may 
  +     * define it's own meanings for pass, fail, ambiguous, etc.
        */
       public int check(Logger logger, Object actual, Object reference,
                        String msg)
  @@ -153,49 +147,6 @@
       }
   
       /**
  -     * Compare two files for equivalence, and return appropriate *_RESULT flag.
  -     * <b>Note:</b> Only provided for backwards compatibility!
  -     * <p>Uses appropriate values from Logger for return values.</p>
  -     * @param file1 Actual (current) file to check
  -     * @param file2 Reference (gold, or expected) file to check against
  -     * @return PASS if equal, FAIL if not, AMBG if gold does not exist
  -     */
  -    public int checkFiles(Logger logger, File file1, File file2)
  -    {
  -
  -        String fVal1 = readFileIntoString(logger, file1);
  -
  -        // Fail if Actual file doesn't exist
  -        if (fVal1 == null)
  -            return Logger.FAIL_RESULT;
  -
  -        String fVal2 = readFileIntoString(logger, file2);
  -
  -        // Ambiguous if gold or reference file doesn't exist
  -        if (fVal2 == null)
  -            return Logger.AMBG_RESULT;
  -
  -        // Pass if they're equal, fail otherwise        
  -        if (fVal1.equals(fVal2))
  -            return Logger.PASS_RESULT;
  -        else
  -            return Logger.FAIL_RESULT;
  -    }
  -
  -    /**
  -     * Compare two files for equivalence, and return appropriate *_RESULT flag.
  -     * <b>Note:</b> Only provided for backwards compatibility!
  -     * @param file1 Actual (current) file to check
  -     * @param file2 Reference (gold, or expected) file to check against
  -     * @return PASS if equal, FAIL if not, AMBG if gold does not exist
  -     */
  -    public int checkFiles(File file1, File file2)
  -    {
  -
  -        return checkFiles(null, file1, file2);
  -    }
  -
  -    /**
        * Read text file into string line-by-line.  
        * @param logger to dump any messages to
        * @param f File object to read
  @@ -239,31 +190,57 @@
       }
   
       /**
  -     * Read text file into string line-by-line.  
  -     * For backwards compatibility.
  -     * @param f File object to read
  -     * @return String of file's contents
  +     * Gets extended information about the last checkFiles call: NONE AVAILABLE.
  +     * @return null, since we don't support this
        */
  -    private String readFileIntoString(File f)
  +    public String getExtendedInfo()
       {
  -        return readFileIntoString(null, f);
  +        return null;
       }
  +
       /**
  -     * Description of algorithim used to check file equivalence.  
  -     * @return String description of algorithim
  -     */
  -    public String getDescription()
  +     * Allows the user to set specific attributes on the testing 
  +     * utility or it's underlying product object under test.
  +     * 
  +     * No-op; this class does not have any supported attributes.
  +     * 
  +     * @param name The name of the attribute.
  +     * @param value The value of the attribute.
  +     * @throws IllegalArgumentException thrown if the underlying
  +     * implementation doesn't recognize the attribute and wants to 
  +     * inform the user of this fact.
  +     */
  +    public void setAttribute(String name, Object value)
  +        throws IllegalArgumentException
       {
  -        return ("Reads in text files line-by-line as strings (ignoring newlines) and does String.equals()");
  +        /* no-op */        
       }
   
       /**
  -     * Gets extended information about the last checkFiles call: NONE AVAILABLE.
  -     * @return null, since we don't support this
  +     * Allows the user to retrieve specific attributes on the testing 
  +     * utility or it's underlying product object under test.
  +     *
  +     * @param name The name of the attribute.
  +     * @return null, no attributes supported.
  +     * @throws IllegalArgumentException thrown if the underlying
  +     * implementation doesn't recognize the attribute and wants to 
  +     * inform the user of this fact.
        */
  -    public String getExtendedInfo()
  +    public Object getAttribute(String name)
  +        throws IllegalArgumentException
       {
           return null;
       }
  +
  +    /**
  +     * Description of what this testing utility does.  
  +     * 
  +     * @return String description of extension
  +     */
  +    public String getDescription()
  +    {
  +        return ("Reads in text files line-by-line as strings (ignoring newlines) and does String.equals()");
  +    }
  +
   }  // end of class SimpleFileCheckService
   
  
  
  
  1.5       +47 -60    xml-xalan/test/java/src/org/apache/qetest/xsl/XHTComparator.java
  
  Index: XHTComparator.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/test/java/src/org/apache/qetest/xsl/XHTComparator.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- XHTComparator.java	2001/03/02 21:15:56	1.4
  +++ XHTComparator.java	2001/11/02 15:04:03	1.5
  @@ -62,7 +62,8 @@
    */
   package org.apache.qetest.xsl;
   
  -import org.apache.qetest.Reporter;  // Only for PASS_RESULT, etc.
  +import org.apache.qetest.Logger;  // Only for PASS_RESULT, etc.
  +import org.apache.qetest.QetestUtils;
   
   import java.io.PrintWriter;
   import java.io.File;
  @@ -72,6 +73,7 @@
   import java.net.URL;
   import java.net.MalformedURLException;
   
  +import java.util.Hashtable;
   import java.util.StringTokenizer;
   
   // DOM imports
  @@ -109,7 +111,7 @@
    * attempt to parse it as XML, not other types)
    * @author Scott_Boag@lotus.com
    * @author Shane_Curcuru@lotus.com
  - * @version $Id: XHTComparator.java,v 1.4 2001/03/02 21:15:56 curcuru Exp $
  + * @version $Id: XHTComparator.java,v 1.5 2001/11/02 15:04:03 curcuru Exp $
    */
   public class XHTComparator
   {
  @@ -138,60 +140,60 @@
       /** Constants for reporting out reason for failed diffs. */
       public static final String SEPARATOR = ";";
   
  -    /** NEEDSDOC Field LBRACKET          */
  +    /** LBRACKET '['  */
       public static final String LBRACKET = "[";
   
  -    /** NEEDSDOC Field RBRACKET          */
  +    /** RBRACKET ']'  */
       public static final String RBRACKET = "]";
   
  -    /** NEEDSDOC Field TEST          */
  +    /** TEST 'test', for the actual value.  */
       public static final String TEST = "test";
   
  -    /** NEEDSDOC Field GOLD          */
  +    /** GOLD 'gold' for the gold or expected value.  */
       public static final String GOLD = "gold";
   
  -    /** NEEDSDOC Field PARSE_TYPE          */
  +    /** PARSE_TYPE '-parse-type' */
       public static final String PARSE_TYPE = "-parse-type" + SEPARATOR;  // postpended to TEST or GOLD
   
  -    /** NEEDSDOC Field OTHER_ERROR          */
  +    /** OTHER_ERROR 'other-error'  */
       public static final String OTHER_ERROR = "other-error" + SEPARATOR;
   
  -    /** NEEDSDOC Field WARNING          */
  +    /** WARNING 'warning'  */
       public static final String WARNING = "warning" + SEPARATOR;
   
  -    /** NEEDSDOC Field MISMATCH_NODE          */
  +    /** MISMATCH_NODE  */
       public static final String MISMATCH_NODE = "mismatch-node" + SEPARATOR;
   
  -    /** NEEDSDOC Field MISSING_TEST_NODE          */
  +    /** MISSING_TEST_NODE  */
       public static final String MISSING_TEST_NODE = "missing-node-" + TEST
                                                          + SEPARATOR;
   
  -    /** NEEDSDOC Field MISSING_GOLD_NODE          */
  +    /** MISSING_GOLD_NODE  */
       public static final String MISSING_GOLD_NODE = "missing-node-" + GOLD
                                                          + SEPARATOR;
   
  -    /** NEEDSDOC Field MISMATCH_ATTRIBUTE          */
  +    /** MISMATCH_ATTRIBUTE */
       public static final String MISMATCH_ATTRIBUTE = "mismatch-attribute"
                                                           + SEPARATOR;
   
  -    /** NEEDSDOC Field MISMATCH_VALUE          */
  +    /** MISMATCH_VALUE  */
       public static final String MISMATCH_VALUE = "mismatch-value" + SEPARATOR;
   
  -    /** NEEDSDOC Field MISMATCH_VALUE          */
  +    /** MISMATCH_VALUE  */
       public static final String MISMATCH_VALUE_GOLD = "mismatch-value-gold" + SEPARATOR;
   
  -    /** NEEDSDOC Field MISMATCH_VALUE          */
  +    /** MISMATCH_VALUE  */
       public static final String MISMATCH_VALUE_TEXT = "mismatch-value-text" + SEPARATOR;
   
  -    /** NEEDSDOC Field MISSING_TEST_VALUE          */
  +    /** MISSING_TEST_VALUE  */
       public static final String MISSING_TEST_VALUE = "missing-value-" + TEST
                                                           + SEPARATOR;
   
  -    /** NEEDSDOC Field MISSING_GOLD_VALUE          */
  +    /** MISSING_GOLD_VALUE  */
       public static final String MISSING_GOLD_VALUE = "missing-value-" + GOLD
                                                           + SEPARATOR;
   
  -    /** NEEDSDOC Field WHITESPACE_DIFF          */
  +    /** WHITESPACE_DIFF  */
       public static final String WHITESPACE_DIFF = "whitespace-diff;";
   
       /**
  @@ -201,18 +203,20 @@
        * @param reporter PrintWriter to dump status info to
        * @param array of warning flags (for whitespace diffs, I think?)
        * NEEDSDOC @param warning
  +     * @param attributes to attempt to set onto parsers
        * @return true if they match, false otherwise
        */
       public boolean compare(String goldFileName, String testFileName,
  -                           PrintWriter reporter, boolean[] warning)
  +                           PrintWriter reporter, boolean[] warning,
  +                           Hashtable attributes)
       {
   
           // parse the gold doc
  -        Document goldDoc = parse(goldFileName, reporter, GOLD);
  +        Document goldDoc = parse(goldFileName, reporter, GOLD, attributes);
   
           // parse the test doc only if gold doc was parsed OK
           Document testDoc = (null != goldDoc)
  -                           ? parse(testFileName, reporter, TEST) : null;
  +                           ? parse(testFileName, reporter, TEST, attributes) : null;
   
           if (null == goldDoc)
           {
  @@ -648,49 +652,48 @@
        *
        * NEEDSDOC (parse) @return
        */
  -    Document parse(String filename, PrintWriter reporter, String which)
  +    Document parse(String filename, PrintWriter reporter, String which, Hashtable attributes)
       {
           // Force filerefs to be URI's if needed: note this is independent of any other files
  -        // Remember: this only applies to the wacky Xerces parser, which we're presumably
  -        //  using as our default DOMParser() below
  -        String xercesFilename = filename;
  +        String docURI = filename;
           if (useURI)
           {
  -            try
  -            {
  +            // Use static worker method to get the correct format
  +            docURI = QetestUtils.filenameToURL(filename);
  +        }
   
  -                // Use static worker method to get the correct format
  -                // Note: this is copied straight from Xalan 1.x's org.apache.xalan.xslt.Process
  -                // TODO verify this is the most correct and simplest way to munge the filename
  -                xercesFilename = filenameToURL(filename);
  -            }
  -            catch (Exception e)
  +        // Use JAXP instead of Xerces-specific calls
  +        DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
  +        // Always set namespaces on
  +        dfactory.setNamespaceAware(true);
  +        // Set other attributes here as needed
  +        if (null != attributes)
  +        {
  +            Object tmp = attributes.get("setValidating");
  +            if (null != tmp)
               {
  -                reporter.print(WARNING + e.toString() + "\n");
  +                if (tmp instanceof Boolean)
  +                    dfactory.setValidating(((Boolean)tmp).booleanValue());
  +                else if (tmp instanceof String)
  +                    dfactory.setValidating(new Boolean((String)tmp).booleanValue());
               }
           }
   
           String parseType = which + PARSE_TYPE + "[xml];";
  -        // Use JAXP instead of Xerces-specific calls
  -        DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
  -        dfactory.setNamespaceAware(true);
           Document doc = null;
  -
           try
           {
  -            // Use the Xerces-munged name specifically here!
               DocumentBuilder docBuilder = dfactory.newDocumentBuilder();
  -            doc = docBuilder.parse(new InputSource(xercesFilename));
  +            doc = docBuilder.parse(new InputSource(docURI));
           }
           catch (Throwable se)
           {
  +            // We couldn't parse as XML, attempt parse as HTML
               reporter.println(WARNING + se.toString());
  -
               parseType = which + PARSE_TYPE + "[html];";
   
               try
               {
  -
                   // @todo need to find an HTML to DOM parser we can use!!!
                   // doc = someHTMLParser.parse(new InputSource(filename));
                   throw new RuntimeException("We need an HTML to DOM parser!");
  @@ -699,8 +702,8 @@
               {
                   try
                   {
  +                    // We couldn't parse as HTML, just compare as strings
                       reporter.println(WARNING + e.toString());
  -
                       parseType = which + PARSE_TYPE + "[text];";
   
                       // Parse as text, line by line
  @@ -749,20 +752,4 @@
           return doc;
       }  // end of parse()
   
  -    /**
  -     * Worker method to translate a String filename to URL.  
  -     * Note: This method is not necessarily proven to get the 
  -     * correct URL for every possible kind of filename.
  -     * @param String path\filename of test file
  -     * @return URL to pass to SystemId
  -     */
  -    public static String filenameToURL(String filename)
  -    {
  -        File f = new File(filename);
  -        String tmp = f.getAbsolutePath();
  -	    if (File.separatorChar == '\\') {
  -	        tmp = tmp.replace('\\', '/');
  -	    }
  -        return "file:///" + tmp;
  -    }
   }
  
  
  
  1.9       +93 -43    xml-xalan/test/java/src/org/apache/qetest/xsl/XHTFileCheckService.java
  
  Index: XHTFileCheckService.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/test/java/src/org/apache/qetest/xsl/XHTFileCheckService.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- XHTFileCheckService.java	2001/10/29 15:21:44	1.8
  +++ XHTFileCheckService.java	2001/11/02 15:04:03	1.9
  @@ -75,7 +75,7 @@
    * Uses an XML/HTML/Text diff comparator to check or diff two files.
    * @see #check(Logger logger, Object actual, Object reference, String msg, String id)
    * @author Shane_Curcuru@lotus.com
  - * @version $Id: XHTFileCheckService.java,v 1.8 2001/10/29 15:21:44 curcuru Exp $
  + * @version $Id: XHTFileCheckService.java,v 1.9 2001/11/02 15:04:03 curcuru Exp $
    */
   public class XHTFileCheckService implements CheckService
   {
  @@ -116,8 +116,8 @@
        * @param description of what you're checking
        * @param msg comment to log out with this test point
        * @param id ID tag to log out with this test point
  -     * @return Logger.*_RESULT code denoting status; each method may define
  -     * it's own meanings for pass, fail, ambiguous, etc.
  +     * @return Logger.*_RESULT code denoting status; each method may 
  +     * define it's own meanings for pass, fail, ambiguous, etc.
        */
       public int check(Logger logger, Object actual, Object reference,
                        String msg, String id)
  @@ -177,7 +177,7 @@
               // Note calling order (gold, act) is different than checkFiles()
               isEqual = comparator.compare(referenceFile.getCanonicalPath(),
                                            actualFile.getCanonicalPath(), pw,
  -                                         warning);
  +                                         warning, attributes);
               // Side effect: fills in pw/sw with info about the comparison
           }
           catch (Throwable t)
  @@ -205,7 +205,7 @@
               pw.flush();
               if (allowWhitespaceDiff)
               {
  -                logger.logMsg(Logger.TRACEMSG, "XHTFileCheckService whitespace diff warning, passing!");
  +                logger.logMsg(Logger.STATUSMSG, "XHTFileCheckService whitespace diff warning, passing!");
                   logger.checkPass(msg, id);
                   return Logger.PASS_RESULT;
               }
  @@ -279,8 +279,8 @@
        * @param reference (gold, or expected) File to check against
        * @param description of what you're checking
        * @param msg comment to log out with this test point
  -     * @return Logger.*_RESULT code denoting status; each method may define
  -     * it's own meanings for pass, fail, ambiguous, etc.
  +     * @return Logger.*_RESULT code denoting status; each method may 
  +     * define it's own meanings for pass, fail, ambiguous, etc.
        */
       public int check(Logger logger, Object actual, Object reference,
                        String msg)
  @@ -289,58 +289,108 @@
       }
   
       /**
  -     * Gets extended information about the last check call.
  -     * This info is filled in for every call to check() with brief
  -     * descriptions of what happened; will return 
  -     * <code>XHTFileCheckService-no-info-available</code> if 
  -     * check() has never been called.
  -     * @return String describing any additional info about the 
  -     * last two files that were checked
  -     */
  -    public String getExtendedInfo()
  -    {
  -
  -        if (sw != null)
  -            return sw.toString();
  -        else
  -            return "XHTFileCheckService-no-info-available";
  -    }
  -
  -    /**
  -     * Description of algorithim used to check file equivalence.  
  -     * @return basic description of how we compare files
  +     * Whether whitespace differences will cause a fail or not.  
        */
  -    public String getDescription()
  -    {
  -        return ("Uses an XML/HTML/Text diff comparator to check or diff two files.");
  -    }
  +    public static final String ALLOW_WHITESPACE_DIFF = "urn:XHTFileCheckService:allowWhitespaceDiff";
   
       /**
        * Whether whitespace differences will cause a fail or not.  
  -     * setFeature("allow-whitespace-diff", "true"|"false")
  +     * setAttribute("allow-whitespace-diff", true|false)
        * true=whitespace-only diff will pass;
        * false, whitespace-only diff will fail
        */
       protected boolean allowWhitespaceDiff = false;  // default; backwards compatible
   
       /**
  -     * Set a custom option or feature.  
  -     * @param feature name
  -     * @param feature value
  +     * Hash of parser-like attributes that have been set.  
  +     */
  +    protected Hashtable attributes = null;
  +
  +    /**
  +     * Allows the user to set specific attributes on the testing 
  +     * utility or it's underlying product object under test.
  +     * 
  +     * Supports basic JAXP DocumentBuilder attributes, plus our own 
  +     * "allow-whitespace-diff" attribute.
  +     * 
  +     * @param name The name of the attribute.
  +     * @param value The value of the attribute.
  +     * @throws IllegalArgumentException thrown if the underlying
  +     * implementation doesn't recognize the attribute and wants to 
  +     * inform the user of this fact.
        */
  -    public void setFeature(String name, String value)
  +    public void setAttribute(String name, Object value)
  +        throws IllegalArgumentException
       {
  -        if ("allow-whitespace-diff".equals(name))
  +        // Check for our own attributes first
  +        if (ALLOW_WHITESPACE_DIFF.equals(name))
           {
  -            if ("true".equals(value) || "yes".equals(value))
  -            {
  -                allowWhitespaceDiff = true;
  -            }
  -            else if ("false".equals(value) || "no".equals(value))
  +            //@todo set allowWhitespaceDiff based on value here
  +        }
  +        else
  +        {
  +            if (null == attributes)
               {
  -                allowWhitespaceDiff = false;
  +                attributes = new Hashtable();
               }
  +            attributes.put(name, value);
           }
       }
  +
  +    /**
  +     * Allows the user to retrieve specific attributes on the testing 
  +     * utility or it's underlying product object under test.
  +     *
  +     * @param name The name of the attribute.
  +     * @return value of supported attributes or null if not recognized.
  +     * @throws IllegalArgumentException thrown if the underlying
  +     * implementation doesn't recognize the attribute and wants to 
  +     * inform the user of this fact.
  +     */
  +    public Object getAttribute(String name)
  +        throws IllegalArgumentException
  +    {
  +        // Check for our own attributes first
  +        if (ALLOW_WHITESPACE_DIFF.equals(name))
  +        {
  +            return new Boolean(allowWhitespaceDiff);
  +            
  +        }
  +        else if (null != attributes)
  +        {
  +            return attributes.get(name);
  +        }
  +        else
  +            return null;
  +    }
  +
  +    /**
  +     * Description of what this testing utility does.  
  +     * 
  +     * @return String description of extension
  +     */
  +    public String getDescription()
  +    {
  +        return ("Uses an XML/HTML/Text diff comparator to check or diff two files.");
  +    }
  +
  +    /**
  +     * Gets extended information about the last check call.
  +     * This info is filled in for every call to check() with brief
  +     * descriptions of what happened; will return 
  +     * <code>XHTFileCheckService-no-info-available</code> if 
  +     * check() has never been called.
  +     * @return String describing any additional info about the 
  +     * last two files that were checked
  +     */
  +    public String getExtendedInfo()
  +    {
  +
  +        if (sw != null)
  +            return sw.toString();
  +        else
  +            return "XHTFileCheckService-no-info-available";
  +    }
  +
   }  // end of class XHTFileCheckService
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org