Methods Summary |
---|
private void | assertStringContains(java.lang.String string, java.lang.String contains)
assertTrue("[" + string + "] does not contain [" + contains +"]",
string.indexOf(contains) > -1);
|
private void | assertStringNotContains(java.lang.String string, java.lang.String contains)
assertTrue("[" + string + "] does contain [" + contains +"]",
string.indexOf(contains) == -1);
|
private void | expectFileContains(java.lang.String name, java.lang.String contains)
String content = getFileString(name);
assertTrue(
"expecting file " + name + " to contain " + contains +
" but got " + content, content.indexOf(contains) > -1);
|
private void | expectFileContains(java.lang.String target, java.lang.String name, java.lang.String contains)
executeTarget(target);
expectFileContains(name, contains);
|
private java.lang.String | getFileString(java.lang.String filename)
Reader r = null;
try {
r = new FileReader(FILE_UTILS.resolveFile(getProject().getBaseDir(),filename));
return FileUtils.readFully(r);
}
finally {
FileUtils.close(r);
}
|
private java.lang.String | getFileString(java.lang.String target, java.lang.String filename)
executeTarget(target);
return getFileString(filename);
|
private boolean | hasRegex(java.lang.String test)
try {
executeTarget("hasregex");
expectFileContains("result/replaceregexp", "bye world");
}
catch (Throwable ex) {
System.out.println(test + ": skipped - regex not present "
+ ex);
return false;
}
return true;
|
private boolean | hasScript(java.lang.String test)
try {
executeTarget("hasscript");
}
catch (Throwable ex) {
System.out.println(
test + ": skipped - script not present ");
return false;
}
return true;
|
public void | setUp()
configureProject("src/etc/testcases/filters/tokenfilter.xml");
executeTarget("init");
|
public void | tearDown()
executeTarget("cleanup");
|
public void | testContainsRegex()
if (! hasRegex("testContainsRegex"))
return;
String contents = getFileString(
"containsregex", "result/containsregex");
assertStringContains(contents, "hello world");
assertStringNotContains(contents, "this is the moon");
assertStringContains(contents, "World here");
|
public void | testContainsRegex2()
if (! hasRegex("testContainsRegex2"))
return;
String contents = getFileString(
"containsregex2", "result/containsregex2");
assertStringContains(contents, "void register_bits();");
|
public void | testContainsString()
String contents = getFileString(
"containsstring", "result/containsstring");
assertStringContains(contents, "this is a line contains foo");
assertStringNotContains(contents, "this line does not");
|
public void | testCustomTokenFilter()
expectFileContains("customtokenfilter", "result/custom",
"Hello World");
|
public void | testDeleteCharacters()
String contents = getFileString(
"deletecharacters", "result/deletechars");
assertStringNotContains(contents, "#");
assertStringNotContains(contents, "*");
assertStringContains(contents, "This is some ");
|
public void | testDosLineOutput()
expectFileContains(
"doslineoutput", "result/doslineoutput",
"\r\nThis\r\nis\r\na\r\nnumber\r\nof\r\nwords\r\n");
|
public void | testFileTokenizer()
String contents = getFileString(
"filetokenizer", "result/filetokenizer");
assertStringContains(contents, " of words");
assertStringNotContains(contents, " This is");
|
public void | testFilterContainsRegex()
if (! hasRegex("testFilterContainsRegex"))
return;
String contents = getFileString(
"filtercontainsregex", "result/filtercontainsregex");
assertStringContains(contents, "hello world");
assertStringNotContains(contents, "this is the moon");
assertStringContains(contents, "World here");
|
public void | testFilterReplaceRegex()
if (! hasRegex("testFilterReplaceRegex"))
return;
String contents = getFileString(
"filterreplaceregex", "result/filterreplaceregex");
assertStringContains(contents, "world world world world");
|
public void | testFilterReplaceString()
String contents = getFileString(
"filterreplacestring", "result/filterreplacestring");
assertStringContains(contents, "This is the moon");
|
public void | testFilterReplaceStrings()
expectLogContaining("filterreplacestrings", "bar bar bar");
|
public void | testHandleDollerMatch()
if (! hasRegex("testFilterReplaceRegex"))
return;
executeTarget("dollermatch");
|
public void | testReplaceRegex()
if (! hasRegex("testReplaceRegex"))
return;
String contents = getFileString(
"replaceregex", "result/replaceregex");
assertStringContains(contents, "world world world world");
assertStringContains(contents, "dog Cat dog");
assertStringContains(contents, "moon Sun Sun");
assertStringContains(contents, "found WhiteSpace");
assertStringContains(contents, "Found digits [1234]");
assertStringNotContains(contents, "This is a line with digits");
|
public void | testReplaceString()
expectFileContains(
"replacestring", "result/replacestring",
"this is the moon");
|
public void | testReplaceStrings()
expectLogContaining("replacestrings", "bar bar bar");
|
public void | testScriptFilter()
if (! hasScript("testScriptFilter"))
return;
expectFileContains("scriptfilter", "result/scriptfilter",
"HELLO WORLD");
|
public void | testScriptFilter2()
if (! hasScript("testScriptFilter"))
return;
expectFileContains("scriptfilter2", "result/scriptfilter2",
"HELLO MOON");
|
public void | testStringTokenizer()
expectLogContaining(
"stringtokenizer", "#This#is#a#number#of#words#");
|
public void | testTokenfilter()make sure tokenfilter exists
executeTarget("tokenfilter");
|
public void | testTrimFile()
String contents = getFileString(
"trimfile", "result/trimfile");
assertTrue("no ws at start", contents.startsWith("This is th"));
assertTrue("no ws at end", contents.endsWith("second line."));
assertStringContains(contents, " This is the second");
|
public void | testTrimFileByLine()
String contents = getFileString(
"trimfilebyline", "result/trimfilebyline");
assertFalse("no ws at start", contents.startsWith("This is th"));
assertFalse("no ws at end", contents.endsWith("second line."));
assertStringNotContains(contents, " This is the second");
assertStringContains(contents, "file.\nThis is the second");
|
public void | testTrimignore()
expectLogContaining("trimignore", "Hello-World");
|
public void | testUnixLineOutput()
expectFileContains(
"unixlineoutput", "result/unixlineoutput",
"\nThis\nis\na\nnumber\nof\nwords\n");
|