From 42747bcc8bd19f9160bcf44001209d068f26d448 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Thu, 5 Mar 2026 23:08:51 +0100 Subject: [PATCH 1/5] Migration to JUnit 5 - avoid using AbstractMojoTestCase --- pom.xml | 5 +- .../plugins/install/InstallFileMojoTest.java | 97 +++++---- .../plugins/install/InstallMojoTest.java | 191 +++++++++++------- .../unit/basic-install-test/plugin-config.xml | 8 - 4 files changed, 180 insertions(+), 121 deletions(-) diff --git a/pom.xml b/pom.xml index 6f585248..2ff7f665 100644 --- a/pom.xml +++ b/pom.xml @@ -156,9 +156,8 @@ - junit - junit - 4.13.2 + org.junit.jupiter + junit-jupiter-api test diff --git a/src/test/java/org/apache/maven/plugins/install/InstallFileMojoTest.java b/src/test/java/org/apache/maven/plugins/install/InstallFileMojoTest.java index 3ec2fe3b..826c063f 100644 --- a/src/test/java/org/apache/maven/plugins/install/InstallFileMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/install/InstallFileMojoTest.java @@ -24,7 +24,6 @@ import org.apache.maven.execution.MavenSession; import org.apache.maven.model.Model; import org.apache.maven.model.io.xpp3.MavenXpp3Reader; -import org.apache.maven.plugin.testing.AbstractMojoTestCase; import org.apache.maven.project.DefaultProjectBuildingRequest; import org.apache.maven.project.ProjectBuildingRequest; import org.codehaus.plexus.util.FileUtils; @@ -37,13 +36,19 @@ import org.eclipse.aether.repository.LocalRepository; import org.eclipse.aether.repository.NoLocalRepositoryManagerException; +import static org.apache.maven.api.plugin.testing.MojoExtension.getBasedir; +import static org.apache.maven.api.plugin.testing.MojoExtension.getVariableValueFromObject; +import static org.apache.maven.api.plugin.testing.MojoExtension.setVariableValueToObject; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; /** * @author Allan Ramirez */ -public class InstallFileMojoTest extends AbstractMojoTestCase { +public class InstallFileMojoTest { private String groupId; private String artifactId; @@ -61,19 +66,19 @@ public class InstallFileMojoTest extends AbstractMojoTestCase { private static final String SPECIFIC_LOCAL_REPO = "target/specific-local-repo/"; public void setUp() throws Exception { - super.setUp(); + // super.setUp(); FileUtils.deleteDirectory(new File(getBasedir() + "/" + LOCAL_REPO)); FileUtils.deleteDirectory(new File(getBasedir() + "/" + SPECIFIC_LOCAL_REPO)); } - public void testInstallFileFromLocalRepositoryToLocalRepositoryPath() throws Exception { + public void testInstallFileFromLocalRepositoryToLocalRepositoryPath(InstallFileMojo mojo) throws Exception { File localRepository = new File(getBasedir(), "target/test-classes/unit/install-file-from-local-repository-test/target"); - File testPom = new File(localRepository.getParentFile(), "plugin-config.xml"); + // File testPom = new File(localRepository.getParentFile(), "plugin-config.xml"); - InstallFileMojo mojo = (InstallFileMojo) lookupMojo("install-file", testPom); + // InstallFileMojo mojo = (InstallFileMojo) lookupMojo("install-file", testPom); assertNotNull(mojo); @@ -95,16 +100,17 @@ public void testInstallFileFromLocalRepositoryToLocalRepositoryPath() throws Exc assertTrue(installedArtifact.exists()); assertEquals( - FileUtils.getFiles(new File(SPECIFIC_LOCAL_REPO), null, null).toString(), 5, - FileUtils.getFiles(new File(SPECIFIC_LOCAL_REPO), null, null).size()); + FileUtils.getFiles(new File(SPECIFIC_LOCAL_REPO), null, null).size(), + FileUtils.getFiles(new File(SPECIFIC_LOCAL_REPO), null, null).toString()); } - public void testInstallFileWithLocalRepositoryPath() throws Exception { - File testPom = - new File(getBasedir(), "target/test-classes/unit/install-file-with-checksum/" + "plugin-config.xml"); + public void testInstallFileWithLocalRepositoryPath(InstallFileMojo mojo) throws Exception { + // File testPom = + // new File(getBasedir(), "target/test-classes/unit/install-file-with-checksum/" + + // "plugin-config.xml"); - InstallFileMojo mojo = (InstallFileMojo) lookupMojo("install-file", testPom); + // InstallFileMojo mojo = (InstallFileMojo) lookupMojo("install-file", testPom); assertNotNull(mojo); @@ -126,25 +132,27 @@ public void testInstallFileWithLocalRepositoryPath() throws Exception { assertTrue(installedArtifact.exists()); assertEquals( - FileUtils.getFiles(new File(SPECIFIC_LOCAL_REPO), null, null).toString(), 5, - FileUtils.getFiles(new File(SPECIFIC_LOCAL_REPO), null, null).size()); + FileUtils.getFiles(new File(SPECIFIC_LOCAL_REPO), null, null).size(), + FileUtils.getFiles(new File(SPECIFIC_LOCAL_REPO), null, null).toString()); } - public void testInstallFileTestEnvironment() throws Exception { - File testPom = new File(getBasedir(), "target/test-classes/unit/install-file-basic-test/plugin-config.xml"); + public void testInstallFileTestEnvironment(InstallFileMojo mojo) throws Exception { + // File testPom = new File(getBasedir(), + // "target/test-classes/unit/install-file-basic-test/plugin-config.xml"); - InstallFileMojo mojo = (InstallFileMojo) lookupMojo("install-file", testPom); + // InstallFileMojo mojo = (InstallFileMojo) lookupMojo("install-file", testPom); setVariableValueToObject(mojo, "session", createMavenSession(LOCAL_REPO)); assertNotNull(mojo); } - public void testBasicInstallFile() throws Exception { - File testPom = new File(getBasedir(), "target/test-classes/unit/install-file-basic-test/plugin-config.xml"); + public void testBasicInstallFile(InstallFileMojo mojo) throws Exception { + // File testPom = new File(getBasedir(), + // "target/test-classes/unit/install-file-basic-test/plugin-config.xml"); - InstallFileMojo mojo = (InstallFileMojo) lookupMojo("install-file", testPom); + // InstallFileMojo mojo = (InstallFileMojo) lookupMojo("install-file", testPom); assertNotNull(mojo); @@ -164,11 +172,12 @@ public void testBasicInstallFile() throws Exception { assertEquals(5, FileUtils.getFiles(new File(LOCAL_REPO), null, null).size()); } - public void testInstallFileWithClassifier() throws Exception { - File testPom = - new File(getBasedir(), "target/test-classes/unit/install-file-with-classifier/plugin-config.xml"); + public void testInstallFileWithClassifier(InstallFileMojo mojo) throws Exception { + // File testPom = + // new File(getBasedir(), + // "target/test-classes/unit/install-file-with-classifier/plugin-config.xml"); - InstallFileMojo mojo = (InstallFileMojo) lookupMojo("install-file", testPom); + // InstallFileMojo mojo = (InstallFileMojo) lookupMojo("install-file", testPom); assertNotNull(mojo); @@ -190,11 +199,12 @@ public void testInstallFileWithClassifier() throws Exception { assertEquals(5, FileUtils.getFiles(new File(LOCAL_REPO), null, null).size()); } - public void testInstallFileWithGeneratePom() throws Exception { - File testPom = - new File(getBasedir(), "target/test-classes/unit/install-file-test-generatePom/plugin-config.xml"); + public void testInstallFileWithGeneratePom(InstallFileMojo mojo) throws Exception { + // File testPom = + // new File(getBasedir(), + // "target/test-classes/unit/install-file-test-generatePom/plugin-config.xml"); - InstallFileMojo mojo = (InstallFileMojo) lookupMojo("install-file", testPom); + // InstallFileMojo mojo = (InstallFileMojo) lookupMojo("install-file", testPom); assertNotNull(mojo); @@ -233,11 +243,12 @@ public void testInstallFileWithGeneratePom() throws Exception { assertEquals(5, FileUtils.getFiles(new File(LOCAL_REPO), null, null).size()); } - public void testInstallFileWithPomFile() throws Exception { - File testPom = - new File(getBasedir(), "target/test-classes/unit/install-file-with-pomFile-test/plugin-config.xml"); + public void testInstallFileWithPomFile(InstallFileMojo mojo) throws Exception { + // File testPom = + // new File(getBasedir(), + // "target/test-classes/unit/install-file-with-pomFile-test/plugin-config.xml"); - InstallFileMojo mojo = (InstallFileMojo) lookupMojo("install-file", testPom); + // InstallFileMojo mojo = (InstallFileMojo) lookupMojo("install-file", testPom); assertNotNull(mojo); @@ -268,11 +279,12 @@ public void testInstallFileWithPomFile() throws Exception { assertEquals(5, FileUtils.getFiles(new File(LOCAL_REPO), null, null).size()); } - public void testInstallFileWithPomAsPackaging() throws Exception { - File testPom = new File( - getBasedir(), "target/test-classes/unit/install-file-with-pom-as-packaging/" + "plugin-config.xml"); + public void testInstallFileWithPomAsPackaging(InstallFileMojo mojo) throws Exception { + // File testPom = new File( + // getBasedir(), "target/test-classes/unit/install-file-with-pom-as-packaging/" + + // "plugin-config.xml"); - InstallFileMojo mojo = (InstallFileMojo) lookupMojo("install-file", testPom); + // InstallFileMojo mojo = (InstallFileMojo) lookupMojo("install-file", testPom); assertNotNull(mojo); @@ -296,11 +308,12 @@ public void testInstallFileWithPomAsPackaging() throws Exception { assertEquals(4, FileUtils.getFiles(new File(LOCAL_REPO), null, null).size()); } - public void testInstallFile() throws Exception { - File testPom = - new File(getBasedir(), "target/test-classes/unit/install-file-with-checksum/" + "plugin-config.xml"); + public void testInstallFile(InstallFileMojo mojo) throws Exception { + // File testPom = + // new File(getBasedir(), "target/test-classes/unit/install-file-with-checksum/" + + // "plugin-config.xml"); - InstallFileMojo mojo = (InstallFileMojo) lookupMojo("install-file", testPom); + // InstallFileMojo mojo = (InstallFileMojo) lookupMojo("install-file", testPom); assertNotNull(mojo); @@ -318,9 +331,9 @@ public void testInstallFile() throws Exception { assertTrue(installedArtifact.exists()); assertEquals( - FileUtils.getFiles(new File(LOCAL_REPO), null, null).toString(), 5, - FileUtils.getFiles(new File(LOCAL_REPO), null, null).size()); + FileUtils.getFiles(new File(LOCAL_REPO), null, null).size(), + FileUtils.getFiles(new File(LOCAL_REPO), null, null).toString()); } private void assignValuesForParameter(Object obj) throws Exception { diff --git a/src/test/java/org/apache/maven/plugins/install/InstallMojoTest.java b/src/test/java/org/apache/maven/plugins/install/InstallMojoTest.java index d5809672..d271b8fb 100644 --- a/src/test/java/org/apache/maven/plugins/install/InstallMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/install/InstallMojoTest.java @@ -18,19 +18,24 @@ */ package org.apache.maven.plugins.install; +import javax.inject.Inject; + import java.io.File; import java.util.Collections; import java.util.List; import java.util.concurrent.ConcurrentHashMap; +import org.apache.maven.api.plugin.testing.Basedir; +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.model.Build; import org.apache.maven.model.Plugin; -import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.model.PluginExecution; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.descriptor.PluginDescriptor; -import org.apache.maven.plugin.testing.AbstractMojoTestCase; import org.apache.maven.plugins.install.stubs.AttachedArtifactStub0; import org.apache.maven.plugins.install.stubs.InstallArtifactStub; import org.apache.maven.project.DefaultProjectBuildingRequest; @@ -45,7 +50,18 @@ import org.eclipse.aether.internal.impl.EnhancedLocalRepositoryManagerFactory; import org.eclipse.aether.repository.LocalRepository; import org.eclipse.aether.repository.NoLocalRepositoryManagerException; - +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.apache.maven.api.plugin.testing.MojoExtension.getBasedir; +import static org.apache.maven.api.plugin.testing.MojoExtension.getVariableValueFromObject; +import static org.apache.maven.api.plugin.testing.MojoExtension.setVariableValueToObject; +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.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -53,30 +69,56 @@ /** * @author Allan Ramirez */ -public class InstallMojoTest extends AbstractMojoTestCase { +@MojoTest(realRepositorySession = true) +public class InstallMojoTest { + + @Inject + private MavenProject mavenProject; + + @Inject + private MavenSession mavenSession; InstallArtifactStub artifact; private static final String LOCAL_REPO = "target/local-repo/"; + @BeforeEach public void setUp() throws Exception { - super.setUp(); + // super.setUp(); FileUtils.deleteDirectory(new File(getBasedir() + "/" + LOCAL_REPO)); + + mavenProject.setGroupId("org.apache.maven.test"); + mavenProject.setArtifactId("maven-install-test"); + mavenProject.setVersion("1.0-SNAPSHOT"); + + Plugin plugin = new Plugin(); + plugin.setArtifactId("maven-install-plugin"); + PluginExecution execution = new PluginExecution(); + execution.setGoals(Collections.singletonList("install")); + plugin.setExecutions(Collections.singletonList(execution)); + mavenProject.getBuild().addPlugin(plugin); + + when(mavenSession.getProjects()).thenReturn(Collections.singletonList(mavenProject)); } - public void testInstallTestEnvironment() throws Exception { - File testPom = new File(getBasedir(), "target/test-classes/unit/basic-install-test/plugin-config.xml"); + @Test + @InjectMojo(goal = "install") + @Basedir("/unit/basic-install-test") + public void testInstallTestEnvironment(InstallMojo mojo) throws Exception { + // File testPom = new File(getBasedir(), + // "target/test-classes/unit/basic-install-test/plugin-config.xml"); - AbstractMojo mojo = (AbstractMojo) lookupMojo("install", testPom); + // AbstractMojo mojo = (AbstractMojo) lookupMojo("install", testPom); assertNotNull(mojo); } - public void testBasicInstall() throws Exception { - File testPom = new File(getBasedir(), "target/test-classes/unit/basic-install-test/plugin-config.xml"); + public void testBasicInstall(InstallMojo mojo) throws Exception { + // File testPom = new File(getBasedir(), + // "target/test-classes/unit/basic-install-test/plugin-config.xml"); - AbstractMojo mojo = (AbstractMojo) lookupMojo("install", testPom); + // AbstractMojo mojo = (AbstractMojo) lookupMojo("install", testPom); assertNotNull(mojo); @@ -112,12 +154,12 @@ public void testBasicInstall() throws Exception { assertEquals(5, FileUtils.getFiles(new File(LOCAL_REPO), null, null).size()); } - public void testBasicInstallWithAttachedArtifacts() throws Exception { - File testPom = new File( - getBasedir(), - "target/test-classes/unit/basic-install-test-with-attached-artifacts/" + "plugin-config.xml"); + public void testBasicInstallWithAttachedArtifacts(InstallMojo mojo) throws Exception { + // File testPom = new File( + // getBasedir(), + // "target/test-classes/unit/basic-install-test-with-attached-artifacts/" + "plugin-config.xml"); - AbstractMojo mojo = (AbstractMojo) lookupMojo("install", testPom); + // AbstractMojo mojo = (AbstractMojo) lookupMojo("install", testPom); assertNotNull(mojo); @@ -149,18 +191,18 @@ public void testBasicInstallWithAttachedArtifacts() throws Exception { + "/" + attachedArtifact.getVersion() + "/" + attachedArtifact.getArtifactId() + "-" + attachedArtifact.getVersion() + "." + packaging); - assertTrue(installedArtifact.getPath() + " does not exist", installedArtifact.exists()); + assertTrue(installedArtifact.exists(), installedArtifact.getPath() + " does not exist"); } assertEquals(13, FileUtils.getFiles(new File(LOCAL_REPO), null, null).size()); } - public void testNonPomInstallWithAttachedArtifactsOnly() throws Exception { - File testPom = new File( - getBasedir(), - "target/test-classes/unit/basic-install-test-with-attached-artifacts/" + "plugin-config.xml"); + public void testNonPomInstallWithAttachedArtifactsOnly(InstallMojo mojo) throws Exception { + // File testPom = new File( + // getBasedir(), + // "target/test-classes/unit/basic-install-test-with-attached-artifacts/" + "plugin-config.xml"); - AbstractMojo mojo = (AbstractMojo) lookupMojo("install", testPom); + // AbstractMojo mojo = (AbstractMojo) lookupMojo("install", testPom); assertNotNull(mojo); @@ -187,10 +229,11 @@ public void testNonPomInstallWithAttachedArtifactsOnly() throws Exception { } } - public void testUpdateReleaseParamSetToTrue() throws Exception { - File testPom = new File(getBasedir(), "target/test-classes/unit/configured-install-test/plugin-config.xml"); + public void testUpdateReleaseParamSetToTrue(InstallMojo mojo) throws Exception { + // File testPom = new File(getBasedir(), + // "target/test-classes/unit/configured-install-test/plugin-config.xml"); - AbstractMojo mojo = (AbstractMojo) lookupMojo("install", testPom); + // AbstractMojo mojo = (AbstractMojo) lookupMojo("install", testPom); assertNotNull(mojo); @@ -218,10 +261,11 @@ public void testUpdateReleaseParamSetToTrue() throws Exception { assertEquals(5, FileUtils.getFiles(new File(LOCAL_REPO), null, null).size()); } - public void testInstallIfArtifactFileIsNull() throws Exception { - File testPom = new File(getBasedir(), "target/test-classes/unit/basic-install-test/plugin-config.xml"); + public void testInstallIfArtifactFileIsNull(InstallMojo mojo) throws Exception { + // File testPom = new File(getBasedir(), + // "target/test-classes/unit/basic-install-test/plugin-config.xml"); - AbstractMojo mojo = (AbstractMojo) lookupMojo("install", testPom); + // AbstractMojo mojo = (AbstractMojo) lookupMojo("install", testPom); assertNotNull(mojo); @@ -253,10 +297,11 @@ public void testInstallIfArtifactFileIsNull() throws Exception { assertFalse(new File(LOCAL_REPO).exists()); } - public void testInstallIfProjectFileIsNull() throws Exception { - File testPom = new File(getBasedir(), "target/test-classes/unit/basic-install-test/plugin-config.xml"); + public void testInstallIfProjectFileIsNull(InstallMojo mojo) throws Exception { + // File testPom = new File(getBasedir(), + // "target/test-classes/unit/basic-install-test/plugin-config.xml"); - AbstractMojo mojo = (AbstractMojo) lookupMojo("install", testPom); + // AbstractMojo mojo = (AbstractMojo) lookupMojo("install", testPom); assertNotNull(mojo); @@ -280,11 +325,12 @@ public void testInstallIfProjectFileIsNull() throws Exception { } } - public void testInstallIfPackagingIsPom() throws Exception { - File testPom = new File( - getBasedir(), "target/test-classes/unit/basic-install-test-packaging-pom/" + "plugin-config.xml"); + public void testInstallIfPackagingIsPom(InstallMojo mojo) throws Exception { + // File testPom = new File( + // getBasedir(), "target/test-classes/unit/basic-install-test-packaging-pom/" + + // "plugin-config.xml"); - AbstractMojo mojo = (AbstractMojo) lookupMojo("install", testPom); + // AbstractMojo mojo = (AbstractMojo) lookupMojo("install", testPom); assertNotNull(mojo); @@ -317,11 +363,12 @@ public void testInstallIfPackagingIsPom() throws Exception { assertEquals(4, FileUtils.getFiles(new File(LOCAL_REPO), null, null).size()); } - public void testInstallIfPackagingIsBom() throws Exception { - File testPom = new File( - getBasedir(), "target/test-classes/unit/basic-install-test-packaging-bom/" + "plugin-config.xml"); + public void testInstallIfPackagingIsBom(InstallMojo mojo) throws Exception { + // File testPom = new File( + // getBasedir(), "target/test-classes/unit/basic-install-test-packaging-bom/" + + // "plugin-config.xml"); - AbstractMojo mojo = (AbstractMojo) lookupMojo("install", testPom); + // AbstractMojo mojo = (AbstractMojo) lookupMojo("install", testPom); assertNotNull(mojo); @@ -354,10 +401,11 @@ public void testInstallIfPackagingIsBom() throws Exception { assertEquals(4, FileUtils.getFiles(new File(LOCAL_REPO), null, null).size()); } - public void testBasicInstallAndCreate() throws Exception { - File testPom = new File(getBasedir(), "target/test-classes/unit/basic-install-checksum/plugin-config.xml"); + public void testBasicInstallAndCreate(InstallMojo mojo) throws Exception { + // File testPom = new File(getBasedir(), + // "target/test-classes/unit/basic-install-checksum/plugin-config.xml"); - AbstractMojo mojo = (AbstractMojo) lookupMojo("install", testPom); + // AbstractMojo mojo = (AbstractMojo) lookupMojo("install", testPom); assertNotNull(mojo); @@ -401,45 +449,52 @@ public void testBasicInstallAndCreate() throws Exception { assertEquals(5, FileUtils.getFiles(new File(LOCAL_REPO), null, null).size()); } - public void testSkip() throws Exception { - File testPom = new File(getBasedir(), "target/test-classes/unit/basic-install-test/plugin-config.xml"); + @Test + @InjectMojo(goal = "install") + @MojoParameter(name = "skip", value = "true") + @Basedir("/unit/basic-install-test") + public void testSkip(InstallMojo mojo) throws Exception { + mojo.setPluginContext(new ConcurrentHashMap<>()); + // File testPom = new File(getBasedir(), + // "target/test-classes/unit/basic-install-test/plugin-config.xml"); - InstallMojo mojo = (InstallMojo) lookupMojo("install", testPom); + // InstallMojo mojo = (InstallMojo) lookupMojo("install", testPom); assertNotNull(mojo); - File file = new File( - getBasedir(), - "target/test-classes/unit/basic-install-test/target/" + "maven-install-test-1.0-SNAPSHOT.jar"); + // File file = new File( + // getBasedir(), + // "target/test-classes/unit/basic-install-test/target/" + + // "maven-install-test-1.0-SNAPSHOT.jar"); - MavenProject project = (MavenProject) getVariableValueFromObject(mojo, "project"); - updateMavenProject(project); + // MavenProject project = (MavenProject) getVariableValueFromObject(mojo, "project"); + // updateMavenProject(project); - MavenSession session = createMavenSession(); - session.setProjects(Collections.singletonList(project)); - setVariableValueToObject(mojo, "session", session); - setVariableValueToObject(mojo, "pluginContext", new ConcurrentHashMap<>()); - setVariableValueToObject(mojo, "pluginDescriptor", new PluginDescriptor()); - setVariableValueToObject(mojo, "skip", Boolean.TRUE); + // MavenSession session = createMavenSession(); + // session.setProjects(Collections.singletonList(project)); + // setVariableValueToObject(mojo, "session", session); + // setVariableValueToObject(mojo, "pluginContext", new ConcurrentHashMap<>()); + // setVariableValueToObject(mojo, "pluginDescriptor", new PluginDescriptor()); + // setVariableValueToObject(mojo, "skip", Boolean.TRUE); - artifact = (InstallArtifactStub) project.getArtifact(); + // artifact = (InstallArtifactStub) project.getArtifact(); - artifact.setFile(file); + // artifact.setFile(file); mojo.execute(); - String groupId = dotToSlashReplacer(artifact.getGroupId()); + // String groupId = dotToSlashReplacer(artifact.getGroupId()); - String packaging = project.getPackaging(); + // String packaging = project.getPackaging(); - File installedArtifact = new File( - getBasedir(), - LOCAL_REPO + groupId + "/" + artifact.getArtifactId() + "/" + artifact.getVersion() + "/" - + artifact.getArtifactId() + "-" + artifact.getVersion() + "." + packaging); - - assertFalse(installedArtifact.exists()); - - assertFalse(new File(LOCAL_REPO).exists()); + // File installedArtifact = new File( + // getBasedir(), + // LOCAL_REPO + groupId + "/" + artifact.getArtifactId() + "/" + artifact.getVersion() + "/" + // + artifact.getArtifactId() + "-" + artifact.getVersion() + "." + packaging); + // + // assertFalse(installedArtifact.exists()); + // + // assertFalse(new File(LOCAL_REPO).exists()); } private String dotToSlashReplacer(String parameter) { diff --git a/src/test/resources/unit/basic-install-test/plugin-config.xml b/src/test/resources/unit/basic-install-test/plugin-config.xml index c95dccc0..b72dc783 100644 --- a/src/test/resources/unit/basic-install-test/plugin-config.xml +++ b/src/test/resources/unit/basic-install-test/plugin-config.xml @@ -21,14 +21,6 @@ under the License. maven-install-plugin - - - ${basedir}/src/test/resources/unit/basic-install-test/plugin-config.xml - jar - - - - From 1efaca5a46c1f6a30d54989d7fc2877412d693af Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Sat, 7 Mar 2026 13:22:15 +0100 Subject: [PATCH 2/5] Migration to JUnit 5 - avoid using AbstractMojoTestCase --- pom.xml | 6 + .../plugins/install/InstallMojoTest.java | 515 +++++------------- 2 files changed, 146 insertions(+), 375 deletions(-) diff --git a/pom.xml b/pom.xml index 2ff7f665..0b8df866 100644 --- a/pom.xml +++ b/pom.xml @@ -179,6 +179,12 @@ 4.11.0 test + + org.mockito + mockito-junit-jupiter + 4.11.0 + test + org.slf4j slf4j-nop diff --git a/src/test/java/org/apache/maven/plugins/install/InstallMojoTest.java b/src/test/java/org/apache/maven/plugins/install/InstallMojoTest.java index d271b8fb..557b1f36 100644 --- a/src/test/java/org/apache/maven/plugins/install/InstallMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/install/InstallMojoTest.java @@ -20,77 +20,80 @@ import javax.inject.Inject; -import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.ArrayList; import java.util.Collections; -import java.util.List; -import java.util.concurrent.ConcurrentHashMap; +import java.util.HashMap; -import org.apache.maven.api.plugin.testing.Basedir; +import org.apache.maven.api.di.Provides; 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.artifact.handler.DefaultArtifactHandler; import org.apache.maven.execution.MavenSession; -import org.apache.maven.model.Build; import org.apache.maven.model.Plugin; import org.apache.maven.model.PluginExecution; import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.descriptor.PluginDescriptor; -import org.apache.maven.plugins.install.stubs.AttachedArtifactStub0; -import org.apache.maven.plugins.install.stubs.InstallArtifactStub; -import org.apache.maven.project.DefaultProjectBuildingRequest; import org.apache.maven.project.MavenProject; -import org.apache.maven.project.ProjectBuildingRequest; -import org.codehaus.plexus.util.FileUtils; -import org.eclipse.aether.DefaultRepositorySystemSession; -import org.eclipse.aether.artifact.DefaultArtifact; -import org.eclipse.aether.internal.impl.DefaultLocalPathComposer; -import org.eclipse.aether.internal.impl.DefaultLocalPathPrefixComposerFactory; -import org.eclipse.aether.internal.impl.DefaultTrackingFileManager; -import org.eclipse.aether.internal.impl.EnhancedLocalRepositoryManagerFactory; -import org.eclipse.aether.repository.LocalRepository; -import org.eclipse.aether.repository.NoLocalRepositoryManagerException; +import org.apache.maven.project.MavenProjectHelper; +import org.eclipse.aether.RepositorySystem; +import org.eclipse.aether.artifact.Artifact; +import org.eclipse.aether.installation.InstallRequest; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.io.TempDir; +import org.mockito.ArgumentCaptor; +import org.mockito.Captor; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; -import static org.apache.maven.api.plugin.testing.MojoExtension.getBasedir; -import static org.apache.maven.api.plugin.testing.MojoExtension.getVariableValueFromObject; -import static org.apache.maven.api.plugin.testing.MojoExtension.setVariableValueToObject; 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.assertNull; -import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; +import static org.mockito.Mockito.lenient; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoInteractions; /** * @author Allan Ramirez */ -@MojoTest(realRepositorySession = true) +@ExtendWith(MockitoExtension.class) +@MojoTest public class InstallMojoTest { + @TempDir + private Path tempDir; + @Inject private MavenProject mavenProject; @Inject private MavenSession mavenSession; - InstallArtifactStub artifact; + @Inject + private MavenProjectHelper mavenProjectHelper; - private static final String LOCAL_REPO = "target/local-repo/"; + @Mock + private RepositorySystem repositorySystem; - @BeforeEach - public void setUp() throws Exception { - // super.setUp(); + @Captor + private ArgumentCaptor installRequestCaptor; - FileUtils.deleteDirectory(new File(getBasedir() + "/" + LOCAL_REPO)); + @Provides + @SuppressWarnings("unused") + private RepositorySystem repositorySystemProvides() { + return repositorySystem; + } + @BeforeEach + public void setUp() throws Exception { mavenProject.setGroupId("org.apache.maven.test"); mavenProject.setArtifactId("maven-install-test"); mavenProject.setVersion("1.0-SNAPSHOT"); + mavenProject.setPackaging("jar"); Plugin plugin = new Plugin(); plugin.setArtifactId("maven-install-plugin"); @@ -99,123 +102,71 @@ public void setUp() throws Exception { plugin.setExecutions(Collections.singletonList(execution)); mavenProject.getBuild().addPlugin(plugin); - when(mavenSession.getProjects()).thenReturn(Collections.singletonList(mavenProject)); + lenient().when(mavenSession.getProjects()).thenReturn(Collections.singletonList(mavenProject)); } @Test @InjectMojo(goal = "install") - @Basedir("/unit/basic-install-test") - public void testInstallTestEnvironment(InstallMojo mojo) throws Exception { - // File testPom = new File(getBasedir(), - // "target/test-classes/unit/basic-install-test/plugin-config.xml"); - - // AbstractMojo mojo = (AbstractMojo) lookupMojo("install", testPom); - - assertNotNull(mojo); - } - public void testBasicInstall(InstallMojo mojo) throws Exception { - // File testPom = new File(getBasedir(), - // "target/test-classes/unit/basic-install-test/plugin-config.xml"); - - // AbstractMojo mojo = (AbstractMojo) lookupMojo("install", testPom); - - assertNotNull(mojo); - - File file = new File( - getBasedir(), - "target/test-classes/unit/basic-install-test/target/" + "maven-install-test-1.0-SNAPSHOT.jar"); - - MavenProject project = (MavenProject) getVariableValueFromObject(mojo, "project"); - updateMavenProject(project); - - MavenSession session = createMavenSession(); - session.setProjects(Collections.singletonList(project)); - setVariableValueToObject(mojo, "session", session); - setVariableValueToObject(mojo, "pluginContext", new ConcurrentHashMap<>()); - setVariableValueToObject(mojo, "pluginDescriptor", new PluginDescriptor()); - - artifact = (InstallArtifactStub) project.getArtifact(); - - artifact.setFile(file); + mojo.setPluginContext(new HashMap<>()); + setProjectArtifact(mavenProject); mojo.execute(); - String groupId = dotToSlashReplacer(artifact.getGroupId()); - - File installedArtifact = new File( - getBasedir(), - LOCAL_REPO + groupId + "/" + artifact.getArtifactId() + "/" + artifact.getVersion() + "/" - + artifact.getArtifactId() + "-" + artifact.getVersion() + "." - + artifact.getArtifactHandler().getExtension()); + verify(repositorySystem).install(any(), installRequestCaptor.capture()); - assertTrue(installedArtifact.exists()); + InstallRequest installRequest = installRequestCaptor.getValue(); + ArrayList artifacts = new ArrayList<>(installRequest.getArtifacts()); + assertEquals(2, artifacts.size()); - assertEquals(5, FileUtils.getFiles(new File(LOCAL_REPO), null, null).size()); + assertArtifactInstalled(mavenProject, artifacts.get(0), "pom"); + assertArtifactInstalled(mavenProject, artifacts.get(1), "jar"); } + @Test + @InjectMojo(goal = "install") public void testBasicInstallWithAttachedArtifacts(InstallMojo mojo) throws Exception { - // File testPom = new File( - // getBasedir(), - // "target/test-classes/unit/basic-install-test-with-attached-artifacts/" + "plugin-config.xml"); - - // AbstractMojo mojo = (AbstractMojo) lookupMojo("install", testPom); - - assertNotNull(mojo); - - MavenProject project = (MavenProject) getVariableValueFromObject(mojo, "project"); - updateMavenProject(project); - - MavenSession session = createMavenSession(); - session.setProjects(Collections.singletonList(project)); - setVariableValueToObject(mojo, "session", session); - setVariableValueToObject(mojo, "pluginContext", new ConcurrentHashMap<>()); - setVariableValueToObject(mojo, "pluginDescriptor", new PluginDescriptor()); - - List attachedArtifacts = project.getAttachedArtifacts(); + mojo.setPluginContext(new HashMap<>()); + setProjectArtifact(mavenProject); + + mavenProjectHelper.attachArtifact( + mavenProject, + "jar", + "next1", + Files.createTempFile(tempDir, "test-artifact1", "jar").toFile()); + mavenProjectHelper.attachArtifact( + mavenProject, + "jar", + "next2", + Files.createTempFile(tempDir, "test-artifact2", "jar").toFile()); mojo.execute(); - String packaging = project.getPackaging(); - - String groupId; + verify(repositorySystem).install(any(), installRequestCaptor.capture()); - for (Object attachedArtifact1 : attachedArtifacts) { - AttachedArtifactStub0 attachedArtifact = (AttachedArtifactStub0) attachedArtifact1; + InstallRequest installRequest = installRequestCaptor.getValue(); + ArrayList artifacts = new ArrayList<>(installRequest.getArtifacts()); - groupId = dotToSlashReplacer(attachedArtifact.getGroupId()); - - File installedArtifact = new File( - getBasedir(), - LOCAL_REPO + groupId + "/" + attachedArtifact.getArtifactId() - + "/" + attachedArtifact.getVersion() + "/" + attachedArtifact.getArtifactId() - + "-" + attachedArtifact.getVersion() + "." + packaging); - - assertTrue(installedArtifact.exists(), installedArtifact.getPath() + " does not exist"); - } - - assertEquals(13, FileUtils.getFiles(new File(LOCAL_REPO), null, null).size()); + assertEquals(4, artifacts.size()); + assertArtifactInstalled(mavenProject, artifacts.get(0), "pom"); + assertArtifactInstalled(mavenProject, artifacts.get(1), "jar"); + assertArtifactInstalled(mavenProject, artifacts.get(2), "next1", "jar"); + assertArtifactInstalled(mavenProject, artifacts.get(3), "next2", "jar"); } + @Test + @InjectMojo(goal = "install") public void testNonPomInstallWithAttachedArtifactsOnly(InstallMojo mojo) throws Exception { - // File testPom = new File( - // getBasedir(), - // "target/test-classes/unit/basic-install-test-with-attached-artifacts/" + "plugin-config.xml"); - - // AbstractMojo mojo = (AbstractMojo) lookupMojo("install", testPom); + mojo.setPluginContext(new HashMap<>()); + setProjectArtifact(mavenProject); - assertNotNull(mojo); + mavenProjectHelper.attachArtifact( + mavenProject, + "jar", + "next1", + Files.createTempFile(tempDir, "test-artifact1", "jar").toFile()); - MavenProject project = (MavenProject) getVariableValueFromObject(mojo, "project"); - updateMavenProject(project); - - setVariableValueToObject(mojo, "pluginContext", new ConcurrentHashMap<>()); - setVariableValueToObject(mojo, "pluginDescriptor", new PluginDescriptor()); - setVariableValueToObject(mojo, "session", createMavenSession()); - - artifact = (InstallArtifactStub) project.getArtifact(); - - artifact.setFile(null); + mavenProject.getArtifact().setFile(null); try { mojo.execute(); @@ -227,62 +178,15 @@ public void testNonPomInstallWithAttachedArtifactsOnly(InstallMojo mojo) throws + "but it has attachments. Change packaging to 'pom'.", e.getMessage()); } + verifyNoInteractions(repositorySystem); } - public void testUpdateReleaseParamSetToTrue(InstallMojo mojo) throws Exception { - // File testPom = new File(getBasedir(), - // "target/test-classes/unit/configured-install-test/plugin-config.xml"); - - // AbstractMojo mojo = (AbstractMojo) lookupMojo("install", testPom); - - assertNotNull(mojo); - - File file = new File( - getBasedir(), - "target/test-classes/unit/configured-install-test/target/" + "maven-install-test-1.0-SNAPSHOT.jar"); - - MavenProject project = (MavenProject) getVariableValueFromObject(mojo, "project"); - updateMavenProject(project); - - MavenSession session = createMavenSession(); - session.setProjects(Collections.singletonList(project)); - setVariableValueToObject(mojo, "session", session); - setVariableValueToObject(mojo, "pluginContext", new ConcurrentHashMap<>()); - setVariableValueToObject(mojo, "pluginDescriptor", new PluginDescriptor()); - - artifact = (InstallArtifactStub) project.getArtifact(); - - artifact.setFile(file); - - mojo.execute(); - - // assertTrue( artifact.isRelease() ); - - assertEquals(5, FileUtils.getFiles(new File(LOCAL_REPO), null, null).size()); - } - + @Test + @InjectMojo(goal = "install") public void testInstallIfArtifactFileIsNull(InstallMojo mojo) throws Exception { - // File testPom = new File(getBasedir(), - // "target/test-classes/unit/basic-install-test/plugin-config.xml"); - - // AbstractMojo mojo = (AbstractMojo) lookupMojo("install", testPom); - - assertNotNull(mojo); - - MavenProject project = (MavenProject) getVariableValueFromObject(mojo, "project"); - updateMavenProject(project); - - MavenSession session = createMavenSession(); - session.setProjects(Collections.singletonList(project)); - setVariableValueToObject(mojo, "session", session); - setVariableValueToObject(mojo, "pluginContext", new ConcurrentHashMap<>()); - setVariableValueToObject(mojo, "pluginDescriptor", new PluginDescriptor()); - - artifact = (InstallArtifactStub) project.getArtifact(); - - artifact.setFile(null); - - assertNull(artifact.getFile()); + mojo.setPluginContext(new HashMap<>()); + setProjectArtifact(mavenProject); + mavenProject.getArtifact().setFile(null); try { mojo.execute(); @@ -293,28 +197,15 @@ public void testInstallIfArtifactFileIsNull(InstallMojo mojo) throws Exception { "The packaging plugin for project maven-install-test did not assign a file to the build artifact", e.getMessage()); } - - assertFalse(new File(LOCAL_REPO).exists()); + verifyNoInteractions(repositorySystem); } + @Test + @InjectMojo(goal = "install") public void testInstallIfProjectFileIsNull(InstallMojo mojo) throws Exception { - // File testPom = new File(getBasedir(), - // "target/test-classes/unit/basic-install-test/plugin-config.xml"); - - // AbstractMojo mojo = (AbstractMojo) lookupMojo("install", testPom); - - assertNotNull(mojo); - - MavenProject project = (MavenProject) getVariableValueFromObject(mojo, "project"); - updateMavenProject(project); - - setVariableValueToObject(mojo, "pluginContext", new ConcurrentHashMap<>()); - setVariableValueToObject(mojo, "pluginDescriptor", new PluginDescriptor()); - setVariableValueToObject(mojo, "session", createMavenSession()); - - project.setFile(null); - - assertNull(project.getFile()); + mojo.setPluginContext(new HashMap<>()); + setProjectArtifact(mavenProject); + mavenProject.setFile(null); try { mojo.execute(); @@ -323,209 +214,83 @@ public void testInstallIfProjectFileIsNull(InstallMojo mojo) throws Exception { // expected, message should include artifactId assertEquals("The POM for project maven-install-test could not be attached", e.getMessage()); } + verifyNoInteractions(repositorySystem); } + @Test + @InjectMojo(goal = "install") public void testInstallIfPackagingIsPom(InstallMojo mojo) throws Exception { - // File testPom = new File( - // getBasedir(), "target/test-classes/unit/basic-install-test-packaging-pom/" + - // "plugin-config.xml"); - - // AbstractMojo mojo = (AbstractMojo) lookupMojo("install", testPom); - - assertNotNull(mojo); - - MavenProject project = (MavenProject) getVariableValueFromObject(mojo, "project"); - updateMavenProject(project); - - MavenSession session = createMavenSession(); - session.setProjects(Collections.singletonList(project)); - setVariableValueToObject(mojo, "session", session); - setVariableValueToObject(mojo, "pluginContext", new ConcurrentHashMap<>()); - setVariableValueToObject(mojo, "pluginDescriptor", new PluginDescriptor()); - - String packaging = project.getPackaging(); - - assertEquals("pom", packaging); - - artifact = (InstallArtifactStub) project.getArtifact(); + mojo.setPluginContext(new HashMap<>()); + mavenProject.setPomFile( + Files.createTempFile(tempDir, "test-artifact", "pom").toFile()); + mavenProject.setPackaging("pom"); mojo.execute(); - String groupId = dotToSlashReplacer(artifact.getGroupId()); - - File installedArtifact = new File( - getBasedir(), - LOCAL_REPO + groupId + "/" + artifact.getArtifactId() + "/" + artifact.getVersion() + "/" - + artifact.getArtifactId() + "-" + artifact.getVersion() + "." + "pom"); + verify(repositorySystem).install(any(), installRequestCaptor.capture()); - assertTrue(installedArtifact.exists()); + InstallRequest installRequest = installRequestCaptor.getValue(); + ArrayList artifacts = new ArrayList<>(installRequest.getArtifacts()); - assertEquals(4, FileUtils.getFiles(new File(LOCAL_REPO), null, null).size()); + assertEquals(1, artifacts.size()); + assertArtifactInstalled(mavenProject, artifacts.get(0), "pom"); } + @Test + @InjectMojo(goal = "install") public void testInstallIfPackagingIsBom(InstallMojo mojo) throws Exception { - // File testPom = new File( - // getBasedir(), "target/test-classes/unit/basic-install-test-packaging-bom/" + - // "plugin-config.xml"); - - // AbstractMojo mojo = (AbstractMojo) lookupMojo("install", testPom); - - assertNotNull(mojo); - - MavenProject project = (MavenProject) getVariableValueFromObject(mojo, "project"); - updateMavenProject(project); - - MavenSession session = createMavenSession(); - session.setProjects(Collections.singletonList(project)); - setVariableValueToObject(mojo, "session", session); - setVariableValueToObject(mojo, "pluginContext", new ConcurrentHashMap<>()); - setVariableValueToObject(mojo, "pluginDescriptor", new PluginDescriptor()); - - String packaging = project.getPackaging(); - - assertEquals("bom", packaging); - - artifact = (InstallArtifactStub) project.getArtifact(); - - mojo.execute(); - - String groupId = dotToSlashReplacer(artifact.getGroupId()); - - File installedArtifact = new File( - getBasedir(), - LOCAL_REPO + groupId + "/" + artifact.getArtifactId() + "/" + artifact.getVersion() + "/" - + artifact.getArtifactId() + "-" + artifact.getVersion() + "." + "pom"); - - assertTrue(installedArtifact.exists()); - - assertEquals(4, FileUtils.getFiles(new File(LOCAL_REPO), null, null).size()); - } - - public void testBasicInstallAndCreate(InstallMojo mojo) throws Exception { - // File testPom = new File(getBasedir(), - // "target/test-classes/unit/basic-install-checksum/plugin-config.xml"); - - // AbstractMojo mojo = (AbstractMojo) lookupMojo("install", testPom); - - assertNotNull(mojo); - - File file = new File(getBasedir(), "target/test-classes/unit/basic-install-checksum/" + "maven-test-jar.jar"); - - MavenProject project = (MavenProject) getVariableValueFromObject(mojo, "project"); - MavenSession mavenSession = createMavenSession(); - updateMavenProject(project); - - MavenSession session = createMavenSession(); - session.setProjects(Collections.singletonList(project)); - setVariableValueToObject(mojo, "session", session); - setVariableValueToObject(mojo, "pluginContext", new ConcurrentHashMap<>()); - setVariableValueToObject(mojo, "pluginDescriptor", new PluginDescriptor()); - - artifact = (InstallArtifactStub) project.getArtifact(); - - artifact.setFile(file); + mojo.setPluginContext(new HashMap<>()); + mavenProject.setPomFile( + Files.createTempFile(tempDir, "test-artifact", "pom").toFile()); + mavenProject.setPackaging("bom"); mojo.execute(); - File pom = new File( - new File(LOCAL_REPO), - mavenSession - .getRepositorySession() - .getLocalRepositoryManager() - .getPathForLocalArtifact(new DefaultArtifact( - artifact.getGroupId(), artifact.getArtifactId(), "pom", artifact.getVersion()))); - - assertTrue(pom.exists()); + verify(repositorySystem).install(any(), installRequestCaptor.capture()); - String groupId = dotToSlashReplacer(artifact.getGroupId()); - String packaging = project.getPackaging(); - String localPath = getBasedir() + "/" + LOCAL_REPO + groupId + "/" + artifact.getArtifactId() + "/" - + artifact.getVersion() + "/" + artifact.getArtifactId() + "-" + artifact.getVersion(); + InstallRequest installRequest = installRequestCaptor.getValue(); + ArrayList artifacts = new ArrayList<>(installRequest.getArtifacts()); - File installedArtifact = new File(localPath + "." + packaging); - - assertTrue(installedArtifact.exists()); - - assertEquals(5, FileUtils.getFiles(new File(LOCAL_REPO), null, null).size()); + assertEquals(1, artifacts.size()); + assertArtifactInstalled(mavenProject, artifacts.get(0), "pom"); } @Test @InjectMojo(goal = "install") @MojoParameter(name = "skip", value = "true") - @Basedir("/unit/basic-install-test") public void testSkip(InstallMojo mojo) throws Exception { - mojo.setPluginContext(new ConcurrentHashMap<>()); - // File testPom = new File(getBasedir(), - // "target/test-classes/unit/basic-install-test/plugin-config.xml"); - - // InstallMojo mojo = (InstallMojo) lookupMojo("install", testPom); - - assertNotNull(mojo); - - // File file = new File( - // getBasedir(), - // "target/test-classes/unit/basic-install-test/target/" + - // "maven-install-test-1.0-SNAPSHOT.jar"); - - // MavenProject project = (MavenProject) getVariableValueFromObject(mojo, "project"); - // updateMavenProject(project); - - // MavenSession session = createMavenSession(); - // session.setProjects(Collections.singletonList(project)); - // setVariableValueToObject(mojo, "session", session); - // setVariableValueToObject(mojo, "pluginContext", new ConcurrentHashMap<>()); - // setVariableValueToObject(mojo, "pluginDescriptor", new PluginDescriptor()); - // setVariableValueToObject(mojo, "skip", Boolean.TRUE); - - // artifact = (InstallArtifactStub) project.getArtifact(); - - // artifact.setFile(file); + mojo.setPluginContext(new HashMap<>()); mojo.execute(); - // String groupId = dotToSlashReplacer(artifact.getGroupId()); - - // String packaging = project.getPackaging(); - - // File installedArtifact = new File( - // getBasedir(), - // LOCAL_REPO + groupId + "/" + artifact.getArtifactId() + "/" + artifact.getVersion() + "/" - // + artifact.getArtifactId() + "-" + artifact.getVersion() + "." + packaging); - // - // assertFalse(installedArtifact.exists()); - // - // assertFalse(new File(LOCAL_REPO).exists()); + verifyNoInteractions(repositorySystem); } - private String dotToSlashReplacer(String parameter) { - return parameter.replace('.', '/'); + private void assertArtifactInstalled( + MavenProject mavenProject, org.eclipse.aether.artifact.Artifact artifact, String type) { + assertEquals(mavenProject.getArtifactId(), artifact.getArtifactId()); + assertEquals(mavenProject.getGroupId(), artifact.getGroupId()); + assertEquals(mavenProject.getVersion(), artifact.getVersion()); + assertEquals(type, artifact.getExtension()); } - private MavenSession createMavenSession() throws NoLocalRepositoryManagerException { - MavenSession session = mock(MavenSession.class); - DefaultRepositorySystemSession repositorySession = new DefaultRepositorySystemSession(); - repositorySession.setLocalRepositoryManager(new EnhancedLocalRepositoryManagerFactory( - new DefaultLocalPathComposer(), - new DefaultTrackingFileManager(), - new DefaultLocalPathPrefixComposerFactory()) - .newInstance(repositorySession, new LocalRepository(LOCAL_REPO))); - ProjectBuildingRequest buildingRequest = new DefaultProjectBuildingRequest(); - buildingRequest.setRepositorySession(repositorySession); - when(session.getProjectBuildingRequest()).thenReturn(buildingRequest); - when(session.getRepositorySession()).thenReturn(repositorySession); - when(session.getPluginContext(any(PluginDescriptor.class), any(MavenProject.class))) - .thenReturn(new ConcurrentHashMap()); - return session; + private void assertArtifactInstalled(MavenProject mavenProject, Artifact artifact, String classifier, String type) { + assertArtifactInstalled(mavenProject, artifact, type); + assertEquals(classifier, artifact.getClassifier()); } - private void updateMavenProject(MavenProject project) { - project.setGroupId(project.getArtifact().getGroupId()); - project.setArtifactId(project.getArtifact().getArtifactId()); - project.setVersion(project.getArtifact().getVersion()); - - Plugin plugin = new Plugin(); - plugin.setArtifactId("maven-install-plugin"); - project.setBuild(new Build()); - project.getBuild().addPlugin(plugin); + private void setProjectArtifact(MavenProject mavenProject) throws IOException { + org.apache.maven.artifact.DefaultArtifact artifact = new org.apache.maven.artifact.DefaultArtifact( + mavenProject.getGroupId(), + mavenProject.getArtifactId(), + mavenProject.getVersion(), + null, + "jar", + null, + new DefaultArtifactHandler("jar")); + artifact.setFile(Files.createTempFile(tempDir, "test-artifact", "jar").toFile()); + mavenProject.setArtifact(artifact); + mavenProject.setPomFile( + Files.createTempFile(tempDir, "test-artifact", "pom").toFile()); } } From a4390f2b222ace08ca96af9edc5616c94bf21045 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Sun, 8 Mar 2026 19:02:42 +0100 Subject: [PATCH 3/5] Migration to JUnit 5 - avoid using AbstractMojoTestCase --- pom.xml | 6 - .../plugins/install/InstallMojoTest.java | 151 +++++++++--------- 2 files changed, 77 insertions(+), 80 deletions(-) diff --git a/pom.xml b/pom.xml index 0b8df866..2ff7f665 100644 --- a/pom.xml +++ b/pom.xml @@ -179,12 +179,6 @@ 4.11.0 test - - org.mockito - mockito-junit-jupiter - 4.11.0 - test - org.slf4j slf4j-nop diff --git a/src/test/java/org/apache/maven/plugins/install/InstallMojoTest.java b/src/test/java/org/apache/maven/plugins/install/InstallMojoTest.java index 557b1f36..cd18e235 100644 --- a/src/test/java/org/apache/maven/plugins/install/InstallMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/install/InstallMojoTest.java @@ -20,17 +20,18 @@ import javax.inject.Inject; +import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; -import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; +import java.util.List; -import org.apache.maven.api.di.Provides; 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.artifact.handler.DefaultArtifactHandler; import org.apache.maven.execution.MavenSession; import org.apache.maven.model.Plugin; @@ -38,31 +39,22 @@ import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.project.MavenProject; import org.apache.maven.project.MavenProjectHelper; -import org.eclipse.aether.RepositorySystem; -import org.eclipse.aether.artifact.Artifact; -import org.eclipse.aether.installation.InstallRequest; +import org.codehaus.plexus.util.FileUtils; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.io.TempDir; -import org.mockito.ArgumentCaptor; -import org.mockito.Captor; -import org.mockito.Mock; -import org.mockito.junit.jupiter.MockitoExtension; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; -import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.lenient; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoInteractions; /** * @author Allan Ramirez */ -@ExtendWith(MockitoExtension.class) -@MojoTest -public class InstallMojoTest { +@MojoTest(realRepositorySession = true) +class InstallMojoTest { @TempDir private Path tempDir; @@ -76,20 +68,10 @@ public class InstallMojoTest { @Inject private MavenProjectHelper mavenProjectHelper; - @Mock - private RepositorySystem repositorySystem; - - @Captor - private ArgumentCaptor installRequestCaptor; - - @Provides - @SuppressWarnings("unused") - private RepositorySystem repositorySystemProvides() { - return repositorySystem; - } + private File localRepo; @BeforeEach - public void setUp() throws Exception { + void setUp() throws Exception { mavenProject.setGroupId("org.apache.maven.test"); mavenProject.setArtifactId("maven-install-test"); mavenProject.setVersion("1.0-SNAPSHOT"); @@ -103,29 +85,36 @@ public void setUp() throws Exception { mavenProject.getBuild().addPlugin(plugin); lenient().when(mavenSession.getProjects()).thenReturn(Collections.singletonList(mavenProject)); + + localRepo = tempDir.resolve("local-repo").toAbsolutePath().toFile(); + mavenSession.getRequest().setLocalRepositoryPath(localRepo); } @Test @InjectMojo(goal = "install") - public void testBasicInstall(InstallMojo mojo) throws Exception { + void testBasicInstall(InstallMojo mojo) throws Exception { mojo.setPluginContext(new HashMap<>()); setProjectArtifact(mavenProject); mojo.execute(); - verify(repositorySystem).install(any(), installRequestCaptor.capture()); + Artifact artifact = mavenProject.getArtifact(); + String groupId = dotToSlashReplacer(artifact.getGroupId()); - InstallRequest installRequest = installRequestCaptor.getValue(); - ArrayList artifacts = new ArrayList<>(installRequest.getArtifacts()); - assertEquals(2, artifacts.size()); + File installedArtifact = new File( + localRepo, + groupId + "/" + artifact.getArtifactId() + "/" + artifact.getVersion() + "/" + + artifact.getArtifactId() + "-" + artifact.getVersion() + "." + + artifact.getArtifactHandler().getExtension()); - assertArtifactInstalled(mavenProject, artifacts.get(0), "pom"); - assertArtifactInstalled(mavenProject, artifacts.get(1), "jar"); + assertTrue(installedArtifact.exists()); + + assertEquals(5, FileUtils.getFiles(localRepo, null, null).size()); } @Test @InjectMojo(goal = "install") - public void testBasicInstallWithAttachedArtifacts(InstallMojo mojo) throws Exception { + void testBasicInstallWithAttachedArtifacts(InstallMojo mojo) throws Exception { mojo.setPluginContext(new HashMap<>()); setProjectArtifact(mavenProject); @@ -142,21 +131,28 @@ public void testBasicInstallWithAttachedArtifacts(InstallMojo mojo) throws Excep mojo.execute(); - verify(repositorySystem).install(any(), installRequestCaptor.capture()); + List attachedArtifacts = mavenProject.getAttachedArtifacts(); + + for (Artifact attachedArtifact : attachedArtifacts) { + + String groupId = dotToSlashReplacer(attachedArtifact.getGroupId()); + + File installedArtifact = new File( + localRepo, + groupId + "/" + attachedArtifact.getArtifactId() + + "/" + attachedArtifact.getVersion() + "/" + attachedArtifact.getArtifactId() + + "-" + attachedArtifact.getVersion() + "-" + attachedArtifact.getClassifier() + + "." + attachedArtifact.getArtifactHandler().getExtension()); - InstallRequest installRequest = installRequestCaptor.getValue(); - ArrayList artifacts = new ArrayList<>(installRequest.getArtifacts()); + assertTrue(installedArtifact.exists(), installedArtifact.getPath() + " does not exist"); + } - assertEquals(4, artifacts.size()); - assertArtifactInstalled(mavenProject, artifacts.get(0), "pom"); - assertArtifactInstalled(mavenProject, artifacts.get(1), "jar"); - assertArtifactInstalled(mavenProject, artifacts.get(2), "next1", "jar"); - assertArtifactInstalled(mavenProject, artifacts.get(3), "next2", "jar"); + assertEquals(7, FileUtils.getFiles(localRepo, null, null).size()); } @Test @InjectMojo(goal = "install") - public void testNonPomInstallWithAttachedArtifactsOnly(InstallMojo mojo) throws Exception { + void testNonPomInstallWithAttachedArtifactsOnly(InstallMojo mojo) throws Exception { mojo.setPluginContext(new HashMap<>()); setProjectArtifact(mavenProject); @@ -178,12 +174,11 @@ public void testNonPomInstallWithAttachedArtifactsOnly(InstallMojo mojo) throws + "but it has attachments. Change packaging to 'pom'.", e.getMessage()); } - verifyNoInteractions(repositorySystem); } @Test @InjectMojo(goal = "install") - public void testInstallIfArtifactFileIsNull(InstallMojo mojo) throws Exception { + void testInstallIfArtifactFileIsNull(InstallMojo mojo) throws Exception { mojo.setPluginContext(new HashMap<>()); setProjectArtifact(mavenProject); mavenProject.getArtifact().setFile(null); @@ -197,12 +192,11 @@ public void testInstallIfArtifactFileIsNull(InstallMojo mojo) throws Exception { "The packaging plugin for project maven-install-test did not assign a file to the build artifact", e.getMessage()); } - verifyNoInteractions(repositorySystem); } @Test @InjectMojo(goal = "install") - public void testInstallIfProjectFileIsNull(InstallMojo mojo) throws Exception { + void testInstallIfProjectFileIsNull(InstallMojo mojo) throws Exception { mojo.setPluginContext(new HashMap<>()); setProjectArtifact(mavenProject); mavenProject.setFile(null); @@ -214,12 +208,11 @@ public void testInstallIfProjectFileIsNull(InstallMojo mojo) throws Exception { // expected, message should include artifactId assertEquals("The POM for project maven-install-test could not be attached", e.getMessage()); } - verifyNoInteractions(repositorySystem); } @Test @InjectMojo(goal = "install") - public void testInstallIfPackagingIsPom(InstallMojo mojo) throws Exception { + void testInstallIfPackagingIsPom(InstallMojo mojo) throws Exception { mojo.setPluginContext(new HashMap<>()); mavenProject.setPomFile( Files.createTempFile(tempDir, "test-artifact", "pom").toFile()); @@ -227,18 +220,22 @@ public void testInstallIfPackagingIsPom(InstallMojo mojo) throws Exception { mojo.execute(); - verify(repositorySystem).install(any(), installRequestCaptor.capture()); + String groupId = dotToSlashReplacer(mavenProject.getGroupId()); + + File installedArtifact = new File( + localRepo, + groupId + "/" + mavenProject.getArtifactId() + "/" + mavenProject.getVersion() + "/" + + mavenProject.getArtifactId() + "-" + mavenProject.getVersion() + "." + + mavenProject.getPackaging()); - InstallRequest installRequest = installRequestCaptor.getValue(); - ArrayList artifacts = new ArrayList<>(installRequest.getArtifacts()); + assertTrue(installedArtifact.exists()); - assertEquals(1, artifacts.size()); - assertArtifactInstalled(mavenProject, artifacts.get(0), "pom"); + assertEquals(4, FileUtils.getFiles(localRepo, null, null).size()); } @Test @InjectMojo(goal = "install") - public void testInstallIfPackagingIsBom(InstallMojo mojo) throws Exception { + void testInstallIfPackagingIsBom(InstallMojo mojo) throws Exception { mojo.setPluginContext(new HashMap<>()); mavenProject.setPomFile( Files.createTempFile(tempDir, "test-artifact", "pom").toFile()); @@ -246,37 +243,43 @@ public void testInstallIfPackagingIsBom(InstallMojo mojo) throws Exception { mojo.execute(); - verify(repositorySystem).install(any(), installRequestCaptor.capture()); + String groupId = dotToSlashReplacer(mavenProject.getGroupId()); - InstallRequest installRequest = installRequestCaptor.getValue(); - ArrayList artifacts = new ArrayList<>(installRequest.getArtifacts()); + File installedArtifact = new File( + localRepo, + groupId + "/" + mavenProject.getArtifactId() + "/" + mavenProject.getVersion() + "/" + + mavenProject.getArtifactId() + "-" + mavenProject.getVersion() + ".pom"); - assertEquals(1, artifacts.size()); - assertArtifactInstalled(mavenProject, artifacts.get(0), "pom"); + assertTrue(installedArtifact.exists()); + + assertEquals(4, FileUtils.getFiles(localRepo, null, null).size()); } @Test @InjectMojo(goal = "install") @MojoParameter(name = "skip", value = "true") - public void testSkip(InstallMojo mojo) throws Exception { + void testSkip(InstallMojo mojo) throws Exception { mojo.setPluginContext(new HashMap<>()); + setProjectArtifact(mavenProject); mojo.execute(); - verifyNoInteractions(repositorySystem); - } + Artifact artifact = mavenProject.getArtifact(); + String groupId = dotToSlashReplacer(artifact.getGroupId()); + + String packaging = mavenProject.getPackaging(); + + File installedArtifact = + new File(localRepo + groupId + "/" + artifact.getArtifactId() + "/" + artifact.getVersion() + "/" + + artifact.getArtifactId() + "-" + artifact.getVersion() + "." + packaging); + + assertFalse(installedArtifact.exists()); - private void assertArtifactInstalled( - MavenProject mavenProject, org.eclipse.aether.artifact.Artifact artifact, String type) { - assertEquals(mavenProject.getArtifactId(), artifact.getArtifactId()); - assertEquals(mavenProject.getGroupId(), artifact.getGroupId()); - assertEquals(mavenProject.getVersion(), artifact.getVersion()); - assertEquals(type, artifact.getExtension()); + assertFalse(localRepo.exists()); } - private void assertArtifactInstalled(MavenProject mavenProject, Artifact artifact, String classifier, String type) { - assertArtifactInstalled(mavenProject, artifact, type); - assertEquals(classifier, artifact.getClassifier()); + private String dotToSlashReplacer(String parameter) { + return parameter.replace('.', '/'); } private void setProjectArtifact(MavenProject mavenProject) throws IOException { From f18fb88cf932ec9592eb07ba8c3c6706a4e3069c Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Mon, 9 Mar 2026 23:14:13 +0100 Subject: [PATCH 4/5] Migration to JUnit 5 - avoid using AbstractMojoTestCase --- .../plugins/install/InstallFileMojoTest.java | 351 ++++++------------ 1 file changed, 113 insertions(+), 238 deletions(-) diff --git a/src/test/java/org/apache/maven/plugins/install/InstallFileMojoTest.java b/src/test/java/org/apache/maven/plugins/install/InstallFileMojoTest.java index 826c063f..4863e2c0 100644 --- a/src/test/java/org/apache/maven/plugins/install/InstallFileMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/install/InstallFileMojoTest.java @@ -18,229 +18,166 @@ */ package org.apache.maven.plugins.install; +import javax.inject.Inject; + import java.io.File; import java.io.Reader; +import org.apache.maven.api.plugin.testing.Basedir; +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.execution.MavenSession; import org.apache.maven.model.Model; import org.apache.maven.model.io.xpp3.MavenXpp3Reader; -import org.apache.maven.project.DefaultProjectBuildingRequest; -import org.apache.maven.project.ProjectBuildingRequest; import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.xml.XmlStreamReader; -import org.eclipse.aether.DefaultRepositorySystemSession; -import org.eclipse.aether.internal.impl.DefaultLocalPathComposer; -import org.eclipse.aether.internal.impl.DefaultLocalPathPrefixComposerFactory; -import org.eclipse.aether.internal.impl.DefaultTrackingFileManager; -import org.eclipse.aether.internal.impl.EnhancedLocalRepositoryManagerFactory; -import org.eclipse.aether.repository.LocalRepository; -import org.eclipse.aether.repository.NoLocalRepositoryManagerException; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.apache.maven.api.plugin.testing.MojoExtension.getBasedir; import static org.apache.maven.api.plugin.testing.MojoExtension.getVariableValueFromObject; -import static org.apache.maven.api.plugin.testing.MojoExtension.setVariableValueToObject; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; /** * @author Allan Ramirez */ +@MojoTest(realRepositorySession = true) public class InstallFileMojoTest { - private String groupId; - - private String artifactId; - - private String version; - - private String packaging; - - private String classifier; - - private File file; private static final String LOCAL_REPO = "target/local-repo/"; - private static final String SPECIFIC_LOCAL_REPO = "target/specific-local-repo/"; - public void setUp() throws Exception { - // super.setUp(); + @Inject + private MavenSession mavenSession; + @BeforeEach + public void setUp() throws Exception { FileUtils.deleteDirectory(new File(getBasedir() + "/" + LOCAL_REPO)); FileUtils.deleteDirectory(new File(getBasedir() + "/" + SPECIFIC_LOCAL_REPO)); - } - - public void testInstallFileFromLocalRepositoryToLocalRepositoryPath(InstallFileMojo mojo) throws Exception { - File localRepository = - new File(getBasedir(), "target/test-classes/unit/install-file-from-local-repository-test/target"); - - // File testPom = new File(localRepository.getParentFile(), "plugin-config.xml"); - - // InstallFileMojo mojo = (InstallFileMojo) lookupMojo("install-file", testPom); - - assertNotNull(mojo); - setVariableValueToObject(mojo, "session", createMavenSession(localRepository.getAbsolutePath())); - - File specificLocalRepositoryPath = new File(getBasedir() + "/" + SPECIFIC_LOCAL_REPO); - - setVariableValueToObject(mojo, "localRepositoryPath", specificLocalRepositoryPath); - - assignValuesForParameter(mojo); - - mojo.execute(); - - String localPath = getBasedir() + "/" + SPECIFIC_LOCAL_REPO + groupId + "/" + artifactId + "/" + version + "/" - + artifactId + "-" + version; - - File installedArtifact = new File(localPath + "." + "jar"); - - assertTrue(installedArtifact.exists()); - - assertEquals( - 5, - FileUtils.getFiles(new File(SPECIFIC_LOCAL_REPO), null, null).size(), - FileUtils.getFiles(new File(SPECIFIC_LOCAL_REPO), null, null).toString()); + mavenSession.getRequest().setLocalRepositoryPath(getBasedir() + "/" + LOCAL_REPO); } + @Test + @InjectMojo(goal = "install-file") + @MojoParameter(name = "groupId", value = "org.apache.maven.test") + @MojoParameter(name = "artifactId", value = "maven-install-file-test") + @MojoParameter(name = "version", value = "1.0-SNAPSHOT") + @MojoParameter(name = "packaging", value = "jar") + @MojoParameter(name = "file", value = "${basedir}/target/maven-install-test-1.0-SNAPSHOT.jar") + @MojoParameter(name = "localRepositoryPath", value = "${basedir}/" + SPECIFIC_LOCAL_REPO) + @Basedir("/unit/install-file-basic-test") public void testInstallFileWithLocalRepositoryPath(InstallFileMojo mojo) throws Exception { - // File testPom = - // new File(getBasedir(), "target/test-classes/unit/install-file-with-checksum/" + - // "plugin-config.xml"); - - // InstallFileMojo mojo = (InstallFileMojo) lookupMojo("install-file", testPom); - - assertNotNull(mojo); - - setVariableValueToObject(mojo, "session", createMavenSession(LOCAL_REPO)); - - File specificLocalRepositoryPath = new File(getBasedir() + "/" + SPECIFIC_LOCAL_REPO); - - setVariableValueToObject(mojo, "localRepositoryPath", specificLocalRepositoryPath); - - assignValuesForParameter(mojo); - mojo.execute(); - String localPath = getBasedir() + "/" + SPECIFIC_LOCAL_REPO + groupId + "/" + artifactId + "/" + version + "/" - + artifactId + "-" + version; - - File installedArtifact = new File(localPath + "." + "jar"); + File installedArtifact = new File( + getBasedir(), + SPECIFIC_LOCAL_REPO + + "org/apache/maven/test/maven-install-file-test/1.0-SNAPSHOT/maven-install-file-test-1.0-SNAPSHOT.jar"); - assertTrue(installedArtifact.exists()); + assertTrue( + installedArtifact.exists(), "Installed artifact should exist: " + installedArtifact.getAbsolutePath()); assertEquals( 5, - FileUtils.getFiles(new File(SPECIFIC_LOCAL_REPO), null, null).size(), - FileUtils.getFiles(new File(SPECIFIC_LOCAL_REPO), null, null).toString()); - } - - public void testInstallFileTestEnvironment(InstallFileMojo mojo) throws Exception { - // File testPom = new File(getBasedir(), - // "target/test-classes/unit/install-file-basic-test/plugin-config.xml"); - - // InstallFileMojo mojo = (InstallFileMojo) lookupMojo("install-file", testPom); - - setVariableValueToObject(mojo, "session", createMavenSession(LOCAL_REPO)); - - assertNotNull(mojo); + FileUtils.getFiles(new File(getBasedir(), SPECIFIC_LOCAL_REPO), null, null) + .size(), + FileUtils.getFiles(new File(getBasedir(), SPECIFIC_LOCAL_REPO), null, null) + .toString()); } + @Test + @InjectMojo(goal = "install-file") + @MojoParameter(name = "groupId", value = "org.apache.maven.test") + @MojoParameter(name = "artifactId", value = "maven-install-file-test") + @MojoParameter(name = "version", value = "1.0-SNAPSHOT") + @MojoParameter(name = "packaging", value = "jar") + @MojoParameter(name = "file", value = "${basedir}/target/maven-install-test-1.0-SNAPSHOT.jar") + @Basedir("/unit/install-file-basic-test") public void testBasicInstallFile(InstallFileMojo mojo) throws Exception { - // File testPom = new File(getBasedir(), - // "target/test-classes/unit/install-file-basic-test/plugin-config.xml"); - - // InstallFileMojo mojo = (InstallFileMojo) lookupMojo("install-file", testPom); - - assertNotNull(mojo); - - setVariableValueToObject(mojo, "session", createMavenSession(LOCAL_REPO)); - - assignValuesForParameter(mojo); - mojo.execute(); File installedArtifact = new File( getBasedir(), - LOCAL_REPO + groupId + "/" + artifactId + "/" + version + "/" + artifactId + "-" + version + "." - + packaging); + LOCAL_REPO + + "org/apache/maven/test/maven-install-file-test/1.0-SNAPSHOT/maven-install-file-test-1.0-SNAPSHOT.jar"); - assertTrue(installedArtifact.exists()); + assertTrue( + installedArtifact.exists(), "Installed artifact should exist: " + installedArtifact.getAbsolutePath()); - assertEquals(5, FileUtils.getFiles(new File(LOCAL_REPO), null, null).size()); + assertEquals( + 5, + FileUtils.getFiles(new File(getBasedir(), LOCAL_REPO), null, null) + .size()); } + @Test + @InjectMojo(goal = "install-file") + @MojoParameter(name = "groupId", value = "org.apache.maven.test") + @MojoParameter(name = "artifactId", value = "maven-install-file-test") + @MojoParameter(name = "version", value = "1.0-SNAPSHOT") + @MojoParameter(name = "packaging", value = "jar") + @MojoParameter(name = "classifier", value = "sources") + @MojoParameter(name = "file", value = "${basedir}/target/maven-install-test-1.0-SNAPSHOT.jar") + @Basedir("/unit/install-file-basic-test") public void testInstallFileWithClassifier(InstallFileMojo mojo) throws Exception { - // File testPom = - // new File(getBasedir(), - // "target/test-classes/unit/install-file-with-classifier/plugin-config.xml"); - - // InstallFileMojo mojo = (InstallFileMojo) lookupMojo("install-file", testPom); - - assertNotNull(mojo); - - setVariableValueToObject(mojo, "session", createMavenSession(LOCAL_REPO)); - - assignValuesForParameter(mojo); - - assertNotNull(classifier); - mojo.execute(); File installedArtifact = new File( getBasedir(), - LOCAL_REPO + groupId + "/" + artifactId + "/" + version + "/" + artifactId + "-" + version + "-" - + classifier + "." + packaging); + LOCAL_REPO + + "org/apache/maven/test/maven-install-file-test/1.0-SNAPSHOT/maven-install-file-test-1.0-SNAPSHOT-sources.jar"); - assertTrue(installedArtifact.exists()); + assertTrue( + installedArtifact.exists(), "Installed artifact should exist: " + installedArtifact.getAbsolutePath()); - assertEquals(5, FileUtils.getFiles(new File(LOCAL_REPO), null, null).size()); + assertEquals( + 5, + FileUtils.getFiles(new File(getBasedir(), LOCAL_REPO), null, null) + .size()); } + @Test + @InjectMojo(goal = "install-file") + @MojoParameter(name = "groupId", value = "org.apache.maven.test") + @MojoParameter(name = "artifactId", value = "maven-install-file-test") + @MojoParameter(name = "version", value = "1.0-SNAPSHOT") + @MojoParameter(name = "packaging", value = "jar") + @MojoParameter(name = "generatePom", value = "true") + @MojoParameter(name = "file", value = "${basedir}/target/maven-install-test-1.0-SNAPSHOT.jar") + @Basedir("/unit/install-file-test-generatePom") public void testInstallFileWithGeneratePom(InstallFileMojo mojo) throws Exception { - // File testPom = - // new File(getBasedir(), - // "target/test-classes/unit/install-file-test-generatePom/plugin-config.xml"); - - // InstallFileMojo mojo = (InstallFileMojo) lookupMojo("install-file", testPom); - - assertNotNull(mojo); - - setVariableValueToObject(mojo, "session", createMavenSession(LOCAL_REPO)); - - assignValuesForParameter(mojo); - mojo.execute(); File installedArtifact = new File( getBasedir(), - LOCAL_REPO + groupId + "/" + artifactId + "/" + version + "/" + artifactId + "-" + version + "." - + packaging); + LOCAL_REPO + + "org/apache/maven/test/maven-install-file-test/1.0-SNAPSHOT/maven-install-file-test-1.0-SNAPSHOT.jar"); - assertTrue((Boolean) getVariableValueFromObject(mojo, "generatePom")); - - assertTrue(installedArtifact.exists()); + assertTrue( + installedArtifact.exists(), "Installed artifact should exist: " + installedArtifact.getAbsolutePath()); File installedPom = new File( getBasedir(), - LOCAL_REPO + groupId + "/" + artifactId + "/" + version + "/" + artifactId + "-" + version + "." - + "pom"); + LOCAL_REPO + + "org/apache/maven/test/maven-install-file-test/1.0-SNAPSHOT/maven-install-file-test-1.0-SNAPSHOT.pom"); try (Reader reader = new XmlStreamReader(installedPom)) { Model model = new MavenXpp3Reader().read(reader); assertEquals("4.0.0", model.getModelVersion()); - - assertEquals((String) getVariableValueFromObject(mojo, "groupId"), model.getGroupId()); - - assertEquals(artifactId, model.getArtifactId()); - - assertEquals(version, model.getVersion()); + assertEquals("org.apache.maven.test", model.getGroupId()); + assertEquals("maven-install-file-test", model.getArtifactId()); + assertEquals("1.0-SNAPSHOT", model.getVersion()); } - assertEquals(5, FileUtils.getFiles(new File(LOCAL_REPO), null, null).size()); + assertEquals( + 5, + FileUtils.getFiles(new File(getBasedir(), LOCAL_REPO), null, null) + .size()); } public void testInstallFileWithPomFile(InstallFileMojo mojo) throws Exception { @@ -252,9 +189,7 @@ public void testInstallFileWithPomFile(InstallFileMojo mojo) throws Exception { assertNotNull(mojo); - setVariableValueToObject(mojo, "session", createMavenSession(LOCAL_REPO)); - - assignValuesForParameter(mojo); + // setVariableValueToObject(mojo, "session", createMavenSession(LOCAL_REPO)); mojo.execute(); @@ -262,19 +197,21 @@ public void testInstallFileWithPomFile(InstallFileMojo mojo) throws Exception { assertTrue(pomFile.exists()); - File installedArtifact = new File( - getBasedir(), - LOCAL_REPO + groupId + "/" + artifactId + "/" + version + "/" + artifactId + "-" + version + "." - + packaging); - - assertTrue(installedArtifact.exists()); - - File installedPom = new File( - getBasedir(), - LOCAL_REPO + groupId + "/" + artifactId + "/" + version + "/" + artifactId + "-" + version + "." - + "pom"); - - assertTrue(installedPom.exists()); + // File installedArtifact = new File( + // getBasedir(), + // LOCAL_REPO + groupId + "/" + artifactId + "/" + version + "/" + artifactId + "-" + version + + // "." + // + packaging); + // + // assertTrue(installedArtifact.exists()); + // + // File installedPom = new File( + // getBasedir(), + // LOCAL_REPO + groupId + "/" + artifactId + "/" + version + "/" + artifactId + "-" + version + + // "." + // + "pom"); + // + // assertTrue(installedPom.exists()); assertEquals(5, FileUtils.getFiles(new File(LOCAL_REPO), null, null).size()); } @@ -288,84 +225,22 @@ public void testInstallFileWithPomAsPackaging(InstallFileMojo mojo) throws Excep assertNotNull(mojo); - setVariableValueToObject(mojo, "session", createMavenSession(LOCAL_REPO)); - - assignValuesForParameter(mojo); + // setVariableValueToObject(mojo, "session", createMavenSession(LOCAL_REPO)); - assertTrue(file.exists()); + // assertTrue(file.exists()); - assertEquals("pom", packaging); + // assertEquals("pom", packaging); mojo.execute(); - File installedPom = new File( - getBasedir(), - LOCAL_REPO + groupId + "/" + artifactId + "/" + version + "/" + artifactId + "-" + version + "." - + "pom"); + // File installedPom = new File( + // getBasedir(), + // LOCAL_REPO + groupId + "/" + artifactId + "/" + version + "/" + artifactId + "-" + version + + // "." + // + "pom"); - assertTrue(installedPom.exists()); + // assertTrue(installedPom.exists()); assertEquals(4, FileUtils.getFiles(new File(LOCAL_REPO), null, null).size()); } - - public void testInstallFile(InstallFileMojo mojo) throws Exception { - // File testPom = - // new File(getBasedir(), "target/test-classes/unit/install-file-with-checksum/" + - // "plugin-config.xml"); - - // InstallFileMojo mojo = (InstallFileMojo) lookupMojo("install-file", testPom); - - assertNotNull(mojo); - - setVariableValueToObject(mojo, "session", createMavenSession(LOCAL_REPO)); - - assignValuesForParameter(mojo); - - mojo.execute(); - - String localPath = getBasedir() + "/" + LOCAL_REPO + groupId + "/" + artifactId + "/" + version + "/" - + artifactId + "-" + version; - - File installedArtifact = new File(localPath + "." + "jar"); - - assertTrue(installedArtifact.exists()); - - assertEquals( - 5, - FileUtils.getFiles(new File(LOCAL_REPO), null, null).size(), - FileUtils.getFiles(new File(LOCAL_REPO), null, null).toString()); - } - - private void assignValuesForParameter(Object obj) throws Exception { - this.groupId = dotToSlashReplacer((String) getVariableValueFromObject(obj, "groupId")); - - this.artifactId = (String) getVariableValueFromObject(obj, "artifactId"); - - this.version = (String) getVariableValueFromObject(obj, "version"); - - this.packaging = (String) getVariableValueFromObject(obj, "packaging"); - - this.classifier = (String) getVariableValueFromObject(obj, "classifier"); - - this.file = (File) getVariableValueFromObject(obj, "file"); - } - - private String dotToSlashReplacer(String parameter) { - return parameter.replace('.', '/'); - } - - private MavenSession createMavenSession(String localRepositoryBaseDir) throws NoLocalRepositoryManagerException { - MavenSession session = mock(MavenSession.class); - DefaultRepositorySystemSession repositorySession = new DefaultRepositorySystemSession(); - repositorySession.setLocalRepositoryManager(new EnhancedLocalRepositoryManagerFactory( - new DefaultLocalPathComposer(), - new DefaultTrackingFileManager(), - new DefaultLocalPathPrefixComposerFactory()) - .newInstance(repositorySession, new LocalRepository(localRepositoryBaseDir))); - ProjectBuildingRequest buildingRequest = new DefaultProjectBuildingRequest(); - buildingRequest.setRepositorySession(repositorySession); - when(session.getProjectBuildingRequest()).thenReturn(buildingRequest); - when(session.getRepositorySession()).thenReturn(repositorySession); - return session; - } } From 8c155b3713d2f31f728d15bc00b127c521fa44bd Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Wed, 11 Mar 2026 21:49:26 +0100 Subject: [PATCH 5/5] Migration to JUnit 5 - avoid using AbstractMojoTestCase --- pom.xml | 19 +- .../plugins/install/InstallFileMojoTest.java | 188 +++++++----------- .../install/stubs/AttachedArtifactStub0.java | 34 ---- .../install/stubs/AttachedArtifactStub1.java | 25 --- .../install/stubs/InstallArtifactStub.java | 99 --------- .../install/stubs/InstallBomArtifactStub.java | 37 ---- .../install/stubs/InstallPomArtifactStub.java | 37 ---- .../basic-install-checksum/maven-test-jar.jar | 1 - .../basic-install-checksum/plugin-config.xml | 35 ---- .../plugin-config.xml | 35 ---- .../plugin-config.xml | 35 ---- .../plugin-config.xml | 42 ---- .../maven-install-test-1.0-SNAPSHOT.jar | Bin 2372 -> 0 bytes .../configured-install-test/plugin-config.xml | 35 ---- .../maven-install-test-1.0-SNAPSHOT.jar | Bin 2372 -> 0 bytes .../install-file-basic-test/plugin-config.xml | 35 ---- .../maven-install-test-1.0-SNAPSHOT.jar | Bin 2372 -> 0 bytes .../plugin-config.xml | 35 ---- .../maven-install-test-1.0-SNAPSHOT.jar | Bin 2372 -> 0 bytes .../plugin-config.xml | 37 ---- .../maven-install-test-1.0-SNAPSHOT.jar | Bin 1244 -> 0 bytes .../plugin-config.xml | 0 .../maven-install-test-1.0-SNAPSHOT.jar | Bin .../maven-test-jar.jar | 1 - .../plugin-config.xml | 35 ---- .../plugin-config.xml | 36 ---- .../maven-install-test-1.0-SNAPSHOT.jar | Bin 2372 -> 0 bytes .../plugin-config.xml | 34 ---- .../plugin-config.xml | Bin 2934 -> 0 bytes .../maven-install-test-1.0-SNAPSHOT.jar | Bin 2372 -> 0 bytes 30 files changed, 83 insertions(+), 752 deletions(-) delete mode 100644 src/test/java/org/apache/maven/plugins/install/stubs/AttachedArtifactStub0.java delete mode 100644 src/test/java/org/apache/maven/plugins/install/stubs/AttachedArtifactStub1.java delete mode 100644 src/test/java/org/apache/maven/plugins/install/stubs/InstallArtifactStub.java delete mode 100644 src/test/java/org/apache/maven/plugins/install/stubs/InstallBomArtifactStub.java delete mode 100644 src/test/java/org/apache/maven/plugins/install/stubs/InstallPomArtifactStub.java delete mode 100644 src/test/resources/unit/basic-install-checksum/maven-test-jar.jar delete mode 100644 src/test/resources/unit/basic-install-checksum/plugin-config.xml delete mode 100644 src/test/resources/unit/basic-install-test-packaging-bom/plugin-config.xml delete mode 100644 src/test/resources/unit/basic-install-test-packaging-pom/plugin-config.xml delete mode 100644 src/test/resources/unit/basic-install-test-with-attached-artifacts/plugin-config.xml delete mode 100644 src/test/resources/unit/basic-install-test/target/maven-install-test-1.0-SNAPSHOT.jar delete mode 100644 src/test/resources/unit/configured-install-test/plugin-config.xml delete mode 100644 src/test/resources/unit/configured-install-test/target/maven-install-test-1.0-SNAPSHOT.jar delete mode 100644 src/test/resources/unit/install-file-basic-test/plugin-config.xml delete mode 100644 src/test/resources/unit/install-file-basic-test/target/maven-install-test-1.0-SNAPSHOT.jar delete mode 100644 src/test/resources/unit/install-file-from-local-repository-test/plugin-config.xml delete mode 100644 src/test/resources/unit/install-file-from-local-repository-test/target/org/apache/maven/test/maven-install-test/1.0-SNAPSHOT/maven-install-test-1.0-SNAPSHOT.jar delete mode 100644 src/test/resources/unit/install-file-test-generatePom/plugin-config.xml delete mode 100644 src/test/resources/unit/install-file-test-generatePom/target/maven-install-test-1.0-SNAPSHOT.jar rename src/test/resources/unit/{basic-install-test => install-file-test}/plugin-config.xml (100%) rename src/test/resources/unit/{basic-install-test-with-attached-artifacts => install-file-test}/target/maven-install-test-1.0-SNAPSHOT.jar (100%) delete mode 100644 src/test/resources/unit/install-file-with-checksum/maven-test-jar.jar delete mode 100644 src/test/resources/unit/install-file-with-checksum/plugin-config.xml delete mode 100644 src/test/resources/unit/install-file-with-classifier/plugin-config.xml delete mode 100644 src/test/resources/unit/install-file-with-classifier/target/maven-install-test-1.0-SNAPSHOT.jar delete mode 100644 src/test/resources/unit/install-file-with-pom-as-packaging/plugin-config.xml delete mode 100644 src/test/resources/unit/install-file-with-pomFile-test/plugin-config.xml delete mode 100644 src/test/resources/unit/install-file-with-pomFile-test/target/maven-install-test-1.0-SNAPSHOT.jar diff --git a/pom.xml b/pom.xml index 2ff7f665..0f2c0356 100644 --- a/pom.xml +++ b/pom.xml @@ -132,6 +132,12 @@ compile + + javax.inject + javax.inject + 1 + provided + org.slf4j slf4j-api @@ -166,13 +172,6 @@ 3.5.1 test - - - org.apache.maven - maven-compat - ${mavenVersion} - test - org.mockito mockito-core @@ -185,12 +184,6 @@ ${slf4jVersion} test - - org.apache.maven.resolver - maven-resolver-impl - ${resolverVersion} - test - diff --git a/src/test/java/org/apache/maven/plugins/install/InstallFileMojoTest.java b/src/test/java/org/apache/maven/plugins/install/InstallFileMojoTest.java index 4863e2c0..52a048a6 100644 --- a/src/test/java/org/apache/maven/plugins/install/InstallFileMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/install/InstallFileMojoTest.java @@ -22,9 +22,12 @@ import java.io.File; import java.io.Reader; +import java.nio.file.Files; +import java.nio.file.Path; import org.apache.maven.api.plugin.testing.Basedir; import org.apache.maven.api.plugin.testing.InjectMojo; +import org.apache.maven.api.plugin.testing.MojoExtension; import org.apache.maven.api.plugin.testing.MojoParameter; import org.apache.maven.api.plugin.testing.MojoTest; import org.apache.maven.execution.MavenSession; @@ -34,136 +37,114 @@ import org.codehaus.plexus.util.xml.XmlStreamReader; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; -import static org.apache.maven.api.plugin.testing.MojoExtension.getBasedir; -import static org.apache.maven.api.plugin.testing.MojoExtension.getVariableValueFromObject; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Allan Ramirez */ @MojoTest(realRepositorySession = true) +@Basedir("/unit/install-file-test") +@MojoParameter(name = "groupId", value = "org.apache.maven.test") +@MojoParameter(name = "artifactId", value = "maven-install-file-test") +@MojoParameter(name = "version", value = "1.0-SNAPSHOT") public class InstallFileMojoTest { - private static final String LOCAL_REPO = "target/local-repo/"; - private static final String SPECIFIC_LOCAL_REPO = "target/specific-local-repo/"; + @TempDir + private Path tempDir; + + private File localRepo; + private File specificLocalRepositoryPath; @Inject private MavenSession mavenSession; @BeforeEach public void setUp() throws Exception { - FileUtils.deleteDirectory(new File(getBasedir() + "/" + LOCAL_REPO)); - FileUtils.deleteDirectory(new File(getBasedir() + "/" + SPECIFIC_LOCAL_REPO)); - - mavenSession.getRequest().setLocalRepositoryPath(getBasedir() + "/" + LOCAL_REPO); + localRepo = tempDir.resolve("local-repo").toAbsolutePath().toFile(); + mavenSession.getRequest().setLocalRepositoryPath(localRepo); + + specificLocalRepositoryPath = + tempDir.resolve("specific-local-repo").toAbsolutePath().toFile(); + mavenSession + .getUserProperties() + .setProperty("specificLocalRepositoryPath", specificLocalRepositoryPath.getAbsolutePath()); } @Test @InjectMojo(goal = "install-file") - @MojoParameter(name = "groupId", value = "org.apache.maven.test") - @MojoParameter(name = "artifactId", value = "maven-install-file-test") - @MojoParameter(name = "version", value = "1.0-SNAPSHOT") @MojoParameter(name = "packaging", value = "jar") @MojoParameter(name = "file", value = "${basedir}/target/maven-install-test-1.0-SNAPSHOT.jar") - @MojoParameter(name = "localRepositoryPath", value = "${basedir}/" + SPECIFIC_LOCAL_REPO) - @Basedir("/unit/install-file-basic-test") + @MojoParameter(name = "localRepositoryPath", value = "${specificLocalRepositoryPath}") public void testInstallFileWithLocalRepositoryPath(InstallFileMojo mojo) throws Exception { mojo.execute(); File installedArtifact = new File( - getBasedir(), - SPECIFIC_LOCAL_REPO - + "org/apache/maven/test/maven-install-file-test/1.0-SNAPSHOT/maven-install-file-test-1.0-SNAPSHOT.jar"); + specificLocalRepositoryPath, + "org/apache/maven/test/maven-install-file-test/1.0-SNAPSHOT/maven-install-file-test-1.0-SNAPSHOT.jar"); assertTrue( installedArtifact.exists(), "Installed artifact should exist: " + installedArtifact.getAbsolutePath()); assertEquals( - 5, - FileUtils.getFiles(new File(getBasedir(), SPECIFIC_LOCAL_REPO), null, null) - .size(), - FileUtils.getFiles(new File(getBasedir(), SPECIFIC_LOCAL_REPO), null, null) - .toString()); + 5, FileUtils.getFiles(specificLocalRepositoryPath, null, null).size()); } @Test @InjectMojo(goal = "install-file") - @MojoParameter(name = "groupId", value = "org.apache.maven.test") - @MojoParameter(name = "artifactId", value = "maven-install-file-test") - @MojoParameter(name = "version", value = "1.0-SNAPSHOT") @MojoParameter(name = "packaging", value = "jar") @MojoParameter(name = "file", value = "${basedir}/target/maven-install-test-1.0-SNAPSHOT.jar") - @Basedir("/unit/install-file-basic-test") - public void testBasicInstallFile(InstallFileMojo mojo) throws Exception { + void testBasicInstallFile(InstallFileMojo mojo) throws Exception { mojo.execute(); File installedArtifact = new File( - getBasedir(), - LOCAL_REPO - + "org/apache/maven/test/maven-install-file-test/1.0-SNAPSHOT/maven-install-file-test-1.0-SNAPSHOT.jar"); + localRepo, + "org/apache/maven/test/maven-install-file-test/1.0-SNAPSHOT/maven-install-file-test-1.0-SNAPSHOT.jar"); assertTrue( installedArtifact.exists(), "Installed artifact should exist: " + installedArtifact.getAbsolutePath()); - assertEquals( - 5, - FileUtils.getFiles(new File(getBasedir(), LOCAL_REPO), null, null) - .size()); + assertEquals(5, FileUtils.getFiles(localRepo, null, null).size()); } @Test @InjectMojo(goal = "install-file") - @MojoParameter(name = "groupId", value = "org.apache.maven.test") - @MojoParameter(name = "artifactId", value = "maven-install-file-test") - @MojoParameter(name = "version", value = "1.0-SNAPSHOT") @MojoParameter(name = "packaging", value = "jar") @MojoParameter(name = "classifier", value = "sources") @MojoParameter(name = "file", value = "${basedir}/target/maven-install-test-1.0-SNAPSHOT.jar") - @Basedir("/unit/install-file-basic-test") - public void testInstallFileWithClassifier(InstallFileMojo mojo) throws Exception { + void testInstallFileWithClassifier(InstallFileMojo mojo) throws Exception { mojo.execute(); File installedArtifact = new File( - getBasedir(), - LOCAL_REPO - + "org/apache/maven/test/maven-install-file-test/1.0-SNAPSHOT/maven-install-file-test-1.0-SNAPSHOT-sources.jar"); + localRepo, + "org/apache/maven/test/maven-install-file-test/1.0-SNAPSHOT/maven-install-file-test-1.0-SNAPSHOT-sources.jar"); assertTrue( installedArtifact.exists(), "Installed artifact should exist: " + installedArtifact.getAbsolutePath()); - assertEquals( - 5, - FileUtils.getFiles(new File(getBasedir(), LOCAL_REPO), null, null) - .size()); + assertEquals(5, FileUtils.getFiles(localRepo, null, null).size()); } @Test @InjectMojo(goal = "install-file") - @MojoParameter(name = "groupId", value = "org.apache.maven.test") - @MojoParameter(name = "artifactId", value = "maven-install-file-test") - @MojoParameter(name = "version", value = "1.0-SNAPSHOT") @MojoParameter(name = "packaging", value = "jar") @MojoParameter(name = "generatePom", value = "true") @MojoParameter(name = "file", value = "${basedir}/target/maven-install-test-1.0-SNAPSHOT.jar") - @Basedir("/unit/install-file-test-generatePom") - public void testInstallFileWithGeneratePom(InstallFileMojo mojo) throws Exception { + void testInstallFileWithGeneratePom(InstallFileMojo mojo) throws Exception { mojo.execute(); File installedArtifact = new File( - getBasedir(), - LOCAL_REPO - + "org/apache/maven/test/maven-install-file-test/1.0-SNAPSHOT/maven-install-file-test-1.0-SNAPSHOT.jar"); + localRepo, + "org/apache/maven/test/maven-install-file-test/1.0-SNAPSHOT/maven-install-file-test-1.0-SNAPSHOT.jar"); assertTrue( installedArtifact.exists(), "Installed artifact should exist: " + installedArtifact.getAbsolutePath()); File installedPom = new File( - getBasedir(), - LOCAL_REPO - + "org/apache/maven/test/maven-install-file-test/1.0-SNAPSHOT/maven-install-file-test-1.0-SNAPSHOT.pom"); + localRepo, + "org/apache/maven/test/maven-install-file-test/1.0-SNAPSHOT/maven-install-file-test-1.0-SNAPSHOT.pom"); try (Reader reader = new XmlStreamReader(installedPom)) { Model model = new MavenXpp3Reader().read(reader); @@ -174,73 +155,58 @@ public void testInstallFileWithGeneratePom(InstallFileMojo mojo) throws Exceptio assertEquals("1.0-SNAPSHOT", model.getVersion()); } - assertEquals( - 5, - FileUtils.getFiles(new File(getBasedir(), LOCAL_REPO), null, null) - .size()); + assertEquals(5, FileUtils.getFiles(localRepo, null, null).size()); } - public void testInstallFileWithPomFile(InstallFileMojo mojo) throws Exception { - // File testPom = - // new File(getBasedir(), - // "target/test-classes/unit/install-file-with-pomFile-test/plugin-config.xml"); - - // InstallFileMojo mojo = (InstallFileMojo) lookupMojo("install-file", testPom); - - assertNotNull(mojo); - - // setVariableValueToObject(mojo, "session", createMavenSession(LOCAL_REPO)); - + @Test + @InjectMojo(goal = "install-file") + @MojoParameter(name = "packaging", value = "jar") + @MojoParameter(name = "file", value = "${basedir}/target/maven-install-test-1.0-SNAPSHOT.jar") + @MojoParameter(name = "pomFile", value = "${basedir}/plugin-config.xml") + void testInstallFileWithPomFile(InstallFileMojo mojo) throws Exception { mojo.execute(); - File pomFile = (File) getVariableValueFromObject(mojo, "pomFile"); - - assertTrue(pomFile.exists()); - - // File installedArtifact = new File( - // getBasedir(), - // LOCAL_REPO + groupId + "/" + artifactId + "/" + version + "/" + artifactId + "-" + version + - // "." - // + packaging); - // - // assertTrue(installedArtifact.exists()); - // - // File installedPom = new File( - // getBasedir(), - // LOCAL_REPO + groupId + "/" + artifactId + "/" + version + "/" + artifactId + "-" + version + - // "." - // + "pom"); - // - // assertTrue(installedPom.exists()); - - assertEquals(5, FileUtils.getFiles(new File(LOCAL_REPO), null, null).size()); - } - - public void testInstallFileWithPomAsPackaging(InstallFileMojo mojo) throws Exception { - // File testPom = new File( - // getBasedir(), "target/test-classes/unit/install-file-with-pom-as-packaging/" + - // "plugin-config.xml"); + File installedArtifact = new File( + localRepo, + "org/apache/maven/test/maven-install-file-test/1.0-SNAPSHOT/maven-install-file-test-1.0-SNAPSHOT.jar"); - // InstallFileMojo mojo = (InstallFileMojo) lookupMojo("install-file", testPom); + assertTrue( + installedArtifact.exists(), "Installed artifact should exist: " + installedArtifact.getAbsolutePath()); - assertNotNull(mojo); + File installedPom = new File( + localRepo, + "org/apache/maven/test/maven-install-file-test/1.0-SNAPSHOT/maven-install-file-test-1.0-SNAPSHOT.pom"); - // setVariableValueToObject(mojo, "session", createMavenSession(LOCAL_REPO)); + assertTrue(installedPom.exists(), "Installed pom should exist: " + installedPom.getAbsolutePath()); - // assertTrue(file.exists()); + // Compare the contents of the installed pom with the original pom file + assertEquals( + Files.readAllLines( + MojoExtension.getTestFile("plugin-config.xml").toPath()), + Files.readAllLines(installedPom.toPath())); - // assertEquals("pom", packaging); + assertEquals(5, FileUtils.getFiles(localRepo, null, null).size()); + } + @Test + @InjectMojo(goal = "install-file") + @MojoParameter(name = "packaging", value = "pom") + @MojoParameter(name = "file", value = "${basedir}/plugin-config.xml") + void testInstallFileWithPomAsPackaging(InstallFileMojo mojo) throws Exception { mojo.execute(); - // File installedPom = new File( - // getBasedir(), - // LOCAL_REPO + groupId + "/" + artifactId + "/" + version + "/" + artifactId + "-" + version + - // "." - // + "pom"); + File installedPom = new File( + localRepo, + "org/apache/maven/test/maven-install-file-test/1.0-SNAPSHOT/maven-install-file-test-1.0-SNAPSHOT.pom"); + + assertTrue(installedPom.exists(), "Installed pom should exist: " + installedPom.getAbsolutePath()); - // assertTrue(installedPom.exists()); + // Compare the contents of the installed pom with the original pom file + assertEquals( + Files.readAllLines( + MojoExtension.getTestFile("plugin-config.xml").toPath()), + Files.readAllLines(installedPom.toPath())); - assertEquals(4, FileUtils.getFiles(new File(LOCAL_REPO), null, null).size()); + assertEquals(4, FileUtils.getFiles(localRepo, null, null).size()); } } diff --git a/src/test/java/org/apache/maven/plugins/install/stubs/AttachedArtifactStub0.java b/src/test/java/org/apache/maven/plugins/install/stubs/AttachedArtifactStub0.java deleted file mode 100644 index 53f30b4e..00000000 --- a/src/test/java/org/apache/maven/plugins/install/stubs/AttachedArtifactStub0.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.maven.plugins.install.stubs; - -import java.io.File; - -public class AttachedArtifactStub0 extends InstallArtifactStub { - public String getArtifactId() { - return "attached-artifact-test-0"; - } - - public File getFile() { - return new File( - System.getProperty("basedir"), - "target/test-classes/unit/basic-install-test-with-attached-artifacts/" - + "target/maven-install-test-1.0-SNAPSHOT.jar"); - } -} diff --git a/src/test/java/org/apache/maven/plugins/install/stubs/AttachedArtifactStub1.java b/src/test/java/org/apache/maven/plugins/install/stubs/AttachedArtifactStub1.java deleted file mode 100644 index ad869b8c..00000000 --- a/src/test/java/org/apache/maven/plugins/install/stubs/AttachedArtifactStub1.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.maven.plugins.install.stubs; - -public class AttachedArtifactStub1 extends AttachedArtifactStub0 { - public String getArtifactId() { - return "attached-artifact-test-1"; - } -} diff --git a/src/test/java/org/apache/maven/plugins/install/stubs/InstallArtifactStub.java b/src/test/java/org/apache/maven/plugins/install/stubs/InstallArtifactStub.java deleted file mode 100644 index 46d58c48..00000000 --- a/src/test/java/org/apache/maven/plugins/install/stubs/InstallArtifactStub.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.maven.plugins.install.stubs; - -import java.io.File; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -import org.apache.maven.artifact.handler.ArtifactHandler; -import org.apache.maven.artifact.handler.DefaultArtifactHandler; -import org.apache.maven.artifact.metadata.ArtifactMetadata; -import org.apache.maven.plugin.testing.stubs.ArtifactStub; - -public class InstallArtifactStub extends ArtifactStub { - private Map metadataMap; - - private File file; - - private boolean release; - - public String getArtifactId() { - return "maven-install-test"; - } - - public String getGroupId() { - return "org.apache.maven.test"; - } - - public String getVersion() { - return "1.0-SNAPSHOT"; - } - - public String getBaseVersion() { - return getVersion(); - } - - public void setFile(File file) { - this.file = file; - } - - public File getFile() { - return file; - } - - public String getType() { - return "jar"; - } - - public ArtifactHandler getArtifactHandler() { - return new DefaultArtifactHandler() { - public String getExtension() { - return "jar"; - } - }; - } - - public void addMetadata(ArtifactMetadata metadata) { - if (metadataMap == null) { - metadataMap = new HashMap<>(); - } - - ArtifactMetadata m = metadataMap.get(metadata.getKey()); - if (m != null) { - m.merge(metadata); - } else { - metadataMap.put(metadata.getKey(), metadata); - } - } - - public Collection getMetadataList() { - return metadataMap == null ? Collections.emptyList() : metadataMap.values(); - } - - public boolean isRelease() { - return release; - } - - public void setRelease(boolean release) { - this.release = release; - } -} diff --git a/src/test/java/org/apache/maven/plugins/install/stubs/InstallBomArtifactStub.java b/src/test/java/org/apache/maven/plugins/install/stubs/InstallBomArtifactStub.java deleted file mode 100644 index 7980b95a..00000000 --- a/src/test/java/org/apache/maven/plugins/install/stubs/InstallBomArtifactStub.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.maven.plugins.install.stubs; - -import org.apache.maven.artifact.handler.ArtifactHandler; -import org.apache.maven.artifact.handler.DefaultArtifactHandler; - -public class InstallBomArtifactStub extends InstallArtifactStub { - - public String getType() { - return "bom"; - } - - public ArtifactHandler getArtifactHandler() { - return new DefaultArtifactHandler() { - public String getExtension() { - return "pom"; - } - }; - } -} diff --git a/src/test/java/org/apache/maven/plugins/install/stubs/InstallPomArtifactStub.java b/src/test/java/org/apache/maven/plugins/install/stubs/InstallPomArtifactStub.java deleted file mode 100644 index df6abd55..00000000 --- a/src/test/java/org/apache/maven/plugins/install/stubs/InstallPomArtifactStub.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.maven.plugins.install.stubs; - -import org.apache.maven.artifact.handler.ArtifactHandler; -import org.apache.maven.artifact.handler.DefaultArtifactHandler; - -public class InstallPomArtifactStub extends InstallArtifactStub { - - public String getType() { - return "pom"; - } - - public ArtifactHandler getArtifactHandler() { - return new DefaultArtifactHandler() { - public String getExtension() { - return "pom"; - } - }; - } -} diff --git a/src/test/resources/unit/basic-install-checksum/maven-test-jar.jar b/src/test/resources/unit/basic-install-checksum/maven-test-jar.jar deleted file mode 100644 index 5be54536..00000000 --- a/src/test/resources/unit/basic-install-checksum/maven-test-jar.jar +++ /dev/null @@ -1 +0,0 @@ -this is just a test jar \ No newline at end of file diff --git a/src/test/resources/unit/basic-install-checksum/plugin-config.xml b/src/test/resources/unit/basic-install-checksum/plugin-config.xml deleted file mode 100644 index 6b4b56c6..00000000 --- a/src/test/resources/unit/basic-install-checksum/plugin-config.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - maven-install-plugin - - - ${basedir}/src/test/resources/unit/basic-install-checksum/plugin-config.xml - jar - - - - - - - - diff --git a/src/test/resources/unit/basic-install-test-packaging-bom/plugin-config.xml b/src/test/resources/unit/basic-install-test-packaging-bom/plugin-config.xml deleted file mode 100644 index 6c08d07c..00000000 --- a/src/test/resources/unit/basic-install-test-packaging-bom/plugin-config.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - maven-install-plugin - - - ${basedir}/src/test/resources/unit/basic-install-test-packaging-bom/plugin-config.xml - bom - - - - - - - - diff --git a/src/test/resources/unit/basic-install-test-packaging-pom/plugin-config.xml b/src/test/resources/unit/basic-install-test-packaging-pom/plugin-config.xml deleted file mode 100644 index 647ddab7..00000000 --- a/src/test/resources/unit/basic-install-test-packaging-pom/plugin-config.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - maven-install-plugin - - - ${basedir}/src/test/resources/unit/basic-install-test-packaging-pom/plugin-config.xml - pom - - - - - - - - diff --git a/src/test/resources/unit/basic-install-test-with-attached-artifacts/plugin-config.xml b/src/test/resources/unit/basic-install-test-with-attached-artifacts/plugin-config.xml deleted file mode 100644 index 30113ec9..00000000 --- a/src/test/resources/unit/basic-install-test-with-attached-artifacts/plugin-config.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - maven-install-plugin - - - ${basedir}/src/test/resources/unit/basic-install-test-with-attached-artifacts/plugin-config.xml - jar - - ${basedir}/src/test/resources/unit/basic-install-test-with-attached-artifacts/plugin-config.xml - - - - - - - - - - - diff --git a/src/test/resources/unit/basic-install-test/target/maven-install-test-1.0-SNAPSHOT.jar b/src/test/resources/unit/basic-install-test/target/maven-install-test-1.0-SNAPSHOT.jar deleted file mode 100644 index 4a0e834e29ba17727a180d6ba70fdf6f845cd84c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2372 zcmWIWW@h1H0D;t?RueD-N^k;cU)K;vT~9wZ{Q#&k4u%w(Y*MaWyRGzVWFhvfs27e5rC<&Q(!-%be8B zm%cpuys`c<-={o|r@J$%dy~)cX)olx8sOF3X`sk`s%lacv#okznbBmo=4mRd$%{Sy zKmTLPTskxC>&H6<$8IviJj1|{jOJ$+pl9-n(&664RKX2ZkywzJoRNx0p&+Wl+{Cif zJUq(9uqiJ|EiQrU;Q+gKFPFT%AtM9BejrxBsV4-eQ7<_svADQ2@U$P3p@?nk#Kyu3 z4m&~L8;zacm<@Ir6q*JKbNn_k2{5{>xOBpg$XyqXw8}qlm&{k!Gr4&0$(?z{?`>Z` ze*F2Ztm~Y|CJvmvTxAz@7K5$?o=;kyq-?sqDD`JY!T|xE&09O4t}Rj) zRgcp-;@0vZ@LQq8BaYm*R~{0EqPMJG{IcM?c#zZicYS_aoAIO03&wT!ktcp^H>rt< zoO$W$CR5RGi}oxs`j;?en{)OOkCzo|?Niw5Uq&p-Tqpi_!xokEY<~@R-B{#a+8uZy zltcT-y1)gp0k+kw)ou$TYZ|}1I59FN_S&&rc_YZZ(Ui0K+|plu{{N*7UbvZRpjP`_MhfDWFX-Bz4f1Sy#oKirve4brL{xu@Mrd{%oUn6 zv6D;W`Y-TOn|tq5H; zo&$9^%v$%|w_$`u7YDff>e158t^<0o1Bl%y^k_j*enDzcNoHzsaGC#EZ(T1PPv1a~ zRUsdIb-d3$ej3EbUL?!iCBow)%EP;cM|Ulcj>w#5XOSKro--9YPX%>%8Grtq!~2z| zr1`H5bCc~K=Zc+|x<7ey+XUx)?!NR@h+Al~anRQy$73(2E)kplp-5G1YRWQIwdo9@ z4XvfdpS!$;ii=7VFEIpoGct)V<1V9t-UI>xhPRF&8lFHA+OU_|AjKfCq){D6!nGll z;0O~ii$PF92>~FBzW|w#ViVz1^r971a6$k`hZwN<0_lJkqqsGK3Q~kddsL0EY=~Ps zs9;5C&%>r2nqy#QU@vH4rYvb(gwqT}v5Opb=tTpl9Dx8(NC+|`g+8Wt&^3d~6@+Fx zOwG7T8JO>|moo?>8;La%YpDaX1$(&zbNZ6T>lD}mErk$4j6LroEIR;9t?&d631aM_ cgvCoB%Mc|&fHx}}$Xp&E>;ZaV5i5uX0NN - - - - - maven-install-plugin - - - ${basedir}/src/test/resources/unit/configured-install-test/plugin-config.xml - jar - - - - - - - - diff --git a/src/test/resources/unit/configured-install-test/target/maven-install-test-1.0-SNAPSHOT.jar b/src/test/resources/unit/configured-install-test/target/maven-install-test-1.0-SNAPSHOT.jar deleted file mode 100644 index 4a0e834e29ba17727a180d6ba70fdf6f845cd84c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2372 zcmWIWW@h1H0D;t?RueD-N^k;cU)K;vT~9wZ{Q#&k4u%w(Y*MaWyRGzVWFhvfs27e5rC<&Q(!-%be8B zm%cpuys`c<-={o|r@J$%dy~)cX)olx8sOF3X`sk`s%lacv#okznbBmo=4mRd$%{Sy zKmTLPTskxC>&H6<$8IviJj1|{jOJ$+pl9-n(&664RKX2ZkywzJoRNx0p&+Wl+{Cif zJUq(9uqiJ|EiQrU;Q+gKFPFT%AtM9BejrxBsV4-eQ7<_svADQ2@U$P3p@?nk#Kyu3 z4m&~L8;zacm<@Ir6q*JKbNn_k2{5{>xOBpg$XyqXw8}qlm&{k!Gr4&0$(?z{?`>Z` ze*F2Ztm~Y|CJvmvTxAz@7K5$?o=;kyq-?sqDD`JY!T|xE&09O4t}Rj) zRgcp-;@0vZ@LQq8BaYm*R~{0EqPMJG{IcM?c#zZicYS_aoAIO03&wT!ktcp^H>rt< zoO$W$CR5RGi}oxs`j;?en{)OOkCzo|?Niw5Uq&p-Tqpi_!xokEY<~@R-B{#a+8uZy zltcT-y1)gp0k+kw)ou$TYZ|}1I59FN_S&&rc_YZZ(Ui0K+|plu{{N*7UbvZRpjP`_MhfDWFX-Bz4f1Sy#oKirve4brL{xu@Mrd{%oUn6 zv6D;W`Y-TOn|tq5H; zo&$9^%v$%|w_$`u7YDff>e158t^<0o1Bl%y^k_j*enDzcNoHzsaGC#EZ(T1PPv1a~ zRUsdIb-d3$ej3EbUL?!iCBow)%EP;cM|Ulcj>w#5XOSKro--9YPX%>%8Grtq!~2z| zr1`H5bCc~K=Zc+|x<7ey+XUx)?!NR@h+Al~anRQy$73(2E)kplp-5G1YRWQIwdo9@ z4XvfdpS!$;ii=7VFEIpoGct)V<1V9t-UI>xhPRF&8lFHA+OU_|AjKfCq){D6!nGll z;0O~ii$PF92>~FBzW|w#ViVz1^r971a6$k`hZwN<0_lJkqqsGK3Q~kddsL0EY=~Ps zs9;5C&%>r2nqy#QU@vH4rYvb(gwqT}v5Opb=tTpl9Dx8(NC+|`g+8Wt&^3d~6@+Fx zOwG7T8JO>|moo?>8;La%YpDaX1$(&zbNZ6T>lD}mErk$4j6LroEIR;9t?&d631aM_ cgvCoB%Mc|&fHx}}$Xp&E>;ZaV5i5uX0NN - - - - - maven-install-plugin - - org.apache.maven.test - maven-install-file-test - 1.0-SNAPSHOT - jar - ${basedir}/target/test-classes/unit/install-file-basic-test/target/maven-install-test-1.0-SNAPSHOT.jar - - - - - - diff --git a/src/test/resources/unit/install-file-basic-test/target/maven-install-test-1.0-SNAPSHOT.jar b/src/test/resources/unit/install-file-basic-test/target/maven-install-test-1.0-SNAPSHOT.jar deleted file mode 100644 index 4a0e834e29ba17727a180d6ba70fdf6f845cd84c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2372 zcmWIWW@h1H0D;t?RueD-N^k;cU)K;vT~9wZ{Q#&k4u%w(Y*MaWyRGzVWFhvfs27e5rC<&Q(!-%be8B zm%cpuys`c<-={o|r@J$%dy~)cX)olx8sOF3X`sk`s%lacv#okznbBmo=4mRd$%{Sy zKmTLPTskxC>&H6<$8IviJj1|{jOJ$+pl9-n(&664RKX2ZkywzJoRNx0p&+Wl+{Cif zJUq(9uqiJ|EiQrU;Q+gKFPFT%AtM9BejrxBsV4-eQ7<_svADQ2@U$P3p@?nk#Kyu3 z4m&~L8;zacm<@Ir6q*JKbNn_k2{5{>xOBpg$XyqXw8}qlm&{k!Gr4&0$(?z{?`>Z` ze*F2Ztm~Y|CJvmvTxAz@7K5$?o=;kyq-?sqDD`JY!T|xE&09O4t}Rj) zRgcp-;@0vZ@LQq8BaYm*R~{0EqPMJG{IcM?c#zZicYS_aoAIO03&wT!ktcp^H>rt< zoO$W$CR5RGi}oxs`j;?en{)OOkCzo|?Niw5Uq&p-Tqpi_!xokEY<~@R-B{#a+8uZy zltcT-y1)gp0k+kw)ou$TYZ|}1I59FN_S&&rc_YZZ(Ui0K+|plu{{N*7UbvZRpjP`_MhfDWFX-Bz4f1Sy#oKirve4brL{xu@Mrd{%oUn6 zv6D;W`Y-TOn|tq5H; zo&$9^%v$%|w_$`u7YDff>e158t^<0o1Bl%y^k_j*enDzcNoHzsaGC#EZ(T1PPv1a~ zRUsdIb-d3$ej3EbUL?!iCBow)%EP;cM|Ulcj>w#5XOSKro--9YPX%>%8Grtq!~2z| zr1`H5bCc~K=Zc+|x<7ey+XUx)?!NR@h+Al~anRQy$73(2E)kplp-5G1YRWQIwdo9@ z4XvfdpS!$;ii=7VFEIpoGct)V<1V9t-UI>xhPRF&8lFHA+OU_|AjKfCq){D6!nGll z;0O~ii$PF92>~FBzW|w#ViVz1^r971a6$k`hZwN<0_lJkqqsGK3Q~kddsL0EY=~Ps zs9;5C&%>r2nqy#QU@vH4rYvb(gwqT}v5Opb=tTpl9Dx8(NC+|`g+8Wt&^3d~6@+Fx zOwG7T8JO>|moo?>8;La%YpDaX1$(&zbNZ6T>lD}mErk$4j6LroEIR;9t?&d631aM_ cgvCoB%Mc|&fHx}}$Xp&E>;ZaV5i5uX0NN - - - - - maven-install-plugin - - org.apache.maven.test - maven-install-test - 1.0-SNAPSHOT - jar - ${basedir}/target/test-classes/unit/install-file-from-local-repository-test/target/org/apache/maven/test/maven-install-test/1.0-SNAPSHOT/maven-install-test-1.0-SNAPSHOT.jar - - - - - - diff --git a/src/test/resources/unit/install-file-from-local-repository-test/target/org/apache/maven/test/maven-install-test/1.0-SNAPSHOT/maven-install-test-1.0-SNAPSHOT.jar b/src/test/resources/unit/install-file-from-local-repository-test/target/org/apache/maven/test/maven-install-test/1.0-SNAPSHOT/maven-install-test-1.0-SNAPSHOT.jar deleted file mode 100644 index 4a0e834e29ba17727a180d6ba70fdf6f845cd84c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2372 zcmWIWW@h1H0D;t?RueD-N^k;cU)K;vT~9wZ{Q#&k4u%w(Y*MaWyRGzVWFhvfs27e5rC<&Q(!-%be8B zm%cpuys`c<-={o|r@J$%dy~)cX)olx8sOF3X`sk`s%lacv#okznbBmo=4mRd$%{Sy zKmTLPTskxC>&H6<$8IviJj1|{jOJ$+pl9-n(&664RKX2ZkywzJoRNx0p&+Wl+{Cif zJUq(9uqiJ|EiQrU;Q+gKFPFT%AtM9BejrxBsV4-eQ7<_svADQ2@U$P3p@?nk#Kyu3 z4m&~L8;zacm<@Ir6q*JKbNn_k2{5{>xOBpg$XyqXw8}qlm&{k!Gr4&0$(?z{?`>Z` ze*F2Ztm~Y|CJvmvTxAz@7K5$?o=;kyq-?sqDD`JY!T|xE&09O4t}Rj) zRgcp-;@0vZ@LQq8BaYm*R~{0EqPMJG{IcM?c#zZicYS_aoAIO03&wT!ktcp^H>rt< zoO$W$CR5RGi}oxs`j;?en{)OOkCzo|?Niw5Uq&p-Tqpi_!xokEY<~@R-B{#a+8uZy zltcT-y1)gp0k+kw)ou$TYZ|}1I59FN_S&&rc_YZZ(Ui0K+|plu{{N*7UbvZRpjP`_MhfDWFX-Bz4f1Sy#oKirve4brL{xu@Mrd{%oUn6 zv6D;W`Y-TOn|tq5H; zo&$9^%v$%|w_$`u7YDff>e158t^<0o1Bl%y^k_j*enDzcNoHzsaGC#EZ(T1PPv1a~ zRUsdIb-d3$ej3EbUL?!iCBow)%EP;cM|Ulcj>w#5XOSKro--9YPX%>%8Grtq!~2z| zr1`H5bCc~K=Zc+|x<7ey+XUx)?!NR@h+Al~anRQy$73(2E)kplp-5G1YRWQIwdo9@ z4XvfdpS!$;ii=7VFEIpoGct)V<1V9t-UI>xhPRF&8lFHA+OU_|AjKfCq){D6!nGll z;0O~ii$PF92>~FBzW|w#ViVz1^r971a6$k`hZwN<0_lJkqqsGK3Q~kddsL0EY=~Ps zs9;5C&%>r2nqy#QU@vH4rYvb(gwqT}v5Opb=tTpl9Dx8(NC+|`g+8Wt&^3d~6@+Fx zOwG7T8JO>|moo?>8;La%YpDaX1$(&zbNZ6T>lD}mErk$4j6LroEIR;9t?&d631aM_ cgvCoB%Mc|&fHx}}$Xp&E>;ZaV5i5uX0NN - - - - - maven-install-plugin - - org.apache.maven.test - maven-install-file-test - 1.0-SNAPSHOT - jar - - ${basedir}/src/test/resources/unit/install-file-test-generatePom/target/maven-install-test-1.0-SNAPSHOT.jar - - true - - - - - diff --git a/src/test/resources/unit/install-file-test-generatePom/target/maven-install-test-1.0-SNAPSHOT.jar b/src/test/resources/unit/install-file-test-generatePom/target/maven-install-test-1.0-SNAPSHOT.jar deleted file mode 100644 index 9c1e111664811cd02729e2a2da3e7a0a23c91117..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1244 zcmWIWW@h1H0D;t?RueD-N^k;cU)K;vT~9wZ{Q#&k4u%w(Y*MaWyRGzVWFhvfs27e5rC<&Q(!-%be8B zm%cpuys`c<-={o|r@J$%dy~)cX)olx8sOF3X`sk`s%lacv#okznbBmo=4mRd$%{Sy zKmTLPTskxC>&H6<$8IviJj1|{jOJ$+pl9-n(&664RKX2ZkywzJoRNx0p&+Wl+{Cif zJUq(9uqiJ|EiQrU;Q+gKFPFT%AtM9BejrxBsV4-eQ7<_svADQ2@U$P3p@?nk#Kyu3 z4m&~L8;zacm<@Ir6q*JKbNn_k2{5{>xOBpg$XyqXw8}qlm&{k!Gr4&0$(?z{?`>Z` ze*F2Ztm~Y|CJvmvTxAz@7K5$?o=;kyq-?sqDD`JY!T|xE&09O4t}Rj) zRgcp-;@0vZ@LQq8BaYm*R~{0EqPMJG{IcM?c#zZicYS_aoAIO03&wT!ktcp^H>rt< zoO$W$CR5RGi}oxs`j;?en{)OOkCzo|?Niw5Uq&p-Tqpi_!xokEY<~@R-B{#a+8uZy zltcT-y1)gp0k+kw)ou$TYZ|}1I59FN_S&&rc_YZZ(U{$XB=0G68@YWGTBV`bnHtbmhq!2}z|e zJF%xzgbp!aY60nhr&`<^LFpEu(H>PJEEVI{4ob%e?RnU=LsK=(4D9I|X3CPrML5ks Wr1Ai7RyL3hb|BmeR4>R3;sF34m0>vm diff --git a/src/test/resources/unit/basic-install-test/plugin-config.xml b/src/test/resources/unit/install-file-test/plugin-config.xml similarity index 100% rename from src/test/resources/unit/basic-install-test/plugin-config.xml rename to src/test/resources/unit/install-file-test/plugin-config.xml diff --git a/src/test/resources/unit/basic-install-test-with-attached-artifacts/target/maven-install-test-1.0-SNAPSHOT.jar b/src/test/resources/unit/install-file-test/target/maven-install-test-1.0-SNAPSHOT.jar similarity index 100% rename from src/test/resources/unit/basic-install-test-with-attached-artifacts/target/maven-install-test-1.0-SNAPSHOT.jar rename to src/test/resources/unit/install-file-test/target/maven-install-test-1.0-SNAPSHOT.jar diff --git a/src/test/resources/unit/install-file-with-checksum/maven-test-jar.jar b/src/test/resources/unit/install-file-with-checksum/maven-test-jar.jar deleted file mode 100644 index 5be54536..00000000 --- a/src/test/resources/unit/install-file-with-checksum/maven-test-jar.jar +++ /dev/null @@ -1 +0,0 @@ -this is just a test jar \ No newline at end of file diff --git a/src/test/resources/unit/install-file-with-checksum/plugin-config.xml b/src/test/resources/unit/install-file-with-checksum/plugin-config.xml deleted file mode 100644 index 91655ef7..00000000 --- a/src/test/resources/unit/install-file-with-checksum/plugin-config.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - maven-install-plugin - - org.apache.maven.test - maven-install-file-test - 1.0-SNAPSHOT - jar - ${basedir}/src/test/resources/unit/install-file-with-checksum/maven-test-jar.jar - true - - - - - diff --git a/src/test/resources/unit/install-file-with-classifier/plugin-config.xml b/src/test/resources/unit/install-file-with-classifier/plugin-config.xml deleted file mode 100644 index 8d6a18e6..00000000 --- a/src/test/resources/unit/install-file-with-classifier/plugin-config.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - maven-install-plugin - - org.apache.maven.test - maven-install-file-test - 1.0-SNAPSHOT - jar - sources - ${basedir}/target/test-classes/unit/install-file-with-classifier/target/maven-install-test-1.0-SNAPSHOT.jar - - - - - - diff --git a/src/test/resources/unit/install-file-with-classifier/target/maven-install-test-1.0-SNAPSHOT.jar b/src/test/resources/unit/install-file-with-classifier/target/maven-install-test-1.0-SNAPSHOT.jar deleted file mode 100644 index 4a0e834e29ba17727a180d6ba70fdf6f845cd84c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2372 zcmWIWW@h1H0D;t?RueD-N^k;cU)K;vT~9wZ{Q#&k4u%w(Y*MaWyRGzVWFhvfs27e5rC<&Q(!-%be8B zm%cpuys`c<-={o|r@J$%dy~)cX)olx8sOF3X`sk`s%lacv#okznbBmo=4mRd$%{Sy zKmTLPTskxC>&H6<$8IviJj1|{jOJ$+pl9-n(&664RKX2ZkywzJoRNx0p&+Wl+{Cif zJUq(9uqiJ|EiQrU;Q+gKFPFT%AtM9BejrxBsV4-eQ7<_svADQ2@U$P3p@?nk#Kyu3 z4m&~L8;zacm<@Ir6q*JKbNn_k2{5{>xOBpg$XyqXw8}qlm&{k!Gr4&0$(?z{?`>Z` ze*F2Ztm~Y|CJvmvTxAz@7K5$?o=;kyq-?sqDD`JY!T|xE&09O4t}Rj) zRgcp-;@0vZ@LQq8BaYm*R~{0EqPMJG{IcM?c#zZicYS_aoAIO03&wT!ktcp^H>rt< zoO$W$CR5RGi}oxs`j;?en{)OOkCzo|?Niw5Uq&p-Tqpi_!xokEY<~@R-B{#a+8uZy zltcT-y1)gp0k+kw)ou$TYZ|}1I59FN_S&&rc_YZZ(Ui0K+|plu{{N*7UbvZRpjP`_MhfDWFX-Bz4f1Sy#oKirve4brL{xu@Mrd{%oUn6 zv6D;W`Y-TOn|tq5H; zo&$9^%v$%|w_$`u7YDff>e158t^<0o1Bl%y^k_j*enDzcNoHzsaGC#EZ(T1PPv1a~ zRUsdIb-d3$ej3EbUL?!iCBow)%EP;cM|Ulcj>w#5XOSKro--9YPX%>%8Grtq!~2z| zr1`H5bCc~K=Zc+|x<7ey+XUx)?!NR@h+Al~anRQy$73(2E)kplp-5G1YRWQIwdo9@ z4XvfdpS!$;ii=7VFEIpoGct)V<1V9t-UI>xhPRF&8lFHA+OU_|AjKfCq){D6!nGll z;0O~ii$PF92>~FBzW|w#ViVz1^r971a6$k`hZwN<0_lJkqqsGK3Q~kddsL0EY=~Ps zs9;5C&%>r2nqy#QU@vH4rYvb(gwqT}v5Opb=tTpl9Dx8(NC+|`g+8Wt&^3d~6@+Fx zOwG7T8JO>|moo?>8;La%YpDaX1$(&zbNZ6T>lD}mErk$4j6LroEIR;9t?&d631aM_ cgvCoB%Mc|&fHx}}$Xp&E>;ZaV5i5uX0NN - - - - - maven-install-plugin - - org.apache.maven.test - maven-install-file-test - 1.0-SNAPSHOT - pom - ${basedir}/src/test/resources/unit/install-file-with-pomFile-test/plugin-config.xml - - - - - diff --git a/src/test/resources/unit/install-file-with-pomFile-test/plugin-config.xml b/src/test/resources/unit/install-file-with-pomFile-test/plugin-config.xml deleted file mode 100644 index fc7c1080f71b281be7b01129735bcaf0dbe13ff3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2934 zcmd6pO>Yx-5XR^1PqB?SPzl?VLl4Cb3XrH#kwGN1%F%IR$6#+8Z34(u1}*;DQblGMhWUm;Cx z>e3H(ZYS17>sNGM*r9ds_Y)^wp5CB2cDszpYae<<(#0KV%6cUw}syoMLDO~ukdh*g>sO_yp~-;j49{W zTnqkWkx_fXb>^pK-a~s!-KX}-j*(9AGe@K2$YixhQS}xL)f^sX_)Vx%S$uN)$Y+GT zuq`Sbc}Ilx#B~=H6gr;i)R8Ls5tT0O4%v)aZtx^jwvLOsdc*lLujxETJ+N$|p$wIA zkCym~fF-UgU5Kqty@_pWqIS?oyi;p3`px=WTfcf}l+)3}+lrp{8?4PZd6P472v3ihyFgUFKTw^R znK|Rc?SDXP=G@UVUV5I26KITydFdA7!-zaog=VFkjdF^k<}LEztaic^qGn!sb&kc* zwz+8IPZOtL;64wUY-N`c_rUi;0vcz&uU`7Q-o(4VIX|~Qm|X2Fy&u_ot|J@zEFYtn zAbrp8EAB&k?G~s09I_K+(!U_upGc)6-`9?SwwSOI=a!Cf;2sFh*eZdtc0&7JY1STd zUvNmsF7ZAlnkI5gEOkk^Z@fcd?G*H5i>K&Fmblf5_`_Fgr_l2 zryfJoDGX9F3*V}2&eioE6fp-(PrHYE$P4ckmIYRAxkUx~kD^_<%rlEAZq9a@ zZx5fE*EOj1iBq@U%_^d_*HC)hMWNW}-CDeMKl`HAzZDMiFNH31G-OKNao4n+dnHZX zeLiF3eFEEH#S~V2^d1S1Ht9Z3MTPr%Bjg_0e{gdI-kM46#s7(taUXLpI??A{Jy9Pe z(Q}_?&DWZzCc}!z-TVJ3V%;qhc7m? zf2-_6Wzfj<@Q1*tx+l7HKwDoZPr)I+T!S4|jN2-dR@M69DGs0IhN^mO%F68}iM}$+ KeHXg5&G-!tq2+)8 diff --git a/src/test/resources/unit/install-file-with-pomFile-test/target/maven-install-test-1.0-SNAPSHOT.jar b/src/test/resources/unit/install-file-with-pomFile-test/target/maven-install-test-1.0-SNAPSHOT.jar deleted file mode 100644 index 4a0e834e29ba17727a180d6ba70fdf6f845cd84c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2372 zcmWIWW@h1H0D;t?RueD-N^k;cU)K;vT~9wZ{Q#&k4u%w(Y*MaWyRGzVWFhvfs27e5rC<&Q(!-%be8B zm%cpuys`c<-={o|r@J$%dy~)cX)olx8sOF3X`sk`s%lacv#okznbBmo=4mRd$%{Sy zKmTLPTskxC>&H6<$8IviJj1|{jOJ$+pl9-n(&664RKX2ZkywzJoRNx0p&+Wl+{Cif zJUq(9uqiJ|EiQrU;Q+gKFPFT%AtM9BejrxBsV4-eQ7<_svADQ2@U$P3p@?nk#Kyu3 z4m&~L8;zacm<@Ir6q*JKbNn_k2{5{>xOBpg$XyqXw8}qlm&{k!Gr4&0$(?z{?`>Z` ze*F2Ztm~Y|CJvmvTxAz@7K5$?o=;kyq-?sqDD`JY!T|xE&09O4t}Rj) zRgcp-;@0vZ@LQq8BaYm*R~{0EqPMJG{IcM?c#zZicYS_aoAIO03&wT!ktcp^H>rt< zoO$W$CR5RGi}oxs`j;?en{)OOkCzo|?Niw5Uq&p-Tqpi_!xokEY<~@R-B{#a+8uZy zltcT-y1)gp0k+kw)ou$TYZ|}1I59FN_S&&rc_YZZ(Ui0K+|plu{{N*7UbvZRpjP`_MhfDWFX-Bz4f1Sy#oKirve4brL{xu@Mrd{%oUn6 zv6D;W`Y-TOn|tq5H; zo&$9^%v$%|w_$`u7YDff>e158t^<0o1Bl%y^k_j*enDzcNoHzsaGC#EZ(T1PPv1a~ zRUsdIb-d3$ej3EbUL?!iCBow)%EP;cM|Ulcj>w#5XOSKro--9YPX%>%8Grtq!~2z| zr1`H5bCc~K=Zc+|x<7ey+XUx)?!NR@h+Al~anRQy$73(2E)kplp-5G1YRWQIwdo9@ z4XvfdpS!$;ii=7VFEIpoGct)V<1V9t-UI>xhPRF&8lFHA+OU_|AjKfCq){D6!nGll z;0O~ii$PF92>~FBzW|w#ViVz1^r971a6$k`hZwN<0_lJkqqsGK3Q~kddsL0EY=~Ps zs9;5C&%>r2nqy#QU@vH4rYvb(gwqT}v5Opb=tTpl9Dx8(NC+|`g+8Wt&^3d~6@+Fx zOwG7T8JO>|moo?>8;La%YpDaX1$(&zbNZ6T>lD}mErk$4j6LroEIR;9t?&d631aM_ cgvCoB%Mc|&fHx}}$Xp&E>;ZaV5i5uX0NN