### Question:
URIResourceLocator implements ContainerResourceLocator { public InputStream getResource(String configName, String defaultUri) throws IllegalArgumentException, IOException { return getResource(defaultUri); }  InputStream getResource(String configName, String defaultUri); InputStream getResource(String uri); URI resolveURI(String uri); void setBaseURI(URI baseURI); URI getBaseURI(); static URI getSystemBaseURI(); static URI extractBaseURI(String resourceURI); static URI extractBaseURI(URI resourceURI); static final String SCHEME_CLASSPATH; static final String BASE_URI_SYSKEY; static final URI DEFAULT_BASE_URI; }### Answer:
@Test public void test_urlBasedResource() throws IllegalArgumentException, IOException { URIResourceLocator locator = new URIResourceLocator(); InputStream stream; try { stream = locator.getResource((new File("nofile")).toURI() .toString()); fail("Expected FileNotFoundException."); } catch (FileNotFoundException e) { } stream = locator.getResource(file.toURI().toString()); assertNotNull(stream); stream.close(); }
@Test public void test_classpathBasedResource() throws IllegalArgumentException, IOException { URIResourceLocator locator = new URIResourceLocator(); InputStream stream; try { stream = locator.getResource("classpath:/org/smooks/resource/someunknownfile.txt"); fail("Expected IOException for bad resource path."); } catch (IOException e) { assertTrue(e.getMessage().startsWith( "Failed to access data stream for")); } stream = locator.getResource("classpath:/org/smooks/resource/somefile.txt"); assertNotNull(stream); stream = locator.getResource("/org/smooks/resource/somefile.txt"); assertNotNull(stream); }