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 5a5d0d4..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,14 +45,12 @@ 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. */ @MojoTest public class CleanMojoTest { - private static final String LOCAL_REPO = "target/local-repo/"; /** * Tests the simple removal of directories @@ -172,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) { - assertTrue(true); + assertThrows(MojoException.class, () -> mojo.execute()); } } @@ -199,9 +194,6 @@ public void testCleanLockedFileWithNoError(CleanMojo mojo) throws Exception { try (FileChannel channel = new RandomAccessFile(f, "rw").getChannel(); FileLock ignored = channel.lock()) { mojo.execute(); - assertTrue(true); - } catch (MojoException expected) { - fail("Should display a warning when deleting a file that is locked"); } }