PluginClassLoader extends URLClassLoader { @Override public URL getResource(String name) { log.trace("Received request to load resource '{}'", name); for (ClassLoadingStrategy.Source classLoadingSource : classLoadingStrategy.getSources()) { URL url = null; switch (classLoadingSource) { case APPLICATION: url = super.getResource(name); break; case PLUGIN: url = findResource(name); break; case DEPENDENCIES: url = findResourceFromDependencies(name); break; } if (url != null) { log.trace("Found resource '{}' in {} classpath", name, classLoadingSource); return url; } else { log.trace("Couldn't find resource '{}' in {}", name, classLoadingSource); } } return null; } PluginClassLoader(PluginManager pluginManager, PluginDescriptor pluginDescriptor, ClassLoader parent); @Deprecated  PluginClassLoader(PluginManager pluginManager, PluginDescriptor pluginDescriptor, ClassLoader parent, boolean parentFirst);  PluginClassLoader(PluginManager pluginManager, PluginDescriptor pluginDescriptor, ClassLoader parent, ClassLoadingStrategy classLoadingStrategy); @Override void addURL(URL url); void addFile(File file); @Override Class<?> loadClass(String className); @Override URL getResource(String name); @Override Enumeration<URL> getResources(String name);  }
@Test void parentLastGetResourceNonExisting() { assertNull(parentLastPluginClassLoader.getResource("META-INF/non-existing-file")); }
@Test void parentFirstGetResourceNonExisting() { assertNull(parentFirstPluginClassLoader.getResource("META-INF/non-existing-file")); }
@Test void parentLastGetResourceExistsInParent() throws IOException, URISyntaxException { URL resource = parentLastPluginClassLoader.getResource("META-INF/file-only-in-parent"); assertFirstLine("parent", resource); }
@Test void parentFirstGetResourceExistsInParent() throws IOException, URISyntaxException { URL resource = parentFirstPluginClassLoader.getResource("META-INF/file-only-in-parent"); assertFirstLine("parent", resource); }
@Test void parentLastGetResourceExistsOnlyInPlugin() throws IOException, URISyntaxException { URL resource = parentLastPluginClassLoader.getResource("META-INF/plugin-file"); assertFirstLine("plugin", resource); }
@Test void parentFirstGetResourceExistsOnlyInPlugin() throws IOException, URISyntaxException { URL resource = parentFirstPluginClassLoader.getResource("META-INF/plugin-file"); assertFirstLine("plugin", resource); }
@Test void parentLastGetResourceExistsOnlyInDependnecy() throws IOException, URISyntaxException { URL resource = parentLastPluginClassLoader.getResource("META-INF/dependency-file"); assertFirstLine("dependency", resource); }
@Test void parentFirstGetResourceExistsOnlyInDependency() throws IOException, URISyntaxException { URL resource = parentFirstPluginClassLoader.getResource("META-INF/dependency-file"); assertFirstLine("dependency", resource); }
@Test void parentLastGetResourceExistsInBothParentAndPlugin() throws URISyntaxException, IOException { URL resource = parentLastPluginClassLoader.getResource("META-INF/file-in-both-parent-and-plugin"); assertFirstLine("plugin", resource); }
@Test void parentFirstGetResourceExistsInBothParentAndPlugin() throws URISyntaxException, IOException { URL resource = parentFirstPluginClassLoader.getResource("META-INF/file-in-both-parent-and-plugin"); assertFirstLine("parent", resource); }
@Test void parentLastGetResourceExistsInParentAndDependencyAndPlugin() throws URISyntaxException, IOException { URL resource = parentLastPluginClassLoader.getResource("META-INF/file-in-both-parent-and-dependency-and-plugin"); assertFirstLine("plugin", resource); }
@Test void parentFirstGetResourceExistsInParentAndDependencyAndPlugin() throws URISyntaxException, IOException { URL resource = parentFirstPluginClassLoader.getResource("META-INF/file-in-both-parent-and-dependency-and-plugin"); assertFirstLine("parent", resource); }