diff options
author | hush <hush@chromium.org> | 2014-08-26 15:53:19 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-08-26 22:57:18 +0000 |
commit | c4a3f88c4434e86057a8c7ae4e109b8be4138d8f (patch) | |
tree | 8c0f156fede30998df9704dbe572ac1f10a4434b /net/test/android | |
parent | c6593cdd00a2b350a0b3003e7d68171c231907c1 (diff) | |
download | chromium_src-c4a3f88c4434e86057a8c7ae4e109b8be4138d8f.zip chromium_src-c4a3f88c4434e86057a8c7ae4e109b8be4138d8f.tar.gz chromium_src-c4a3f88c4434e86057a8c7ae4e109b8be4138d8f.tar.bz2 |
TestWebServer needs to use a free port.
Instead of a hardcoded port that could be taken.
BUG=
Review URL: https://codereview.chromium.org/502503003
Cr-Commit-Position: refs/heads/master@{#292014}
Diffstat (limited to 'net/test/android')
-rw-r--r-- | net/test/android/javatests/src/org/chromium/net/test/util/TestWebServer.java | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/net/test/android/javatests/src/org/chromium/net/test/util/TestWebServer.java b/net/test/android/javatests/src/org/chromium/net/test/util/TestWebServer.java index 53202a9..eaa7623 100644 --- a/net/test/android/javatests/src/org/chromium/net/test/util/TestWebServer.java +++ b/net/test/android/javatests/src/org/chromium/net/test/util/TestWebServer.java @@ -62,8 +62,6 @@ import javax.net.ssl.X509TrustManager; */ public class 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"; @@ -108,19 +106,21 @@ public class TestWebServer { public TestWebServer(boolean ssl) throws Exception { mSsl = ssl; if (mSsl) { + mServerUri = "https:"; if (sSecureInstance != null) { sSecureInstance.shutdown(); } - mServerUri = "https://localhost:" + SSL_SERVER_PORT; } else { + mServerUri = "http:"; if (sInstance != null) { sInstance.shutdown(); } - mServerUri = "http://localhost:" + SERVER_PORT; } + setInstance(this, mSsl); mServerThread = new ServerThread(this, mSsl); mServerThread.start(); + mServerUri += "//localhost:" + mServerThread.mSocket.getLocalPort(); } /** @@ -552,10 +552,9 @@ public class TestWebServer { if (mIsSsl) { mSslContext = SSLContext.getInstance("TLS"); mSslContext.init(getKeyManagers(), null, null); - mSocket = mSslContext.getServerSocketFactory().createServerSocket( - SSL_SERVER_PORT); + mSocket = mSslContext.getServerSocketFactory().createServerSocket(0); } else { - mSocket = new ServerSocket(SERVER_PORT); + mSocket = new ServerSocket(0); } return; } catch (IOException e) { |