### Question:
BlockingClassLoader extends URLClassLoader { @Override public Enumeration<URL> getResources(String name) throws IOException { if (!m_shared.matches(name, true)) { final List<URL> result = new ArrayList<URL>(); if (m_respectGrandparents) { result.addAll(list(getParent().getParent().getResources(name))); } if (m_blocked.matches(name, true)) { return enumeration(result); } if (m_isolated.matches(name, true)) { result.addAll(list(findResources(name))); return enumeration(result); } } return super.getResources(name); } BlockingClassLoader(URLClassLoader parent,
                             List<URL> additionalClassPath,
                             Set<String> blocked,
                             Set<String> isolated,
                             Set<String> shared,
                             boolean respectGrandparents);  BlockingClassLoader(List<URL> additionalClassPath,
                             Set<String> blocked,
                             Set<String> isolated,
                             Set<String> shared,
                             boolean respectGrandparents);  BlockingClassLoader(Set<String> blocked,
                             Set<String> isolated,
                             Set<String> shared,
                             boolean respectGrandparents); @Override URL getResource(String name); @Override Enumeration<URL> getResources(String name);  }### Answer:
@Test public void testGetResources() throws Exception { final String resourceName = "TestResources.properties"; assertTrue( getClass().getClassLoader().getResources(resourceName).hasMoreElements()); final BlockingClassLoader cl = new BlockingClassLoader(singleton(resourceName), Collections.<String>emptySet(), Collections.<String>emptySet(), false); assertFalse(cl.getResources(resourceName).hasMoreElements()); assertFalse(cl.getResources("Something else").hasMoreElements()); }
@Test public void testGetResources2() throws Exception { final String resourceName = "TestResources.properties"; assertTrue( getClass().getClassLoader().getResources(resourceName).hasMoreElements()); final BlockingClassLoader cl = new BlockingClassLoader(Collections.<String>emptySet(), Collections.<String>emptySet(), singleton(resourceName), false); assertTrue(cl.getResources(resourceName).hasMoreElements()); }