3030import org .apache .hadoop .hdfs .MiniDFSCluster ;
3131import org .apache .hadoop .security .UserGroupInformation ;
3232import 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 ;
3942
4043public class TestFcHdfsSetUMask {
4144
@@ -78,7 +81,7 @@ public class TestFcHdfsSetUMask {
7881 private static final FsPermission WIDE_OPEN_TEST_UMASK = FsPermission
7982 .createImmutable ((short ) (0777 ^ 0777 ));
8083
81- @ BeforeClass
84+ @ BeforeAll
8285 public static void clusterSetupAtBegining ()
8386 throws IOException , LoginException , URISyntaxException {
8487 Configuration conf = new HdfsConfiguration ();
@@ -91,20 +94,20 @@ public static void clusterSetupAtBegining()
9194 fc .mkdir (defaultWorkingDirectory , FileContext .DEFAULT_PERM , true );
9295 }
9396
94- @ AfterClass
97+ @ AfterAll
9598 public static void ClusterShutdownAtEnd () throws Exception {
9699 if (cluster != null ) {
97100 cluster .shutdown ();
98101 }
99102 }
100103
101- @ Before
104+ @ BeforeEach
102105 public void setUp () throws Exception {
103106 fc .setUMask (WIDE_OPEN_TEST_UMASK );
104107 fc .mkdir (fileContextTestHelper .getTestRootPath (fc ), FileContext .DEFAULT_PERM , true );
105108 }
106109
107- @ After
110+ @ AfterEach
108111 public void tearDown () throws Exception {
109112 fc .delete (fileContextTestHelper .getTestRootPath (fc ), true );
110113 }
@@ -165,23 +168,23 @@ public void testCreateRecursiveWithExistingDirMiddle() throws IOException {
165168
166169 @ Test
167170 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
169172 // set of umask
170173 testCreateRecursiveWithNonExistingDir (BLANK_TEST_UMASK ,
171174 WIDE_OPEN_PERMISSIONS , BLANK_PERMISSIONS );
172175 }
173176
174177 @ Test
175178 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
177180 // set of umask
178181 testCreateRecursiveWithNonExistingDir (WIDE_OPEN_TEST_UMASK ,
179182 WIDE_OPEN_PERMISSIONS , WIDE_OPEN_FILE_PERMISSIONS );
180183 }
181184
182185 @ Test
183186 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
185188 // set of umask
186189 testCreateRecursiveWithNonExistingDir (USER_GROUP_OPEN_TEST_UMASK ,
187190 WIDE_OPEN_PERMISSIONS , USER_GROUP_OPEN_FILE_PERMISSIONS );
@@ -193,9 +196,9 @@ public void testMkdirWithExistingDir(FsPermission umask,
193196 Path f = fileContextTestHelper .getTestRootPath (fc , "aDir" );
194197 fc .setUMask (umask );
195198 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" );
199202 }
200203
201204 public void testMkdirRecursiveWithNonExistingDir (FsPermission umask ,
@@ -204,12 +207,12 @@ public void testMkdirRecursiveWithNonExistingDir(FsPermission umask,
204207 Path f = fileContextTestHelper .getTestRootPath (fc , "NonExistant2/aDir" );
205208 fc .setUMask (umask );
206209 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" );
210213 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" );
213216 }
214217
215218
@@ -218,9 +221,9 @@ public void testCreateRecursiveWithExistingDir(FsPermission umask,
218221 Path f = fileContextTestHelper .getTestRootPath (fc ,"foo" );
219222 fc .setUMask (umask );
220223 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" );
224227 }
225228
226229
@@ -229,14 +232,14 @@ public void testCreateRecursiveWithNonExistingDir(FsPermission umask,
229232 throws IOException {
230233 Path f = fileContextTestHelper .getTestRootPath (fc ,"NonExisting/foo" );
231234 Path fParent = fileContextTestHelper .getTestRootPath (fc , "NonExisting" );
232- Assert . assertFalse (exists (fc , fParent ));
235+ assertFalse (exists (fc , fParent ));
233236 fc .setUMask (umask );
234237 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" );
240243 }
241244
242245}
0 commit comments