Search in sources :

Example 1 with ResourceLoader

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

the class ResourceLoaderTest method loadFromJarTest.

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

Example 2 with ResourceLoader

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

the class ResourceLoaderTest method loadFromFolder.

@Test
public void loadFromFolder() {
    // given
    ResourceLoader sut = new ResourceLoader();
    // when
    List<String> listResources = sut.listResources("src/main/resources");
    // then
    Asserts.assertEquals(Objects.requireNonNull(new File("src/main/resources").list()).length, listResources.size());
}
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 3 with ResourceLoader

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

the class ResourceLoaderTest method urlPathEmpty.

@Test
public void urlPathEmpty() {
    // given
    ResourceLoader sut = new ResourceLoader() {

        @Override
        protected Set<URL> getResourceURLs(String resource) {
            try {
                return Sets.newHashSet(new URL("http://locahost"));
            } catch (MalformedURLException e) {
                e.printStackTrace();
                throw new IllegalArgumentException(e);
            }
        }
    };
    // when
    List<String> listResources = sut.listResources("application.yaml");
    // then
    Asserts.assertTrue(listResources.isEmpty());
}
Also used : ResourceLoader(com.tvd12.ezyhttp.server.core.resources.ResourceLoader) MalformedURLException(java.net.MalformedURLException) URL(java.net.URL) Test(org.testng.annotations.Test)

Example 4 with ResourceLoader

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

the class ResourceLoaderTest method getJarFileNullDueToException.

@Test
public void getJarFileNullDueToException() {
    // given
    String filePath = "#$%^&*";
    ResourceLoader sut = new ResourceLoader();
    // when
    JarFile actual = MethodInvoker.create().object(sut).method("getJarFile").param(String.class, filePath).invoke(JarFile.class);
    // then
    Asserts.assertNull(actual);
}
Also used : ResourceLoader(com.tvd12.ezyhttp.server.core.resources.ResourceLoader) JarFile(java.util.jar.JarFile) Test(org.testng.annotations.Test)

Example 5 with ResourceLoader

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

the class ResourceLoaderTest method addURLsToSetURLsIsNull.

@Test
public void addURLsToSetURLsIsNull() {
    // given
    ResourceLoader sut = new ResourceLoader();
    Set<URL> answer = new HashSet<>();
    // when
    MethodInvoker.create().object(sut).method("addURLsToSet").param(Set.class, answer).param(Enumeration.class, null).invoke();
    // then
    Asserts.assertTrue(answer.isEmpty());
}
Also used : ResourceLoader(com.tvd12.ezyhttp.server.core.resources.ResourceLoader) URL(java.net.URL) 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