DirectoryResource implements Resource { @Override public URL getResource(String location) { URL result = null; if (location != null) { File file = new File(rootDirectory, location); if (file.exists()) { try { result = new URL(file.toURI().toString()); } catch (MalformedURLException 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 testGetResource() { DirectoryResource resource = new DirectoryResource(); assertNull(resource.getResource("/resource")); }