ClassLoaderUtils { public static ClassLoader initiate(Path path) { if (path == null) return Thread.currentThread().getContextClassLoader(); else if (Files.isDirectory(path)) return new URLClassLoader( findJarFiles(path), Thread.currentThread().getContextClassLoader() ); else if (Files.isRegularFile(path)) return new URLClassLoader( new URL[]{FileUtils.toUrl(path)}, Thread.currentThread().getContextClassLoader() ); else throw new OxalisPluginException(String.format("Unable to load class loader for '%s'.", path)); }  static ClassLoader initiate(Path path);  }
@Test public void simpleNull() { Assert.assertEquals(ClassLoaderUtils.initiate(null), current); }
@Test public void simpleJavaHome() { Path path = Paths.get(System.getProperty("java.home"), "lib"); Assert.assertNotEquals(ClassLoaderUtils.initiate(path), current); }
@Test public void simpleRT() { Path path = Paths.get(System.getProperty("java.home"), "lib", "rt.jar"); Assert.assertNotEquals(ClassLoaderUtils.initiate(path), current); }
@Test(expectedExceptions = OxalisPluginException.class) public void triggerException() { Path path = Paths.get(System.getProperty("java.home"), "completely", "invalid", "folder"); ClassLoaderUtils.initiate(path); }