svn merge -c 1452338 FIXES: HADOOP-9352. Expose UGI.setLoginUser for tests (daryn)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1452339 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Daryn Sharp 2013-03-04 15:03:33 +00:00
parent a5985e4b0e
commit 221b871f0c
3 changed files with 13 additions and 1 deletions

View File

@ -1065,6 +1065,8 @@ Release 0.23.7 - UNRELEASED
HADOOP-9336. Allow UGI of current connection to be queried. (Daryn Sharp HADOOP-9336. Allow UGI of current connection to be queried. (Daryn Sharp
via kihwal) via kihwal)
HADOOP-9352. Expose UGI.setLoginUser for tests (daryn)
OPTIMIZATIONS OPTIMIZATIONS
BUG FIXES BUG FIXES

View File

@ -65,6 +65,8 @@
import org.apache.hadoop.util.Shell; import org.apache.hadoop.util.Shell;
import org.apache.hadoop.util.Time; import org.apache.hadoop.util.Time;
import com.google.common.annotations.VisibleForTesting;
/** /**
* User and group information for Hadoop. * User and group information for Hadoop.
* This class wraps around a JAAS Subject and provides methods to determine the * This class wraps around a JAAS Subject and provides methods to determine the
@ -702,7 +704,8 @@ static UserGroupInformation getLoginUser() throws IOException {
@InterfaceAudience.Private @InterfaceAudience.Private
@InterfaceStability.Unstable @InterfaceStability.Unstable
synchronized static void setLoginUser(UserGroupInformation ugi) { @VisibleForTesting
public synchronized static void setLoginUser(UserGroupInformation ugi) {
// if this is to become stable, should probably logout the currently // if this is to become stable, should probably logout the currently
// logged in ugi if it's different // logged in ugi if it's different
loginUser = ugi; loginUser = ugi;

View File

@ -608,4 +608,11 @@ public Void run() throws IOException {
} }
}); });
} }
@Test(timeout=1000)
public void testSetLoginUser() throws IOException {
UserGroupInformation ugi = UserGroupInformation.createRemoteUser("test-user");
UserGroupInformation.setLoginUser(ugi);
assertEquals(ugi, UserGroupInformation.getLoginUser());
}
} }