@Test public void testRmRootRecursive() throws Throwable { // extra sanity checks here to avoid support calls about complete loss of data skipIfUnsupported(TEST_ROOT_TESTS_ENABLED); Path root = new Path("/"); ContractTestUtils.assertIsDirectory(getFileSystem(), root); Path file = new Path("/testRmRootRecursive"); ContractTestUtils.touch(getFileSystem(), file); boolean deleted = getFileSystem().delete(root, true); ContractTestUtils.assertIsDirectory(getFileSystem(), root); LOG.info("rm -rf / result is {}", deleted); if (deleted) { assertPathDoesNotExist("expected file to be deleted", file); } else { assertPathExists("expected file to be preserved", file); ; } }
@Test public void testRmNonEmptyRootDirNonRecursive() throws Throwable { // extra sanity checks here to avoid support calls about complete loss of data skipIfUnsupported(TEST_ROOT_TESTS_ENABLED); Path root = new Path("/"); String touchfile = "/testRmNonEmptyRootDirNonRecursive"; Path file = new Path(touchfile); ContractTestUtils.touch(getFileSystem(), file); ContractTestUtils.assertIsDirectory(getFileSystem(), root); try { boolean deleted = getFileSystem().delete(root, false); fail( "non recursive delete should have raised an exception," + " but completed with exit code " + deleted); } catch (IOException e) { // expected handleExpectedException(e); } finally { getFileSystem().delete(file, false); } ContractTestUtils.assertIsDirectory(getFileSystem(), root); }