Search in sources :

Example 1 with FileResolver

use of io.vertx.core.spi.file.FileResolver in project vert.x by eclipse.

the class FileResolverTestBase method testResolveAfterCloseThrowsISE.

@Test
public void testResolveAfterCloseThrowsISE() throws Exception {
    FileResolver resolver2 = new FileResolverImpl();
    File file = resolver2.resolveFile("webroot/somefile.html");
    assertTrue(file.exists());
    File cacheDir = file.getParentFile().getParentFile();
    assertTrue(cacheDir.exists());
    resolver2.close();
    assertFalse(cacheDir.exists());
    try {
        resolver2.resolveFile("webroot/somefile.html");
        fail("Should fail");
    } catch (IllegalStateException e) {
    // OK
    }
}
Also used : FileResolverImpl(io.vertx.core.file.impl.FileResolverImpl) FileResolver(io.vertx.core.spi.file.FileResolver) File(java.io.File) Test(org.junit.Test)

Example 2 with FileResolver

use of io.vertx.core.spi.file.FileResolver in project vert.x by eclipse.

the class FileResolverFactoryTest method testResolver.

@Test
public void testResolver() {
    FileResolver resolver = ((VertxInternal) vertx).fileResolver();
    assertEquals(CustomFileResolver.class, resolver.getClass());
}
Also used : VertxInternal(io.vertx.core.impl.VertxInternal) FileResolver(io.vertx.core.spi.file.FileResolver) Test(org.junit.Test)

Example 3 with FileResolver

use of io.vertx.core.spi.file.FileResolver in project vert.x by eclipse.

the class FileResolverFactory method init.

@Override
default void init(VertxBuilder builder) {
    if (builder.fileResolver() == null) {
        FileResolver fileResolver = resolver(builder.options());
        builder.fileResolver(fileResolver);
    }
}
Also used : FileResolver(io.vertx.core.spi.file.FileResolver)

Example 4 with FileResolver

use of io.vertx.core.spi.file.FileResolver in project vert.x by eclipse.

the class FileResolverTestBase method testDeleteCacheDir.

@Test
public void testDeleteCacheDir() throws Exception {
    FileResolver resolver2 = new FileResolverImpl();
    File file = resolver2.resolveFile("webroot/somefile.html");
    assertTrue(file.exists());
    File cacheDir = file.getParentFile().getParentFile();
    assertTrue(cacheDir.exists());
    resolver2.close();
    assertFalse(cacheDir.exists());
}
Also used : FileResolverImpl(io.vertx.core.file.impl.FileResolverImpl) FileResolver(io.vertx.core.spi.file.FileResolver) File(java.io.File) Test(org.junit.Test)

Aggregations

FileResolver (io.vertx.core.spi.file.FileResolver)4 Test (org.junit.Test)3 FileResolverImpl (io.vertx.core.file.impl.FileResolverImpl)2 File (java.io.File)2 VertxInternal (io.vertx.core.impl.VertxInternal)1