Ejemplo n.º 1
0
 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());
 }
Ejemplo n.º 2
0
 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());
 }
Ejemplo n.º 3
0
 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);
 }
Ejemplo n.º 4
0
 public void testShouldGetEmptyModificationnListWhenURLMalformed() {
   HttpFile httpFile = new HttpFile();
   httpFile.setURL("THISISAMALFORMEDURL");
   assertEquals(0, httpFile.getModifications(new Date(), new Date()).size());
 }