Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(276)

Unified Diff: components/cronet/android/test/javatests/src/org/chromium/net/urlconnection/CronetHttpURLConnectionTest.java

Issue 2164863002: Fix CronetHttpURLConnectionTest#testServerHangsUp flake (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comment Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | components/cronet/android/test/native_test_server.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/cronet/android/test/javatests/src/org/chromium/net/urlconnection/CronetHttpURLConnectionTest.java
diff --git a/components/cronet/android/test/javatests/src/org/chromium/net/urlconnection/CronetHttpURLConnectionTest.java b/components/cronet/android/test/javatests/src/org/chromium/net/urlconnection/CronetHttpURLConnectionTest.java
index bc8ef9873c3d469884bf32c6cd2cc343154c5dc0..c66b4fdbe24289e177b1d027a935970b75d76648 100644
--- a/components/cronet/android/test/javatests/src/org/chromium/net/urlconnection/CronetHttpURLConnectionTest.java
+++ b/components/cronet/android/test/javatests/src/org/chromium/net/urlconnection/CronetHttpURLConnectionTest.java
@@ -846,20 +846,11 @@ public class CronetHttpURLConnectionTest extends CronetTestBase {
@Feature({"Cronet"})
@CompareDefaultWithCronet
public void testServerHangsUp() throws Exception {
- URL url = new URL(NativeTestServer.getEchoBodyURL());
+ URL url = new URL(NativeTestServer.getExabyteResponseURL());
final HttpURLConnection connection = (HttpURLConnection) url.openConnection();
- // Make the server echo a large request body, so it exceeds the internal
- // read buffer.
- connection.setDoOutput(true);
- connection.setRequestMethod("POST");
- byte[] largeData = TestUtil.getLargeData();
- connection.setFixedLengthStreamingMode(largeData.length);
- OutputStream out = connection.getOutputStream();
- out.write(largeData);
-
InputStream in = connection.getInputStream();
// Read one byte and shut down the server.
- assertTrue(in.read() != 1);
+ assertTrue(in.read() != -1);
NativeTestServer.shutdownNativeTestServer();
// Continue reading, and make sure the message loop will not block.
try {
@@ -867,24 +858,32 @@ public class CronetHttpURLConnectionTest extends CronetTestBase {
while (b != -1) {
b = in.read();
}
- // Server closes the connection before EOF can be received.
- fail();
+ // On KitKat, the default implementation doesn't throw an error.
+ if (!testingSystemHttpURLConnection()) {
+ // Server closes the connection before EOF can be received.
+ fail();
+ }
} catch (IOException e) {
// Expected.
// Cronet gives a net::ERR_CONTENT_LENGTH_MISMATCH while the
- // default implementation gives a java.net.ProtocolException with
- // "unexpected end of stream" message.
+ // default implementation sometimes gives a
+ // java.net.ProtocolException with "unexpected end of stream"
+ // message.
}
// Read once more, and make sure exception is thrown.
try {
in.read();
- fail();
+ // On KitKat, the default implementation doesn't throw an error.
+ if (!testingSystemHttpURLConnection()) {
+ fail();
+ }
} catch (IOException e) {
// Expected.
// Cronet gives a net::ERR_CONTENT_LENGTH_MISMATCH while the
- // default implementation gives a java.net.ProtocolException with
- // "unexpected end of stream" message.
+ // default implementation sometimes gives a
+ // java.net.ProtocolException with "unexpected end of stream"
+ // message.
}
// Spins up server to avoid crash when shutting it down in tearDown().
assertTrue(NativeTestServer.startNativeTestServer(getContext()));
« no previous file with comments | « no previous file | components/cronet/android/test/native_test_server.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698