Util { public static List<URL> resolveManifestResources(final URL manifestUrl, final List<String> resources) { return resources.stream() .map(name -> name.contains(":") ? name : "../" + name) .flatMap(composeTry(Stream::of, Stream::empty, (relPath) -> new URL(manifestUrl, relPath), (relPath, error) -> LOGGER.debug("[resolveManifestResources] malformed url: manifestUrl={}, relPath={}, error={}", manifestUrl, relPath, error.getMessage()))) .collect(Collectors.toList()); } private  Util(); static Session wrapSessionReadOnly(final Session session); static List<String> getManifestHeaderValues(final Manifest manifest, final String headerName); static String escapeManifestHeaderValue(final @NotNull String... values); static String escapeManifestHeaderValues(final @NotNull List<String> values); static List<URL> resolveManifestResources(final URL manifestUrl, final List<String> resources); static Map<URL, List<URL>> mapManifestHeaderResources(final String headerName, final ClassLoader classLoader); static Map<URL, List<URL>> mapManifestHeaderResources(final String headerName, final List<File> files); static Map<URL, List<URL>> mapManifestHeaderResources(final String headerName, final URL manifestUrl); static Predicate<T> debugFilter(final Logger logger, final String format); static Predicate<T> traceFilter(final Logger logger, final String format); @Deprecated static Function<T, M> composeTry(final Function<R, M> monadUnit,
                                                      final Supplier<M> monadZero,
                                                      final TryFunction<T, R> onElement,
                                                      final BiConsumer<T, Exception> onError); @Deprecated static Function<T, Optional<R>> optFunc(final Function<T, R> inputFunc); @Deprecated static Function<T, R> compose(final Function<T, I> before, final Function<I, R> after);  }
@Test public void testResolveManifestResources() throws Exception { final File mfFile = new File("src/test/resources/utiljar/META-INF/MANIFEST.MF"); final URL mfUrl = mfFile.toURI().toURL(); final Manifest manifest; final Logger logger = getLoggerFactory().getLogger(Util.class); final Level oldLevel = logger.getLevel(); try (InputStream inputStream = mfUrl.openStream()) { manifest = new Manifest(inputStream); logger.setLevel(Level.DEBUG); List<String> goodRelPaths = Util.getManifestHeaderValues(manifest, "Good-RelPaths"); assertEquals("should be same length for Good-RelPaths", goodRelPaths.size(), Util.resolveManifestResources(mfUrl, goodRelPaths).size()); List<String> badRelPaths = Util.getManifestHeaderValues(manifest, "Bad-RelPaths"); assertNotEquals("should be different length for Bad-RelPaths", badRelPaths.size(), Util.resolveManifestResources(mfUrl, badRelPaths).size()); } finally { logger.setLevel(oldLevel); } }