CloudStore { void setupHttpClient(HttpClient client) { client.setFollowRedirects(false); client.setStopTimeout(1000); try { client.start(); } catch (Exception ex) { LOGGER.error("CloudStore: unable to start http client", ex); throw new ResourceException(ResourceException.INTERNAL_SERVER_ERROR, "Http client not available"); } } CloudStore(); void close(); void setHttpClient(HttpClient client); boolean isAwsEnabled(); AmazonS3 getS3Client(); AWSTemporaryCredentials assumeAWSRole(String account, String roleName, String principal,
                                                 Integer durationSeconds, String externalId); String getCloudAccount(String domainName);  }
@Test public void testSetupHttpClient() throws Exception { CloudStore cloudStore = new CloudStore(); HttpClient client = Mockito.mock(HttpClient.class); Mockito.doThrow(new Exception("Invalid client")).when(client).start(); try { cloudStore.setupHttpClient(client); fail(); } catch (ResourceException ex) { assertEquals(ex.getCode(), 500); } }