|
|
@@ -20,16 +20,20 @@ package org.apache.tools.ant.taskdefs; |
|
|
|
|
|
|
|
import java.io.IOException; |
|
|
|
import java.io.File; |
|
|
|
import java.io.FileInputStream; |
|
|
|
|
|
|
|
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.fail; |
|
|
|
import static org.junit.Assert.assertNull; |
|
|
|
|
|
|
|
public class TarTest { |
|
|
|
|
|
|
@@ -206,5 +210,26 @@ public class TarTest { |
|
|
|
FileUtilities.getFileContents(new File(buildRule.getProject().getProperty("output"), "untar/asf-logo.gif.gz"))); |
|
|
|
} |
|
|
|
|
|
|
|
@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(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |