From 0fda3b7288ee1370de06285dcbdb17075b1bfad8 Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Thu, 14 Nov 2024 07:51:38 -0500 Subject: [PATCH] assertThrows --- .../java/org/apache/maven/plugins/clean/CleanMojoTest.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/test/java/org/apache/maven/plugins/clean/CleanMojoTest.java b/src/test/java/org/apache/maven/plugins/clean/CleanMojoTest.java index 78d2c28..882a672 100644 --- a/src/test/java/org/apache/maven/plugins/clean/CleanMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/clean/CleanMojoTest.java @@ -45,7 +45,6 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.junit.jupiter.api.Assertions.fail; /** * Test the clean mojo. @@ -171,10 +170,7 @@ public void testCleanLockedFile(CleanMojo mojo) throws Exception { File f = new File(getBasedir(), "buildDirectory/file.txt"); try (FileChannel channel = new RandomAccessFile(f, "rw").getChannel(); FileLock ignored = channel.lock()) { - mojo.execute(); - fail("Should fail to delete a file that is locked"); - } catch (MojoException expected) { - assertNotNull(expected.getMessage()); + assertThrows(MojoException.class, () -> mojo.execute()); } }