@Test
    public void readResource_2xx_inputStreamClosed() throws IOException {
        HttpURLConnection mockUrlConn = mock(HttpURLConnection.class);
        when(mockUrlConn.getResponseCode()).thenReturn(200);
        TestInputStream is = new TestInputStream();
        when(mockUrlConn.getInputStream()).thenReturn(is);
        when(mockConnection.connectToEndpoint(eq(endpoint), any(Map.class), eq("GET"))).thenReturn(mockUrlConn);

        new DefaultEC2ResourceFetcher(mockConnection).readResource(endpoint, customRetryPolicy, Collections.<String, String>emptyMap());

        assertTrue(is.closed);
    }
When readResource is called with custom retry policy
and additional headers, the SDK User-Agent should be
added.
aws-java-sdk-core/src/test/java/com/amazonaws/internal/EC2ResourceFetcherTest.java