use of alice.util.JavaDynamicClassLoader in project narchy by automenta.
the class JavaDynamicClassLoaderTestCase method InvalidPathTest.
@Test
public void InvalidPathTest() throws ClassNotFoundException, IOException {
assertThrows(ClassNotFoundException.class, () -> {
JavaDynamicClassLoader loader = null;
URL url = new File(".").toURI().toURL();
loader = new JavaDynamicClassLoader(new URL[] { url }, this.getClass().getClassLoader());
loader.loadClass("Counter");
});
}
use of alice.util.JavaDynamicClassLoader in project narchy by automenta.
the class JavaDynamicClassLoaderTestCase method ConstructorTest.
@Test
public void ConstructorTest() throws IOException, ClassNotFoundException {
JavaDynamicClassLoader loader = new JavaDynamicClassLoader();
assertNotNull(loader);
setPath(true);
URL[] urls = getURLsFromStringArray(paths);
loader = new JavaDynamicClassLoader(urls, this.getClass().getClassLoader());
assertEquals(2, loader.getURLs().length);
}
use of alice.util.JavaDynamicClassLoader in project narchy by automenta.
the class JavaDynamicClassLoaderTestCase method LoadClassTest.
@Disabled
@Test
public void LoadClassTest() throws IOException, ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InstantiationException, InvocationTargetException {
JavaDynamicClassLoader loader = null;
setPath(true);
URL[] urls = getURLsFromStringArray(paths);
loader = new JavaDynamicClassLoader(urls, this.getClass().getClassLoader());
assertEquals(2, loader.getURLs().length);
Class<?> cl = loader.loadClass("Counter");
assertNotNull(cl);
Method m = cl.getMethod("inc");
m.setAccessible(true);
Object obj = cl.newInstance();
m.invoke(obj);
Method m1 = cl.getMethod("getValue");
m1.setAccessible(true);
Object res_obj = m1.invoke(obj);
int res = new Integer(res_obj.toString());
assertEquals(1, res);
}
use of alice.util.JavaDynamicClassLoader in project narchy by automenta.
the class JavaDynamicClassLoaderTestCase method LoadClassNotFoundTest.
@Test
public void LoadClassNotFoundTest() throws ClassNotFoundException, IOException {
assertThrows(ClassNotFoundException.class, () -> {
JavaDynamicClassLoader loader = null;
setPath(true);
URL[] urls = getURLsFromStringArray(paths);
loader = new JavaDynamicClassLoader(urls, this.getClass().getClassLoader());
loader.loadClass("ClassNotFound");
});
}
use of alice.util.JavaDynamicClassLoader in project narchy by automenta.
the class JavaDynamicClassLoaderTestCase method URLHandling.
@Disabled
@Test
public void URLHandling() throws ClassNotFoundException, IOException {
JavaDynamicClassLoader loader = null;
URL url = new File(".").toURI().toURL();
loader = new JavaDynamicClassLoader(new URL[] { url }, this.getClass().getClassLoader());
assertEquals(1, loader.getURLs().length);
loader.removeURL(url);
assertEquals(0, loader.getURLs().length);
setPath(true);
loader.addURLs(getURLsFromStringArray(paths));
assertEquals(2, loader.getURLs().length);
loader.loadClass("Counter");
assertEquals(1, loader.getLoadedClasses().length);
}