Skip to content

Commit

Permalink
assertThrows
Browse files Browse the repository at this point in the history
  • Loading branch information
elharo committed Nov 14, 2024
1 parent e578683 commit 0fda3b7
Showing 1 changed file with 1 addition and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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());
}
}

Expand Down

0 comments on commit 0fda3b7

Please sign in to comment.