1 package org.codehaus.plexus.archiver.util; 2 3 import java.io.File; 4 import java.io.IOException; 5 import java.nio.file.Files; 6 import java.nio.file.Path; 7 import java.util.HashMap; 8 9 import org.codehaus.plexus.components.io.attributes.FileAttributes; 10 import org.junit.jupiter.api.Test; 11 import org.junit.jupiter.api.condition.DisabledOnOs; 12 import org.junit.jupiter.api.condition.OS; 13 import org.junit.jupiter.api.io.TempDir; 14 15 import static org.junit.jupiter.api.Assertions.assertFalse; 16 import static org.junit.jupiter.api.Assertions.assertTrue; 17 18 class ArchiveEntryUtilsTest { 19 20 @TempDir 21 private Path tempDir; 22 23 @Test 24 @DisabledOnOs(OS.WINDOWS) 25 void testChmodForFileWithDollarPLXCOMP164() throws Exception { 26 File temp = Files.createTempFile(tempDir, "A$A", "BB$").toFile(); 27 ArchiveEntryUtils.chmod(temp, 0770); 28 assert0770(temp); 29 } 30 31 @Test 32 @DisabledOnOs(OS.WINDOWS) 33 void testChmodWithJava7() throws Exception { 34 File temp = Files.createTempFile(tempDir, "D$D", "BB$").toFile(); 35 ArchiveEntryUtils.chmod(temp, 0770); 36 assert0770(temp); 37 } 38 39 private void assert0770(File temp) throws IOException { 40 FileAttributes j7 = new FileAttributes(temp, new HashMap<Integer, String>(), new HashMap<Integer, String>()); 41 assertTrue(j7.isGroupExecutable()); 42 assertTrue(j7.isGroupReadable()); 43 assertTrue(j7.isGroupWritable()); 44 45 assertFalse(j7.isWorldExecutable()); 46 assertFalse(j7.isWorldReadable()); 47 assertFalse(j7.isWorldWritable()); 48 } 49 }