Commit 94f5566e authored by Albert J. Wong's avatar Albert J. Wong

Revert "TestWebServer needs to use a free port."

Causing Android Build (dbg) findbugs to fail.

This reverts commit c4a3f88c.

BUG=none
TBR=hush

Review URL: https://codereview.chromium.org/514443002

Cr-Commit-Position: refs/heads/master@{#292025}
parent 5570dc0c
...@@ -62,6 +62,8 @@ import javax.net.ssl.X509TrustManager; ...@@ -62,6 +62,8 @@ import javax.net.ssl.X509TrustManager;
*/ */
public class TestWebServer { public class TestWebServer {
private static final String TAG = "TestWebServer"; private static final String TAG = "TestWebServer";
private static final int SERVER_PORT = 4444;
private static final int SSL_SERVER_PORT = 4445;
public static final String SHUTDOWN_PREFIX = "/shutdown"; public static final String SHUTDOWN_PREFIX = "/shutdown";
...@@ -106,21 +108,19 @@ public class TestWebServer { ...@@ -106,21 +108,19 @@ public class TestWebServer {
public TestWebServer(boolean ssl) throws Exception { public TestWebServer(boolean ssl) throws Exception {
mSsl = ssl; mSsl = ssl;
if (mSsl) { if (mSsl) {
mServerUri = "https:";
if (sSecureInstance != null) { if (sSecureInstance != null) {
sSecureInstance.shutdown(); sSecureInstance.shutdown();
} }
mServerUri = "https://localhost:" + SSL_SERVER_PORT;
} else { } else {
mServerUri = "http:";
if (sInstance != null) { if (sInstance != null) {
sInstance.shutdown(); sInstance.shutdown();
} }
mServerUri = "http://localhost:" + SERVER_PORT;
} }
setInstance(this, mSsl); setInstance(this, mSsl);
mServerThread = new ServerThread(this, mSsl); mServerThread = new ServerThread(this, mSsl);
mServerThread.start(); mServerThread.start();
mServerUri += "//localhost:" + mServerThread.mSocket.getLocalPort();
} }
/** /**
...@@ -552,9 +552,10 @@ public class TestWebServer { ...@@ -552,9 +552,10 @@ public class TestWebServer {
if (mIsSsl) { if (mIsSsl) {
mSslContext = SSLContext.getInstance("TLS"); mSslContext = SSLContext.getInstance("TLS");
mSslContext.init(getKeyManagers(), null, null); mSslContext.init(getKeyManagers(), null, null);
mSocket = mSslContext.getServerSocketFactory().createServerSocket(0); mSocket = mSslContext.getServerSocketFactory().createServerSocket(
SSL_SERVER_PORT);
} else { } else {
mSocket = new ServerSocket(0); mSocket = new ServerSocket(SERVER_PORT);
} }
return; return;
} catch (IOException e) { } catch (IOException e) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment