### Question:
ConnectionCheck { public CheckResult checkURIfor401or403(String uri) { HttpURLConnection conn = null; final String checkName = "checkURIfor401or403" + " " + uri; try { conn = createConnection(uri); int responseCode = conn.getResponseCode(); if (responseCode == HttpStatus.SC_FORBIDDEN || responseCode == HttpStatus.SC_UNAUTHORIZED) { return new CheckResult(checkName, Status.UP, "expecting to get 401/403! " + createMessageFromConn(conn)); } else { return new CheckResult(checkName, Status.DOWN, "expecting to get 401/403! " + createMessageFromConn(conn)); } } catch (IOException e) { LOG.info(APIM_1001.pattern(), uri, e); return new CheckResult(checkName, Status.DOWN, e.getMessage()); } finally { if (conn != null) { conn.disconnect(); } } } ConnectionCheck(ApimAdapterConfig config, EmergencyModeState emergencyModeState, int connectionTimeoutMillis, int readTimeoutMillis);  ConnectionCheck(ApimAdapterConfig config, EmergencyModeState emergencyModeState); CheckResult checkURIfor401or403(String uri); CheckResult checkURI(String uri); CheckResult checkThreeScaleAdmin(); CheckResult checkThreeScaleBackend();  }### Answer:
@Test public void checkURIfor4xxOr200() { ConnectionCheck connectionCheck = new ConnectionCheck(apimAdapterConfig, emergencyModeState); CheckResult check200 = connectionCheck.checkURIfor401or403(baseUrl + "/admin/api/services/.*/proxy/mapping_rules.json.*"); CheckResult check400 = connectionCheck.checkURIfor401or403(baseUrl + "/YouShallNotPass"); CheckResult check500 = connectionCheck.checkURIfor401or403(baseUrl + "/misterStarkIDontFeelSoGood"); assertFalse(check200.isUp()); assertEquals(Status.DOWN, check200.getStatus()); assertTrue(check400.isUp()); assertEquals(Status.UP, check400.getStatus()); assertFalse(check500.isUp()); assertEquals(Status.DOWN, check500.getStatus()); }