This is an automated email from the ASF dual-hosted git repository. slachiewicz pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/maven-clean-plugin.git
commit 90bc23d7a7949abe3093e834b3038b2821f6d690 Author: Sylwester Lachiewicz <[email protected]> AuthorDate: Tue Nov 17 09:29:20 2026 +0000 Use assertThrows and assertDoesNotThrow in the locked-file tests --- .../java/org/apache/maven/plugins/clean/CleanMojoTest.java | 10 +++------- 1 file changed, 3 insertions(+), 7 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 0e13f58..51c3e1d 100644 --- a/src/test/java/org/apache/maven/plugins/clean/CleanMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/clean/CleanMojoTest.java @@ -42,11 +42,11 @@ import org.junit.jupiter.api.condition.OS; import static org.apache.maven.api.plugin.testing.MojoExtension.getBasedir; import static org.codehaus.plexus.util.IOUtil.copy; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.junit.jupiter.api.Assertions.assertFalse; 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. @@ -174,9 +174,7 @@ class CleanMojoTest { 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 (MojoExecutionException expected) { + assertThrows(MojoExecutionException.class, mojo::execute, "Should fail to delete a file that is locked"); } } @@ -199,9 +197,7 @@ class CleanMojoTest { File f = new File(getBasedir(), "/buildDirectory/file.txt"); try (FileChannel channel = new RandomAccessFile(f, "rw").getChannel(); FileLock ignored = channel.lock()) { - mojo.execute(); - } catch (MojoExecutionException expected) { - fail("Should display a warning when deleting a file that is locked"); + assertDoesNotThrow(mojo::execute, "Should display a warning when deleting a file that is locked"); } }
