Methods Summary |
---|
private void | expectFileContains(java.lang.String target, java.lang.String filename, java.lang.String contains)
String content = getFileString(target, filename);
assertTrue(
"expecting file " + filename + " to contain " +
contains +
" but got " + content, content.indexOf(contains) > -1);
|
private java.lang.String | getFileString(java.lang.String filename)
Reader r = null;
try {
r = new FileReader(getProject().resolveFile(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);
|
public void | setUp()Test set up, called by the unit test framework prior to each
test.
configureProject("src/etc/testcases/taskdefs/concat.xml");
|
public void | tearDown()Test tear down, called by the unit test framework prior to each
test.
executeTarget("cleanup");
|
public void | test1()Expect an exception when insufficient information is provided.
expectBuildException("test1", "Insufficient information.");
|
public void | test2()Expect an exception when the destination file is invalid.
expectBuildException("test2", "Invalid destination file.");
|
public void | test3()Cats the string 'Hello, World!' to a temporary file.
File file = new File(getProjectDir(), tempFile);
if (file.exists()) {
file.delete();
}
executeTarget("test3");
assertTrue(file.exists());
|
public void | test4()Cats the file created in test3 three times.
test3();
File file = new File(getProjectDir(), tempFile);
final long origSize = file.length();
executeTarget("test4");
File file2 = new File(getProjectDir(), tempFile2);
final long newSize = file2.length();
assertEquals(origSize * 3, newSize);
|
public void | test5()Cats the string 'Hello, World!' to the console.
expectLog("test5", "Hello, World!");
|
public void | test6()
String filename = "src/etc/testcases/taskdefs/thisfiledoesnotexist"
.replace('/", File.separatorChar);
expectLogContaining("test6", filename +" does not exist.");
|
public void | testAppend()
test3();
File file = new File(getProjectDir(), tempFile);
final long origSize = file.length();
executeTarget("testAppend");
File file2 = new File(getProjectDir(), tempFile2);
final long newSize = file2.length();
assertEquals(origSize*2, newSize);
|
public void | testConcatNoNewline()
expectLog("testConcatNoNewline", "ab");
|
public void | testConcatNoNewlineEncoding()
expectLog("testConcatNoNewlineEncoding", "ab");
|
public void | testFilter()
executeTarget("testfilter");
assertTrue(getLog().indexOf("REPLACED") > -1);
|
public void | testNoOverwrite()
executeTarget("testnooverwrite");
File file2 = new File(getProjectDir(), tempFile2);
long size = file2.length();
assertEquals(size, 0);
|
public void | testPath()
test3();
File file = new File(getProjectDir(), tempFile);
final long origSize = file.length();
executeTarget("testPath");
File file2 = new File(getProjectDir(), tempFile2);
final long newSize = file2.length();
assertEquals(origSize, newSize);
|
public void | testResources()
executeTarget("testResources");
|
public void | testTranscoding()
executeTarget("testTranscoding");
File f1 = getProject().resolveFile("copy/expected/utf-8");
File f2 = getProject().resolveFile("concat.utf8");
assertTrue(FILE_UTILS.contentEquals(f1, f2));
|
public void | testfileheader()
test3();
expectLog("testfileheader", "Hello, World!Hello, World!");
|
public void | testfilterinline()Check if filter inline works
executeTarget("testfilterinline");
assertTrue(getLog().indexOf("REPLACED") > -1);
|
public void | testfixlastline()Check if fixlastline works
expectFileContains(
"testfixlastline", "concat.line4",
"end of line" + System.getProperty("line.separator")
+ "This has");
|
public void | testfixlastlineeol()Check if fixlastline works with eol
expectFileContains(
"testfixlastlineeol", "concat.linecr",
"end of line\rThis has");
|
public void | testheaderfooter()
test3();
expectLog("testheaderfooter", "headerHello, World!footer");
|
public void | testmultireader()Check if multireader works
executeTarget("testmultireader");
assertTrue(getLog().indexOf("Bye") > -1);
assertTrue(getLog().indexOf("Hello") == -1);
|
public void | testsame()Expect an exception when attempting to cat an file to itself
expectBuildException("samefile", "output file same as input");
|