From 952f014f3ffab13e2f3b34661befc90041913004 Mon Sep 17 00:00:00 2001 From: sendaoYan Date: Sun, 28 Jan 2024 23:57:16 +0800 Subject: [PATCH] 8322881: [TESTBUG]java/nio/file/Files/CopyMoveVariations.java fails when run with non-root user Signed-off-by: sendaoYan --- test/jdk/java/nio/file/Files/CopyMoveVariations.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/test/jdk/java/nio/file/Files/CopyMoveVariations.java b/test/jdk/java/nio/file/Files/CopyMoveVariations.java index b55c1e508fb2e..a6d4f13326fec 100644 --- a/test/jdk/java/nio/file/Files/CopyMoveVariations.java +++ b/test/jdk/java/nio/file/Files/CopyMoveVariations.java @@ -192,8 +192,12 @@ void op(OpType op, PathType type, String mode, boolean replaceExisting, assertThrows(FileAlreadyExistsException.class, () -> Files.move(src, dst, options)); } else { - Files.move(source, target, options); - assert Files.exists(target); + try { + Files.move(source, target, options); + assert Files.exists(target); + } catch (AccessDeniedException ade) { + assertTrue(mode.charAt(0) != 'r'); + } } } else if (type == PathType.DIR) { if (op == OpType.COPY) { @@ -212,7 +216,7 @@ void op(OpType op, PathType type, String mode, boolean replaceExisting, Files.move(source, target, options); assert Files.exists(target); } catch (AccessDeniedException ade) { - assertTrue(mode.charAt(1) != 'w'); + assertTrue(mode.charAt(1) != 'r'); } catch (FileAlreadyExistsException faee) { assertTrue(targetExists && !replaceExisting); }