diff --git a/pom.xml b/pom.xml index 9b37307ab..24c93bfc0 100644 --- a/pom.xml +++ b/pom.xml @@ -95,22 +95,12 @@ under the License. 2023-10-20T21:21:50Z 1.7.36 4.9.2 + + 3.11.0 - - - - org.eclipse.sisu - org.eclipse.sisu.inject - 0.3.0.M1 - - - org.eclipse.sisu - org.eclipse.sisu.plexus - 0.3.0.M1 - org.apache.commons @@ -321,6 +311,12 @@ under the License. maven-plugin-testing-harness ${pluginTestingVersion} test + + + org.codehaus.plexus + plexus-container-default + + org.mockito @@ -414,7 +410,7 @@ under the License. maven-surefire-plugin - -Xmx384m + -Xmx512m ${maven.home} diff --git a/src/test/java/org/apache/maven/plugins/dependency/TestCollectMojo.java b/src/test/java/org/apache/maven/plugins/dependency/TestCollectMojo.java index 30f84893b..070cbb69c 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/TestCollectMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/TestCollectMojo.java @@ -22,8 +22,10 @@ import java.util.Set; import org.apache.maven.artifact.Artifact; +import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.testing.SilentLog; import org.apache.maven.plugins.dependency.resolvers.CollectDependenciesMojo; +import org.apache.maven.plugins.dependency.testUtils.stubs.DependencyProjectStub; import org.apache.maven.plugins.dependency.utils.DependencyStatusSets; import org.apache.maven.project.MavenProject; @@ -32,6 +34,11 @@ public class TestCollectMojo extends AbstractDependencyMojoTestCase { protected void setUp() throws Exception { // required for mojo lookups to work super.setUp("markers", false); + MavenProject project = new DependencyProjectStub(); + getContainer().addComponent(project, MavenProject.class.getName()); + + MavenSession session = newMavenSession(project); + getContainer().addComponent(session, MavenSession.class.getName()); } /** diff --git a/src/test/java/org/apache/maven/plugins/dependency/TestGetMojo.java b/src/test/java/org/apache/maven/plugins/dependency/TestGetMojo.java index 4dfcc284c..fd820791d 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/TestGetMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/TestGetMojo.java @@ -30,7 +30,8 @@ import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.LegacySupport; import org.apache.maven.plugin.MojoFailureException; -import org.apache.maven.plugin.testing.stubs.MavenProjectStub; +import org.apache.maven.plugins.dependency.testUtils.stubs.DependencyProjectStub; +import org.apache.maven.project.MavenProject; import org.apache.maven.settings.Server; import org.apache.maven.settings.Settings; import org.eclipse.jetty.security.ConstraintMapping; @@ -49,6 +50,11 @@ public class TestGetMojo extends AbstractDependencyMojoTestCase { protected void setUp() throws Exception { // required for mojo lookups to work super.setUp("markers", false); + MavenProject project = new DependencyProjectStub(); + getContainer().addComponent(project, MavenProject.class.getName()); + + MavenSession session = newMavenSession(project); + getContainer().addComponent(session, MavenSession.class.getName()); File testPom = new File(getBasedir(), "target/test-classes/unit/get-test/plugin-config.xml"); mojo = (GetMojo) lookupMojo("get", testPom); @@ -56,14 +62,13 @@ protected void setUp() throws Exception { assertNotNull(mojo); LegacySupport legacySupport = lookup(LegacySupport.class); - MavenSession mavenSession = newMavenSession(new MavenProjectStub()); - Settings settings = mavenSession.getSettings(); + Settings settings = session.getSettings(); Server server = new Server(); server.setId("myserver"); server.setUsername("foo"); server.setPassword("bar"); settings.addServer(server); - legacySupport.setSession(mavenSession); + legacySupport.setSession(session); installLocalRepository(legacySupport); diff --git a/src/test/java/org/apache/maven/plugins/dependency/TestListClassesMojo.java b/src/test/java/org/apache/maven/plugins/dependency/TestListClassesMojo.java index cd73bf741..92cf2d68a 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/TestListClassesMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/TestListClassesMojo.java @@ -27,7 +27,8 @@ import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.LegacySupport; import org.apache.maven.plugin.logging.Log; -import org.apache.maven.plugin.testing.stubs.MavenProjectStub; +import org.apache.maven.plugins.dependency.testUtils.stubs.DependencyProjectStub; +import org.apache.maven.project.MavenProject; import org.apache.maven.settings.Server; import org.apache.maven.settings.Settings; import org.junit.Assert; @@ -39,6 +40,13 @@ public class TestListClassesMojo extends AbstractDependencyMojoTestCase { protected void setUp() throws Exception { super.setUp("markers", false); + + MavenProject project = new DependencyProjectStub(); + getContainer().addComponent(project, MavenProject.class.getName()); + + MavenSession session = newMavenSession(project); + getContainer().addComponent(session, MavenSession.class.getName()); + File testPom = new File(getBasedir(), "target/test-classes/unit/get-test/plugin-config.xml"); assertTrue(testPom.exists()); @@ -47,7 +55,6 @@ protected void setUp() throws Exception { assertNotNull(mojo); LegacySupport legacySupport = lookup(LegacySupport.class); - MavenSession session = newMavenSession(new MavenProjectStub()); Settings settings = session.getSettings(); Server server = new Server(); server.setId("myserver"); @@ -57,8 +64,6 @@ protected void setUp() throws Exception { legacySupport.setSession(session); installLocalRepository(legacySupport); - - setVariableValueToObject(mojo, "session", legacySupport.getSession()); } public void testListClassesNotTransitive() throws Exception { diff --git a/src/test/java/org/apache/maven/plugins/dependency/TestPropertiesMojo.java b/src/test/java/org/apache/maven/plugins/dependency/TestPropertiesMojo.java index 3b0a6f2c3..ede675d2d 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/TestPropertiesMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/TestPropertiesMojo.java @@ -22,12 +22,20 @@ import java.util.Set; import org.apache.maven.artifact.Artifact; +import org.apache.maven.execution.MavenSession; +import org.apache.maven.plugins.dependency.testUtils.stubs.DependencyProjectStub; import org.apache.maven.project.MavenProject; public class TestPropertiesMojo extends AbstractDependencyMojoTestCase { protected void setUp() throws Exception { // required for mojo lookups to work super.setUp("markers", true); + + MavenProject project = new DependencyProjectStub(); + getContainer().addComponent(project, MavenProject.class.getName()); + + MavenSession session = newMavenSession(project); + getContainer().addComponent(session, MavenSession.class.getName()); } /** diff --git a/src/test/java/org/apache/maven/plugins/dependency/TestSkip.java b/src/test/java/org/apache/maven/plugins/dependency/TestSkip.java index 1b1923089..b52a9e812 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/TestSkip.java +++ b/src/test/java/org/apache/maven/plugins/dependency/TestSkip.java @@ -20,8 +20,11 @@ import java.io.File; +import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.Mojo; import org.apache.maven.plugin.logging.Log; +import org.apache.maven.plugins.dependency.testUtils.stubs.DependencyProjectStub; +import org.apache.maven.project.MavenProject; import org.mockito.ArgumentCaptor; import static org.mockito.Mockito.atLeastOnce; @@ -29,6 +32,17 @@ import static org.mockito.Mockito.verify; public class TestSkip extends AbstractDependencyMojoTestCase { + + @Override + protected void setUp() throws Exception { + super.setUp(); + MavenProject project = new DependencyProjectStub(); + getContainer().addComponent(project, MavenProject.class.getName()); + + MavenSession session = newMavenSession(project); + getContainer().addComponent(session, MavenSession.class.getName()); + } + public void testSkipAnalyze() throws Exception { doTest("analyze"); } diff --git a/src/test/java/org/apache/maven/plugins/dependency/analyze/TestAnalyzeDuplicateMojo.java b/src/test/java/org/apache/maven/plugins/dependency/analyze/TestAnalyzeDuplicateMojo.java index 23796923b..c74d24ecf 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/analyze/TestAnalyzeDuplicateMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/analyze/TestAnalyzeDuplicateMojo.java @@ -22,8 +22,12 @@ import java.io.PrintWriter; import java.io.StringWriter; +import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.logging.Log; import org.apache.maven.plugins.dependency.AbstractDependencyMojoTestCase; +import org.apache.maven.plugins.dependency.testUtils.stubs.DuplicateDependencies2ProjectStub; +import org.apache.maven.plugins.dependency.testUtils.stubs.DuplicateDependenciesProjectStub; +import org.apache.maven.project.MavenProject; /** * @author Vincent Siveton @@ -31,6 +35,12 @@ */ public class TestAnalyzeDuplicateMojo extends AbstractDependencyMojoTestCase { public void testDuplicate() throws Exception { + MavenProject project = new DuplicateDependenciesProjectStub(); + getContainer().addComponent(project, MavenProject.class.getName()); + + MavenSession session = newMavenSession(project); + getContainer().addComponent(session, MavenSession.class.getName()); + File testPom = new File(getBasedir(), "target/test-classes/unit/duplicate-dependencies/plugin-config.xml"); AnalyzeDuplicateMojo mojo = (AnalyzeDuplicateMojo) lookupMojo("analyze-duplicate", testPom); assertNotNull(mojo); @@ -44,6 +54,12 @@ public void testDuplicate() throws Exception { } public void testDuplicate2() throws Exception { + MavenProject project = new DuplicateDependencies2ProjectStub(); + getContainer().addComponent(project, MavenProject.class.getName()); + + MavenSession session = newMavenSession(project); + getContainer().addComponent(session, MavenSession.class.getName()); + File testPom = new File(getBasedir(), "target/test-classes/unit/duplicate-dependencies/plugin-config2.xml"); AnalyzeDuplicateMojo mojo = (AnalyzeDuplicateMojo) lookupMojo("analyze-duplicate", testPom); assertNotNull(mojo); diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestCopyMojo.java b/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestCopyMojo.java index cdd132f4d..4390f9bf7 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestCopyMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestCopyMojo.java @@ -31,6 +31,7 @@ import org.apache.maven.plugin.LegacySupport; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.dependency.AbstractDependencyMojoTestCase; +import org.apache.maven.plugins.dependency.testUtils.stubs.DependencyProjectStub; import org.apache.maven.plugins.dependency.utils.DependencyUtil; import org.apache.maven.project.MavenProject; @@ -39,6 +40,11 @@ public class TestCopyMojo extends AbstractDependencyMojoTestCase { protected void setUp() throws Exception { super.setUp("copy", false, false); + MavenProject project = new DependencyProjectStub(); + getContainer().addComponent(project, MavenProject.class.getName()); + + MavenSession session = newMavenSession(project); + getContainer().addComponent(session, MavenSession.class.getName()); File testPom = new File(getBasedir(), "target/test-classes/unit/copy-test/plugin-config.xml"); mojo = (CopyMojo) lookupMojo("copy", testPom); @@ -48,9 +54,6 @@ protected void setUp() throws Exception { assertNotNull(mojo); assertNotNull(mojo.getProject()); - MavenSession session = newMavenSession(mojo.getProject()); - setVariableValueToObject(mojo, "session", session); - LegacySupport legacySupport = lookup(LegacySupport.class); legacySupport.setSession(session); installLocalRepository(legacySupport); diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestIncludeExcludeUnpackMojo.java b/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestIncludeExcludeUnpackMojo.java index 31de69673..5778f0e29 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestIncludeExcludeUnpackMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestIncludeExcludeUnpackMojo.java @@ -28,7 +28,9 @@ import org.apache.maven.plugin.LegacySupport; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.dependency.AbstractDependencyMojoTestCase; +import org.apache.maven.plugins.dependency.testUtils.stubs.DependencyProjectStub; import org.apache.maven.plugins.dependency.utils.markers.UnpackFileMarkerHandler; +import org.apache.maven.project.MavenProject; public class TestIncludeExcludeUnpackMojo extends AbstractDependencyMojoTestCase { private final String PACKED_FILE = "test.zip"; @@ -45,6 +47,12 @@ protected void setUp() throws Exception { // required for mojo lookups to work super.setUp("unpack", true, false); + MavenProject project = new DependencyProjectStub(); + getContainer().addComponent(project, MavenProject.class.getName()); + + MavenSession session = newMavenSession(project); + getContainer().addComponent(session, MavenSession.class.getName()); + File testPom = new File(getBasedir(), "target/test-classes/unit/unpack-test/plugin-config.xml"); mojo = (UnpackMojo) lookupMojo("unpack", testPom); mojo.setOutputDirectory(new File(this.testDir, "outputDirectory")); @@ -63,9 +71,6 @@ protected void setUp() throws Exception { mojo.setMarkersDirectory(new File(this.testDir, "markers")); mojo.setArtifactItems(list); - MavenSession session = newMavenSession(mojo.getProject()); - setVariableValueToObject(mojo, "session", session); - LegacySupport legacySupport = lookup(LegacySupport.class); legacySupport.setSession(session); installLocalRepository(legacySupport); diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestUnpackMojo.java b/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestUnpackMojo.java index 2adc2860f..6671c515a 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestUnpackMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestUnpackMojo.java @@ -34,6 +34,7 @@ import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.dependency.AbstractDependencyMojoTestCase; import org.apache.maven.plugins.dependency.testUtils.DependencyArtifactStubFactory; +import org.apache.maven.plugins.dependency.testUtils.stubs.DependencyProjectStub; import org.apache.maven.plugins.dependency.utils.markers.UnpackFileMarkerHandler; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.archiver.manager.ArchiverManager; @@ -45,6 +46,12 @@ public class TestUnpackMojo extends AbstractDependencyMojoTestCase { protected void setUp() throws Exception { super.setUp("unpack", true, false); + MavenProject project = new DependencyProjectStub(); + getContainer().addComponent(project, MavenProject.class.getName()); + + MavenSession session = newMavenSession(project); + getContainer().addComponent(session, MavenSession.class.getName()); + File testPom = new File(getBasedir(), "target/test-classes/unit/unpack-test/plugin-config.xml"); mojo = (UnpackMojo) lookupMojo("unpack", testPom); mojo.setOutputDirectory(new File(this.testDir, "outputDirectory")); @@ -62,9 +69,6 @@ protected void setUp() throws Exception { stubFactory.setSrcFile(new File( getBasedir() + File.separatorChar + "target/test-classes/unit/unpack-dependencies-test/test.txt")); - MavenSession session = newMavenSession(mojo.getProject()); - setVariableValueToObject(mojo, "session", session); - LegacySupport legacySupport = lookup(LegacySupport.class); legacySupport.setSession(session); diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestBuildClasspathMojo.java b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestBuildClasspathMojo.java index 52beca51d..3c6f3eb08 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestBuildClasspathMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestBuildClasspathMojo.java @@ -25,6 +25,7 @@ import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.LegacySupport; import org.apache.maven.plugins.dependency.AbstractDependencyMojoTestCase; +import org.apache.maven.plugins.dependency.testUtils.stubs.DependencyProjectStub; import org.apache.maven.plugins.dependency.utils.DependencyUtil; import org.apache.maven.project.MavenProject; @@ -36,6 +37,12 @@ protected void setUp() throws Exception { // required for mojo lookups to work super.setUp("build-classpath", true); + MavenProject project = new DependencyProjectStub(); + getContainer().addComponent(project, MavenProject.class.getName()); + + MavenSession session = newMavenSession(project); + getContainer().addComponent(session, MavenSession.class.getName()); + File testPom = new File(getBasedir(), "target/test-classes/unit/build-classpath-test/plugin-config.xml"); mojo = (BuildClasspathMojo) lookupMojo("build-classpath", testPom); @@ -101,11 +108,9 @@ public void testEnvironment() throws Exception { } public void testPath() throws Exception { - MavenSession session = newMavenSession(mojo.getProject()); - setVariableValueToObject(mojo, "session", session); LegacySupport legacySupport = lookup(LegacySupport.class); - legacySupport.setSession(session); + legacySupport.setSession(lookup(MavenSession.class)); installLocalRepository(legacySupport); Artifact artifact = stubFactory.getReleaseArtifact(); diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo.java b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo.java index b79a876b6..f83743a05 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo.java @@ -31,6 +31,7 @@ import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.dependency.AbstractDependencyMojoTestCase; +import org.apache.maven.plugins.dependency.testUtils.stubs.DependencyProjectStub; import org.apache.maven.plugins.dependency.utils.DependencyUtil; import org.apache.maven.plugins.dependency.utils.markers.DefaultFileMarkerHandler; import org.apache.maven.project.MavenProject; @@ -44,6 +45,12 @@ protected void setUp() throws Exception { // required for mojo lookups to work super.setUp("copy-dependencies", true, false); + MavenProject project = new DependencyProjectStub(); + getContainer().addComponent(project, MavenProject.class.getName()); + + MavenSession session = newMavenSession(project); + getContainer().addComponent(session, MavenSession.class.getName()); + File testPom = new File(getBasedir(), "target/test-classes/unit/copy-dependencies-test/plugin-config.xml"); mojo = (CopyDependenciesMojo) lookupMojo("copy-dependencies", testPom); mojo.outputDirectory = new File(this.testDir, "outputDirectory"); @@ -51,10 +58,6 @@ protected void setUp() throws Exception { assertNotNull(mojo); assertNotNull(mojo.getProject()); - MavenProject project = mojo.getProject(); - - MavenSession session = newMavenSession(project); - setVariableValueToObject(mojo, "session", session); LegacySupport legacySupport = lookup(LegacySupport.class); legacySupport.setSession(session); diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo2.java b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo2.java index c755a62a7..231c620a5 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo2.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestCopyDependenciesMojo2.java @@ -43,6 +43,7 @@ import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.LegacySupport; import org.apache.maven.plugins.dependency.AbstractDependencyMojoTestCase; +import org.apache.maven.plugins.dependency.testUtils.stubs.DependencyProjectStub; import org.apache.maven.plugins.dependency.utils.DependencyUtil; import org.apache.maven.project.MavenProject; @@ -53,6 +54,11 @@ public class TestCopyDependenciesMojo2 extends AbstractDependencyMojoTestCase { protected void setUp() throws Exception { // required for mojo lookups to work super.setUp("copy-dependencies", true); + MavenProject project = new DependencyProjectStub(); + getContainer().addComponent(project, MavenProject.class.getName()); + + MavenSession session = newMavenSession(project); + getContainer().addComponent(session, MavenSession.class.getName()); File testPom = new File(getBasedir(), "target/test-classes/unit/copy-dependencies-test/plugin-config.xml"); mojo = (CopyDependenciesMojo) lookupMojo("copy-dependencies", testPom); @@ -61,7 +67,6 @@ protected void setUp() throws Exception { assertNotNull(mojo); assertNotNull(mojo.getProject()); - MavenProject project = mojo.getProject(); Set artifacts = this.stubFactory.getScopedArtifacts(); Set directArtifacts = this.stubFactory.getReleaseAndSnapshotArtifacts(); @@ -72,9 +77,6 @@ protected void setUp() throws Exception { mojo.markersDirectory = new File(this.testDir, "markers"); LegacySupport legacySupport = lookup(LegacySupport.class); - MavenSession session = newMavenSession(project); - setVariableValueToObject(mojo, "session", session); - legacySupport.setSession(session); installLocalRepository(legacySupport); } diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestIncludeExcludeUnpackDependenciesMojo.java b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestIncludeExcludeUnpackDependenciesMojo.java index 60faec3ee..8195ae16c 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestIncludeExcludeUnpackDependenciesMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestIncludeExcludeUnpackDependenciesMojo.java @@ -22,7 +22,9 @@ import java.util.Set; import org.apache.maven.artifact.Artifact; +import org.apache.maven.execution.MavenSession; import org.apache.maven.plugins.dependency.AbstractDependencyMojoTestCase; +import org.apache.maven.plugins.dependency.testUtils.stubs.DependencyProjectStub; import org.apache.maven.project.MavenProject; public class TestIncludeExcludeUnpackDependenciesMojo extends AbstractDependencyMojoTestCase { @@ -40,6 +42,12 @@ protected void setUp() throws Exception { // required for mojo lookups to work super.setUp("unpack-dependencies", true); + MavenProject project = new DependencyProjectStub(); + getContainer().addComponent(project, MavenProject.class.getName()); + + MavenSession session = newMavenSession(project); + getContainer().addComponent(session, MavenSession.class.getName()); + File testPom = new File(getBasedir(), "target/test-classes/unit/unpack-dependencies-test/plugin-config.xml"); mojo = (UnpackDependenciesMojo) lookupMojo("unpack-dependencies", testPom); mojo.outputDirectory = new File(this.testDir, "outputDirectory"); @@ -53,7 +61,6 @@ protected void setUp() throws Exception { assertNotNull(mojo); assertNotNull(mojo.getProject()); - MavenProject project = mojo.getProject(); Set artifacts = this.stubFactory.getScopedArtifacts(); Set directArtifacts = this.stubFactory.getReleaseAndSnapshotArtifacts(); diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo.java b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo.java index c8e9f0dfe..44c7cbeb0 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo.java @@ -34,6 +34,7 @@ import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.dependency.AbstractDependencyMojoTestCase; import org.apache.maven.plugins.dependency.testUtils.DependencyArtifactStubFactory; +import org.apache.maven.plugins.dependency.testUtils.stubs.DependencyProjectStub; import org.apache.maven.plugins.dependency.utils.DependencyUtil; import org.apache.maven.plugins.dependency.utils.markers.DefaultFileMarkerHandler; import org.apache.maven.project.MavenProject; @@ -51,6 +52,12 @@ protected void setUp() throws Exception { // required for mojo lookups to work super.setUp("unpack-dependencies", true, false); + MavenProject project = new DependencyProjectStub(); + getContainer().addComponent(project, MavenProject.class.getName()); + + MavenSession session = newMavenSession(project); + getContainer().addComponent(session, MavenSession.class.getName()); + File testPom = new File(getBasedir(), "target/test-classes/unit/unpack-dependencies-test/plugin-config.xml"); mojo = (UnpackDependenciesMojo) lookupMojo("unpack-dependencies", testPom); mojo.outputDirectory = new File(this.testDir, "outputDirectory"); @@ -64,10 +71,6 @@ protected void setUp() throws Exception { assertNotNull(mojo); assertNotNull(mojo.getProject()); - MavenProject project = mojo.getProject(); - - MavenSession session = newMavenSession(project); - setVariableValueToObject(mojo, "session", session); LegacySupport legacySupport = lookup(LegacySupport.class); legacySupport.setSession(session); diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo2.java b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo2.java index 515a87c24..70941f9c8 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo2.java +++ b/src/test/java/org/apache/maven/plugins/dependency/fromDependencies/TestUnpackDependenciesMojo2.java @@ -24,10 +24,12 @@ import java.util.Set; import org.apache.maven.artifact.Artifact; +import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.dependency.AbstractDependencyMojoTestCase; import org.apache.maven.plugins.dependency.testUtils.DependencyArtifactStubFactory; +import org.apache.maven.plugins.dependency.testUtils.stubs.DependencyProjectStub; import org.apache.maven.plugins.dependency.utils.DependencyUtil; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.archiver.manager.ArchiverManager; @@ -44,6 +46,12 @@ protected void setUp() throws Exception { // required for mojo lookups to work super.setUp("unpack-dependencies", true); + MavenProject project = new DependencyProjectStub(); + getContainer().addComponent(project, MavenProject.class.getName()); + + MavenSession session = newMavenSession(project); + getContainer().addComponent(session, MavenSession.class.getName()); + File testPom = new File(getBasedir(), "target/test-classes/unit/unpack-dependencies-test/plugin-config.xml"); mojo = (UnpackDependenciesMojo) lookupMojo("unpack-dependencies", testPom); mojo.outputDirectory = new File(this.testDir, "outputDirectory"); @@ -57,7 +65,6 @@ protected void setUp() throws Exception { assertNotNull(mojo); assertNotNull(mojo.getProject()); - MavenProject project = mojo.getProject(); Set artifacts = this.stubFactory.getScopedArtifacts(); Set directArtifacts = this.stubFactory.getReleaseAndSnapshotArtifacts(); diff --git a/src/test/java/org/apache/maven/plugins/dependency/resolvers/TestResolveMojo.java b/src/test/java/org/apache/maven/plugins/dependency/resolvers/TestResolveMojo.java index 8d74d2345..9c1d6a56f 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/resolvers/TestResolveMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/resolvers/TestResolveMojo.java @@ -22,8 +22,10 @@ import java.util.Set; import org.apache.maven.artifact.Artifact; +import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.testing.SilentLog; import org.apache.maven.plugins.dependency.AbstractDependencyMojoTestCase; +import org.apache.maven.plugins.dependency.testUtils.stubs.DependencyProjectStub; import org.apache.maven.plugins.dependency.utils.DependencyStatusSets; import org.apache.maven.project.MavenProject; @@ -32,6 +34,12 @@ public class TestResolveMojo extends AbstractDependencyMojoTestCase { protected void setUp() throws Exception { // required for mojo lookups to work super.setUp("markers", false); + + MavenProject project = new DependencyProjectStub(); + getContainer().addComponent(project, MavenProject.class.getName()); + + MavenSession session = newMavenSession(project); + getContainer().addComponent(session, MavenSession.class.getName()); } /** diff --git a/src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo.java b/src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo.java index aef1c69db..79e734825 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo.java @@ -26,6 +26,9 @@ import java.util.Set; import org.apache.maven.artifact.Artifact; +import org.apache.maven.execution.MavenSession; +import org.apache.maven.plugin.LegacySupport; +import org.apache.maven.plugin.testing.stubs.MavenProjectStub; import org.apache.maven.plugins.dependency.AbstractDependencyMojoTestCase; import org.apache.maven.project.MavenProject; import org.apache.maven.shared.dependency.graph.DependencyNode; @@ -46,16 +49,23 @@ public class TestTreeMojo extends AbstractDependencyMojoTestCase { protected void setUp() throws Exception { // required for mojo lookups to work super.setUp("tree", false); - } - // tests ------------------------------------------------------------------ + MavenProject project = new MavenProjectStub(); + getContainer().addComponent(project, MavenProject.class.getName()); + + MavenSession session = newMavenSession(project); + getContainer().addComponent(session, MavenSession.class.getName()); - public void testVoid() { - // TODO: tests disabled during MDEP-339 work, to be reactivated + LegacySupport legacySupport = lookup(LegacySupport.class); + legacySupport.setSession(session); + installLocalRepository(legacySupport); } + // tests ------------------------------------------------------------------ + /** * Tests the proper discovery and configuration of the mojo. + * // TODO: tests disabled during MDEP-339 work, to be reactivated * * @throws Exception in case of an error. */ @@ -89,7 +99,7 @@ public void _testTreeTestEnvironment() throws Exception { * * @throws Exception in case of an error. */ - public void _testTreeDotSerializing() throws Exception { + public void testTreeDotSerializing() throws Exception { List contents = runTreeMojo("tree1.dot", "dot"); assertTrue(findString(contents, "digraph \"testGroupId:project:jar:1.0:compile\" {")); assertTrue(findString( @@ -104,7 +114,7 @@ public void _testTreeDotSerializing() throws Exception { * * @throws Exception in case of an error. */ - public void _testTreeGraphMLSerializing() throws Exception { + public void testTreeGraphMLSerializing() throws Exception { List contents = runTreeMojo("tree1.graphml", "graphml"); assertTrue(findString(contents, "")); @@ -120,7 +130,7 @@ public void _testTreeGraphMLSerializing() throws Exception { * * @throws Exception in case of an error. */ - public void _testTreeTGFSerializing() throws Exception { + public void testTreeTGFSerializing() throws Exception { List contents = runTreeMojo("tree1.tgf", "tgf"); assertTrue(findString(contents, "testGroupId:project:jar:1.0:compile")); assertTrue(findString(contents, "testGroupId:snapshot:jar:2.0-SNAPSHOT:compile")); diff --git a/src/test/resources/unit/build-classpath-test/plugin-config.xml b/src/test/resources/unit/build-classpath-test/plugin-config.xml index df85345b4..1a046caeb 100644 --- a/src/test/resources/unit/build-classpath-test/plugin-config.xml +++ b/src/test/resources/unit/build-classpath-test/plugin-config.xml @@ -23,7 +23,6 @@ maven-dependency-plugin - diff --git a/src/test/resources/unit/collect-test/plugin-config.xml b/src/test/resources/unit/collect-test/plugin-config.xml index 664fb38e9..3d1210a58 100644 --- a/src/test/resources/unit/collect-test/plugin-config.xml +++ b/src/test/resources/unit/collect-test/plugin-config.xml @@ -23,7 +23,6 @@ maven-dependency-plugin - diff --git a/src/test/resources/unit/copy-dependencies-test/plugin-config.xml b/src/test/resources/unit/copy-dependencies-test/plugin-config.xml index 726aa2109..d2eb2b561 100644 --- a/src/test/resources/unit/copy-dependencies-test/plugin-config.xml +++ b/src/test/resources/unit/copy-dependencies-test/plugin-config.xml @@ -23,7 +23,6 @@ maven-dependency-plugin - true diff --git a/src/test/resources/unit/copy-test/plugin-config.xml b/src/test/resources/unit/copy-test/plugin-config.xml index df85345b4..1a046caeb 100644 --- a/src/test/resources/unit/copy-test/plugin-config.xml +++ b/src/test/resources/unit/copy-test/plugin-config.xml @@ -23,7 +23,6 @@ maven-dependency-plugin - diff --git a/src/test/resources/unit/duplicate-dependencies/plugin-config.xml b/src/test/resources/unit/duplicate-dependencies/plugin-config.xml index acbbe93ca..0cd446369 100644 --- a/src/test/resources/unit/duplicate-dependencies/plugin-config.xml +++ b/src/test/resources/unit/duplicate-dependencies/plugin-config.xml @@ -55,7 +55,6 @@ maven-dependency-plugin - diff --git a/src/test/resources/unit/duplicate-dependencies/plugin-config2.xml b/src/test/resources/unit/duplicate-dependencies/plugin-config2.xml index 282080592..908226dbd 100644 --- a/src/test/resources/unit/duplicate-dependencies/plugin-config2.xml +++ b/src/test/resources/unit/duplicate-dependencies/plugin-config2.xml @@ -67,7 +67,6 @@ maven-dependency-plugin - diff --git a/src/test/resources/unit/properties-test/plugin-config.xml b/src/test/resources/unit/properties-test/plugin-config.xml index 60ef26f5d..e7edfc507 100644 --- a/src/test/resources/unit/properties-test/plugin-config.xml +++ b/src/test/resources/unit/properties-test/plugin-config.xml @@ -23,7 +23,6 @@ maven-dependency-plugin - diff --git a/src/test/resources/unit/resolve-test/plugin-config.xml b/src/test/resources/unit/resolve-test/plugin-config.xml index df85345b4..1a046caeb 100644 --- a/src/test/resources/unit/resolve-test/plugin-config.xml +++ b/src/test/resources/unit/resolve-test/plugin-config.xml @@ -23,7 +23,6 @@ maven-dependency-plugin - diff --git a/src/test/resources/unit/skip-test/plugin-analyze-report-config.xml b/src/test/resources/unit/skip-test/plugin-analyze-report-config.xml index 33d7c2f8d..ac324dd00 100644 --- a/src/test/resources/unit/skip-test/plugin-analyze-report-config.xml +++ b/src/test/resources/unit/skip-test/plugin-analyze-report-config.xml @@ -36,7 +36,6 @@ maven-dependency-plugin - true target/unit-tests/skip-test diff --git a/src/test/resources/unit/skip-test/plugin-config.xml b/src/test/resources/unit/skip-test/plugin-config.xml index 3c6076504..0006e2729 100644 --- a/src/test/resources/unit/skip-test/plugin-config.xml +++ b/src/test/resources/unit/skip-test/plugin-config.xml @@ -36,7 +36,6 @@ maven-dependency-plugin - true diff --git a/src/test/resources/unit/skip-test/plugin-purge-local-repository-config.xml b/src/test/resources/unit/skip-test/plugin-purge-local-repository-config.xml index 707b9dfa0..0006e2729 100644 --- a/src/test/resources/unit/skip-test/plugin-purge-local-repository-config.xml +++ b/src/test/resources/unit/skip-test/plugin-purge-local-repository-config.xml @@ -36,10 +36,6 @@ maven-dependency-plugin - - - - true diff --git a/src/test/resources/unit/tree-test/plugin-config.xml b/src/test/resources/unit/tree-test/plugin-config.xml index 5d61ca75a..511d1147c 100644 --- a/src/test/resources/unit/tree-test/plugin-config.xml +++ b/src/test/resources/unit/tree-test/plugin-config.xml @@ -23,7 +23,6 @@ maven-dependency-plugin - diff --git a/src/test/resources/unit/unpack-dependencies-test/plugin-config.xml b/src/test/resources/unit/unpack-dependencies-test/plugin-config.xml index d44f38a36..30d2867c3 100644 --- a/src/test/resources/unit/unpack-dependencies-test/plugin-config.xml +++ b/src/test/resources/unit/unpack-dependencies-test/plugin-config.xml @@ -23,7 +23,6 @@ maven-dependency-plugin - true diff --git a/src/test/resources/unit/unpack-dependencies-test/test.txt b/src/test/resources/unit/unpack-dependencies-test/test.txt index 4ee425451..d2eb2b561 100644 --- a/src/test/resources/unit/unpack-dependencies-test/test.txt +++ b/src/test/resources/unit/unpack-dependencies-test/test.txt @@ -23,7 +23,6 @@ maven-dependency-plugin - true diff --git a/src/test/resources/unit/unpack-test/plugin-config.xml b/src/test/resources/unit/unpack-test/plugin-config.xml index df85345b4..1a046caeb 100644 --- a/src/test/resources/unit/unpack-test/plugin-config.xml +++ b/src/test/resources/unit/unpack-test/plugin-config.xml @@ -23,7 +23,6 @@ maven-dependency-plugin -