@SuppressWarnings("unchecked") @Test public void failed_get_should_call_error_method_in_callback_and_relase_connection() throws Exception { RestTemplate template = new RestTemplate(client); ResponseCallback<String> callback = mock(ResponseCallback.class); HttpResponse rsp = mock(HttpResponse.class); when(client.get("some_path")).thenReturn(rsp); when(rsp.isSuccessful()).thenReturn(Boolean.FALSE); template.get("some_path", callback); verify(callback).error(any(HttpResponse.class)); verify(rsp).releaseConnection(); }
public <T> T get(String path, ResponseCallback<T> callback) { HttpResponse hr = client.get(path); return handleResponse(callback, hr); }
RestTemplate { public <T> T get(String path, ResponseCallback<T> callback) { HttpResponse hr = client.get(path); return handleResponse(callback, hr); } }
RestTemplate { public <T> T get(String path, ResponseCallback<T> callback) { HttpResponse hr = client.get(path); return handleResponse(callback, hr); } RestTemplate(HttpClient client); }
RestTemplate { public <T> T get(String path, ResponseCallback<T> callback) { HttpResponse hr = client.get(path); return handleResponse(callback, hr); } RestTemplate(HttpClient client); T get(String path, ResponseCallback<T> callback); T getUncached(String path, ResponseCallback<T> callback); HttpResponse get(String path); HttpResponse getUncached(String path); void put(String path); T put(String path, ResponseCallback<T> callback); T put(String path, String content, ResponseCallback<T> callback); T put(String path, HttpEntity httpEntity, ResponseCallback<T> callback); T copy(String path, String destinationUri, ResponseCallback<T> callback); void put(String path, String content); void put(String path, HttpEntity httpEntity); void put(String path, InputStream data, String contentType,
			long contentLength); T put(String path, InputStream data, String contentType,
			long contentLength, ResponseCallback<T> callback); T post(String path, String content, ResponseCallback<T> callback); T post(String path, HttpEntity httpEntity, ResponseCallback<T> callback); T post(String path, InputStream content, ResponseCallback<T> callback); T postUncached(String path, String content, ResponseCallback<T> callback); HttpResponse post(String path, String content ); HttpResponse postUncached(String path, String content ); T delete(String path, ResponseCallback<T> callback); void delete(String path); T head(String path, ResponseCallback<T> callback); }
RestTemplate { public <T> T get(String path, ResponseCallback<T> callback) { HttpResponse hr = client.get(path); return handleResponse(callback, hr); } RestTemplate(HttpClient client); T get(String path, ResponseCallback<T> callback); T getUncached(String path, ResponseCallback<T> callback); HttpResponse get(String path); HttpResponse getUncached(String path); void put(String path); T put(String path, ResponseCallback<T> callback); T put(String path, String content, ResponseCallback<T> callback); T put(String path, HttpEntity httpEntity, ResponseCallback<T> callback); T copy(String path, String destinationUri, ResponseCallback<T> callback); void put(String path, String content); void put(String path, HttpEntity httpEntity); void put(String path, InputStream data, String contentType,
			long contentLength); T put(String path, InputStream data, String contentType,
			long contentLength, ResponseCallback<T> callback); T post(String path, String content, ResponseCallback<T> callback); T post(String path, HttpEntity httpEntity, ResponseCallback<T> callback); T post(String path, InputStream content, ResponseCallback<T> callback); T postUncached(String path, String content, ResponseCallback<T> callback); HttpResponse post(String path, String content ); HttpResponse postUncached(String path, String content ); T delete(String path, ResponseCallback<T> callback); void delete(String path); T head(String path, ResponseCallback<T> callback);  }