~ubuntu-branches/ubuntu/utopic/ant/utopic

« back to all changes in this revision

Viewing changes to src/tests/junit/org/apache/tools/ant/taskdefs/BZip2Test.java

  • Committer: Package Import Robot
  • Author(s): Emmanuel Bourg
  • Date: 2014-05-09 11:46:04 UTC
  • mfrom: (25.1.1 sid)
  • Revision ID: package-import@ubuntu.com-20140509114604-3h26sbqgjef3jln4
Tags: 1.9.4-1
* New upstream release
  - Refreshed the patches
  - Removed the patch for #735786 (Fixed upstream)

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
package org.apache.tools.ant.taskdefs;
20
20
 
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;
23
27
 
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;
 
33
 
 
34
import static org.junit.Assert.assertEquals;
 
35
import static org.junit.Assert.assertTrue;
 
36
import static org.junit.Assert.fail;
29
37
 
30
38
/**
31
39
 */
32
 
public class BZip2Test extends BuildFileTest {
33
 
 
34
 
    public BZip2Test(String name) {
35
 
        super(name);
36
 
    }
37
 
 
 
40
public class BZip2Test {
 
41
 
 
42
    @Rule
 
43
    public BuildFileRule buildRule = new BuildFileRule();
 
44
 
 
45
    @Before
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");
41
49
    }
42
50
 
 
51
    @After
43
52
    public void tearDown() {
44
 
        executeTarget("cleanup");
 
53
        buildRule.executeTarget("cleanup");
45
54
    }
46
55
 
 
56
    @Test
47
57
    public void testRealTest() throws IOException {
48
 
        executeTarget("realTest");
 
58
        buildRule.executeTarget("realTest");
49
59
 
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:
58
68
 
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");
62
72
 
63
73
        InputStream originalIn =
64
74
            new BufferedInputStream(new FileInputStream(originalFile));
92
102
        actualIn.close();
93
103
    }
94
104
 
 
105
    @Test
95
106
    public void testResource(){
96
 
        executeTarget("realTestWithResource");
 
107
        buildRule.executeTarget("realTestWithResource");
97
108
    }
98
109
 
 
110
    @Test
99
111
    public void testDateCheck(){
100
 
        executeTarget("testDateCheck");
101
 
        String log = getLog();
 
112
        buildRule.executeTarget("testDateCheck");
 
113
        String log = buildRule.getLog();
102
114
        assertTrue(
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."));