### Question:
JarWildcardStreamLocator extends DefaultWildcardStreamLocator { @Override public InputStream locateStream(final String uri, final File folder) throws IOException { Validate.notNull(folder); final File jarPath = getJarFile(folder); if (isSupported(jarPath)) { return locateStreamFromJar(uri, jarPath); } return super.locateStream(uri, folder); }  @Override InputStream locateStream(final String uri, final File folder);  }### Answer:
@Test(expected = NullPointerException.class) public void cannotLocateStreamWithNullFolder() throws Exception { jarStreamLocator.locateStream("", null); }
@Test public void testLocateJarStream() throws IOException { final InputStream is = jarStreamLocator.locateStream("com/test/app/*.js", new File(jarFileName)); final List<String> lines = IOUtils.readLines(is); LOG.debug("lines: " + lines); assertEquals(testInfo, lines.get(0)); IOUtils.closeQuietly(is); }
@Test public void testLocateJarStreamDelegate() throws IOException { final InputStream is = jarStreamLocator.locateStream("classpath:com/test/app/*.js", new File("src/test/resources/")); final String content = IOUtils.readLines(is).get(0); assertTrue(content.contains("1.js")); assertTrue(content.contains("2.js")); assertTrue(content.contains("3.js")); assertTrue(!content.contains("1.css")); IOUtils.closeQuietly(is); }
@Test(expected = IOException.class) public void testLocateJarStreamDelegateFail() throws IOException { jarStreamLocator.locateStream("com/test/app/*.js", new File("test.jpg")); }
@Test public void shouldLocateJarStream() throws IOException { final InputStream is = jarStreamLocator.locateStream("com/test/app/*.js", new File(FILE_NAME_JAR)); final List<String> lines = readLines(is); LOG.debug("lines: " + lines); assertEquals(1, lines.size()); assertEquals(TEST_INFO, lines.get(0)); closeQuietly(is); }
@Test(expected = IOException.class) public void shouldNotLocateEmbeddedJarStream() throws IOException { jarStreamLocator.locateStream("com/test/app/*.js", new File(FILE_NAME_WITH_EMBEDDED_JAR)); }
@Test public void testLocateJarStreamDelegate() throws IOException { final InputStream is = jarStreamLocator.locateStream("classpath:com/test/app/*.js", new File("src/test/resources/")); final String content = readLines(is).get(0); assertTrue(content.contains("1.js")); assertTrue(content.contains("2.js")); assertTrue(content.contains("3.js")); assertTrue(!content.contains("1.css")); closeQuietly(is); }