jvanzyl     00/10/23 18:43:34

  Modified:    src/java/org/apache/velocity/test TemplateTestCase.java
  Log:
  - added isMatch() body using a simple String.equals(). We can get
    more sophisticated later, this will detect errors for now.
  
  - added closeWriter() after the template is merged so that
    the file could be opened again by isMatch(). commented
    out closeWriter() in the tearDown().
  
  Revision  Changes    Path
  1.7       +20 -3     
jakarta-velocity/src/java/org/apache/velocity/test/TemplateTestCase.java
  
  Index: TemplateTestCase.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/test/TemplateTestCase.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- TemplateTestCase.java     2000/10/23 22:19:37     1.6
  +++ TemplateTestCase.java     2000/10/24 01:43:33     1.7
  @@ -65,12 +65,15 @@
   import org.apache.velocity.test.provider.TestProvider;
   import org.apache.velocity.runtime.Runtime;
   import org.apache.velocity.io.FastWriter;
  +import org.apache.velocity.util.StringUtils;
   
  +
   /**
    * Easily add test cases which evaluate templates and check their output.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]">Daniel Rall</a>
  - * @version $Id: TemplateTestCase.java,v 1.6 2000/10/23 22:19:37 dlr Exp $
  + * @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
  + * @version $Id: TemplateTestCase.java,v 1.7 2000/10/24 01:43:33 jvanzyl Exp $
    */
   public class TemplateTestCase extends BaseTestCase
   {
  @@ -95,6 +98,11 @@
       private static final String RESULT_DIR = "../test/templates/results/";
   
       /**
  +     * Results relative to the build directory.
  +     */
  +    private static final String COMPARE_DIR = "../test/templates/compare/";
  +
  +    /**
        * The base file name of the template and comparison file (i.e. array for 
        * array.vm and array.cmp).
        */
  @@ -158,6 +166,8 @@
                   new FileOutputStream(
                       RESULT_DIR + baseFileName + "." + RESULT_FILE_EXT)));
               
  +            closeWriter();
  +            
               if (!isMatch())
               {
                   fail("Processed template did not match expected output");
  @@ -203,8 +213,13 @@
        */
       protected boolean isMatch () throws Exception
       {
  -        // TODO: Implement matching.
  -        return true;
  +        String result = StringUtils.fileContentsToString(
  +            RESULT_DIR + baseFileName + "." + RESULT_FILE_EXT);
  +            
  +        String compare = StringUtils.fileContentsToString(
  +            COMPARE_DIR + baseFileName + "." + CMP_FILE_EXT);
  +
  +        return result.equals(compare);
       }
   
       /**
  @@ -212,6 +227,7 @@
        */
       protected void tearDown ()
       {
  +        /*
           try
           {
               closeWriter();
  @@ -220,6 +236,7 @@
           {
               fail(e.getMessage());
           }
  +        */
       }
   
       /**
  
  
  

Reply via email to