| 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 72f74ae14823bc0c15c03bd96cbe0127dac86a15..d7765f1e260da2874de39bfd41852e40a05fbb24 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
|
| @@ -97,6 +97,46 @@ public class CronetFixedModeOutputStreamTest extends CronetTestBase {
|
| @SmallTest
|
| @Feature({"Cronet"})
|
| @CompareDefaultWithCronet
|
| + public void testGetResponseAfterWriteFailed() throws Exception {
|
| + URL url = new URL(NativeTestServer.getEchoBodyURL());
|
| + NativeTestServer.shutdownNativeTestServer();
|
| + HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
| + connection.setDoOutput(true);
|
| + connection.setRequestMethod("POST");
|
| + // Set content-length as 1 byte, so Cronet will upload once that 1 byte
|
| + // is passed to it.
|
| + connection.setFixedLengthStreamingMode(1);
|
| + try {
|
| + OutputStream out = connection.getOutputStream();
|
| + out.write(1);
|
| + fail();
|
| + } catch (IOException e) {
|
| + if (!testingSystemHttpURLConnection()) {
|
| + UrlRequestException requestException = (UrlRequestException) e;
|
| + assertEquals(UrlRequestException.ERROR_CONNECTION_REFUSED,
|
| + requestException.getErrorCode());
|
| + }
|
| + }
|
| + // Make sure IOException is reported again when trying to read response
|
| + // from the connection.
|
| + try {
|
| + 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"));
|
|
|