PluginClassLoader extends URLClassLoader { @Override public Enumeration<URL> getResources(String name) throws IOException { List<URL> resources = new ArrayList<>(); log.trace("Received request to load resources '{}'", name); for (ClassLoadingStrategy.Source classLoadingSource : classLoadingStrategy.getSources()) { switch (classLoadingSource) { case APPLICATION: if (getParent() != null) { resources.addAll(Collections.list(getParent().getResources(name))); } break; case PLUGIN: resources.addAll(Collections.list(findResources(name))); break; case DEPENDENCIES: resources.addAll(findResourcesFromDependencies(name)); break; } } return Collections.enumeration(resources); } 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 parentLastGetResourcesNonExisting() throws IOException { assertFalse(parentLastPluginClassLoader.getResources("META-INF/non-existing-file").hasMoreElements()); }
@Test void parentFirstGetResourcesNonExisting() throws IOException { assertFalse(parentFirstPluginClassLoader.getResources("META-INF/non-existing-file").hasMoreElements()); }
@Test void parentLastGetResourcesExistsInParent() throws IOException, URISyntaxException { Enumeration<URL> resources = parentLastPluginClassLoader.getResources("META-INF/file-only-in-parent"); assertNumberOfResourcesAndFirstLineOfFirstElement(1, "parent", resources); }
@Test void parentFirstGetResourcesExistsInParent() throws IOException, URISyntaxException { Enumeration<URL> resources = parentFirstPluginClassLoader.getResources("META-INF/file-only-in-parent"); assertNumberOfResourcesAndFirstLineOfFirstElement(1, "parent", resources); }
@Test void parentLastGetResourcesExistsOnlyInDependency() throws IOException, URISyntaxException { Enumeration<URL> resources = parentLastPluginClassLoader.getResources("META-INF/dependency-file"); assertNumberOfResourcesAndFirstLineOfFirstElement(1, "dependency", resources); }
@Test void parentFirstGetResourcesExistsOnlyInDependency() throws IOException, URISyntaxException { Enumeration<URL> resources = parentFirstPluginClassLoader.getResources("META-INF/dependency-file"); assertNumberOfResourcesAndFirstLineOfFirstElement(1, "dependency", resources); }
@Test void parentLastGetResourcesExistsOnlyInPlugin() throws IOException, URISyntaxException { Enumeration<URL> resources = parentLastPluginClassLoader.getResources("META-INF/plugin-file"); assertNumberOfResourcesAndFirstLineOfFirstElement(1, "plugin", resources); }
@Test void parentFirstGetResourcesExistsOnlyInPlugin() throws IOException, URISyntaxException { Enumeration<URL> resources = parentFirstPluginClassLoader.getResources("META-INF/plugin-file"); assertNumberOfResourcesAndFirstLineOfFirstElement(1, "plugin", resources); }
@Test void parentLastGetResourcesExistsInBothParentAndPlugin() throws URISyntaxException, IOException { Enumeration<URL> resources = parentLastPluginClassLoader.getResources("META-INF/file-in-both-parent-and-plugin"); assertNumberOfResourcesAndFirstLineOfFirstElement(2, "plugin", resources); }
@Test void parentFirstGetResourcesExistsInBothParentAndPlugin() throws URISyntaxException, IOException { Enumeration<URL> resources = parentFirstPluginClassLoader.getResources("META-INF/file-in-both-parent-and-plugin"); assertNumberOfResourcesAndFirstLineOfFirstElement(2, "parent", resources); }
@Test void parentLastGetResourcesExistsInParentAndDependencyAndPlugin() throws URISyntaxException, IOException { Enumeration<URL> resources = parentLastPluginClassLoader.getResources("META-INF/file-in-both-parent-and-dependency-and-plugin"); assertNumberOfResourcesAndFirstLineOfFirstElement(3, "plugin", resources); }
@Test void parentFirstGetResourcesExistsInParentAndDependencyAndPlugin() throws URISyntaxException, IOException { Enumeration<URL> resources = parentFirstPluginClassLoader.getResources("META-INF/file-in-both-parent-and-dependency-and-plugin"); assertNumberOfResourcesAndFirstLineOfFirstElement(3, "parent", resources); }