| 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..965005051e5c1ef3714f4bac0f978af3d60e1f00 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
|
| @@ -11,6 +11,7 @@ import org.chromium.net.CronetTestBase;
|
| import org.chromium.net.CronetTestFramework;
|
| import org.chromium.net.NativeTestServer;
|
|
|
| +import java.io.IOException;
|
| import java.io.OutputStream;
|
| import java.net.HttpRetryException;
|
| import java.net.HttpURLConnection;
|
| @@ -66,8 +67,31 @@ 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.
|
| + }
|
| + // 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 =
|
|
|