assertThat(resource.getResourceName()).doesNotContain("com/google/common/reflect/");
public static void unpackDummyResources(String prefix, Path output) throws IOException { ClassPath classPath = ClassPath.from(TestData.class.getClassLoader()); Map<String, URL> files = classPath.getResources().stream() .filter(info -> info.getResourceName().startsWith(prefix)) .collect(Collectors.toMap( info -> info.getResourceName().substring(prefix.length()), ClassPath.ResourceInfo::url) ); files.forEach((name, url) -> { Path file = output.resolve(name); try (InputStream is = url.openStream()) { Files.copy(is, file); } catch (IOException e) { throw new RuntimeException(String.format("name: %s, url: %s", name, url), e); } }); }
private void matchesResource( final ClassPath.ResourceInfo info, final List<Pattern> patterns, final List<ResourcePath> list ) { final String path = "/" + info.getResourceName(); patterns.stream().filter( pattern -> pattern.matcher( path ).find() ).forEach( pattern -> list.add( ResourcePath.from( path ) ) ); }
assertThat(resource.getResourceName()).doesNotContain("com/google/common/reflect/");
/** * Unpack report face to given directory. * * @param outputDirectory the output directory to unpack face. * @throws IOException if any occurs. */ private static void unpackFace(File outputDirectory) throws IOException { ClassLoader loader = AllureMain.class.getClassLoader(); for (ClassPath.ResourceInfo info : ClassPath.from(loader).getResources()) { Matcher matcher = REPORT_RESOURCE_PATTERN.matcher(info.getResourceName()); if (matcher.find()) { String resourcePath = matcher.group(1); File dest = new File(outputDirectory, resourcePath); Files.createParentDirs(dest); try (FileOutputStream output = new FileOutputStream(dest); InputStream input = info.url().openStream()) { IOUtils.copy(input, output); LOGGER.debug("{} successfully copied.", resourcePath); } } } } }