@Test
public void testRequestOpenFailDueToDnsFailure() {

  mockResponseStartFailure();
  when(mockNetworkException.getErrorCode())
      .thenReturn(NetworkException.ERROR_HOSTNAME_NOT_RESOLVED);
  try {
    dataSourceUnderTest.open(testDataSpec);
    fail("HttpDataSource.HttpDataSourceException expected");
  } catch (HttpDataSourceException e) {
    // Check for connection not automatically closed.
    assertThat(e.getCause() instanceof UnknownHostException).isTrue();
    verify(mockUrlRequest, never()).cancel();
    verify(mockTransferListener, never())
        .onTransferStart(dataSourceUnderTest, testDataSpec, /* isNetwork= */ true);
  }
}