@Test public void testCreateClient() throws Exception { int maxRedirects = 5; final CloseableHttpClient client = HttpClientHelper.createHttpClient(maxRedirects); assertThat(client, notNullValue()); }
@BeforeClass public static void setupClass() throws Exception { request = HttpUriRequestBuilder.create() .method(HttpMethods.GET) .path("/path") .build(); httpClient = spy(HttpClientHelper.createHttpClient(2)); }
protected NiciraNvpApi createNiciraNvpApi(final String host, final String username, final String password) throws CloudstackRESTException { try { return NiciraNvpApi.create().host(host).username(username).password(password).httpClient(HttpClientHelper.createHttpClient(MAX_REDIRECTS)).build(); } catch (final KeyManagementException e) { throw new CloudstackRESTException("Could not create HTTP client", e); } catch (final NoSuchAlgorithmException e) { throw new CloudstackRESTException("Could not create HTTP client", e); } catch (final KeyStoreException e) { throw new CloudstackRESTException("Could not create HTTP client", e); } }
@Test(expected = CloudstackRESTException.class) public void testExecuteRequestWhenClientThrowsIOException() throws Exception { final BasicRestClient restClient = BasicRestClient.create() .host(LOCALHOST) .client(HttpClientHelper.createHttpClient(5)) .build(); final CloseableHttpResponse response = restClient.execute(request); fail("A CloudstackRESTException should have been thrown by now."+ "\nWe got " + response.getStatusLine() + "\nMake sure you cannot reach '" + request.getURI() + "' by method " + request.getMethod()); }
@Test public void testCreateClient() throws Exception { final int maxRedirects = 5; final CloseableHttpClient client = HttpClientHelper.createHttpClient(maxRedirects); assertThat(client, notNullValue()); } }
@BeforeClass public static void setupClass() throws Exception { request = HttpUriRequestBuilder.create() .method(HttpMethods.GET) .path("/path") .build(); httpClient = spy(HttpClientHelper.createHttpClient(2)); }
@Test(expected = CosmicRESTException.class) public void testExecuteRequestWhenClientThrowsIOException() throws Exception { final BasicRestClient restClient = BasicRestClient.create() .host(LOCALHOST) .client(HttpClientHelper.createHttpClient(5)) .build(); final CloseableHttpResponse response = restClient.execute(request); fail("A CloudstackRESTException should have been thrown by now." + "\nWe got " + response.getStatusLine() + "\nMake sure you cannot reach '" + request.getURI() + "' by method " + request.getMethod()); } }