ayushtkn commented on code in PR #5239:
URL: https://github.com/apache/ozone/pull/5239#discussion_r1313832035
##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestOzoneFileSystem.java:
##########
@@ -1638,6 +1639,26 @@ public void testRenameToTrashEnabled() throws Exception {
Assert.assertTrue(o3fs.exists(userTrashCurrent));
// Check under trash, the key should be present
Assert.assertTrue(o3fs.exists(trashPath));
+
+ // Try to delete root
+ Path root = new Path(OZONE_URI_DELIMITER);
+ try {
+ trash.moveToTrash(root);
+ Assert.fail("Trying to delete root should throw exception");
+ } catch (Exception e) {
+ Assert.assertTrue(e instanceof IOException);
+ }
Review Comment:
Does this work:
```
Assert.assertThrows(IOException.class, () -> trash.moveToTrash(root));
```
##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestOzoneFileSystem.java:
##########
@@ -1638,6 +1639,26 @@ public void testRenameToTrashEnabled() throws Exception {
Assert.assertTrue(o3fs.exists(userTrashCurrent));
// Check under trash, the key should be present
Assert.assertTrue(o3fs.exists(trashPath));
+
+ // Try to delete root
+ Path root = new Path(OZONE_URI_DELIMITER);
+ try {
+ trash.moveToTrash(root);
+ Assert.fail("Trying to delete root should throw exception");
+ } catch (Exception e) {
+ Assert.assertTrue(e instanceof IOException);
+ }
+ // Also try with TrashPolicyDefault
+ OzoneConfiguration conf2 = new OzoneConfiguration(cluster.getConf());
+ conf2.setClass("fs.trash.classname", TrashPolicyDefault.class,
+ TrashPolicy.class);
+ Trash trashPolicyDefault = new Trash(conf2);
+ try {
+ trashPolicyDefault.moveToTrash(root);
+ Assert.fail("Trying to delete root should throw exception");
+ } catch (Exception e) {
+ Assert.assertTrue(e instanceof IOException);
+ }
Review Comment:
```
Assert.assertThrows(IOException.class, () ->
trashPolicyDefault.moveToTrash(root));
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]