Esempio n. 1
0
 @Test
 public void testRecursivelyUnpack2() throws Exception {
   File file = resolver.resolveFile(webRoot + "/subdir");
   assertTrue(file.exists());
   File sub = new File(new File(file, "subdir2"), "subfile2.html");
   assertTrue(sub.exists());
   assertEquals("<html><body>subfile2</body></html>", readFile(sub));
 }
Esempio n. 2
0
 @Test
 public void testResolveSubDirectoryFromClasspath() throws Exception {
   for (int i = 0; i < 2; i++) {
     File file = resolver.resolveFile(webRoot + "/subdir");
     assertTrue(file.exists());
     assertTrue(file.getPath().startsWith(".vertx" + File.separator + "file-cache-"));
     assertTrue(file.isDirectory());
   }
 }
Esempio n. 3
0
 @Test
 public void testResolveFileFromClasspath() throws Exception {
   for (int i = 0; i < 2; i++) {
     File file = resolver.resolveFile("afile.html");
     assertTrue(file.exists());
     assertTrue(file.getPath().startsWith(".vertx" + File.separator + "file-cache-"));
     assertFalse(file.isDirectory());
     assertEquals("<html><body>afile</body></html>", readFile(file));
   }
 }
Esempio n. 4
0
 @Test
 public void testResolveFileFromClasspathDisableCaching() throws Exception {
   System.setProperty(FileResolver.DISABLE_FILE_CACHING_PROP_NAME, "true");
   resolver = new FileResolver(vertx);
   for (int i = 0; i < 2; i++) {
     File file = resolver.resolveFile("afile.html");
     assertTrue(file.exists());
     assertTrue(file.getPath().startsWith(".vertx" + File.separator + "file-cache-"));
     assertFalse(file.isDirectory());
     assertEquals("<html><body>afile</body></html>", readFile(file));
   }
 }
Esempio n. 5
0
 @Test
 public void testDeleteCacheDir() throws Exception {
   Vertx vertx2 = vertx();
   FileResolver resolver2 = new FileResolver(vertx2);
   File file = resolver2.resolveFile(webRoot + "/somefile.html");
   assertTrue(file.exists());
   File cacheDir = file.getParentFile().getParentFile();
   assertTrue(cacheDir.exists());
   resolver2.close(
       onSuccess(
           res -> {
             assertFalse(cacheDir.exists());
             vertx2.close(
                 res2 -> {
                   testComplete();
                 });
           }));
   await();
 }
Esempio n. 6
0
 @Test
 public void testResolveNotExistFileInDirectory() {
   File file = resolver.resolveFile("somedir/doesnotexist.txt");
   assertFalse(file.exists());
   assertEquals("somedir" + File.separator + "doesnotexist.txt", file.getPath());
 }
Esempio n. 7
0
 @Test
 public void testResolveNotExistDirectory() {
   File file = resolver.resolveFile("somedir");
   assertFalse(file.exists());
   assertEquals("somedir", file.getPath());
 }
Esempio n. 8
0
 @Test
 public void testResolveNotExistFile() {
   File file = resolver.resolveFile("doesnotexist.txt");
   assertFalse(file.exists());
   assertEquals("doesnotexist.txt", file.getPath());
 }