30
30
import org .apache .hadoop .hdfs .MiniDFSCluster ;
31
31
import org .apache .hadoop .security .UserGroupInformation ;
32
32
import static org .apache .hadoop .fs .FileContextTestHelper .*;
33
- import org .junit .After ;
34
- import org .junit .AfterClass ;
35
- import org .junit .Assert ;
36
- import org .junit .Before ;
37
- import org .junit .BeforeClass ;
38
- import org .junit .Test ;
33
+ import static org .junit .jupiter .api .Assertions .assertEquals ;
34
+ import static org .junit .jupiter .api .Assertions .assertFalse ;
35
+ import static org .junit .jupiter .api .Assertions .assertTrue ;
36
+
37
+ import org .junit .jupiter .api .AfterEach ;
38
+ import org .junit .jupiter .api .AfterAll ;
39
+ import org .junit .jupiter .api .BeforeEach ;
40
+ import org .junit .jupiter .api .BeforeAll ;
41
+ import org .junit .jupiter .api .Test ;
39
42
40
43
public class TestFcHdfsSetUMask {
41
44
@@ -78,7 +81,7 @@ public class TestFcHdfsSetUMask {
78
81
private static final FsPermission WIDE_OPEN_TEST_UMASK = FsPermission
79
82
.createImmutable ((short ) (0777 ^ 0777 ));
80
83
81
- @ BeforeClass
84
+ @ BeforeAll
82
85
public static void clusterSetupAtBegining ()
83
86
throws IOException , LoginException , URISyntaxException {
84
87
Configuration conf = new HdfsConfiguration ();
@@ -91,20 +94,20 @@ public static void clusterSetupAtBegining()
91
94
fc .mkdir (defaultWorkingDirectory , FileContext .DEFAULT_PERM , true );
92
95
}
93
96
94
- @ AfterClass
97
+ @ AfterAll
95
98
public static void ClusterShutdownAtEnd () throws Exception {
96
99
if (cluster != null ) {
97
100
cluster .shutdown ();
98
101
}
99
102
}
100
103
101
- @ Before
104
+ @ BeforeEach
102
105
public void setUp () throws Exception {
103
106
fc .setUMask (WIDE_OPEN_TEST_UMASK );
104
107
fc .mkdir (fileContextTestHelper .getTestRootPath (fc ), FileContext .DEFAULT_PERM , true );
105
108
}
106
109
107
- @ After
110
+ @ AfterEach
108
111
public void tearDown () throws Exception {
109
112
fc .delete (fileContextTestHelper .getTestRootPath (fc ), true );
110
113
}
@@ -165,23 +168,23 @@ public void testCreateRecursiveWithExistingDirMiddle() throws IOException {
165
168
166
169
@ Test
167
170
public void testCreateRecursiveWithNonExistingDirClear () throws IOException {
168
- // directory permission inherited from parent so this must match the @Before
171
+ // directory permission inherited from parent so this must match the @BeforeEach
169
172
// set of umask
170
173
testCreateRecursiveWithNonExistingDir (BLANK_TEST_UMASK ,
171
174
WIDE_OPEN_PERMISSIONS , BLANK_PERMISSIONS );
172
175
}
173
176
174
177
@ Test
175
178
public void testCreateRecursiveWithNonExistingDirOpen () throws IOException {
176
- // directory permission inherited from parent so this must match the @Before
179
+ // directory permission inherited from parent so this must match the @BeforeEach
177
180
// set of umask
178
181
testCreateRecursiveWithNonExistingDir (WIDE_OPEN_TEST_UMASK ,
179
182
WIDE_OPEN_PERMISSIONS , WIDE_OPEN_FILE_PERMISSIONS );
180
183
}
181
184
182
185
@ Test
183
186
public void testCreateRecursiveWithNonExistingDirMiddle () throws IOException {
184
- // directory permission inherited from parent so this must match the @Before
187
+ // directory permission inherited from parent so this must match the @BeforeEach
185
188
// set of umask
186
189
testCreateRecursiveWithNonExistingDir (USER_GROUP_OPEN_TEST_UMASK ,
187
190
WIDE_OPEN_PERMISSIONS , USER_GROUP_OPEN_FILE_PERMISSIONS );
@@ -193,9 +196,9 @@ public void testMkdirWithExistingDir(FsPermission umask,
193
196
Path f = fileContextTestHelper .getTestRootPath (fc , "aDir" );
194
197
fc .setUMask (umask );
195
198
fc .mkdir (f , FileContext .DEFAULT_PERM , true );
196
- Assert . assertTrue (isDir (fc , f ));
197
- Assert . assertEquals ("permissions on directory are wrong" ,
198
- expectedPerms , fc . getFileStatus ( f ). getPermission () );
199
+ assertTrue (isDir (fc , f ));
200
+ assertEquals (expectedPerms , fc . getFileStatus ( f ). getPermission (),
201
+ "permissions on directory are wrong" );
199
202
}
200
203
201
204
public void testMkdirRecursiveWithNonExistingDir (FsPermission umask ,
@@ -204,12 +207,12 @@ public void testMkdirRecursiveWithNonExistingDir(FsPermission umask,
204
207
Path f = fileContextTestHelper .getTestRootPath (fc , "NonExistant2/aDir" );
205
208
fc .setUMask (umask );
206
209
fc .mkdir (f , FileContext .DEFAULT_PERM , true );
207
- Assert . assertTrue (isDir (fc , f ));
208
- Assert . assertEquals ("permissions on directory are wrong" ,
209
- expectedPerms , fc . getFileStatus ( f ). getPermission () );
210
+ assertTrue (isDir (fc , f ));
211
+ assertEquals (expectedPerms , fc . getFileStatus ( f ). getPermission (),
212
+ "permissions on directory are wrong" );
210
213
Path fParent = fileContextTestHelper .getTestRootPath (fc , "NonExistant2" );
211
- Assert . assertEquals ("permissions on parent directory are wrong" ,
212
- expectedParentPerms , fc . getFileStatus ( fParent ). getPermission () );
214
+ assertEquals (expectedParentPerms , fc . getFileStatus ( fParent ). getPermission (),
215
+ "permissions on parent directory are wrong" );
213
216
}
214
217
215
218
@@ -218,9 +221,9 @@ public void testCreateRecursiveWithExistingDir(FsPermission umask,
218
221
Path f = fileContextTestHelper .getTestRootPath (fc ,"foo" );
219
222
fc .setUMask (umask );
220
223
createFile (fc , f );
221
- Assert . assertTrue (isFile (fc , f ));
222
- Assert . assertEquals ("permissions on file are wrong" ,
223
- expectedPerms , fc . getFileStatus ( f ). getPermission () );
224
+ assertTrue (isFile (fc , f ));
225
+ assertEquals (expectedPerms , fc . getFileStatus ( f ). getPermission (),
226
+ "permissions on file are wrong" );
224
227
}
225
228
226
229
@@ -229,14 +232,14 @@ public void testCreateRecursiveWithNonExistingDir(FsPermission umask,
229
232
throws IOException {
230
233
Path f = fileContextTestHelper .getTestRootPath (fc ,"NonExisting/foo" );
231
234
Path fParent = fileContextTestHelper .getTestRootPath (fc , "NonExisting" );
232
- Assert . assertFalse (exists (fc , fParent ));
235
+ assertFalse (exists (fc , fParent ));
233
236
fc .setUMask (umask );
234
237
createFile (fc , f );
235
- Assert . assertTrue (isFile (fc , f ));
236
- Assert . assertEquals ("permissions on file are wrong" ,
237
- expectedFilePerms , fc . getFileStatus ( f ). getPermission () );
238
- Assert . assertEquals ("permissions on parent directory are wrong" ,
239
- expectedDirPerms , fc . getFileStatus ( fParent ). getPermission () );
238
+ assertTrue (isFile (fc , f ));
239
+ assertEquals (expectedFilePerms , fc . getFileStatus ( f ). getPermission (),
240
+ "permissions on file are wrong" );
241
+ assertEquals (expectedDirPerms , fc . getFileStatus ( fParent ). getPermission (),
242
+ "permissions on parent directory are wrong" );
240
243
}
241
244
242
245
}
0 commit comments