org.apache.velocity.test
Class BaseTestCase

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.apache.velocity.test.BaseTestCase
All Implemented Interfaces:
junit.framework.Test
Direct Known Subclasses:
AnakiaTestCase, ClasspathResourceTest, CommonsExtPropTestCase, ConfigurationTestCase, ContextSafetyTestCase, EncodingTestCase, InlineScopeVMTestCase, IntrospectorTestCase, IntrospectorTestCase2, IntrospectorTestCase3, MiscTestCase, MultiLoaderTestCase, MultipleFileResourcePathTest, ResourceLoaderInstanceTest, TemplateTestCase, TexenClasspathTestCase, TexenTestCase, VelocityAppTestCase

public class BaseTestCase
extends junit.framework.TestCase

Base test case that provides a few utility methods for the rest of the tests.

Version:
$Id: BaseTestCase.java 191743 2005-06-21 23:22:20Z dlr $
Author:
Daniel Rall

Constructor Summary
BaseTestCase(String name)
          Default constructor.
 
Method Summary
protected static void assureResultsDirectoryExists(String resultsDirectory)
          Assures that the results directory exists.
protected static String getFileName(String dir, String base, String ext)
          Concatenates the file name parts together appropriately.
protected static String getTestCaseName(String s)
          Turns a base file name into a test case name.
protected  boolean isMatch(String resultsDir, String compareDir, String baseFileName, String resultExt, String compareExt)
          Returns whether the processed template matches the content of the provided comparison file.
protected  String normalizeNewlines(String source)
          Normalizes lines to account for platform differences.
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, setUp, tearDown, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BaseTestCase

public BaseTestCase(String name)
Default constructor.

Method Detail

getFileName

protected static String getFileName(String dir,
                                    String base,
                                    String ext)
Concatenates the file name parts together appropriately.

Returns:
The full path to the file.

assureResultsDirectoryExists

protected static void assureResultsDirectoryExists(String resultsDirectory)
Assures that the results directory exists. If the results directory cannot be created, fails the test.


normalizeNewlines

protected String normalizeNewlines(String source)
Normalizes lines to account for platform differences. Macs use a single \r, DOS derived operating systems use \r\n, and Unix uses \n. Replace each with a single \n.

Returns:
source with all line terminations changed to Unix style

isMatch

protected boolean isMatch(String resultsDir,
                          String compareDir,
                          String baseFileName,
                          String resultExt,
                          String compareExt)
                   throws Exception
Returns whether the processed template matches the content of the provided comparison file.

Returns:
Whether the output matches the contents of the comparison file.
Throws:
Exception - Test failure condition.

getTestCaseName

protected static final String getTestCaseName(String s)
Turns a base file name into a test case name.

Parameters:
s - The base file name.
Returns:
The test case name.


Copyright © 2002 Apache Software Foundation. All Rights Reserved.