org.apache.velocity.test

Class BaseTestCase

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
Perl5Utilperl
used for nomalization of output and compare data
Constructor Summary
BaseTestCase(String name)
Default constructor.
Method Summary
protected static voidassureResultsDirectoryExists(String resultsDirectory)
Assures that the results directory exists.
protected static StringgetFileName(String dir, String base, String ext)
Concatenates the file name parts together appropriately.
protected static StringgetTestCaseName(String s)
Turns a base file name into a test case name.
protected booleanisMatch(String resultsDir, String compareDir, String baseFileName, String resultExt, String compareExt)
Returns whether the processed template matches the content of the provided comparison file.
protected StringnormalizeNewlines(String source)
Normalizes lines to account for platform differences.

Field Detail

perl

private Perl5Util perl
used for nomalization of output and compare data

Constructor Detail

BaseTestCase

public BaseTestCase(String name)
Default constructor.

Method Detail

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)
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.

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.