diff options
author | Yi Kong <yikong@google.com> | 2016-11-01 09:13:55 +0800 |
---|---|---|
committer | Yi Kong <yikong@google.com> | 2016-11-02 11:56:00 +0800 |
commit | 76fcaa0e395ed2795e271213b10056264cb79aec (patch) | |
tree | ca67b0a6391c60d7842d3801a48434e2007ba3dc /support | |
parent | e9b3abc6bc5dcf9fb09dbf10a9751b09e3dc99a8 (diff) |
Address URLConnectionTest post-commit review comments
This change addresses some post-commit review comments for
commit 44c55c5b639d6c1eea6eeae8414ef9df95b67bb7:
* Moved SocketTimeoutException into a separate test.
* Added more infomative comments regarding setDelay.
* Reduced method visibility, being public method is unnecessary.
Bug: 32363029
Test: URLConnectionTest#test_setReadTimeoutI_SocketTimeoutException
Change-Id: Ia13ba801cfa6e06fc7597f4f665fa2d002b688e1
Diffstat (limited to 'support')
-rw-r--r-- | support/src/test/java/tests/support/Support_TestWebServer.java | 29 |
1 files changed, 11 insertions, 18 deletions
diff --git a/support/src/test/java/tests/support/Support_TestWebServer.java b/support/src/test/java/tests/support/Support_TestWebServer.java index 91fe6eef09..80e7361707 100644 --- a/support/src/test/java/tests/support/Support_TestWebServer.java +++ b/support/src/test/java/tests/support/Support_TestWebServer.java @@ -69,7 +69,7 @@ public class Support_TestWebServer implements Support_HttpConstants { /* Switch on/off logging */ boolean mLog = false; - /* Minimum delay before sending response */ + /* Minimum delay before sending each response */ int mDelay = 0; /* If set, this will keep connections alive after a request has been @@ -327,7 +327,7 @@ public class Support_TestWebServer implements Support_HttpConstants { this.s = s; } - public Worker setDelay(int delay) { + Worker setDelay(int delay) { this.delay = delay; return this; } @@ -606,6 +606,15 @@ public class Support_TestWebServer implements Support_HttpConstants { // Reset test number prior to outputing data testNum = -1; + // Delay before sending response + if (mDelay > 0) { + try { + Thread.sleep(mDelay); + } catch (InterruptedException e) { + // Ignored + } + } + // Write out the data printStatus(ps); printHeaders(ps); @@ -807,14 +816,6 @@ public class Support_TestWebServer implements Support_HttpConstants { * @param ps The PrintStream to write to */ void send404(PrintStream ps) throws IOException { - if (delay > 0) { - try { - Thread.sleep(delay); - } catch (InterruptedException e) { - // Ignored - } - } - ps.println("Not Found\n\n"+ "The requested resource was not found.\n"); } @@ -836,14 +837,6 @@ public class Support_TestWebServer implements Support_HttpConstants { } void sendFile(PrintStream ps, byte[] bytes) throws IOException { - if (delay > 0) { - try { - Thread.sleep(delay); - } catch (InterruptedException e) { - // Ignored - } - } - if (chunked) { int offset = 0; while (offset < bytes.length) { |