Search in sources :

Example 6 with JavaDynamicClassLoader

use of alice.util.JavaDynamicClassLoader in project narchy by automenta.

the class JavaDynamicClassLoaderTestCase method TestNestedPackage.

@Test
public void TestNestedPackage() throws ClassNotFoundException, IOException {
    assertThrows(ClassNotFoundException.class, () -> {
        JavaDynamicClassLoader loader = null;
        File file = new File(".");
        String tempPath = file.getCanonicalPath() + File.separator + "test" + File.separator + "unit" + File.separator + "TestURLClassLoaderNestedPackage.jar";
        URL[] urls = getURLsFromStringArray(tempPath);
        loader = new JavaDynamicClassLoader(urls, this.getClass().getClassLoader());
        Class<?> cl = loader.loadClass("acme.corp.Counter");
        assertNotNull(cl);
        cl = loader.loadClass("java.lang.String");
        assertNotNull(cl);
        loader.removeAllURLs();
        cl = loader.loadClass("Counter");
    });
}
Also used : File(java.io.File) URL(java.net.URL) JavaDynamicClassLoader(alice.util.JavaDynamicClassLoader) Test(org.junit.jupiter.api.Test)

Aggregations

JavaDynamicClassLoader (alice.util.JavaDynamicClassLoader)6 URL (java.net.URL)6 Test (org.junit.jupiter.api.Test)6 File (java.io.File)3 Disabled (org.junit.jupiter.api.Disabled)2 Method (java.lang.reflect.Method)1