1717 */
1818package org .apache .hadoop .hbase .security ;
1919
20- import static org .junit .Assert .*;
20+ import static org .junit .jupiter .api .Assertions .assertArrayEquals ;
21+ import static org .junit .jupiter .api .Assertions .assertEquals ;
22+ import static org .junit .jupiter .api .Assertions .assertFalse ;
23+ import static org .junit .jupiter .api .Assertions .assertNotNull ;
24+ import static org .junit .jupiter .api .Assertions .assertTrue ;
2125
2226import java .io .IOException ;
2327import java .security .PrivilegedAction ;
2428import java .security .PrivilegedExceptionAction ;
2529import org .apache .commons .lang3 .SystemUtils ;
2630import org .apache .hadoop .conf .Configuration ;
2731import org .apache .hadoop .fs .CommonConfigurationKeys ;
28- import org .apache .hadoop .hbase .HBaseClassTestRule ;
2932import org .apache .hadoop .hbase .HBaseConfiguration ;
3033import org .apache .hadoop .hbase .testclassification .SecurityTests ;
3134import org .apache .hadoop .hbase .testclassification .SmallTests ;
3235import org .apache .hadoop .security .UserGroupInformation ;
33- import org .junit .ClassRule ;
34- import org .junit .Test ;
35- import org .junit .experimental .categories .Category ;
36+ import org .junit .jupiter .api .Tag ;
37+ import org .junit .jupiter .api .Test ;
3638import org .slf4j .Logger ;
3739import org .slf4j .LoggerFactory ;
3840
3941import org .apache .hbase .thirdparty .com .google .common .collect .ImmutableSet ;
4042
41- @ Category ({ SecurityTests .class , SmallTests .class })
43+ @ Tag (SecurityTests .TAG )
44+ @ Tag (SmallTests .TAG )
4245public class TestUser {
4346
44- @ ClassRule
45- public static final HBaseClassTestRule CLASS_RULE = HBaseClassTestRule .forClass (TestUser .class );
46-
4747 private static final Logger LOG = LoggerFactory .getLogger (TestUser .class );
4848
4949 @ Test
@@ -113,8 +113,8 @@ public void testCacheGetGroupsRoot() throws Exception {
113113 public void testBasicAttributes () throws Exception {
114114 Configuration conf = HBaseConfiguration .create ();
115115 User user = User .createUserForTesting (conf , "simple" , new String [] { "foo" });
116- assertEquals ("Username should match" , " simple" , user .getName ());
117- assertEquals ("Short username should match" , " simple" , user .getShortName ());
116+ assertEquals ("simple" , user .getName (), "Username should match" );
117+ assertEquals ("simple" , user .getShortName (), "Short username should match" );
118118 // don't test shortening of kerberos names because regular Hadoop doesn't support them
119119 }
120120
@@ -131,12 +131,12 @@ public String run() throws IOException {
131131 };
132132
133133 String username = user .runAs (action );
134- assertEquals ("Current user within runAs() should match" , "testuser" , username );
134+ assertEquals ("testuser" , username , " Current user within runAs() should match" );
135135
136136 // ensure the next run is correctly set
137137 User user2 = User .createUserForTesting (conf , "testuser2" , new String [] { "foo" });
138138 String username2 = user2 .runAs (action );
139- assertEquals ("Second username should match second user" , "testuser2" , username2 );
139+ assertEquals ("testuser2" , username2 , " Second username should match second user" );
140140
141141 // check the exception version
142142 username = user .runAs (new PrivilegedExceptionAction <String >() {
@@ -145,16 +145,16 @@ public String run() throws Exception {
145145 return User .getCurrent ().getName ();
146146 }
147147 });
148- assertEquals ("User name in runAs() should match" , "testuser" , username );
148+ assertEquals ("testuser" , username , " User name in runAs() should match" );
149149
150150 // verify that nested contexts work
151151 user2 .runAs (new PrivilegedExceptionAction <Object >() {
152152 @ Override
153153 public Object run () throws IOException , InterruptedException {
154154 String nestedName = user .runAs (action );
155- assertEquals ("Nest name should match nested user" , "testuser" , nestedName );
156- assertEquals ("Current name should match current user " , "testuser2" ,
157- User . getCurrent (). getName () );
155+ assertEquals ("testuser" , nestedName , " Nest name should match nested user" );
156+ assertEquals ("testuser2 " , User . getCurrent (). getName () ,
157+ "Current name should match current user" );
158158 return null ;
159159 }
160160 });
@@ -173,7 +173,7 @@ public String run() {
173173 }
174174 });
175175
176- assertEquals ("Current user within runAs() should match" , "testuser" , username );
176+ assertEquals ("testuser" , username , " Current user within runAs() should match" );
177177 }
178178
179179 /**
@@ -211,32 +211,32 @@ public void testUserGroupNames() throws Exception {
211211 }
212212
213213 private void assertUserGroup (User user , ImmutableSet <String > groups ) {
214- assertNotNull ("GroupNames should be not null" , user . getGroupNames () );
215- assertTrue ("UserGroupNames length should be == " + groups .size (),
216- user . getGroupNames (). length == groups .size ());
214+ assertNotNull (user . getGroupNames (), "GroupNames should be not null" );
215+ assertTrue (user . getGroupNames (). length == groups .size (),
216+ "UserGroupNames length should be == " + groups .size ());
217217
218218 for (String group : user .getGroupNames ()) {
219- assertTrue ("groupName should be in set " , groups . contains ( group ) );
219+ assertTrue (groups . contains ( group ), "groupName should be in set " );
220220 }
221221 }
222222
223223 @ Test
224224 public void testSecurityForNonSecureHadoop () {
225- assertFalse ("Security should be disable in non-secure Hadoop" , User . isSecurityEnabled () );
225+ assertFalse (User . isSecurityEnabled (), "Security should be disable in non-secure Hadoop" );
226226
227227 Configuration conf = HBaseConfiguration .create ();
228228 conf .set (CommonConfigurationKeys .HADOOP_SECURITY_AUTHENTICATION , "kerberos" );
229229 conf .set (User .HBASE_SECURITY_CONF_KEY , "kerberos" );
230- assertTrue ("Security should be enabled" , User . isHBaseSecurityEnabled ( conf ) );
230+ assertTrue (User . isHBaseSecurityEnabled ( conf ), "Security should be enabled" );
231231
232232 conf = HBaseConfiguration .create ();
233233 conf .set (CommonConfigurationKeys .HADOOP_SECURITY_AUTHENTICATION , "kerberos" );
234- assertFalse ("HBase security should not be enabled if " + User . HBASE_SECURITY_CONF_KEY
235- + " is not set accordingly" , User . isHBaseSecurityEnabled ( conf ) );
234+ assertFalse (User . isHBaseSecurityEnabled ( conf ), "HBase security should not be enabled if "
235+ + User . HBASE_SECURITY_CONF_KEY + " is not set accordingly" );
236236
237237 conf = HBaseConfiguration .create ();
238238 conf .set (User .HBASE_SECURITY_CONF_KEY , "kerberos" );
239- assertTrue ("HBase security should be enabled regardless of underlying " + "HDFS settings" ,
240- User . isHBaseSecurityEnabled ( conf ) );
239+ assertTrue (User . isHBaseSecurityEnabled ( conf ) ,
240+ "HBase security should be enabled regardless of underlying " + "HDFS settings" );
241241 }
242242}
0 commit comments