WebjarUriLocator implements UriLocator { @Override public InputStream locate(final String uri) throws IOException { LOG.debug("Locating: {}", uri); try { final String fullpath = webjarAssetLocator.getFullPath(extractPath(uri)); return classpathLocator.locate(ClasspathUriLocator.createUri(fullpath)); } catch (final Exception e) { throw new IOException("No webjar with uri: " + uri + " available.", e); } }  static String createUri(final String path); @Override InputStream locate(final String uri); @Override boolean accept(final String uri); static final String ALIAS; static final String PREFIX; }
@Test public void shouldFindValidWebjar() throws Exception { assertNotEmpty(victim.locate("webjar:jquery.js")); assertNotEmpty(victim.locate("webjar:jquery/2.0.0/jquery.js")); assertNotEmpty(victim.locate("webjar:/jquery/2.0.0/jquery.js")); }
@Test(expected = IOException.class) public void cannotFindInvalidWebjar() throws Exception { victim.locate("webjar:invalid.js"); }
@Test public void shouldNotFailWhenThereIsAWebjarResourceOutsideOfJar() throws IOException { assertNotEmpty(victim.locate("webjar:webjarFail.js")); }
@Test public void shouldLocateWebjarResourceContainingQuestionMarkInUri() throws Exception { victim.locate("webjar:font-awesome/5.12.0/webfonts/fa-regular-400.woff?v=5.12.0"); }