Skip to content

Commit

Permalink
Clean up assertions in CleanMojoTest (#61)
Browse files Browse the repository at this point in the history
* Clean up assertions
  • Loading branch information
elharo authored Nov 27, 2024
1 parent 68d4eca commit 155e5dc
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions src/test/java/org/apache/maven/plugins/clean/CleanMojoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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());
}
}

Expand All @@ -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");
}
}

Expand Down

0 comments on commit 155e5dc

Please sign in to comment.