Browse Source

BUnzipTest was writing outside of ${output}

master
Stefan Bodewig 11 years ago
parent
commit
f0f1a3ca00
2 changed files with 19 additions and 21 deletions
  1. +13
    -14
      src/etc/testcases/taskdefs/bunzip2.xml
  2. +6
    -7
      src/tests/junit/org/apache/tools/ant/taskdefs/BUnzip2Test.java

+ 13
- 14
src/etc/testcases/taskdefs/bunzip2.xml View File

@@ -16,33 +16,32 @@
limitations under the License. limitations under the License.
--> -->


<project basedir="." default="cleanup">
<project basedir="." default="tearDown">

<import file="../buildfiletest-base.xml"/>

<target name="prepare">
<mkdir dir="${output}"/>
<gunzip src="expected/asf-logo-huge.tar.gz"
dest="${output}/asf-logo-huge-from-gzip.tar"/>
</target>


<target name="realTest"> <target name="realTest">
<bunzip2 src="expected/asf-logo-huge.tar.bz2" dest="asf-logo-huge.tar" />
<bunzip2 src="expected/asf-logo-huge.tar.bz2" dest="${output}/asf-logo-huge.tar" />
</target> </target>


<target name="realTestWithResource"> <target name="realTestWithResource">
<bunzip2 dest="asf-logo-huge.tar">
<bunzip2 dest="${output}/asf-logo-huge.tar">
<file file="expected/asf-logo-huge.tar.bz2"/> <file file="expected/asf-logo-huge.tar.bz2"/>
</bunzip2> </bunzip2>
</target> </target>


<target name="cleanup">
<delete file="asf-logo-huge.tar" />
<delete file="expected/asf-logo-huge.tar" />
</target>

<target name="prepare">
<gunzip src="expected/asf-logo-huge.tar.gz"/>
</target>

<target name="testDocumentationClaimsOnCopy"> <target name="testDocumentationClaimsOnCopy">
<copy todir=".">
<copy todir="${output}">
<bzip2resource> <bzip2resource>
<file file="expected/asf-logo-huge.tar.bz2"/> <file file="expected/asf-logo-huge.tar.bz2"/>
</bzip2resource> </bzip2resource>
<mapper type="glob" from="*.bz2" to="*"/> <mapper type="glob" from="*.bz2" to="*"/>
</copy> </copy>
</target> </target>
</project>
</project>

+ 6
- 7
src/tests/junit/org/apache/tools/ant/taskdefs/BUnzip2Test.java View File

@@ -18,6 +18,7 @@


package org.apache.tools.ant.taskdefs; package org.apache.tools.ant.taskdefs;


import java.io.File;
import org.apache.tools.ant.BuildFileRule; import org.apache.tools.ant.BuildFileRule;
import org.apache.tools.ant.FileUtilities; import org.apache.tools.ant.FileUtilities;
import org.junit.Before; import org.junit.Before;
@@ -32,17 +33,15 @@ public class BUnzip2Test {
@Rule @Rule
public BuildFileRule buildRule = new BuildFileRule(); public BuildFileRule buildRule = new BuildFileRule();


private File outputDir;

@Before @Before
public void setUp() { public void setUp() {
buildRule.configureProject("src/etc/testcases/taskdefs/bunzip2.xml"); buildRule.configureProject("src/etc/testcases/taskdefs/bunzip2.xml");
outputDir = new File(buildRule.getProject().getProperty("output"));
buildRule.executeTarget("prepare"); buildRule.executeTarget("prepare");
} }


@Test
public void tearDown() {
buildRule.executeTarget("cleanup");
}

@Test @Test
public void testRealTest() throws java.io.IOException { public void testRealTest() throws java.io.IOException {
testRealTest("realTest"); testRealTest("realTest");
@@ -56,8 +55,8 @@ public class BUnzip2Test {
private void testRealTest(String target) throws java.io.IOException { private void testRealTest(String target) throws java.io.IOException {
buildRule.executeTarget(target); buildRule.executeTarget(target);
assertEquals("File content mismatch after bunzip2", assertEquals("File content mismatch after bunzip2",
FileUtilities.getFileContents(buildRule.getProject().resolveFile("expected/asf-logo-huge.tar")),
FileUtilities.getFileContents(buildRule.getProject().resolveFile("asf-logo-huge.tar")));
FileUtilities.getFileContents(new File(outputDir, "asf-logo-huge-from-gzip.tar")),
FileUtilities.getFileContents(new File(outputDir, "asf-logo-huge.tar")));
} }


@Test @Test


Loading…
Cancel
Save