Trash extends Configured { public boolean isEnabled() { return trashPolicy.isEnabled(); } Trash(Configuration conf);  Trash(FileSystem fs, Configuration conf); static boolean moveToAppropriateTrash(FileSystem fs, Path p,
      Configuration conf); boolean isEnabled(); boolean moveToTrash(Path path); void checkpoint(); void expunge(); void expungeImmediately(); Runnable getEmptier(); Path getCurrentTrashDir(Path path);  }
@Test public void testExistingFileTrash() throws IOException { Configuration conf = new Configuration(); conf.setClass("fs.file.impl", TestLFS.class, FileSystem.class); FileSystem fs = FileSystem.getLocal(conf); conf.set("fs.defaultFS", fs.getUri().toString()); conf.setLong(FS_TRASH_INTERVAL_KEY, 0); assertFalse(new Trash(conf).isEnabled()); conf.setLong(FS_TRASH_INTERVAL_KEY, -1); assertFalse(new Trash(conf).isEnabled()); conf.setLong(FS_TRASH_INTERVAL_KEY, 10); assertTrue(new Trash(conf).isEnabled()); FsShell shell = new FsShell(); shell.setConf(conf); Path myPath = new Path(TEST_DIR, "test/mkdirs"); mkdir(fs, myPath); Path myFile = new Path(TEST_DIR, "test/mkdirs/myExistingFile"); writeFile(fs, myFile, 10); mkdir(fs, myPath); writeFile(fs, myFile, 10); String[] args1 = new String[2]; args1[0] = "-rm"; args1[1] = myFile.toString(); int val1 = -1; try { val1 = shell.run(args1); } catch (Exception e) { System.err.println("Exception raised from Trash.run " + e.getLocalizedMessage()); } assertTrue(val1 == 0); mkdir(fs, myFile); writeFile(fs, new Path(myFile, "mySubFile"), 10); String[] args2 = new String[2]; args2[0] = "-rm"; args2[1] = new Path(myFile, "mySubFile").toString(); int val2 = -1; try { val2 = shell.run(args2); } catch (Exception e) { System.err.println("Exception raised from Trash.run " + e.getLocalizedMessage()); } assertTrue(val2 == 0); }