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

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

Issue 2131323002: [Cronet] Check whether request is done before spinning up message loop (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 | « components/cronet/android/test/javatests/src/org/chromium/net/urlconnection/CronetChunkedOutputStreamTest.java ('k') | no next file » | 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/CronetFixedModeOutputStreamTest.java
diff --git a/components/cronet/android/test/javatests/src/org/chromium/net/urlconnection/CronetFixedModeOutputStreamTest.java b/components/cronet/android/test/javatests/src/org/chromium/net/urlconnection/CronetFixedModeOutputStreamTest.java
index 81eb364bb1f16e1235d0e560e051621cf8d782e8..72f74ae14823bc0c15c03bd96cbe0127dac86a15 100644
--- a/components/cronet/android/test/javatests/src/org/chromium/net/urlconnection/CronetFixedModeOutputStreamTest.java
+++ b/components/cronet/android/test/javatests/src/org/chromium/net/urlconnection/CronetFixedModeOutputStreamTest.java
@@ -10,7 +10,9 @@ import org.chromium.base.test.util.Feature;
import org.chromium.net.CronetTestBase;
import org.chromium.net.CronetTestFramework;
import org.chromium.net.NativeTestServer;
+import org.chromium.net.UrlRequestException;
+import java.io.IOException;
import java.io.OutputStream;
import java.net.HttpRetryException;
import java.net.HttpURLConnection;
@@ -66,8 +68,36 @@ public class CronetFixedModeOutputStreamTest extends CronetTestBase {
@SmallTest
@Feature({"Cronet"})
@CompareDefaultWithCronet
- public void testFixedLengthStreamingModeZeroContentLength()
- throws Exception {
+ public void testWriteAfterRequestFailed() throws Exception {
+ URL url = new URL(NativeTestServer.getEchoBodyURL());
+ HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+ connection.setDoOutput(true);
+ connection.setRequestMethod("POST");
+ byte[] largeData = TestUtil.getLargeData();
+ connection.setFixedLengthStreamingMode(largeData.length);
+ OutputStream out = connection.getOutputStream();
+ out.write(largeData, 0, 10);
+ NativeTestServer.shutdownNativeTestServer();
+ try {
+ out.write(largeData, 10, largeData.length - 10);
+ connection.getResponseCode();
+ fail();
+ } catch (IOException e) {
+ // Expected.
+ if (!testingSystemHttpURLConnection()) {
+ UrlRequestException requestException = (UrlRequestException) e;
+ assertEquals(UrlRequestException.ERROR_CONNECTION_REFUSED,
+ requestException.getErrorCode());
+ }
+ }
+ // Restarting server to run the test for a second time.
+ assertTrue(NativeTestServer.startNativeTestServer(getContext()));
+ }
+
+ @SmallTest
+ @Feature({"Cronet"})
+ @CompareDefaultWithCronet
+ public void testFixedLengthStreamingModeZeroContentLength() throws Exception {
// Check content length is set.
URL echoLength = new URL(NativeTestServer.getEchoHeaderURL("Content-Length"));
HttpURLConnection connection1 =
« no previous file with comments | « components/cronet/android/test/javatests/src/org/chromium/net/urlconnection/CronetChunkedOutputStreamTest.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698