HttpConnectionServerChecker extends ServerChecker { boolean isConnectionSuccessful(HttpURLConnection conn) { try { int responseCode = conn.getResponseCode(); return responseCode >= 200 && responseCode < 400; } catch (IOException e) { return false; } } HttpConnectionServerChecker(
      URL url,
      String machineName,
      String serverRef,
      long period,
      long timeout,
      int successThreshold,
      TimeUnit timeUnit,
      Timer timer,
      String token); @Override boolean isAvailable();  }
@Test(dataProvider = "successfulResponseCodeProvider") public void shouldConfirmConnectionSuccessIfResponseCodeIsBetween200And400(Integer responseCode) throws Exception { when(conn.getResponseCode()).thenReturn(responseCode); assertTrue(checker.isConnectionSuccessful(conn)); }
@Test(dataProvider = "nonSuccessfulResponseCodeProvider") public void shouldNotConfirmConnectionSuccessIfResponseCodeIsLessThan200Or400OrMore( Integer responseCode) throws Exception { when(conn.getResponseCode()).thenReturn(responseCode); assertFalse(checker.isConnectionSuccessful(conn)); }