public void testGetModificationsInvalidURL() throws Exception { HttpFile httpFile = new HttpFile(); File tempFile = File.createTempFile("HttpFileTest", null); tempFile.deleteOnExit(); httpFile.setURL(tempFile.toURI().toURL().toExternalForm()); tempFile.delete(); // should not throw with a URL that cannot be connected to httpFile.getModifications(new Date(), new Date()); }
public void testShouldGetEmptyModificationListWhenURLNotAvailable() throws MalformedURLException { HttpFile httpFile = new HttpFile() { protected long getURLLastModified(URL url) throws IOException { throw new UnknownHostException(url.getHost()); } }; String urlString = "http://NOTAREALURL" + System.currentTimeMillis() + ".com"; new URL(urlString); httpFile.setURL(urlString); assertEquals(0, httpFile.getModifications(new Date(), new Date()).size()); }
public void testGetModifications() throws Exception { final long timestamp = 100; HttpFile httpFile = new HttpFile() { protected long getURLLastModified(URL url) { return timestamp; } }; httpFile.setURL("http://dummy.domain.net/my/path?que=ry"); List modifications = httpFile.getModifications(new Date(1), new Date()); assertEquals(1, modifications.size()); Modification modif = (Modification) modifications.get(0); assertEquals("my/path?que=ry", modif.getFileName()); assertEquals("dummy.domain.net", modif.getFolderName()); assertEquals("dummy.domain.net/my/path?que=ry", modif.getFullPath()); assertEquals("", modif.comment); assertEquals(timestamp, modif.modifiedTime.getTime()); assertEquals("User", modif.userName); }
public void testShouldGetEmptyModificationnListWhenURLMalformed() { HttpFile httpFile = new HttpFile(); httpFile.setURL("THISISAMALFORMEDURL"); assertEquals(0, httpFile.getModifications(new Date(), new Date()).size()); }