Index: components/cronet/android/test/javatests/src/org/chromium/net/urlconnection/CronetChunkedOutputStreamTest.java |
diff --git a/components/cronet/android/test/javatests/src/org/chromium/net/urlconnection/CronetChunkedOutputStreamTest.java b/components/cronet/android/test/javatests/src/org/chromium/net/urlconnection/CronetChunkedOutputStreamTest.java |
index a7df1c01f2a3dea60c23d53761d1f5080fb7438f..8cff9ddfc33c73b47f6dca7209a7c3d2f1b498c8 100644 |
--- a/components/cronet/android/test/javatests/src/org/chromium/net/urlconnection/CronetChunkedOutputStreamTest.java |
+++ b/components/cronet/android/test/javatests/src/org/chromium/net/urlconnection/CronetChunkedOutputStreamTest.java |
@@ -10,6 +10,7 @@ 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; |
@@ -87,6 +88,33 @@ public class CronetChunkedOutputStreamTest extends CronetTestBase { |
@SmallTest |
@Feature({"Cronet"}) |
@CompareDefaultWithCronet |
+ public void testWriteAfterRequestFailed() throws Exception { |
+ URL url = new URL(NativeTestServer.getEchoBodyURL()); |
+ HttpURLConnection connection = (HttpURLConnection) url.openConnection(); |
+ connection.setDoOutput(true); |
+ connection.setRequestMethod("POST"); |
+ connection.setChunkedStreamingMode(0); |
+ OutputStream out = connection.getOutputStream(); |
+ out.write(UPLOAD_DATA); |
+ NativeTestServer.shutdownNativeTestServer(); |
+ try { |
+ out.write(TestUtil.getLargeData()); |
+ connection.getResponseCode(); |
+ fail(); |
+ } catch (IOException e) { |
+ 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 testPost() throws Exception { |
URL url = new URL(NativeTestServer.getEchoBodyURL()); |
HttpURLConnection connection = (HttpURLConnection) url.openConnection(); |