ClassLoaderManager { public ClassLoader get(String configurationName) throws ConfigurationException { return get(configurationName, null); } ClassLoaderManager(IbisContext ibisContext); ClassLoader get(String configurationName); ClassLoader get(String configurationName, String classLoaderType); void reload(String configurationName); void reload(ClassLoader classLoader); boolean contains(String currentConfigurationName); void shutdown();  }
@Test public void properClassLoaderType() throws ConfigurationException { assertNull(appConstants.get("configurations."+configurationName+".parentConfig")); ClassLoader config = getClassLoader(); String name = type; if(type.indexOf(".") > 0) name = type.substring(type.lastIndexOf(".")+1); assertEquals(name, config.getClass().getSimpleName()); }
@Test public void retrieveTestFileNotInClassLoader() throws ConfigurationException, IOException { assertNull(appConstants.get("configurations."+configurationName+".parentConfig")); ClassLoader config = getClassLoader(); URL resource = config.getResource("test1.xml"); MatchUtils.assertTestFileEquals("/test1.xml", resource); }
@Test public void retrieveTestFileInClassLoaderRoot() throws ConfigurationException, IOException { if(skip) return; assertNull(appConstants.get("configurations."+configurationName+".parentConfig")); ClassLoader config = getClassLoader(); URL resource = config.getResource("ClassLoaderTestFile.xml"); MatchUtils.assertTestFileEquals("/ClassLoaderTestFile.xml", resource); }
@Test public void retrieveTestFileInSubFolder() throws ConfigurationException, IOException { if(skip) return; assertNull(appConstants.get("configurations."+configurationName+".parentConfig")); ClassLoader config = getClassLoader(); URL resource = config.getResource(BASE_DIR.substring(1)+"/ClassLoaderTestFile.xml"); MatchUtils.assertTestFileEquals(BASE_DIR+"/ClassLoaderTestFile.xml", resource); }
@Test public void retrieveNonExistingTestFile() throws ConfigurationException, IOException { assertNull(appConstants.get("configurations."+configurationName+".parentConfig")); ClassLoader config = getClassLoader(); URL resource = config.getResource("dummy-test-file.xml"); assertNull(resource); }
@Test public void testInheritanceMakeSureFileIsFoundInBothParentAndChild() throws ConfigurationException, IOException { if(skip) return; String testConfiguration = "myNewClassLoader"; setLocalProperty("configurations."+testConfiguration+".classLoaderType", "DirectoryClassLoader"); setLocalProperty("configurations."+testConfiguration+".basePath", "."); setLocalProperty("configurations."+configurationName+".parentConfig", testConfiguration); String directory = getTestClassesLocation()+"ClassLoader/"; setLocalProperty("configurations."+testConfiguration+".directory", directory); setLocalProperty("configurations.names", appConstants.get("configurations.names") + ","+testConfiguration); String testFile = "fileOnlyOnLocalClassPath.txt"; ClassLoader parentClassloader = getClassLoader(testConfiguration); assertEquals("DirectoryClassLoader", parentClassloader.getClass().getSimpleName()); URL parentResource = parentClassloader.getResource(testFile); assertNotNull(parentResource); ClassLoader config = getClassLoader(); URL resource = config.getResource(testFile); assertNotNull(resource); appConstants.remove("configurations."+configurationName+".parentConfig"); }