IsolatingClassLoaderFactory { @VisibleForTesting static List<String> getFrameworkApiClassGlobs(File directoryWithClassList) { File parentPreferredFile = new File(directoryWithClassList, DependencyIsolationUtils.FRAMEWORK_API_CLASS_LIST_FILE_NAME); validateCanAccess(parentPreferredFile); try { return Files.readAllLines(Paths.get(parentPreferredFile.toURI()), StandardCharsets.UTF_8) .stream() .filter(StringUtils::isNotBlank) .collect(Collectors.toList()); } catch (IOException e) { throw new SamzaException("Error while reading samza-api class list", e); } }  ClassLoader buildClassLoader();  }
@Test public void testGetApiClasses() throws URISyntaxException { File apiClassListFile = Paths.get(getClass().getResource("/classloader").toURI()).toFile(); List<String> apiClassNames = IsolatingClassLoaderFactory.getFrameworkApiClassGlobs(apiClassListFile); List<String> expected = ImmutableList.of( "org.apache.samza.JavaClass", "org.apache.samza.JavaClass$InnerJavaClass", "org.apache.samza.ScalaClass$", "org.apache.samza.ScalaClass$$anon$1", "my.package.with.wildcard.*", "my.package.with.question.mark?"); assertEquals(expected, apiClassNames); }
@Test(expected = SamzaException.class) public void testGetApiClassesFileDoesNotExist() throws URISyntaxException { File nonExistentDirectory = new File(Paths.get(getClass().getResource("/classloader").toURI()).toFile(), "doesNotExist"); IsolatingClassLoaderFactory.getFrameworkApiClassGlobs(nonExistentDirectory); }