@Test public void writeEntityWithShouldOverrideHttpClientEntity() throws IOException, NoSuchFieldException, IllegalAccessException { OutputStream out = mock(OutputStream.class); HttpEntityWriter writer = mock(HttpEntityWriter.class); ArgumentCaptor<HttpEntity> entityCaptor = ArgumentCaptor.forClass(HttpEntity.class); when(writer.getContentLength()).thenReturn(123); toTest.writeEntityWith(writer); verify(request).setEntity(entityCaptor.capture()); HttpEntity entity = entityCaptor.getValue(); assertEquals(123, entity.getContentLength()); assertFalse(entity.isRepeatable()); assertTrue(entity.isStreaming()); try { entity.getContent(); fail(); } catch (UnsupportedOperationException e) { } entity.writeTo(out); verify(writer).writeEntityTo(out); }
public void writeEntityWith(HttpEntityWriter httpEntityWriter) throws IOException { ((HttpEntityEnclosingRequest) request).setEntity(new HttpEntityWriterHttpEntity(httpEntityWriter)); }
HttpClientHttpChannel implements HttpChannel { public void writeEntityWith(HttpEntityWriter httpEntityWriter) throws IOException { ((HttpEntityEnclosingRequest) request).setEntity(new HttpEntityWriterHttpEntity(httpEntityWriter)); } }
HttpClientHttpChannel implements HttpChannel { public void writeEntityWith(HttpEntityWriter httpEntityWriter) throws IOException { ((HttpEntityEnclosingRequest) request).setEntity(new HttpEntityWriterHttpEntity(httpEntityWriter)); } HttpClientHttpChannel(HttpClient client, HttpUriRequest request); }
HttpClientHttpChannel implements HttpChannel { public void writeEntityWith(HttpEntityWriter httpEntityWriter) throws IOException { ((HttpEntityEnclosingRequest) request).setEntity(new HttpEntityWriterHttpEntity(httpEntityWriter)); } HttpClientHttpChannel(HttpClient client, HttpUriRequest request); void setConnectionTimeout(int timeout); void setSocketTimeout(int timeout); void setHeader(String name, String value); void addHeader(String name, String value); void setContentType(String value); void setAccept(String value); void writeEntityWith(HttpEntityWriter httpEntityWriter); Response send(); }
HttpClientHttpChannel implements HttpChannel { public void writeEntityWith(HttpEntityWriter httpEntityWriter) throws IOException { ((HttpEntityEnclosingRequest) request).setEntity(new HttpEntityWriterHttpEntity(httpEntityWriter)); } HttpClientHttpChannel(HttpClient client, HttpUriRequest request); void setConnectionTimeout(int timeout); void setSocketTimeout(int timeout); void setHeader(String name, String value); void addHeader(String name, String value); void setContentType(String value); void setAccept(String value); void writeEntityWith(HttpEntityWriter httpEntityWriter); Response send();  }