JarLocationScanner implements LocationScanner { @Override public Set<String> findResourceNames(String location, URI locationUri) throws IOException { notNullOrEmpty(location, "location"); notNull(locationUri, "locationUri"); LOGGER.debug("Scanning in jar {} in location {}", locationUri, location); try(FileSystem fileSystem = getFileSystem(locationUri)) { final Path systemPath = fileSystem.getPath(location); return Files.walk(systemPath) .filter(Files::isRegularFile) .map(path -> normalizePath(path.toString())) .collect(toSet()); } }  @Override Set<String> findResourceNames(String location, URI locationUri);  }
@Test public void shouldReturnTwoResourcesWhenJarFileWithOneScriptGiven() throws Exception { LocationScanner scanner = new JarLocationScanner(); Set<String> resourceNames = scanner.findResourceNames("/", jarUri); assertThat(resourceNames.size(), is(equalTo(2))); assertThat(resourceNames.contains("1_init.cql"), is(true)); assertThat(resourceNames.contains("META-INF/MANIFEST.MF"), is(true)); }
@Test(expected = NoSuchFileException.class) public void shouldThrowExceptionWhenNonExistingPathGiven() throws IOException { LocationScanner scanner = new JarLocationScanner(); Set<String> resourceNames = scanner.findResourceNames("/nonThere", jarUri); assertThat(resourceNames.size(), is(equalTo(0))); }