executeTarget("realTest");
// doesn't work: Depending on the compression engine used,
// compressed bytes may differ. False errors would be
// reported.
// assertTrue("File content mismatch",
// FILE_UTILS.contentEquals(project.resolveFile("expected/asf-logo-huge.tar.bz2"),
// project.resolveFile("asf-logo-huge.tar.bz2")));
// We have to compare the decompressed content instead:
File originalFile =
project.resolveFile("expected/asf-logo-huge.tar.bz2");
File actualFile = project.resolveFile("asf-logo-huge.tar.bz2");
InputStream originalIn =
new BufferedInputStream(new FileInputStream(originalFile));
assertEquals((byte) 'B", originalIn.read());
assertEquals((byte) 'Z", originalIn.read());
InputStream actualIn =
new BufferedInputStream(new FileInputStream(actualFile));
assertEquals((byte) 'B", actualIn.read());
assertEquals((byte) 'Z", actualIn.read());
originalIn = new CBZip2InputStream(originalIn);
actualIn = new CBZip2InputStream(actualIn);
while (true) {
int expected = originalIn.read();
int actual = actualIn.read();
if (expected >= 0) {
if (expected != actual) {
fail("File content mismatch");
}
} else {
if (actual >= 0) {
fail("File content mismatch");
}
break;
}
}
originalIn.close();
actualIn.close();