22
33import org .apache .commons .compress .archivers .tar .TarArchiveEntry ;
44import org .apache .commons .compress .archivers .tar .TarArchiveInputStream ;
5+ import org .apache .commons .lang3 .SystemUtils ;
56import org .junit .Rule ;
67import org .junit .Test ;
78import org .junit .rules .TemporaryFolder ;
2223import static org .junit .Assert .assertEquals ;
2324import static org .junit .Assert .assertNotNull ;
2425import static org .junit .Assert .assertTrue ;
26+ import static org .junit .Assume .assumeFalse ;
2527
2628public class CompressArchiveUtilTest {
2729
@@ -69,6 +71,7 @@ public void tarWithExecutableFileAsInput() throws Exception {
6971
7072 @ Test
7173 public void tarWithSymbolicLinkFileAsInput () throws IOException {
74+ assumeSymbolicLinksAreUnrestrictedByDefault ();
7275 Path archiveSourceFile = tempFolder .getRoot ().toPath ().resolve ("symlinkFile" );
7376 Path linkTargetFile = tempFolder .newFile ("link-target" ).toPath ();
7477 Files .createSymbolicLink (archiveSourceFile , linkTargetFile );
@@ -139,6 +142,7 @@ public void tarWithfolderAsInputAndNestedExecutableFile() throws Exception {
139142
140143 @ Test
141144 public void tarWithfolderAsInputAndNestedSymbolicLinkFile () throws Exception {
145+ assumeSymbolicLinksAreUnrestrictedByDefault ();
142146 Path archiveSourceDir = tempFolder .newFolder ("archive-source" ).toPath ();
143147 Path linkTargetFile = tempFolder .newFile ("link-target" ).toPath ();
144148 Path symlinkFile = archiveSourceDir .resolve ("symlinkFile" );
@@ -160,6 +164,7 @@ public void tarWithfolderAsInputAndNestedSymbolicLinkFile() throws Exception {
160164
161165 @ Test
162166 public void tarWithfolderAsInputAndNestedSymbolicLinkDir () throws Exception {
167+ assumeSymbolicLinksAreUnrestrictedByDefault ();
163168 Path archiveSourceDir = tempFolder .newFolder ("archive-source" ).toPath ();
164169 Path linkTargetDir = tempFolder .newFolder ("link-target" ).toPath ();
165170 Path symlinkFile = archiveSourceDir .resolve ("symlinkFile" );
@@ -204,6 +209,7 @@ public void archiveTARFilesWithExecutableFile() throws Exception {
204209
205210 @ Test
206211 public void archiveTARFilesWithSymbolicLinkFile () throws Exception {
212+ assumeSymbolicLinksAreUnrestrictedByDefault ();
207213 Path linkTargetFile = tempFolder .newFile ("link-target" ).toPath ();
208214 Path symlinkFile = tempFolder .getRoot ().toPath ().resolve ("symlinkFile" );
209215 Files .createSymbolicLink (symlinkFile , linkTargetFile );
@@ -215,6 +221,7 @@ public void archiveTARFilesWithSymbolicLinkFile() throws Exception {
215221
216222 @ Test
217223 public void archiveTARFilesWithSymbolicLinkDir () throws Exception {
224+ assumeSymbolicLinksAreUnrestrictedByDefault ();
218225 Path linkTargetDir = tempFolder .newFolder ("link-target" ).toPath ();
219226 Path symlinkFile = tempFolder .getRoot ().toPath ().resolve ("symlinkFile" );
220227 Files .createSymbolicLink (symlinkFile , linkTargetDir );
@@ -317,4 +324,8 @@ private static int getNumberOfEntryInArchive(File tarArchive) throws IOException
317324 }
318325 return numberOfEntries ;
319326 }
327+
328+ private static void assumeSymbolicLinksAreUnrestrictedByDefault (){
329+ assumeFalse (SystemUtils .IS_OS_WINDOWS );
330+ }
320331}
0 commit comments