@@ -82,7 +82,29 @@ public void setUp()
8282
8383 logger = new ConsoleLogger ( Logger .LEVEL_DEBUG , "test" );
8484 }
85-
85+
86+ public void testImplicitPermissions ()
87+ throws IOException
88+ {
89+ File zipFile = getTestFile ( "target/output/zip-with-implicit-dirmode.zip" );
90+
91+ ZipArchiver archiver = getZipArchiver (zipFile );
92+
93+ archiver .setDefaultDirectoryMode ( 0777 );
94+ archiver .setDirectoryMode ( 0641 );
95+ archiver .setFileMode ( 0222 );
96+ archiver .addFile ( new File ( "pom.xml" ), "fizz/buzz/pom.xml" );
97+ archiver .createArchive ();
98+
99+ assertTrue ( zipFile .exists () );
100+ ZipFile zf = new ZipFile ( zipFile );
101+ ZipArchiveEntry fizz = zf .getEntry ( "fizz/" );
102+ assertEquals ( 040641 , fizz .getUnixMode () );
103+ ZipArchiveEntry pom = zf .getEntry ( "fizz/buzz/pom.xml" );
104+ assertEquals ( 0100222 , pom .getUnixMode () );
105+
106+
107+ }
86108 public void testCreateArchiveWithDetectedModes ()
87109 throws Exception
88110 {
@@ -133,31 +155,31 @@ public void testCreateArchiveWithDetectedModes()
133155 }
134156
135157 {
136- Map attributesByPath = PlexusIoResourceAttributeUtils .getFileAttributesByPath ( tmpDir );
158+ Map < String , PlexusIoResourceAttributes > attributesByPath = PlexusIoResourceAttributeUtils .getFileAttributesByPath ( tmpDir );
137159 for (String path : executablePaths ) {
138- PlexusIoResourceAttributes attrs = ( PlexusIoResourceAttributes ) attributesByPath .get (path );
160+ PlexusIoResourceAttributes attrs = attributesByPath .get (path );
139161 if (attrs == null ) {
140- attrs = ( PlexusIoResourceAttributes ) attributesByPath .get (new File (tmpDir , path ).getAbsolutePath ());
162+ attrs = attributesByPath .get (new File (tmpDir , path ).getAbsolutePath ());
141163 }
142164
143165 assertNotNull (attrs );
144166 assertEquals ("Wrong mode for: " + path + "; expected: " + exeMode , exeMode , attrs .getOctalMode ());
145167 }
146168
147169 for (String path : confPaths ) {
148- PlexusIoResourceAttributes attrs = ( PlexusIoResourceAttributes ) attributesByPath .get (path );
170+ PlexusIoResourceAttributes attrs = attributesByPath .get (path );
149171 if (attrs == null ) {
150- attrs = ( PlexusIoResourceAttributes ) attributesByPath .get (new File (tmpDir , path ).getAbsolutePath ());
172+ attrs = attributesByPath .get (new File (tmpDir , path ).getAbsolutePath ());
151173 }
152174
153175 assertNotNull (attrs );
154176 assertEquals ("Wrong mode for: " + path + "; expected: " + confMode , confMode , attrs .getOctalMode ());
155177 }
156178
157179 for (String path : logPaths ) {
158- PlexusIoResourceAttributes attrs = ( PlexusIoResourceAttributes ) attributesByPath .get (path );
180+ PlexusIoResourceAttributes attrs = attributesByPath .get (path );
159181 if (attrs == null ) {
160- attrs = ( PlexusIoResourceAttributes ) attributesByPath .get (new File (tmpDir , path ).getAbsolutePath ());
182+ attrs = attributesByPath .get (new File (tmpDir , path ).getAbsolutePath ());
161183 }
162184
163185 assertNotNull (attrs );
@@ -182,7 +204,7 @@ public void testCreateArchiveWithDetectedModes()
182204 archiver .addArchivedFileSet ( zipFile );
183205 archiver .createArchive ();
184206
185- org . apache . commons . compress . archivers . zip . ZipFile zf = new org . apache . commons . compress . archivers . zip . ZipFile ( zipFile2 );
207+ ZipFile zf = new ZipFile ( zipFile2 );
186208
187209 for (String path : executablePaths ) {
188210 ZipArchiveEntry ze = zf .getEntry (path );
@@ -370,7 +392,7 @@ private void createArchive( ZipArchiver archiver )
370392 {
371393 archiver .createArchive ();
372394
373- org . apache . commons . compress . archivers . zip . ZipFile zf = new org . apache . commons . compress . archivers . zip . ZipFile ( archiver .getDestFile () );
395+ ZipFile zf = new ZipFile ( archiver .getDestFile () );
374396
375397 Enumeration e = zf .getEntries ();
376398
@@ -545,8 +567,8 @@ public void testCreateResourceCollection()
545567 FileUtils .removePath ( zipFile2 .getPath () );
546568 zipArchiver2 .createArchive ();
547569
548- final org . apache . commons . compress . archivers . zip . ZipFile cmp1 = new org . apache . commons . compress . archivers . zip . ZipFile ( zipFile );
549- final org . apache . commons . compress . archivers . zip . ZipFile cmp2 = new org . apache . commons . compress . archivers . zip . ZipFile ( zipFile2 );
570+ final ZipFile cmp1 = new ZipFile ( zipFile );
571+ final ZipFile cmp2 = new ZipFile ( zipFile2 );
550572 ArchiveFileComparator .assertEquals ( cmp1 , cmp2 , "prfx/" );
551573 cmp1 .close ();
552574 cmp2 .close ();
0 commit comments