Exemplo 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));
 }
Exemplo 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());
   }
 }
Exemplo 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));
   }
 }
Exemplo n.º 4
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();
 }
Exemplo n.º 5
0
 @Override
 protected void tearDown() throws Exception {
   CountDownLatch latch = new CountDownLatch(1);
   resolver.close(
       onSuccess(
           res -> {
             latch.countDown();
           }));
   awaitLatch(latch);
   super.tearDown();
 }
Exemplo n.º 6
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));
   }
 }
Exemplo n.º 7
0
 @Test
 public void testResolveNotExistFileInDirectory() {
   File file = resolver.resolveFile("somedir/doesnotexist.txt");
   assertFalse(file.exists());
   assertEquals("somedir" + File.separator + "doesnotexist.txt", file.getPath());
 }
Exemplo n.º 8
0
 @Test
 public void testResolveNotExistDirectory() {
   File file = resolver.resolveFile("somedir");
   assertFalse(file.exists());
   assertEquals("somedir", file.getPath());
 }
Exemplo n.º 9
0
 @Test
 public void testResolveNotExistFile() {
   File file = resolver.resolveFile("doesnotexist.txt");
   assertFalse(file.exists());
   assertEquals("doesnotexist.txt", file.getPath());
 }