19
19
package org.apache.tools.ant.taskdefs;
21
import org.apache.tools.ant.BuildFileTest;
21
import org.apache.tools.ant.BuildFileRule;
22
22
import org.apache.tools.bzip2.CBZip2InputStream;
23
import org.junit.After;
24
import org.junit.Before;
25
import org.junit.Rule;
26
import org.junit.Test;
24
28
import java.io.BufferedInputStream;
25
29
import java.io.File;
26
30
import java.io.FileInputStream;
31
import java.io.IOException;
27
32
import java.io.InputStream;
28
import java.io.IOException;
34
import static org.junit.Assert.assertEquals;
35
import static org.junit.Assert.assertTrue;
36
import static org.junit.Assert.fail;
32
public class BZip2Test extends BuildFileTest {
34
public BZip2Test(String name) {
40
public class BZip2Test {
43
public BuildFileRule buildRule = new BuildFileRule();
38
46
public void setUp() {
39
configureProject("src/etc/testcases/taskdefs/bzip2.xml");
40
executeTarget("prepare");
47
buildRule.configureProject("src/etc/testcases/taskdefs/bzip2.xml");
48
buildRule.executeTarget("prepare");
43
52
public void tearDown() {
44
executeTarget("cleanup");
53
buildRule.executeTarget("cleanup");
47
57
public void testRealTest() throws IOException {
48
executeTarget("realTest");
58
buildRule.executeTarget("realTest");
50
60
// doesn't work: Depending on the compression engine used,
51
61
// compressed bytes may differ. False errors would be
57
67
// We have to compare the decompressed content instead:
59
69
File originalFile =
60
project.resolveFile("expected/asf-logo-huge.tar.bz2");
61
File actualFile = project.resolveFile("asf-logo-huge.tar.bz2");
70
buildRule.getProject().resolveFile("expected/asf-logo-huge.tar.bz2");
71
File actualFile = buildRule.getProject().resolveFile("asf-logo-huge.tar.bz2");
63
73
InputStream originalIn =
64
74
new BufferedInputStream(new FileInputStream(originalFile));
95
106
public void testResource(){
96
executeTarget("realTestWithResource");
107
buildRule.executeTarget("realTestWithResource");
99
111
public void testDateCheck(){
100
executeTarget("testDateCheck");
101
String log = getLog();
112
buildRule.executeTarget("testDateCheck");
113
String log = buildRule.getLog();
103
115
"Expecting message ending with 'asf-logo.gif.bz2 is up to date.' but got '" + log + "'",
104
116
log.endsWith("asf-logo.gif.bz2 is up to date."));