Skip to content

Commit 091570b

Browse files
peterdemaeyerslawekjaranowski
authored andcommitted
[MCLEAN-124] Replace JUnit Assumptions with @DisabledOnOs, to better align with surrounding tests
1 parent cb2127f commit 091570b

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

src/test/java/org/apache/maven/plugins/clean/CleanerTest.java

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,15 @@
2121
import java.io.IOException;
2222
import java.nio.file.AccessDeniedException;
2323
import java.nio.file.DirectoryNotEmptyException;
24-
import java.nio.file.FileSystems;
2524
import java.nio.file.Path;
2625
import java.nio.file.attribute.PosixFilePermission;
2726
import java.nio.file.attribute.PosixFilePermissions;
2827
import java.util.Set;
2928

3029
import org.apache.maven.plugin.logging.Log;
3130
import org.junit.jupiter.api.Test;
31+
import org.junit.jupiter.api.condition.DisabledOnOs;
32+
import org.junit.jupiter.api.condition.OS;
3233
import org.junit.jupiter.api.io.TempDir;
3334
import org.mockito.ArgumentCaptor;
3435
import org.mockito.InOrder;
@@ -42,7 +43,6 @@
4243
import static org.junit.jupiter.api.Assertions.assertFalse;
4344
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
4445
import static org.junit.jupiter.api.Assertions.assertThrows;
45-
import static org.junit.jupiter.api.Assumptions.assumeTrue;
4646
import static org.mockito.ArgumentMatchers.any;
4747
import static org.mockito.ArgumentMatchers.eq;
4848
import static org.mockito.Mockito.inOrder;
@@ -54,14 +54,11 @@
5454

5555
class CleanerTest {
5656

57-
private static final boolean POSIX_COMPLIANT =
58-
FileSystems.getDefault().supportedFileAttributeViews().contains("posix");
59-
6057
private final Log log = mock();
6158

6259
@Test
60+
@DisabledOnOs(OS.WINDOWS)
6361
void deleteSucceedsDeeply(@TempDir Path tempDir) throws Exception {
64-
assumeTrue(POSIX_COMPLIANT);
6562
final Path basedir = createDirectory(tempDir.resolve("target")).toRealPath();
6663
final Path file = createFile(basedir.resolve("file"));
6764
final Cleaner cleaner = new Cleaner(null, log, false, null, null);
@@ -71,8 +68,8 @@ void deleteSucceedsDeeply(@TempDir Path tempDir) throws Exception {
7168
}
7269

7370
@Test
71+
@DisabledOnOs(OS.WINDOWS)
7472
void deleteFailsWithoutRetryWhenNoPermission(@TempDir Path tempDir) throws Exception {
75-
assumeTrue(POSIX_COMPLIANT);
7673
when(log.isWarnEnabled()).thenReturn(true);
7774
final Path basedir = createDirectory(tempDir.resolve("target")).toRealPath();
7875
createFile(basedir.resolve("file"));
@@ -90,8 +87,8 @@ void deleteFailsWithoutRetryWhenNoPermission(@TempDir Path tempDir) throws Excep
9087
}
9188

9289
@Test
90+
@DisabledOnOs(OS.WINDOWS)
9391
void deleteFailsAfterRetryWhenNoPermission(@TempDir Path tempDir) throws Exception {
94-
assumeTrue(POSIX_COMPLIANT);
9592
final Path basedir = createDirectory(tempDir.resolve("target")).toRealPath();
9693
createFile(basedir.resolve("file"));
9794
// Remove the executable flag to prevent directory listing, which will result in a DirectoryNotEmptyException.
@@ -107,8 +104,8 @@ void deleteFailsAfterRetryWhenNoPermission(@TempDir Path tempDir) throws Excepti
107104
}
108105

109106
@Test
107+
@DisabledOnOs(OS.WINDOWS)
110108
void deleteLogsWarningWithoutRetryWhenNoPermission(@TempDir Path tempDir) throws Exception {
111-
assumeTrue(POSIX_COMPLIANT);
112109
when(log.isWarnEnabled()).thenReturn(true);
113110
final Path basedir = createDirectory(tempDir.resolve("target")).toRealPath();
114111
final Path file = createFile(basedir.resolve("file"));
@@ -128,8 +125,8 @@ void deleteLogsWarningWithoutRetryWhenNoPermission(@TempDir Path tempDir) throws
128125
}
129126

130127
@Test
128+
@DisabledOnOs(OS.WINDOWS)
131129
void deleteDoesNotLogAnythingWhenNoPermissionAndWarnDisabled(@TempDir Path tempDir) throws Exception {
132-
assumeTrue(POSIX_COMPLIANT);
133130
when(log.isWarnEnabled()).thenReturn(false);
134131
final Path basedir = createDirectory(tempDir.resolve("target")).toRealPath();
135132
createFile(basedir.resolve("file"));

0 commit comments

Comments
 (0)