curcuru     01/02/08 16:35:06

  Modified:    test/java/src/org/apache/qetest CheckService.java
                        SimpleFileCheckService.java
               test/java/src/org/apache/qetest/xsl XHTFileCheckService.java
  Log:
  Change Reporter args to Logger since we don't need the extra functionality; 
makes Testlets easier
  
  Revision  Changes    Path
  1.3       +11 -9     
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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- CheckService.java 2000/12/01 22:18:20     1.2
  +++ CheckService.java 2001/02/09 00:35:00     1.3
  @@ -2,7 +2,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 2000 The Apache Software Foundation.  All rights 
  + * Copyright (c) 2000, 2001 The Apache Software Foundation.  All rights 
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -67,7 +67,7 @@
    * Implementers provide their own algorithims for determining
    * equivalence.
    * @author [EMAIL PROTECTED]
  - * @version $Id: CheckService.java,v 1.2 2000/12/01 22:18:20 curcuru Exp $
  + * @version $Id: CheckService.java,v 1.3 2001/02/09 00:35:00 curcuru Exp $
    */
   public interface CheckService
   {
  @@ -75,8 +75,10 @@
       /**
        * Compare two objects for equivalence, and return appropriate result.
        * Implementers should provide the details of their "equals"
  -     * algorithim in getCheckMethod().
  -     * Note that the order of actual, reference is usually important
  +     * algorithim in getCheckMethod().  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:
        * <ul>any unexpected Exceptions thrown -> ERRR_RESULT</ul>
  @@ -86,7 +88,7 @@
        * <ul>actual is not equivalent to reference -> FAIL_RESULT</ul>
        * </li>
        *
  -     * @param reporter to dump any output messages to
  +     * @param logger to dump any output messages to
        * @param actual (current) Object to check
        * @param reference (gold, or expected) Object to check against
        * @param description of what you're checking
  @@ -94,13 +96,13 @@
        * @return Reporter.*_RESULT code denoting status; each method may define
        * it's own meanings for pass, fail, ambiguous, etc.
        */
  -    public abstract int check(Reporter reporter, Object actual,
  +    public abstract int check(Logger logger, Object actual,
                                 Object reference, String msg);
   
       /**
        * Compare two objects for equivalence, and return appropriate result.
        *
  -     * @param reporter to dump any output messages to
  +     * @param logger to dump any output messages to
        * @param actual (current) Object to check
        * @param reference (gold, or expected) Object to check against
        * @param description of what you're checking
  @@ -109,13 +111,13 @@
        * @return Reporter.*_RESULT code denoting status; each method may define
        * it's own meanings for pass, fail, ambiguous, etc.
        */
  -    public abstract int check(Reporter reporter, Object actual,
  +    public abstract int check(Logger logger, Object actual,
                                 Object reference, String msg, String id);
   
       /**
        * Description of algorithim used to check equivalence.  
        *
  -     * NEEDSDOC ($objectName$) @return
  +     * @return String describing algorithim
        */
       public abstract String getDescription();
   
  
  
  
  1.4       +35 -45    
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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SimpleFileCheckService.java       2000/12/05 18:44:14     1.3
  +++ SimpleFileCheckService.java       2001/02/09 00:35:03     1.4
  @@ -2,7 +2,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 2000 The Apache Software Foundation.  All rights 
  + * Copyright (c) 2000, 2001 The Apache Software Foundation.  All rights 
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -69,36 +69,24 @@
   /**
    * Simply does .readLine of each file into string buffers and then 
String.equals().
    * @author [EMAIL PROTECTED]
  - * @version $Id: SimpleFileCheckService.java,v 1.3 2000/12/05 18:44:14 
curcuru Exp $
  + * @version $Id: SimpleFileCheckService.java,v 1.4 2001/02/09 00:35:03 
curcuru Exp $
    */
   public class SimpleFileCheckService implements CheckService
   {
   
       /**
        * Compare two objects for equivalence, and return appropriate result.
  -     * Implementers should provide the details of their "equals"
  -     * algorithim in getCheckMethod().
  -     * Note that the order of actual, reference is usually important
  -     * important in determining the result.
  -     * <li>Typically:
  -     * <ul>any unexpected Exceptions thrown -> ERRR_RESULT</ul>
  -     * <ul>either object is not a File -> ERRR_RESULT</ul>
  -     * <ul>actual does not exist -> FAIL_RESULT</ul>
  -     * <ul>reference does not exist -> AMBG_RESULT</ul>
  -     * <ul>actual is equivalent to reference -> PASS_RESULT</ul>
  -     * <ul>actual is not equivalent to reference -> FAIL_RESULT</ul>
  -     * </li>
        *
  -     * @param reporter to dump any output messages to
  +     * @param logger to dump any output messages to
        * @param actual (current) File to check
        * @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
        * @param id ID tag to log out with this test point
  -     * @return Reporter.*_RESULT code denoting status; each method may define
  +     * @return Logger.*_RESULT code denoting status; each method may define
        * it's own meanings for pass, fail, ambiguous, etc.
        */
  -    public int check(Reporter reporter, Object actual, Object reference,
  +    public int check(Logger logger, Object actual, Object reference,
                        String msg, String id)
       {
   
  @@ -106,96 +94,97 @@
           {
   
               // Must have File objects to continue
  -            reporter.checkErr(
  +            logger.checkErr(
                   "SimpleFileCheckService only takes files, with: " + msg, id);
   
  -            return reporter.ERRR_RESULT;
  +            return Logger.ERRR_RESULT;
           }
   
  -        String fVal1 = readFileIntoString(reporter, (File) actual);
  +        String fVal1 = readFileIntoString(logger, (File) actual);
   
           // Fail if Actual file doesn't exist
           if (fVal1 == null)
           {
  -            reporter.checkFail(msg, id);
  +            logger.checkFail(msg, id);
   
  -            return Reporter.FAIL_RESULT;
  +            return Logger.FAIL_RESULT;
           }
   
  -        String fVal2 = readFileIntoString(reporter, (File) reference);
  +        String fVal2 = readFileIntoString(logger, (File) reference);
   
           // Ambiguous if gold or reference file doesn't exist
           if (fVal2 == null)
           {
  -            reporter.checkAmbiguous(msg, id);
  +            logger.checkAmbiguous(msg, id);
   
  -            return Reporter.AMBG_RESULT;
  +            return Logger.AMBG_RESULT;
           }
   
           // Pass if they're equal, fail otherwise        
           if (fVal1.equals(fVal2))
           {
  -            reporter.checkPass(msg, id);
  +            logger.checkPass(msg, id);
   
  -            return Reporter.PASS_RESULT;
  +            return Logger.PASS_RESULT;
           }
           else
           {
  -            reporter.checkFail(msg, id);
  +            logger.checkFail(msg, id);
   
  -            return Reporter.FAIL_RESULT;
  +            return Logger.FAIL_RESULT;
           }
       }
   
       /**
        * Compare two objects for equivalence, and return appropriate result.
        *
  -     * @param reporter to dump any output messages to
  +     * @param logger to dump any output messages to
        * @param actual (current) File to check
        * @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 Reporter.*_RESULT code denoting status; each method may define
  +     * @return Logger.*_RESULT code denoting status; each method may define
        * it's own meanings for pass, fail, ambiguous, etc.
        */
  -    public int check(Reporter reporter, Object actual, Object reference,
  +    public int check(Logger logger, Object actual, Object reference,
                        String msg)
       {
  -        return check(reporter, actual, reference, msg, null);
  +        return check(logger, actual, reference, msg, null);
       }
   
       /**
        * Compare two files for equivalence, and return appropriate *_RESULT 
flag.
  -     * <p>Uses appropriate values from Reporter for return values.</p>
  +     * <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(Reporter reporter, File file1, File file2)
  +    public int checkFiles(Logger logger, File file1, File file2)
       {
   
  -        String fVal1 = readFileIntoString(reporter, file1);
  +        String fVal1 = readFileIntoString(logger, file1);
   
           // Fail if Actual file doesn't exist
           if (fVal1 == null)
  -            return (Reporter.FAIL_RESULT);
  +            return Logger.FAIL_RESULT;
   
  -        String fVal2 = readFileIntoString(reporter, file2);
  +        String fVal2 = readFileIntoString(logger, file2);
   
           // Ambiguous if gold or reference file doesn't exist
           if (fVal2 == null)
  -            return (Reporter.AMBG_RESULT);
  +            return Logger.AMBG_RESULT;
   
           // Pass if they're equal, fail otherwise        
           if (fVal1.equals(fVal2))
  -            return (Reporter.PASS_RESULT);
  +            return Logger.PASS_RESULT;
           else
  -            return (Reporter.FAIL_RESULT);
  +            return Logger.FAIL_RESULT;
       }
   
       /**
        * Compare two files for equivalence, and return appropriate *_RESULT 
flag.
  -     * For backwards compatibility.
  +     * <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
  @@ -208,10 +197,11 @@
   
       /**
        * Read text file into string line-by-line.  
  +     * @param logger to dump any messages to
        * @param f File object to read
        * @return String of file's contents
        */
  -    private String readFileIntoString(Reporter reporter, File f)
  +    private String readFileIntoString(Logger logger, File f)
       {
   
           StringBuffer sb = new StringBuffer();
  @@ -233,9 +223,9 @@
           }
           catch (Exception e)
           {
  -            if (reporter != null)
  +            if (logger != null)
               {
  -                reporter.logErrorMsg("SimpleFileCheckService(" + f.getPath()
  +                logger.logMsg(Logger.ERRORMSG, "SimpleFileCheckService(" + 
f.getPath()
                                        + ") threw:" + e.toString());
               }
               else
  
  
  
  1.5       +27 -27    
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.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- XHTFileCheckService.java  2001/02/05 16:50:54     1.4
  +++ XHTFileCheckService.java  2001/02/09 00:35:05     1.5
  @@ -2,7 +2,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 2000 The Apache Software Foundation.  All rights 
  + * Copyright (c) 2000, 2001 The Apache Software Foundation.  All rights 
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -72,9 +72,9 @@
   
   /**
    * Uses an XML/HTML/Text diff comparator to check or diff two files.
  - * @see #check(Reporter reporter, Object actual, Object reference, String 
msg, String id)
  + * @see #check(Logger logger, Object actual, Object reference, String msg, 
String id)
    * @author [EMAIL PROTECTED]
  - * @version $Id: XHTFileCheckService.java,v 1.4 2001/02/05 16:50:54 curcuru 
Exp $
  + * @version $Id: XHTFileCheckService.java,v 1.5 2001/02/09 00:35:05 curcuru 
Exp $
    */
   public class XHTFileCheckService implements CheckService
   {
  @@ -109,16 +109,16 @@
        * returned from getExtendedInfo() - this happens no matter what 
        * the result of the check() call was.
        *
  -     * @param reporter to dump any output messages to
  +     * @param logger to dump any output messages to
        * @param actual (current) Object to check
        * @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
        * @param id ID tag to log out with this test point
  -     * @return Reporter.*_RESULT code denoting status; each method may define
  +     * @return Logger.*_RESULT code denoting status; each method may define
        * it's own meanings for pass, fail, ambiguous, etc.
        */
  -    public int check(Reporter reporter, Object actual, Object reference,
  +    public int check(Logger logger, Object actual, Object reference,
                        String msg, String id)
       {
           // Create our 'extended info' stuff now, so it will 
  @@ -130,13 +130,13 @@
           {
   
               // Must have File objects to continue
  -            reporter.checkErr("XHTFileCheckService only takes files, with: "
  +            logger.checkErr("XHTFileCheckService only takes files, with: "
                                 + msg, id);
               pw.println("XHTFileCheckService only takes files, with: " + msg);
               pw.println("   actual: " + actual);
               pw.println("reference: " + reference);
               pw.flush();
  -            return reporter.ERRR_RESULT;
  +            return logger.ERRR_RESULT;
           }
   
           File actualFile = (File) actual;
  @@ -145,19 +145,19 @@
           // Fail if Actual file doesn't exist or is 0 len
           if ((!actualFile.exists()) || (actualFile.length() == 0))
           {
  -            reporter.checkFail(msg, id);
  +            logger.checkFail(msg, id);
               pw.println("actual(" + actualFile.toString() + ") did not exist 
or was 0 len");
               pw.flush();
  -            return reporter.FAIL_RESULT;
  +            return logger.FAIL_RESULT;
           }
   
           // Ambiguous if gold file doesn't exist or is 0 len
           if ((!referenceFile.exists()) || (referenceFile.length() == 0))
           {
  -            reporter.checkAmbiguous(msg, id);
  +            logger.checkAmbiguous(msg, id);
               pw.println("reference(" + referenceFile.toString() + ") did not 
exist or was 0 len");
               pw.flush();
  -            return Reporter.AMBG_RESULT;
  +            return Logger.AMBG_RESULT;
           }
   
           boolean warning[] = new boolean[1];  // TODO: should use this!
  @@ -185,11 +185,11 @@
           if (!isEqual)
           {
               // We fail, obviously!
  -            reporter.checkFail(msg, id);
  +            logger.checkFail(msg, id);
               pw.println("XHTFileCheckService files were not equal");
               pw.flush();
   
  -            return Reporter.FAIL_RESULT;
  +            return Logger.FAIL_RESULT;
           }
           else if (warning[0])
           {
  @@ -197,43 +197,43 @@
               pw.flush();
               if (allowWhitespaceDiff)
               {
  -                reporter.logMsg(Logger.TRACEMSG, "XHTFileCheckService 
whitespace diff warning, passing!");
  -                reporter.checkPass(msg, id);
  -                return Reporter.PASS_RESULT;
  +                logger.logMsg(Logger.TRACEMSG, "XHTFileCheckService 
whitespace diff warning, passing!");
  +                logger.checkPass(msg, id);
  +                return Logger.PASS_RESULT;
               }
               else
               {
  -                reporter.logMsg(Logger.TRACEMSG, "XHTFileCheckService 
whitespace diff warning, failing!");
  -                reporter.checkFail(msg, id);
  -                return Reporter.FAIL_RESULT;
  +                logger.logMsg(Logger.TRACEMSG, "XHTFileCheckService 
whitespace diff warning, failing!");
  +                logger.checkFail(msg, id);
  +                return Logger.FAIL_RESULT;
               }
           }
           else
           {
  -            reporter.checkPass(msg, id);
  +            logger.checkPass(msg, id);
               pw.println("XHTFileCheckService files were equal");
               pw.flush();
   
  -            return Reporter.PASS_RESULT;
  +            return Logger.PASS_RESULT;
           }
       }
   
       /**
        * Compare two objects for equivalence, and return appropriate result.
        *
  -     * @see #check(Reporter reporter, Object actual, Object reference, 
String msg, String id)
  -     * @param reporter to dump any output messages to
  +     * @see #check(Logger logger, Object actual, Object reference, String 
msg, String id)
  +     * @param logger to dump any output messages to
        * @param actual (current) File to check
        * @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 Reporter.*_RESULT code denoting status; each method may define
  +     * @return Logger.*_RESULT code denoting status; each method may define
        * it's own meanings for pass, fail, ambiguous, etc.
        */
  -    public int check(Reporter reporter, Object actual, Object reference,
  +    public int check(Logger logger, Object actual, Object reference,
                        String msg)
       {
  -        return check(reporter, actual, reference, msg, null);
  +        return check(logger, actual, reference, msg, null);
       }
   
       /**
  
  
  

Reply via email to