View Javadoc
1   package org.codehaus.plexus.archiver.util;
2   
3   import java.io.File;
4   import java.io.IOException;
5   import java.util.HashMap;
6   import org.codehaus.plexus.components.io.attributes.FileAttributes;
7   import org.codehaus.plexus.util.Os;
8   import junit.framework.TestCase;
9   
10  public class ArchiveEntryUtilsTest extends TestCase
11  {
12  
13      public void testChmodForFileWithDollarPLXCOMP164() throws Exception
14      {
15  
16          if ( Os.isFamily( Os.FAMILY_WINDOWS ) )
17          {
18              return;
19          }
20          File temp = File.createTempFile( "A$A", "BB$" );
21          ArchiveEntryUtils.chmod( temp, 0770 );
22          assert0770( temp );
23      }
24  
25      public void testChmodWithJava7() throws Exception
26      {
27          if ( Os.isFamily( Os.FAMILY_WINDOWS ) )
28          {
29              return;
30          }
31  
32          File temp = File.createTempFile( "D$D", "BB$" );
33          ArchiveEntryUtils.chmod( temp, 0770 );
34          assert0770( temp );
35      }
36  
37      private void assert0770( File temp ) throws IOException
38      {
39          FileAttributes j7 = new FileAttributes( temp, new HashMap<Integer, String>(),
40                                                  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  
50  }