@Test public void differentHttpClient() throws Exception { // Custom http client try { documentLoader.setHttpClient(JsonUtils.createDefaultHttpClient()); assertNotSame(documentLoader.getHttpClient(), new DocumentLoader().getHttpClient()); } finally { // Use default again documentLoader.setHttpClient(null); assertSame(documentLoader.getHttpClient(), new DocumentLoader().getHttpClient()); } }
final ArgumentCaptor<HttpUriRequest> httpRequest = ArgumentCaptor .forClass(HttpUriRequest.class); documentLoader.setHttpClient(fakeHttpClient(httpRequest)); try { final Object context = JsonUtils.fromURL(url, documentLoader.getHttpClient()); assertTrue(context instanceof Map); } finally { documentLoader.setHttpClient(null); assertSame(documentLoader.getHttpClient(), new DocumentLoader().getHttpClient());