IsolatingClassLoaderFactory { @VisibleForTesting static List<URI> getClasspathAsURIs(File jarsLocation) { return Stream.of(getClasspathAsURLs(jarsLocation)) .map(IsolatingClassLoaderFactory::urlToURI) .collect(Collectors.toList()); }  ClassLoader buildClassLoader();  }
@Test public void testGetClasspathAsURIs() throws URISyntaxException { File classpathDirectory = Paths.get(getClass().getResource("/classloader/classpath").toURI()).toFile(); List<URI> classpath = IsolatingClassLoaderFactory.getClasspathAsURIs(classpathDirectory); assertEquals(2, classpath.size()); Set<URI> classpathSet = ImmutableSet.copyOf(classpath); URL jarUrl = getClass().getResource("/classloader/classpath/placeholder-jar.jar"); assertTrue(classpathSet.contains(jarUrl.toURI())); URL warUrl = getClass().getResource("/classloader/classpath/placeholder-war.war"); assertTrue(classpathSet.contains(warUrl.toURI())); }
@Test(expected = SamzaException.class) public void testGetClasspathAsURIsDirectoryDoesNotExist() throws URISyntaxException { File nonExistentDirectory = new File(Paths.get(getClass().getResource("/classloader").toURI()).toFile(), "doesNotExist"); IsolatingClassLoaderFactory.getClasspathAsURIs(nonExistentDirectory); }