Skip to content
Merged
Show file tree
Hide file tree
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
20 changes: 1 addition & 19 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ under the License.
<jettyVersion>9.4.58.v20250814</jettyVersion>
<mockito.version>4.11.0</mockito.version>
<plexus-archiver.version>4.11.0</plexus-archiver.version>
<pluginTestingVersion>3.4.0</pluginTestingVersion>
<pluginTestingVersion>3.5.0</pluginTestingVersion>

<!-- strict check by dependency:analyze-only -->
<enforce.dependency.declarations>true</enforce.dependency.declarations>
Expand Down Expand Up @@ -179,12 +179,6 @@ under the License.
<artifactId>commons-lang3</artifactId>
<version>3.20.0</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.21.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
Expand Down Expand Up @@ -327,18 +321,6 @@ under the License.
<version>2.0.1</version>
<scope>test</scope>
</dependency>
<dependency>
<!-- support for JUnit 4 -->
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-testing</groupId>
<artifactId>maven-plugin-testing-harness</artifactId>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,50 +18,43 @@
*/
package org.apache.maven.plugins.dependency;

import java.io.File;
import java.util.Set;

import org.apache.maven.api.plugin.testing.InjectMojo;
import org.apache.maven.api.plugin.testing.MojoParameter;
import org.apache.maven.api.plugin.testing.MojoTest;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugins.dependency.resolvers.CollectDependenciesMojo;
import org.apache.maven.plugins.dependency.resolvers.ResolveDependenciesMojo;
import org.apache.maven.plugins.dependency.testUtils.stubs.DependencyProjectStub;
import org.apache.maven.plugins.dependency.testUtils.DependencyArtifactStubFactory;
import org.apache.maven.plugins.dependency.utils.DependencySilentLog;
import org.apache.maven.plugins.dependency.utils.DependencyStatusSets;
import org.apache.maven.project.MavenProject;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

public class TestCollectMojo extends AbstractDependencyMojoTestCase {
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

@Override
protected String getTestDirectoryName() {
return "markers";
}

@Override
protected boolean shouldCreateFiles() {
return false;
}

@Override
protected void setUp() throws Exception {
// required for mojo lookups to work
super.setUp();
@MojoTest
class TestCollectMojo {

MavenProject project = new DependencyProjectStub();
getContainer().addComponent(project, MavenProject.class.getName());
private DependencyArtifactStubFactory stubFactory;

MavenSession session = newMavenSession(project);
getContainer().addComponent(session, MavenSession.class.getName());
@BeforeEach
void setUp() throws Exception {
stubFactory = new DependencyArtifactStubFactory(null, false);
}

/**
* tests the proper discovery and configuration of the mojo
*
* @throws Exception if a problem occurs
*/
public void testCollectTestEnvironment() throws Exception {
File testPom = new File(getBasedir(), "target/test-classes/unit/collect-test/plugin-config.xml");
CollectDependenciesMojo mojo = (CollectDependenciesMojo) lookupMojo("collect", testPom);
@Test
@InjectMojo(goal = "collect")
void testCollectTestEnvironment(CollectDependenciesMojo mojo) throws Exception {

assertNotNull(mojo);
assertNotNull(mojo.getProject());
Expand All @@ -85,10 +78,10 @@ public void testCollectTestEnvironment() throws Exception {
*
* @throws Exception if a problem occurs
*/
public void testCollectTestEnvironmentExcludeTransitive() throws Exception {
File testPom = new File(getBasedir(), "target/test-classes/unit/collect-test/plugin-config.xml");
CollectDependenciesMojo mojo = (CollectDependenciesMojo) lookupMojo("collect", testPom);

@Test
@InjectMojo(goal = "collect")
@MojoParameter(name = "excludeTransitive", value = "true")
void testCollectTestEnvironmentExcludeTransitive(CollectDependenciesMojo mojo) throws Exception {
assertNotNull(mojo);
assertNotNull(mojo.getProject());
MavenProject project = mojo.getProject();
Expand All @@ -100,18 +93,15 @@ public void testCollectTestEnvironmentExcludeTransitive() throws Exception {
project.setArtifacts(artifacts);
project.setDependencyArtifacts(directArtifacts);

setVariableValueToObject(mojo, "excludeTransitive", Boolean.TRUE);

mojo.execute();
DependencyStatusSets results = mojo.getResults();
assertNotNull(results);
assertEquals(directArtifacts.size(), results.getResolvedDependencies().size());
}

public void testSilent() throws Exception {
File testPom = new File(getBasedir(), "target/test-classes/unit/resolve-test/plugin-config.xml");
ResolveDependenciesMojo mojo = (ResolveDependenciesMojo) lookupMojo("resolve", testPom);

@Test
@InjectMojo(goal = "collect")
void testSilent(CollectDependenciesMojo mojo) throws Exception {
assertFalse(mojo.getLog() instanceof DependencySilentLog);

mojo.setSilent(true);
Expand Down
Loading