summaryrefslogtreecommitdiff
path: root/src/tests/junit/org/apache/tools
diff options
context:
space:
mode:
authorMarc Strapetz <marc.strapetz@syntevo.com>2020-12-09 23:58:13 +0100
committerMarc Strapetz <marc.strapetz@syntevo.com>2020-12-10 22:44:09 +0100
commit2e2ed8ad31d5fd262e69e7906009d6c73e57a0c6 (patch)
treedf15c2cb89f3837243df74054bc9bfbb22044ad8 /src/tests/junit/org/apache/tools
parent5034c2c241af7cb441c6c34c5e9914c34ccf7df4 (diff)
downloadant-2e2ed8ad31d5fd262e69e7906009d6c73e57a0c6.tar.gz
Tar: preserve symlinks from <tarfileset> sources
Diffstat (limited to 'src/tests/junit/org/apache/tools')
-rw-r--r--src/tests/junit/org/apache/tools/ant/taskdefs/TarTest.java28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/TarTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/TarTest.java
index e37e2b95a..86a6d9beb 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/TarTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/TarTest.java
@@ -19,16 +19,21 @@
package org.apache.tools.ant.taskdefs;
import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
import java.io.IOException;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.BuildFileRule;
import org.apache.tools.ant.FileUtilities;
+import org.apache.tools.tar.TarEntry;
+import org.apache.tools.tar.TarInputStream;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
public class TarTest {
@@ -186,4 +191,27 @@ public class TarTest {
public void testtestTarFilesetWithReference() {
buildRule.executeTarget("testTarFilesetWithReference");
}
+
+ @Test
+ public void testTarFilesetWithSymlinks() throws IOException {
+ buildRule.executeTarget("testTarFilesetWithSymlinks");
+ final File f = new File(buildRule.getProject().getProperty("output"), "result.tar");
+ final TarInputStream tis = new TarInputStream(new FileInputStream(f));
+ try {
+ final TarEntry e1 = tis.getNextEntry();
+ assertEquals("pre/dir/file", e1.getName());
+ assertEquals("", e1.getLinkName());
+ assertEquals(48, e1.getLinkFlag());
+
+ final TarEntry e2 = tis.getNextEntry();
+ assertEquals("pre/sub/file", e2.getName());
+ assertEquals("../dir/file", e2.getLinkName());
+ assertEquals(50, e2.getLinkFlag());
+
+ assertNull(tis.getNextEntry());
+ }
+ finally {
+ tis.close();
+ }
+ }
}