2121import java .io .IOException ;
2222import java .nio .file .AccessDeniedException ;
2323import java .nio .file .DirectoryNotEmptyException ;
24- import java .nio .file .FileSystems ;
2524import java .nio .file .Path ;
2625import java .nio .file .attribute .PosixFilePermission ;
2726import java .nio .file .attribute .PosixFilePermissions ;
2827import java .util .Set ;
2928
3029import org .apache .maven .plugin .logging .Log ;
3130import org .junit .jupiter .api .Test ;
31+ import org .junit .jupiter .api .condition .DisabledOnOs ;
32+ import org .junit .jupiter .api .condition .OS ;
3233import org .junit .jupiter .api .io .TempDir ;
3334import org .mockito .ArgumentCaptor ;
3435import org .mockito .InOrder ;
4243import static org .junit .jupiter .api .Assertions .assertFalse ;
4344import static org .junit .jupiter .api .Assertions .assertInstanceOf ;
4445import static org .junit .jupiter .api .Assertions .assertThrows ;
45- import static org .junit .jupiter .api .Assumptions .assumeTrue ;
4646import static org .mockito .ArgumentMatchers .any ;
4747import static org .mockito .ArgumentMatchers .eq ;
4848import static org .mockito .Mockito .inOrder ;
5454
5555class 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