### Question:
ResourceFinder { public URL findResource(String resource) throws MojoFailureException { URL res = null; try { final Path p = basedir.resolve(resource); res = toURL(p.toAbsolutePath()); } catch (final InvalidPathException e) { } if (res != null) { return res; } try { res = toURL(Paths.get(resource)); } catch (final InvalidPathException e) { } if (res != null) { return res; } final String cpResource = resource.startsWith("/") ? resource.substring(1) : resource; res = compileClassPath.getResource(cpResource); if (res != null) { return res; } res = pluginClassPath.getResource(cpResource); if (res != null) { return res; } try { res = new URL(resource); res.openStream().close(); return res; } catch (Exception e) { throw new MojoFailureException("Resource " + resource + " not found in file system, classpath or URL: " + e.getMessage(), e); } } ResourceFinder(final Path basedir); void setCompileClassPath(List<String> classpath); void setPluginClassPath(ClassLoader classLoader); URL findResource(String resource);  }### Answer:
@Test public void test_load_absolute_file() throws Exception { final Path path = Paths.get("src").resolve("test/data/compileCP/test.txt").toAbsolutePath(); assertTrue(Files.exists(path)); final URL u = finder.findResource(path.toString()); assertEquals(path, Paths.get(u.toURI())); }
@Test(expected = MojoFailureException.class) public void test_load_inexisting() throws Exception { finder.findResource("ho ho"); }
@Test public void test_load_relative_file() throws Exception { final URL u = finder.findResource("src/test/data/compileCP/test.txt"); assertTrue(u.getPath().contains("src/test/data/compileCP/test.txt")); }
@Test public void test_load_from_compile_CP() throws Exception { assertNotNull(finder.findResource("test.txt")); }
@Test public void test_load_from_plugin_CP() throws Exception { assertNotNull(finder.findResource("/bouh.txt")); }