@@ -82,7 +82,29 @@ public void setUp()
82
82
83
83
logger = new ConsoleLogger ( Logger .LEVEL_DEBUG , "test" );
84
84
}
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
+ }
86
108
public void testCreateArchiveWithDetectedModes ()
87
109
throws Exception
88
110
{
@@ -133,31 +155,31 @@ public void testCreateArchiveWithDetectedModes()
133
155
}
134
156
135
157
{
136
- Map attributesByPath = PlexusIoResourceAttributeUtils .getFileAttributesByPath ( tmpDir );
158
+ Map < String , PlexusIoResourceAttributes > attributesByPath = PlexusIoResourceAttributeUtils .getFileAttributesByPath ( tmpDir );
137
159
for (String path : executablePaths ) {
138
- PlexusIoResourceAttributes attrs = ( PlexusIoResourceAttributes ) attributesByPath .get (path );
160
+ PlexusIoResourceAttributes attrs = attributesByPath .get (path );
139
161
if (attrs == null ) {
140
- attrs = ( PlexusIoResourceAttributes ) attributesByPath .get (new File (tmpDir , path ).getAbsolutePath ());
162
+ attrs = attributesByPath .get (new File (tmpDir , path ).getAbsolutePath ());
141
163
}
142
164
143
165
assertNotNull (attrs );
144
166
assertEquals ("Wrong mode for: " + path + "; expected: " + exeMode , exeMode , attrs .getOctalMode ());
145
167
}
146
168
147
169
for (String path : confPaths ) {
148
- PlexusIoResourceAttributes attrs = ( PlexusIoResourceAttributes ) attributesByPath .get (path );
170
+ PlexusIoResourceAttributes attrs = attributesByPath .get (path );
149
171
if (attrs == null ) {
150
- attrs = ( PlexusIoResourceAttributes ) attributesByPath .get (new File (tmpDir , path ).getAbsolutePath ());
172
+ attrs = attributesByPath .get (new File (tmpDir , path ).getAbsolutePath ());
151
173
}
152
174
153
175
assertNotNull (attrs );
154
176
assertEquals ("Wrong mode for: " + path + "; expected: " + confMode , confMode , attrs .getOctalMode ());
155
177
}
156
178
157
179
for (String path : logPaths ) {
158
- PlexusIoResourceAttributes attrs = ( PlexusIoResourceAttributes ) attributesByPath .get (path );
180
+ PlexusIoResourceAttributes attrs = attributesByPath .get (path );
159
181
if (attrs == null ) {
160
- attrs = ( PlexusIoResourceAttributes ) attributesByPath .get (new File (tmpDir , path ).getAbsolutePath ());
182
+ attrs = attributesByPath .get (new File (tmpDir , path ).getAbsolutePath ());
161
183
}
162
184
163
185
assertNotNull (attrs );
@@ -182,7 +204,7 @@ public void testCreateArchiveWithDetectedModes()
182
204
archiver .addArchivedFileSet ( zipFile );
183
205
archiver .createArchive ();
184
206
185
- org . apache . commons . compress . archivers . zip . ZipFile zf = new org . apache . commons . compress . archivers . zip . ZipFile ( zipFile2 );
207
+ ZipFile zf = new ZipFile ( zipFile2 );
186
208
187
209
for (String path : executablePaths ) {
188
210
ZipArchiveEntry ze = zf .getEntry (path );
@@ -370,7 +392,7 @@ private void createArchive( ZipArchiver archiver )
370
392
{
371
393
archiver .createArchive ();
372
394
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 () );
374
396
375
397
Enumeration e = zf .getEntries ();
376
398
@@ -545,8 +567,8 @@ public void testCreateResourceCollection()
545
567
FileUtils .removePath ( zipFile2 .getPath () );
546
568
zipArchiver2 .createArchive ();
547
569
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 );
550
572
ArchiveFileComparator .assertEquals ( cmp1 , cmp2 , "prfx/" );
551
573
cmp1 .close ();
552
574
cmp2 .close ();
0 commit comments