DirectoryResource implements Resource { @Override public InputStream getResourceAsStream(String location) { InputStream result = null; File file = new File(rootDirectory, location); try { result = new FileInputStream(file); } catch (FileNotFoundException exception) { } return result; } DirectoryResource();  DirectoryResource(String rootDirectory);  DirectoryResource(File rootDirectory); @Override URL getResource(String location); @Override InputStream getResourceAsStream(String location); @Override Stream<String> getAllLocations(); File getRootDirectory(); void setRootDirectory(File rootDirectory);  }
@Test void testGetResourceAsStream() { DirectoryResource resource = new DirectoryResource(); assertNull(resource.getResourceAsStream("/resource")); }
@Test void testGetResourceAsStream2() { DirectoryResource resource = new DirectoryResource(new File(".")); assertNotNull(resource.getResourceAsStream("pom.xml")); }