### Question:
UserGroupInformation { @Override public boolean equals(Object o) { if (o == this) { return true; } else if (o == null || getClass() != o.getClass()) { return false; } else { return subject == ((UserGroupInformation) o).subject; } } UserGroupInformation(Subject subject); static void setConfiguration(Configuration conf); static boolean isSecurityEnabled(); boolean hasKerberosCredentials(); static UserGroupInformation getCurrentUser(); synchronized static UserGroupInformation getLoginUser(); boolean isFromKeytab(); synchronized static void loginUserFromKeytab(String user,
                                  String path
                                  ); synchronized void reloginFromKeytab(); synchronized void reloginFromTicketCache(); synchronized static UserGroupInformation loginUserFromKeytabAndReturnUGI(String user,
                                  String path
                                  ); synchronized static boolean isLoginKeytabBased(); static UserGroupInformation createRemoteUser(String user); static UserGroupInformation createProxyUser(String user,
      UserGroupInformation realUser); UserGroupInformation getRealUser(); @InterfaceAudience.LimitedPrivate({"HDFS", "MapReduce"}) static UserGroupInformation createUserForTesting(String user, 
                                                          String[] userGroups); @InterfaceAudience.LimitedPrivate( { "HDFS", "MapReduce" }) static UserGroupInformation createProxyUserForTesting(String user,
      UserGroupInformation realUser, String[] userGroups); String getShortUserName(); String getUserName(); synchronized boolean addTokenIdentifier(TokenIdentifier tokenId); synchronized Set<TokenIdentifier> getTokenIdentifiers(); synchronized boolean addToken(Token<? extends TokenIdentifier> token); synchronized Collection<Token<? extends TokenIdentifier>> getTokens(); synchronized String[] getGroupNames(); @Override String toString(); synchronized void setAuthenticationMethod(AuthenticationMethod authMethod); synchronized AuthenticationMethod getAuthenticationMethod(); static AuthenticationMethod getRealAuthenticationMethod(
      UserGroupInformation ugi); @Override boolean equals(Object o); @Override int hashCode(); T doAs(PrivilegedAction<T> action); T doAs(PrivilegedExceptionAction<T> action
                    ); static void main(String [] args); static final String HADOOP_TOKEN_FILE_LOCATION; }### Answer:
@Test public void testEquals() throws Exception { UserGroupInformation uugi = UserGroupInformation.createUserForTesting(USER_NAME, GROUP_NAMES); assertEquals(uugi, uugi); UserGroupInformation ugi2 = UserGroupInformation.createUserForTesting(USER_NAME, GROUP_NAMES); assertFalse(uugi.equals(ugi2)); assertFalse(uugi.hashCode() == ugi2.hashCode()); UserGroupInformation ugi3 = new UserGroupInformation(uugi.getSubject()); assertEquals(uugi, ugi3); assertEquals(uugi.hashCode(), ugi3.hashCode()); }