@Test public void testLoadBadClass() throws IOException { // now try getting it as a class try { pluginLoader.loadClass("bogus"); assertFalse("Exception expected", true); } catch (ClassNotFoundException e) { assertTrue("Exception expected", true); } }
@Test public void testLoadClass() throws IOException, ClassNotFoundException { // now try getting it as a class Class<?> testClass = pluginLoader.loadClass("org.pentaho.test.platform.engine.services.TestClassForClassloader"); assertNotNull("class is null", testClass); assertEquals( "wrong class", "org.pentaho.test.platform.engine.services.TestClassForClassloader", testClass.getName()); }
@Test public void testJarListedInClassLoader() throws ClassNotFoundException { boolean jarFound = false; for (URL url : pluginLoader.getURLs()) { if (url.toString().contains("test-jar.jar")) { jarFound = true; } } assertTrue("test-jar.jar not found in classloader", jarFound); // now load a class from the jar pluginLoader.loadClass("org.pentaho.test.platform.engine.services.TestClassForClassloader"); }