@Test
public void testSocketError() {

  // Check true cases.
  Throwable socketError1 = new SocketTimeoutException("socket error 1");
  assertThat(errorExtractor.socketError(socketError1)).isTrue();
  assertThat(errorExtractor.socketError(new Exception(socketError1))).isTrue();
  assertThat(errorExtractor.socketError(new IOException(new IOException(socketError1)))).isTrue();
  Throwable socketError2 = new SocketException("socket error 2");
  assertThat(errorExtractor.socketError(socketError2)).isTrue();
  assertThat(errorExtractor.socketError(new Exception(socketError2))).isTrue();
  assertThat(errorExtractor.socketError(new IOException(new IOException(socketError2)))).isTrue();
  Throwable socketError3 = new SSLException("ssl exception", new EOFException("eof"));
  assertThat(errorExtractor.socketError(socketError3)).isTrue();
  assertThat(errorExtractor.socketError(new Exception(socketError3))).isTrue();
  assertThat(errorExtractor.socketError(new IOException(new IOException(socketError3)))).isTrue();
  // Check false cases.
  Throwable notSocketError = new Exception("not socket error");
  Throwable notIOError = new Exception("not io error");
  assertThat(errorExtractor.socketError(notSocketError)).isFalse();
  assertThat(errorExtractor.socketError(new IOException(notSocketError))).isFalse();
  assertThat(errorExtractor.socketError(new SSLException("handshake failed", notIOError)))
      .isFalse();
}