@Test public void testInterruptedWriteWithoutResponse() throws Exception { MockHttpURLConnection connection = new MockHttpURLConnection(new URL(HttpTesting.SIMPLE_URL)) { @Override public OutputStream getOutputStream() throws IOException { return new OutputStream() { @Override public void write(int b) throws IOException { throw new IOException("Error writing request body to server"); } }; } }; connection.setRequestMethod("POST"); NetHttpRequest request = new NetHttpRequest(connection); InputStream is = NetHttpRequestTest.class.getClassLoader().getResourceAsStream("file.txt"); HttpContent content = new InputStreamContent("text/plain", is); request.setStreamingContent(content); try { request.execute(); fail("Expected to throw an IOException"); } catch (IOException e) { assertEquals("Error writing request body to server", e.getMessage()); } }
@Override public LowLevelHttpResponse execute() throws IOException { return execute(DEFAULT_CONNECTION_WRITER); }
NetHttpRequest extends LowLevelHttpRequest { @Override public LowLevelHttpResponse execute() throws IOException { return execute(DEFAULT_CONNECTION_WRITER); } }
NetHttpRequest extends LowLevelHttpRequest { @Override public LowLevelHttpResponse execute() throws IOException { return execute(DEFAULT_CONNECTION_WRITER); } NetHttpRequest(HttpURLConnection connection); }
NetHttpRequest extends LowLevelHttpRequest { @Override public LowLevelHttpResponse execute() throws IOException { return execute(DEFAULT_CONNECTION_WRITER); } NetHttpRequest(HttpURLConnection connection); @Override void addHeader(String name, String value); @Override void setTimeout(int connectTimeout, int readTimeout); @Override void setWriteTimeout(int writeTimeout); @Override LowLevelHttpResponse execute(); }
NetHttpRequest extends LowLevelHttpRequest { @Override public LowLevelHttpResponse execute() throws IOException { return execute(DEFAULT_CONNECTION_WRITER); } NetHttpRequest(HttpURLConnection connection); @Override void addHeader(String name, String value); @Override void setTimeout(int connectTimeout, int readTimeout); @Override void setWriteTimeout(int writeTimeout); @Override LowLevelHttpResponse execute();  }