29
29
import java .nio .file .Paths ;
30
30
import java .util .Collections ;
31
31
32
- import com .google .inject .Provides ;
33
- import com .google .inject .Singleton ;
34
- import org .apache .maven .execution .DefaultMavenExecutionRequest ;
35
- import org .apache .maven .execution .DefaultMavenExecutionResult ;
36
- import org .apache .maven .execution .MavenExecutionRequest ;
37
- import org .apache .maven .execution .MavenExecutionResult ;
38
- import org .apache .maven .execution .MavenSession ;
39
- import org .apache .maven .plugin .MojoExecution ;
40
32
import org .apache .maven .plugin .MojoExecutionException ;
41
33
import org .apache .maven .plugin .logging .SystemStreamLog ;
42
34
import org .apache .maven .plugin .testing .junit5 .InjectMojo ;
43
35
import org .apache .maven .plugin .testing .junit5 .MojoTest ;
44
- import org .apache .maven .repository .internal .MavenRepositorySystemUtils ;
45
- import org .codehaus .plexus .PlexusContainer ;
46
36
import org .junit .jupiter .api .Test ;
47
37
import org .junit .jupiter .api .condition .DisabledOnOs ;
48
38
import org .junit .jupiter .api .condition .EnabledOnOs ;
63
53
* @author <a href="mailto:[email protected] ">Vincent Siveton</a>
64
54
*/
65
55
@ MojoTest
66
- public class CleanMojoTest {
56
+ class CleanMojoTest {
67
57
/**
68
58
* Tests the simple removal of directories
69
59
*
70
60
* @throws Exception in case of an error.
71
61
*/
72
62
@ Test
73
63
@ InjectMojo (goal = "clean" , pom = "classpath:/unit/basic-clean-test/plugin-pom.xml" )
74
- public void testBasicClean (CleanMojo mojo ) throws Exception {
64
+ void testBasicClean (CleanMojo mojo ) throws Exception {
75
65
mojo .execute ();
76
66
77
67
assertFalse (
@@ -92,7 +82,7 @@ public void testBasicClean(CleanMojo mojo) throws Exception {
92
82
*/
93
83
@ Test
94
84
@ InjectMojo (goal = "clean" , pom = "classpath:/unit/nested-clean-test/plugin-pom.xml" )
95
- public void testCleanNestedStructure (CleanMojo mojo ) throws Exception {
85
+ void testCleanNestedStructure (CleanMojo mojo ) throws Exception {
96
86
mojo .execute ();
97
87
98
88
assertFalse (checkExists (getBasedir () + "/target/test-classes/unit/nested-clean-test/target" ));
@@ -108,7 +98,7 @@ public void testCleanNestedStructure(CleanMojo mojo) throws Exception {
108
98
*/
109
99
@ Test
110
100
@ InjectMojo (goal = "clean" , pom = "classpath:/unit/empty-clean-test/plugin-pom.xml" )
111
- public void testCleanEmptyDirectories (CleanMojo mojo ) throws Exception {
101
+ void testCleanEmptyDirectories (CleanMojo mojo ) throws Exception {
112
102
mojo .execute ();
113
103
114
104
assertTrue (checkExists (getBasedir () + "/target/test-classes/unit/empty-clean-test/testDirectoryStructure" ));
@@ -127,7 +117,7 @@ public void testCleanEmptyDirectories(CleanMojo mojo) throws Exception {
127
117
*/
128
118
@ Test
129
119
@ InjectMojo (goal = "clean" , pom = "classpath:/unit/fileset-clean-test/plugin-pom.xml" )
130
- public void testFilesetsClean (CleanMojo mojo ) throws Exception {
120
+ void testFilesetsClean (CleanMojo mojo ) throws Exception {
131
121
mojo .execute ();
132
122
133
123
// fileset 1
@@ -154,7 +144,7 @@ public void testFilesetsClean(CleanMojo mojo) throws Exception {
154
144
*/
155
145
@ Test
156
146
@ InjectMojo (goal = "clean" , pom = "classpath:/unit/invalid-directory-test/plugin-pom.xml" )
157
- public void testCleanInvalidDirectory (CleanMojo mojo ) throws Exception {
147
+ void testCleanInvalidDirectory (CleanMojo mojo ) throws Exception {
158
148
assertThrows (MojoExecutionException .class , mojo ::execute );
159
149
}
160
150
@@ -165,7 +155,7 @@ public void testCleanInvalidDirectory(CleanMojo mojo) throws Exception {
165
155
*/
166
156
@ Test
167
157
@ InjectMojo (goal = "clean" , pom = "classpath:/unit/missing-directory-test/plugin-pom.xml" )
168
- public void testMissingDirectory (CleanMojo mojo ) throws Exception {
158
+ void testMissingDirectory (CleanMojo mojo ) throws Exception {
169
159
mojo .execute ();
170
160
171
161
assertFalse (checkExists (getBasedir () + "/target/test-classes/unit/missing-directory-test/does-not-exist" ));
@@ -182,7 +172,7 @@ public void testMissingDirectory(CleanMojo mojo) throws Exception {
182
172
@ Test
183
173
@ EnabledOnOs (OS .WINDOWS )
184
174
@ InjectMojo (goal = "clean" , pom = "classpath:/unit/locked-file-test/plugin-pom.xml" )
185
- public void testCleanLockedFile (CleanMojo mojo ) throws Exception {
175
+ void testCleanLockedFile (CleanMojo mojo ) throws Exception {
186
176
File f = new File (getBasedir (), "target/test-classes/unit/locked-file-test/buildDirectory/file.txt" );
187
177
try (FileChannel channel = new RandomAccessFile (f , "rw" ).getChannel ();
188
178
FileLock ignored = channel .lock ()) {
@@ -204,7 +194,7 @@ public void testCleanLockedFile(CleanMojo mojo) throws Exception {
204
194
@ Test
205
195
@ EnabledOnOs (OS .WINDOWS )
206
196
@ InjectMojo (goal = "clean" , pom = "classpath:/unit/locked-file-test/plugin-pom.xml" )
207
- public void testCleanLockedFileWithNoError (CleanMojo mojo ) throws Exception {
197
+ void testCleanLockedFileWithNoError (CleanMojo mojo ) throws Exception {
208
198
setVariableValueToObject (mojo , "failOnError" , Boolean .FALSE );
209
199
assertNotNull (mojo );
210
200
@@ -225,7 +215,7 @@ public void testCleanLockedFileWithNoError(CleanMojo mojo) throws Exception {
225
215
*/
226
216
@ Test
227
217
@ EnabledOnOs (OS .WINDOWS )
228
- public void testFollowLinksWithWindowsJunction () throws Exception {
218
+ void testFollowLinksWithWindowsJunction () throws Exception {
229
219
testSymlink ((link , target ) -> {
230
220
Process process = new ProcessBuilder ()
231
221
.directory (link .getParent ().toFile ())
@@ -248,7 +238,7 @@ public void testFollowLinksWithWindowsJunction() throws Exception {
248
238
*/
249
239
@ Test
250
240
@ DisabledOnOs (OS .WINDOWS )
251
- public void testFollowLinksWithSymLinkOnPosix () throws Exception {
241
+ void testFollowLinksWithSymLinkOnPosix () throws Exception {
252
242
testSymlink ((link , target ) -> {
253
243
try {
254
244
Files .createSymbolicLink (link , target );
@@ -294,23 +284,6 @@ private void testSymlink(LinkCreator linkCreator) throws Exception {
294
284
assertFalse (Files .exists (dirWithLnk ));
295
285
}
296
286
297
- @ Provides
298
- @ Singleton
299
- @ SuppressWarnings ("unused" )
300
- private MavenSession createSession (PlexusContainer container ) {
301
- MavenExecutionRequest request = new DefaultMavenExecutionRequest ();
302
- MavenExecutionResult result = new DefaultMavenExecutionResult ();
303
- MavenSession session = new MavenSession (container , MavenRepositorySystemUtils .newSession (), request , result );
304
- return session ;
305
- }
306
-
307
- @ Provides
308
- @ Singleton
309
- @ SuppressWarnings ("unused" )
310
- private MojoExecution createMojoExecution () {
311
- return new MojoExecution (null );
312
- }
313
-
314
287
/**
315
288
* @param dir a dir or a file
316
289
* @return true if a file/dir exists, false otherwise
0 commit comments