DefaultResourceManager implements ResourceManager { @Override public URL getResource(String location) throws MalformedURLException { URL result = null; Iterator<Resource> iterator = resources.iterator(); while (iterator.hasNext()) { Resource resource = iterator.next(); result = resource.getResource(location); if (result != null) { break; } } if (result == null) { if (location != null) { result = getClass().getResource(location); } } return result; }  @Override void addResource(Resource resource); @Override URL getResource(String location); @Override Collection<URL> getResources(String location); @Override InputStream getResourceAsStream(String location); @Override Stream<String> getAllLocations();  }
@Test void testGetResource() throws Exception { DefaultResourceManager manager = new DefaultResourceManager(); manager.addResource(new DirectoryResource(new File(""))); assertNull(manager.getResource("/doesnotexist")); }