Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up assertions in CleanMojoTest #61

Merged
merged 2 commits into from
Nov 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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