### Question:
PluginClassLoader extends ClassLoader { @Override public URL getResource(final String name) { if (isEntryInPlugin(name)) { return entryMappings.get(name); } else { return super.getResource(name); } } PluginClassLoader(final File pluginFile);  PluginClassLoader(final File pluginFile, final ClassLoader parent);  PluginClassLoader(final File pluginFile, final ClassLoader parent, final File tempDirectory); void close(); URL getLocalResource(final String name); @Override URL getResource(final String name);  }### Answer:
@Test public void testPluginClassLoaderDoesNotLockTheJarsPermanently() throws Exception { String fileLoc = getClass().getClassLoader().getResource(PluginTestUtils.SIMPLE_TEST_JAR).getFile(); File original = new File(fileLoc); File tmpFile = new File(fileLoc + ".tmp"); FileUtils.copyFile(original, tmpFile); PluginClassLoader pluginClassLoaderThatHasNotLockedFileYet = new PluginClassLoader(tmpFile, getClass().getClassLoader()); Class mockVersionedClass = Class.forName("org.maera.plugin.mock.MockVersionedClass", true, pluginClassLoader); assertTrue(tmpFile.delete()); }
@Test public void testPluginClassLoaderLoadsResourceFromOuterJarFirst() throws Exception { URL resourceUrl = pluginClassLoader.getResource("testresource.txt"); assertNotNull(resourceUrl); assertEquals("outerjar", IOUtils.toString(resourceUrl.openStream())); }