### Question:
UrlResource extends Resource { @Override public boolean exists() { try { HttpURLConnection.setFollowRedirects(true); HttpURLConnection con = (HttpURLConnection) new URL(path).openConnection(); con.setRequestMethod("HEAD"); int responseCode = con.getResponseCode(); return (responseCode == HttpURLConnection.HTTP_OK); } catch (Exception e) { return false; } } UrlResource(String path); @Override boolean exists(); @Override InputStream getInputStream();  }### Answer:
@Test public void validUrlsThatDoNotExistShouldWork() throws Exception { final UrlResource urlResource = new UrlResource("http: assertFalse(urlResource.exists()); }
@Test public void validUrlsThatDoExistShouldWork() throws Exception { final UrlResource urlResource = new UrlResource("http: assertTrue(urlResource.exists()); }