Search in sources :

Example 6 with ResourceLoader

use of com.tvd12.ezyhttp.server.core.resources.ResourceLoader in project ezyhttp by youngmonkeys.

the class ResourceLoaderTest method listFileEmptyTest.

@Test
public void listFileEmptyTest() {
    // given
    File file = new File("unknow file");
    ResourceLoader sut = new ResourceLoader();
    // when
    File[] actual = MethodInvoker.create().object(sut).method("listFile").param(File.class, file).invoke(File[].class);
    // then
    Asserts.assertZero(actual.length);
}
Also used : ResourceLoader(com.tvd12.ezyhttp.server.core.resources.ResourceLoader) JarFile(java.util.jar.JarFile) File(java.io.File) Test(org.testng.annotations.Test)

Example 7 with ResourceLoader

use of com.tvd12.ezyhttp.server.core.resources.ResourceLoader in project ezyhttp by youngmonkeys.

the class ResourceLoaderTest method isNotFileElement.

@Test
public void isNotFileElement() {
    // given
    String filePath = "file\\";
    ResourceLoader sut = new ResourceLoader();
    // when
    boolean actual = MethodInvoker.create().object(sut).method("isFileElement").param(String.class, filePath).invoke(Boolean.class);
    // then
    Asserts.assertFalse(actual);
}
Also used : ResourceLoader(com.tvd12.ezyhttp.server.core.resources.ResourceLoader) Test(org.testng.annotations.Test)

Example 8 with ResourceLoader

use of com.tvd12.ezyhttp.server.core.resources.ResourceLoader in project ezyhttp by youngmonkeys.

the class ResourceLoaderTest method urlNull.

@Test
public void urlNull() {
    // given
    ResourceLoader sut = new ResourceLoader();
    // when
    List<String> listResources = sut.listResources("not found");
    // then
    Asserts.assertTrue(listResources.isEmpty());
}
Also used : ResourceLoader(com.tvd12.ezyhttp.server.core.resources.ResourceLoader) Test(org.testng.annotations.Test)

Example 9 with ResourceLoader

use of com.tvd12.ezyhttp.server.core.resources.ResourceLoader in project ezyhttp by youngmonkeys.

the class ResourceLoaderTest method regexTest.

@Test
public void regexTest() {
    // given
    ResourceLoader sut = new ResourceLoader();
    // when
    List<String> listResources = sut.listResources("static", Sets.newHashSet("^static/css/.+"));
    // then
    Asserts.assertEquals(2, listResources.size());
}
Also used : ResourceLoader(com.tvd12.ezyhttp.server.core.resources.ResourceLoader) Test(org.testng.annotations.Test)

Example 10 with ResourceLoader

use of com.tvd12.ezyhttp.server.core.resources.ResourceLoader in project ezyhttp by youngmonkeys.

the class ResourceLoaderTest method addURLsToSetTest.

@Test
public void addURLsToSetTest() {
    // given
    ResourceLoader sut = new ResourceLoader();
    Set<URL> answer = new HashSet<>();
    Exception exception = new Exception("just test");
    EzySupplier<Enumeration<URL>> supplier = () -> {
        throw exception;
    };
    // when
    MethodInvoker.create().object(sut).method("addURLsToSet").param(Set.class, answer).param(EzySupplier.class, supplier).invoke();
    // then
    Asserts.assertTrue(answer.isEmpty());
}
Also used : ResourceLoader(com.tvd12.ezyhttp.server.core.resources.ResourceLoader) EzySupplier(com.tvd12.ezyfox.function.EzySupplier) URL(java.net.URL) MalformedURLException(java.net.MalformedURLException) Test(org.testng.annotations.Test)

Aggregations

ResourceLoader (com.tvd12.ezyhttp.server.core.resources.ResourceLoader)11 Test (org.testng.annotations.Test)11 URL (java.net.URL)3 JarFile (java.util.jar.JarFile)3 File (java.io.File)2 MalformedURLException (java.net.MalformedURLException)2 EzySupplier (com.tvd12.ezyfox.function.EzySupplier)1