org.apache.velocity.test

Class BaseTestCase

Known Direct Subclasses:
AnakiaTestCase, ClasspathResourceTest, CommonsExtPropTestCase, ConfigurationTestCase, ContextSafetyTestCase, EncodingTestCase, InlineScopeVMTestCase, IntrospectorTestCase, IntrospectorTestCase2, IntrospectorTestCase3, MiscTestCase, MultiLoaderTestCase, MultipleFileResourcePathTest, TemplateTestCase, TexenClasspathTestCase, TexenTestCase, VelocityAppTestCase

public class BaseTestCase
extends TestCase

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

Version:
$Id: BaseTestCase.java,v 1.12.4.1 2004/03/03 23:23:04 geirm Exp $

Author:
Daniel Rall

Field Summary

private Perl5Util
perl
used for nomalization of output and compare data

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.

Field Details

perl

private Perl5Util perl
used for nomalization of output and compare data

Constructor Details

BaseTestCase

public BaseTestCase(String name)
Default constructor.

Method Details

assureResultsDirectoryExists

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


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.


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.


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.


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

Author:
Sam Ruby


Copyright B) 2002 Apache Software Foundation. All Rights Reserved.