### Question:
DirectoryScanner implements org.maera.plugin.loaders.classloading.Scanner { public void remove(DeploymentUnit unit) throws PluginException { if (unit.getPath().exists()) { if (!unit.getPath().delete()) { throw new PluginException("Unable to delete file: " + unit.getPath()); } } else { log.debug("Plugin file <" + unit.getPath().getPath() + "> doesn't exist to delete. Ignoring."); } clear(unit.getPath()); } DirectoryScanner(File pluginsDirectory); DeploymentUnit locateDeploymentUnit(File file); void clear(File file); Collection<DeploymentUnit> scan(); Collection<DeploymentUnit> getDeploymentUnits(); void reset(); void remove(DeploymentUnit unit);  }### Answer:
@Test public void testRemove() { File pluginsDirectory = pluginsTestDir; File paddington = new File(pluginsDirectory, "paddington-test-plugin.jar"); assertTrue(paddington.exists()); DirectoryScanner scanner = new DirectoryScanner(pluginsDirectory); scanner.scan(); assertEquals(2, scanner.getDeploymentUnits().size()); DeploymentUnit paddingtonUnit = scanner.locateDeploymentUnit(paddington); scanner.remove(paddingtonUnit); assertFalse(paddington.exists()); assertEquals(1, scanner.getDeploymentUnits().size()); }