@Test
    public void readResourceThrowsIOExceptionWhenNoConnection() throws IOException, URISyntaxException {
        int port = 0;
        try {
            port = SocketUtils.getUnusedPort();
        } catch (IOException ioexception) {
            fail("Unable to find an unused port");
        }

        try {
            ec2ResourceFetcher.readResource(new URI("http://localhost:" + port));
            fail("no exception is thrown");
        } catch (SdkClientException exception) {
            assertTrue(exception.getMessage().contains("Failed to connect"));
        }
    }
When a connection to end host cannot be opened, throws {@link IOException}.
aws-java-sdk-core/src/test/java/com/amazonaws/internal/EC2ResourceFetcherTest.java