HADOOP-15282. HADOOP-15235 broke TestHttpFSServerWebServer

Signed-off-by: Akira Ajisaka <aajisaka@apache.org>
This commit is contained in:
Robert Kanter 2018-03-04 07:33:47 -08:00 committed by Akira Ajisaka
parent 3dc30bc24e
commit 21176a8ba7
No known key found for this signature in database
GPG Key ID: C1EDBB9CA400FD50

View File

@ -22,9 +22,12 @@
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.Charset;
import java.text.MessageFormat;
import org.apache.commons.io.FileUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.security.authentication.server.AuthenticationFilter;
import org.apache.hadoop.test.GenericTestUtils;
import org.apache.hadoop.test.HadoopUsersConfTestHelper;
import org.junit.Assert;
@ -57,7 +60,8 @@ public static void beforeClass() throws Exception {
System.setProperty("httpfs.home.dir", homeDir.getAbsolutePath());
System.setProperty("httpfs.log.dir", logsDir.getAbsolutePath());
System.setProperty("httpfs.config.dir", confDir.getAbsolutePath());
new File(confDir, "httpfs-signature.secret").createNewFile();
FileUtils.writeStringToFile(new File(confDir, "httpfs-signature.secret"),
"foo", Charset.forName("UTF-8"));
}
@Before
@ -65,6 +69,8 @@ public void setUp() throws Exception {
Configuration conf = new Configuration();
conf.set(HttpFSServerWebServer.HTTP_HOSTNAME_KEY, "localhost");
conf.setInt(HttpFSServerWebServer.HTTP_PORT_KEY, 0);
conf.set(AuthenticationFilter.SIGNATURE_SECRET_FILE,
"httpfs-signature.secret");
Configuration sslConf = new Configuration();
webServer = new HttpFSServerWebServer(conf, sslConf);
}
@ -76,7 +82,7 @@ public void testStartStop() throws Exception {
URL url = new URL(webServer.getUrl(), MessageFormat.format(
"/webhdfs/v1/?user.name={0}&op=liststatus", user));
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
Assert.assertEquals(conn.getResponseCode(), HttpURLConnection.HTTP_OK);
Assert.assertEquals(HttpURLConnection.HTTP_OK, conn.getResponseCode());
BufferedReader reader = new BufferedReader(
new InputStreamReader(conn.getInputStream()));
reader.readLine();