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()); } }