Skip to content

Commit 0da13b2

Browse files
[MCLEAN-122] Cleanup declared dependencies, simplify unit test
1 parent 567be96 commit 0da13b2

File tree

2 files changed

+11
-56
lines changed

2 files changed

+11
-56
lines changed

pom.xml

-18
Original file line numberDiff line numberDiff line change
@@ -114,29 +114,11 @@ under the License.
114114
<version>1.3.0</version>
115115
<scope>test</scope>
116116
</dependency>
117-
<dependency>
118-
<groupId>org.eclipse.sisu</groupId>
119-
<artifactId>org.eclipse.sisu.plexus</artifactId>
120-
<scope>test</scope>
121-
</dependency>
122-
<dependency>
123-
<groupId>com.google.inject</groupId>
124-
<artifactId>guice</artifactId>
125-
<version>4.2.3</version>
126-
<classifier>no_aop</classifier>
127-
<scope>test</scope>
128-
</dependency>
129117
<dependency>
130118
<groupId>org.codehaus.plexus</groupId>
131119
<artifactId>plexus-xml</artifactId>
132120
<scope>test</scope>
133121
</dependency>
134-
<dependency>
135-
<groupId>org.apache.maven</groupId>
136-
<artifactId>maven-resolver-provider</artifactId>
137-
<version>${mavenVersion}</version>
138-
<scope>test</scope>
139-
</dependency>
140122
</dependencies>
141123

142124
<profiles>

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

+11-38
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,10 @@
2929
import java.nio.file.Paths;
3030
import java.util.Collections;
3131

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;
4032
import org.apache.maven.plugin.MojoExecutionException;
4133
import org.apache.maven.plugin.logging.SystemStreamLog;
4234
import org.apache.maven.plugin.testing.junit5.InjectMojo;
4335
import org.apache.maven.plugin.testing.junit5.MojoTest;
44-
import org.apache.maven.repository.internal.MavenRepositorySystemUtils;
45-
import org.codehaus.plexus.PlexusContainer;
4636
import org.junit.jupiter.api.Test;
4737
import org.junit.jupiter.api.condition.DisabledOnOs;
4838
import org.junit.jupiter.api.condition.EnabledOnOs;
@@ -63,15 +53,15 @@
6353
* @author <a href="mailto:[email protected]">Vincent Siveton</a>
6454
*/
6555
@MojoTest
66-
public class CleanMojoTest {
56+
class CleanMojoTest {
6757
/**
6858
* Tests the simple removal of directories
6959
*
7060
* @throws Exception in case of an error.
7161
*/
7262
@Test
7363
@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 {
7565
mojo.execute();
7666

7767
assertFalse(
@@ -92,7 +82,7 @@ public void testBasicClean(CleanMojo mojo) throws Exception {
9282
*/
9383
@Test
9484
@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 {
9686
mojo.execute();
9787

9888
assertFalse(checkExists(getBasedir() + "/target/test-classes/unit/nested-clean-test/target"));
@@ -108,7 +98,7 @@ public void testCleanNestedStructure(CleanMojo mojo) throws Exception {
10898
*/
10999
@Test
110100
@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 {
112102
mojo.execute();
113103

114104
assertTrue(checkExists(getBasedir() + "/target/test-classes/unit/empty-clean-test/testDirectoryStructure"));
@@ -127,7 +117,7 @@ public void testCleanEmptyDirectories(CleanMojo mojo) throws Exception {
127117
*/
128118
@Test
129119
@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 {
131121
mojo.execute();
132122

133123
// fileset 1
@@ -154,7 +144,7 @@ public void testFilesetsClean(CleanMojo mojo) throws Exception {
154144
*/
155145
@Test
156146
@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 {
158148
assertThrows(MojoExecutionException.class, mojo::execute);
159149
}
160150

@@ -165,7 +155,7 @@ public void testCleanInvalidDirectory(CleanMojo mojo) throws Exception {
165155
*/
166156
@Test
167157
@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 {
169159
mojo.execute();
170160

171161
assertFalse(checkExists(getBasedir() + "/target/test-classes/unit/missing-directory-test/does-not-exist"));
@@ -182,7 +172,7 @@ public void testMissingDirectory(CleanMojo mojo) throws Exception {
182172
@Test
183173
@EnabledOnOs(OS.WINDOWS)
184174
@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 {
186176
File f = new File(getBasedir(), "target/test-classes/unit/locked-file-test/buildDirectory/file.txt");
187177
try (FileChannel channel = new RandomAccessFile(f, "rw").getChannel();
188178
FileLock ignored = channel.lock()) {
@@ -204,7 +194,7 @@ public void testCleanLockedFile(CleanMojo mojo) throws Exception {
204194
@Test
205195
@EnabledOnOs(OS.WINDOWS)
206196
@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 {
208198
setVariableValueToObject(mojo, "failOnError", Boolean.FALSE);
209199
assertNotNull(mojo);
210200

@@ -225,7 +215,7 @@ public void testCleanLockedFileWithNoError(CleanMojo mojo) throws Exception {
225215
*/
226216
@Test
227217
@EnabledOnOs(OS.WINDOWS)
228-
public void testFollowLinksWithWindowsJunction() throws Exception {
218+
void testFollowLinksWithWindowsJunction() throws Exception {
229219
testSymlink((link, target) -> {
230220
Process process = new ProcessBuilder()
231221
.directory(link.getParent().toFile())
@@ -248,7 +238,7 @@ public void testFollowLinksWithWindowsJunction() throws Exception {
248238
*/
249239
@Test
250240
@DisabledOnOs(OS.WINDOWS)
251-
public void testFollowLinksWithSymLinkOnPosix() throws Exception {
241+
void testFollowLinksWithSymLinkOnPosix() throws Exception {
252242
testSymlink((link, target) -> {
253243
try {
254244
Files.createSymbolicLink(link, target);
@@ -294,23 +284,6 @@ private void testSymlink(LinkCreator linkCreator) throws Exception {
294284
assertFalse(Files.exists(dirWithLnk));
295285
}
296286

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-
314287
/**
315288
* @param dir a dir or a file
316289
* @return true if a file/dir exists, false otherwise

0 commit comments

Comments
 (0)