conf.set("fs.trash.interval", "0.2"); // 12 seconds
conf.set("fs.trash.checkpoint.interval", "0.1"); // 6 seconds
conf.setClass("fs.trash.classname", TrashPolicyPattern.class, TrashPolicy.class);
conf.set("fs.trash.base.paths", TEST_DIR + "/my_root/*/");
conf.set("fs.trash.unmatched.paths", TEST_DIR + "/unmatched/");
Trash trash = new Trash(conf);
// clean up trash can
fs.delete(new Path(TEST_DIR + "/my_root/*/"), true);
fs.delete(new Path(TEST_DIR + "/my_root_not/*/"), true);
FsShell shell = new FsShell();
shell.setConf(conf);
shell.init();
// First create a new directory with mkdirs
deleteAndCheckTrash(fs, shell, "my_root/sub_dir1/sub_dir1_1/myFile",
"my_root/sub_dir1/.Trash/Current/" + TEST_DIR
+ "/my_root/sub_dir1/sub_dir1_1");
deleteAndCheckTrash(fs, shell, "my_root/sub_dir2/sub_dir2_1/myFile",
"my_root/sub_dir2/.Trash/Current/" + TEST_DIR
+ "/my_root/sub_dir2/sub_dir2_1");
deleteAndCheckTrash(fs, shell, "my_root_not/", "unmatched/.Trash/Current"
+ TEST_DIR + "/my_root_not");
deleteAndCheckTrash(fs, shell, "my_root/file", "unmatched/.Trash/Current"
+ TEST_DIR + "/my_root/file");
Path currentTrash = new Path(TEST_DIR, "my_root/sub_dir1/.Trash/Current/");
fs.mkdirs(currentTrash);
cmdUsingShell("-rmr", shell, currentTrash);
TestCase.assertTrue(!fs.exists(currentTrash));
cmdUsingShell("-rmr", shell, new Path(TEST_DIR, "my_root"));
TestCase.assertTrue(fs.exists(new Path(TEST_DIR,
"unmatched/.Trash/Current/" + TEST_DIR + "/my_root")));
// Test Emplier
// Start Emptier in background
Runnable emptier = trash.getEmptier();
Thread emptierThread = new Thread(emptier);
emptierThread.start();
int fileIndex = 0;
Set<String> checkpoints = new HashSet<String>();