public abstract class BaseTestCase extends TestCase implements TemplateTestBase
| Modifier and Type | Field and Description |
|---|---|
protected VelocityContext |
context |
protected boolean |
DEBUG |
protected VelocityEngine |
engine |
protected TestLogChute |
log |
protected String |
stringRepoName |
CMP_FILE_EXT, COMPARE_DIR, FILE_RESOURCE_LOADER_PATH, RESULT_DIR, RESULT_FILE_EXT, TEST_CASE_PROPERTIES, TEST_COMPARE_DIR, TEST_RESULT_DIR, TMPL_FILE_EXT| Constructor and Description |
|---|
BaseTestCase(String name) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addTemplate(String name,
String template) |
protected void |
assertContextValue(String key,
Object expected)
Ensure that a context value is as expected.
|
protected void |
assertEvalEquals(String expected,
String template)
Ensure that a template renders as expected.
|
protected Exception |
assertEvalException(String evil)
Ensure that an exception occurs when the string is evaluated.
|
protected Exception |
assertEvalException(String evil,
Class exceptionType)
Ensure that a specified type of exception occurs when evaluating the string.
|
protected Exception |
assertEvalExceptionAt(String evil,
int line,
int col)
Only ensure that the error message of the expected exception
has the proper line and column info.
|
protected Exception |
assertEvalExceptionAt(String evil,
String template,
int line,
int col)
Ensure that the error message of the expected exception has the proper location info.
|
protected void |
assertSchmoo(String templateIsExpected)
Ensure that the given string renders as itself when evaluated.
|
protected void |
assertTmplEquals(String expected,
String template)
Compare an expected string with the given loaded template
|
protected void |
assureResultsDirectoryExists(String resultsDirectory)
Assures that the results directory exists.
|
protected String |
evaluate(String template)
Evaluate the specified String as a template and return the result as a String.
|
protected String |
getFileContents(String dir,
String baseFileName,
String ext) |
protected String |
getFileName(String dir,
String base,
String ext)
Concatenates the file name parts together appropriately.
|
protected String |
getFileName(String dir,
String base,
String ext,
boolean mustExist) |
protected StringResourceRepository |
getStringRepository() |
protected static String |
getTestCaseName(String s)
Turns a base file name into a test case name.
|
protected void |
info(String msg) |
protected void |
info(String msg,
Throwable t) |
protected boolean |
isMatch(String result,
String compareDir,
String baseFileName,
String compareExt)
Returns whether the processed template matches the
content of the provided comparison file.
|
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.
|
protected void |
removeTemplate(String name) |
protected void |
setUp() |
protected void |
setUpContext(VelocityContext context) |
protected void |
setUpEngine(VelocityEngine engine) |
void |
tearDown() |
void |
testBase() |
countTestCases, createResult, getName, run, run, runBare, runTest, setName, toStringassertEquals, 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, failNotEquals, failNotSame, failSame, formatprotected VelocityEngine engine
protected VelocityContext context
protected boolean DEBUG
protected TestLogChute log
protected String stringRepoName
public BaseTestCase(String name)
protected void setUpEngine(VelocityEngine engine)
protected void setUpContext(VelocityContext context)
protected StringResourceRepository getStringRepository()
protected void addTemplate(String name, String template)
protected void removeTemplate(String name)
public void testBase()
protected void assertTmplEquals(String expected, String template)
protected void assertContextValue(String key, Object expected)
protected void assertEvalEquals(String expected, String template)
protected void assertSchmoo(String templateIsExpected)
protected Exception assertEvalException(String evil)
protected Exception assertEvalException(String evil, Class exceptionType)
protected Exception assertEvalExceptionAt(String evil, String template, int line, int col)
protected Exception assertEvalExceptionAt(String evil, int line, int col)
protected String evaluate(String template)
protected String getFileName(String dir, String base, String ext)
protected String getFileName(String dir, String base, String ext, boolean mustExist)
protected void assureResultsDirectoryExists(String resultsDirectory)
protected String normalizeNewlines(String source)
protected boolean isMatch(String resultsDir, String compareDir, String baseFileName, String resultExt, String compareExt) throws Exception
Exception - Test failure condition.protected String getFileContents(String dir, String baseFileName, String ext)
protected boolean isMatch(String result, String compareDir, String baseFileName, String compareExt) throws Exception
Exception - Test failure condition.protected static final String getTestCaseName(String s)
s - The base file name.