AliasedDirectoryResource implements Resource { @Override public InputStream getResourceAsStream(String location) { InputStream result = null; if (location.startsWith(alias)) { location = location.substring(alias.length() + 1); File file = new File(rootDirectory, location); try { result = new FileInputStream(file); } catch (FileNotFoundException exception) { } } return result; } AliasedDirectoryResource();  AliasedDirectoryResource(File rootDirectory, String alias); @Override URL getResource(String location); @Override InputStream getResourceAsStream(String location); @Override Stream<String> getAllLocations(); String getAlias(); File getRootDirectory(); void setAlias(String alias); void setRootDirectory(File rootDirectory);  }
@Test void testGetResourceAsStream() { AliasedDirectoryResource resource = new AliasedDirectoryResource(null, "/alias"); assertNull(resource.getResourceAsStream("/resource")); }
@Test void testGetResourceAsStream2() { AliasedDirectoryResource resource = new AliasedDirectoryResource(new File("src/main/java"), "/alias"); assertNotNull(resource.getResourceAsStream("/alias/cloud/piranha/resource/DirectoryResource.java")); }
@Test void testGetResourceAsStream3() { AliasedDirectoryResource resource = new AliasedDirectoryResource(new File("src/main/java"), "/alias"); assertNull(resource.getResourceAsStream("/alias/cloud/piranha/DirectoryResource.class")); }