Merge -r 1370811:1370812 from trunk to branch. FIXES: HADOOP-8660

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1370815 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Alejandro Abdelnur 2012-08-08 15:43:26 +00:00
parent 92a99de731
commit 221e491f5d
2 changed files with 17 additions and 3 deletions

View File

@ -13,6 +13,7 @@
*/
package org.apache.hadoop.security.authentication.client;
import junit.framework.Assert;
import org.apache.hadoop.security.authentication.server.AuthenticationFilter;
import junit.framework.TestCase;
import org.mockito.Mockito;
@ -114,6 +115,18 @@ public abstract class AuthenticatorTestCase extends TestCase {
return "http://" + host + ":" + port + "/foo/bar";
}
private static class TestConnectionConfigurator
implements ConnectionConfigurator {
boolean invoked;
@Override
public HttpURLConnection configure(HttpURLConnection conn)
throws IOException {
invoked = true;
return conn;
}
}
private String POST = "test";
protected void _testAuthentication(Authenticator authenticator, boolean doPost) throws Exception {
@ -121,11 +134,10 @@ public abstract class AuthenticatorTestCase extends TestCase {
try {
URL url = new URL(getBaseURL());
AuthenticatedURL.Token token = new AuthenticatedURL.Token();
ConnectionConfigurator connConf =
Mockito.mock(ConnectionConfigurator.class);
TestConnectionConfigurator connConf = new TestConnectionConfigurator();
AuthenticatedURL aUrl = new AuthenticatedURL(authenticator, connConf);
HttpURLConnection conn = aUrl.openConnection(url, token);
Mockito.verify(connConf).configure(Mockito.<HttpURLConnection>any());
Assert.assertTrue(connConf.invoked);
String tokenStr = token.toString();
if (doPost) {
conn.setRequestMethod("POST");

View File

@ -208,6 +208,8 @@ Release 2.0.1-alpha - UNRELEASED
HADOOP-8405. ZKFC tests leak ZK instances. (todd)
HADOOP-8660. TestPseudoAuthenticator failing with NPE. (tucu)
Release 2.0.0-alpha - 05-23-2012
INCOMPATIBLE CHANGES