@Test public void bufferRequests() throws Exception { ClientHttpRequest mockRequest = mock(ClientHttpRequest.class); ClientHttpResponse mockResponse = mock(ClientHttpResponse.class); when(mockResponse.getBody()).thenReturn(new ByteArrayInputStream("Test Body".getBytes())); when(mockRequest.getHeaders()).thenReturn(new HttpHeaders()); when(mockRequest.getBody()).thenReturn(new ByteArrayOutputStream()); when(mockRequest.execute()).thenReturn(mockResponse); ClientHttpRequestFactory mockRequestFactory = mock(ClientHttpRequestFactory.class); when(mockRequestFactory.createRequest(new URI("/VNVOZ/test"), HttpMethod.GET)).thenReturn(mockRequest); ClientHttpRequestFactory bufferingRequestFactory = ClientHttpRequestFactorySelector.bufferRequests(mockRequestFactory); ClientHttpRequest request = bufferingRequestFactory.createRequest(new URI("/VNVOZ/test"), HttpMethod.GET); ClientHttpResponse response = request.execute(); response.getBody(); response.getBody(); response.getBody(); verify(mockRequest, times(1)).getBody(); }
public static ClientHttpRequestFactory bufferRequests(ClientHttpRequestFactory requestFactory) { return new BufferingClientHttpRequestFactory(requestFactory); }
ClientHttpRequestFactorySelector { public static ClientHttpRequestFactory bufferRequests(ClientHttpRequestFactory requestFactory) { return new BufferingClientHttpRequestFactory(requestFactory); } }
ClientHttpRequestFactorySelector { public static ClientHttpRequestFactory bufferRequests(ClientHttpRequestFactory requestFactory) { return new BufferingClientHttpRequestFactory(requestFactory); }  }
ClientHttpRequestFactorySelector { public static ClientHttpRequestFactory bufferRequests(ClientHttpRequestFactory requestFactory) { return new BufferingClientHttpRequestFactory(requestFactory); }  static ClientHttpRequestFactory foo(); static ClientHttpRequestFactory getRequestFactory(); static ClientHttpRequestFactory bufferRequests(ClientHttpRequestFactory requestFactory); static void setAllTrust(boolean isAllTrust); }
ClientHttpRequestFactorySelector { public static ClientHttpRequestFactory bufferRequests(ClientHttpRequestFactory requestFactory) { return new BufferingClientHttpRequestFactory(requestFactory); }  static ClientHttpRequestFactory foo(); static ClientHttpRequestFactory getRequestFactory(); static ClientHttpRequestFactory bufferRequests(ClientHttpRequestFactory requestFactory); static void setAllTrust(boolean isAllTrust);  }