-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TAR: Implement extraction and archiving of hardlinks.
- Loading branch information
Showing
9 changed files
with
144 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
src/test/java/org/codehaus/plexus/archiver/HardlinkTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package org.codehaus.plexus.archiver; | ||
|
||
import java.io.File; | ||
import java.nio.file.Files; | ||
|
||
import org.codehaus.plexus.archiver.tar.TarArchiver; | ||
import org.codehaus.plexus.archiver.tar.TarLongFileMode; | ||
import org.codehaus.plexus.archiver.tar.TarUnArchiver; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.condition.DisabledOnOs; | ||
import org.junit.jupiter.api.condition.OS; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
/** | ||
* @author Kristian Rosenvold | ||
*/ | ||
public class HardlinkTest extends TestSupport { | ||
|
||
@Test | ||
@DisabledOnOs(OS.WINDOWS) | ||
public void testHardlinkTar() throws Exception { | ||
// Extract test files | ||
final File archiveFile = getTestFile("src/test/resources/hardlinks/hardlinks.tar"); | ||
File output = getTestFile("target/output/untaredHardlinks"); | ||
output.mkdirs(); | ||
TarUnArchiver unarchiver = (TarUnArchiver) lookup(UnArchiver.class, "tar"); | ||
unarchiver.setSourceFile(archiveFile); | ||
unarchiver.setDestFile(output); | ||
unarchiver.extract(); | ||
// Check that we have hardlinks | ||
assertTrue(Files.isSameFile( | ||
output.toPath().resolve("fileR.txt"), output.toPath().resolve("hardlink"))); | ||
|
||
// Archive the extracted hardlinks to new archive | ||
TarArchiver archiver = (TarArchiver) lookup(Archiver.class, "tar"); | ||
archiver.setLongfile(TarLongFileMode.posix); | ||
archiver.addDirectory(output); | ||
final File testFile = getTestFile("target/output/untaredHardlinks2.tar"); | ||
archiver.setDestFile(testFile); | ||
archiver.createArchive(); | ||
|
||
// Check that our created archive actually contains hardlinks when extracted | ||
unarchiver = (TarUnArchiver) lookup(UnArchiver.class, "tar"); | ||
output = getTestFile("target/output/untaredHardlinks2"); | ||
output.mkdirs(); | ||
unarchiver.setSourceFile(testFile); | ||
unarchiver.setDestFile(output); | ||
unarchiver.extract(); | ||
assertTrue(Files.isSameFile( | ||
output.toPath().resolve("fileR.txt"), output.toPath().resolve("hardlink"))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters