/** test constructor */ @Test public void testConstructor() throws Exception { UserGroupInformation ugi = UserGroupInformation.createUserForTesting("user2/[email protected]", GROUP_NAMES); // make sure the short and full user names are correct assertEquals("user2/[email protected]", ugi.getUserName()); assertEquals("user2", ugi.getShortUserName()); ugi = UserGroupInformation.createUserForTesting(USER_NAME, GROUP_NAMES); assertEquals("user1", ugi.getShortUserName()); // failure test testConstructorFailures(null); testConstructorFailures(""); }
@Test public void testGettingGroups() throws Exception { UserGroupInformation uugi = UserGroupInformation.createUserForTesting(USER_NAME, GROUP_NAMES); assertEquals(USER_NAME, uugi.getUserName()); assertArrayEquals(new String[] {GROUP1_NAME, GROUP2_NAME, GROUP3_NAME}, uugi.getGroupNames()); }