private Set<File> getFileClassPathEntries(Archive<?> archive) { Node node = archive.get(ClassPath.FILE_CLASSPATH_ENTRIES_ARCHIVE_PATH); if (node != null && (node.getAsset() instanceof StringAsset)) { Set<File> entries = new HashSet<>(); StringAsset asset = (StringAsset) node.getAsset(); BufferedReader reader = new BufferedReader(new StringReader(asset.getSource())); String line; try { while ((line = reader.readLine()) != null) { File file = new File(line); if (file.canRead() && file.isFile()) { entries.add(file); } } } catch (IOException e) { LOGGER.log(Level.WARNING, "Unable to read file class path entries", e); return Collections.emptySet(); } return entries; } return Collections.emptySet(); }
@Test public void shouldBeAbleToReturnString() throws Exception { final String contents = StringAsset.class.getSimpleName(); final StringAsset asset = new StringAsset(contents); Assert.assertTrue(contents.equals(((StringAsset)asset).getSource())); } }