This is an automated email from the ASF dual-hosted git repository.
slachiewicz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-install-plugin.git
The following commit(s) were added to refs/heads/master by this push:
new c7fc51c Align converted test case names with 4.x and share checksum
helper
c7fc51c is described below
commit c7fc51c0aa9922205209eef7d3bbf4985483da5f
Author: Sylwester Lachiewicz <[email protected]>
AuthorDate: Sat Nov 21 14:42:42 2026 +0100
Align converted test case names with 4.x and share checksum helper
Part of #497
---
.../maven/plugins/install/InstallFileMojoTest.java | 26 ++++-------
.../maven/plugins/install/InstallMojoTest.java | 21 +++------
.../maven/plugins/install/InstallTestHelper.java | 50 ++++++++++++++++++++++
3 files changed, 66 insertions(+), 31 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 c9cf2e6..06ebcde 100644
--- a/src/test/java/org/apache/maven/plugins/install/InstallFileMojoTest.java
+++ b/src/test/java/org/apache/maven/plugins/install/InstallFileMojoTest.java
@@ -472,7 +472,7 @@ public class InstallFileMojoTest {
@InjectMojo(goal = "install-file")
@MojoParameter(name = "packaging", value = "jar")
@MojoParameter(name = "file", value =
"${basedir}/target/maven-install-test-1.0-SNAPSHOT.jar")
- void installFileWithInvalidGav(InstallFileMojo mojo) throws Exception {
+ void invalidGavRejectedAndNothingInstalled(InstallFileMojo mojo) throws
Exception {
setMojoField(mojo, "groupId", "invalid~group");
setMojoField(mojo, "artifactId", "invalid/artifactId");
setMojoField(mojo, "version", "1+");
@@ -485,7 +485,7 @@ public class InstallFileMojoTest {
@Test
@InjectMojo(goal = "install-file")
@MojoParameter(name = "file", value =
"${basedir}/target/maven-install-test-1.0-SNAPSHOT.jar")
- void installFileWithMissingGav(InstallFileMojo mojo) throws Exception {
+ void missingCoordinatesRejectedAndNothingInstalled(InstallFileMojo mojo)
throws Exception {
setMojoField(mojo, "groupId", "groupId");
setMojoField(mojo, "artifactId", null);
setMojoField(mojo, "version", null);
@@ -502,7 +502,7 @@ public class InstallFileMojoTest {
@InjectMojo(goal = "install-file")
@MojoParameter(name = "packaging", value = "jar")
@MojoParameter(name = "file", value =
"${basedir}/target/maven-install-test-1.0-SNAPSHOT.jar")
- void installFileGeneratesPomAutomatically(InstallFileMojo mojo) throws
Exception {
+ void generatePomAutoInstallsJarAndPom(InstallFileMojo mojo) throws
Exception {
mojo.execute();
assertInstalled(
@@ -520,7 +520,7 @@ public class InstallFileMojoTest {
@InjectMojo(goal = "install-file")
@MojoParameter(name = "packaging", value = "jar")
@MojoParameter(name = "file", value =
"${basedir}/target/maven-install-test-1.0-SNAPSHOT.jar")
- void installFileDoesNotOverwriteExistingPom(InstallFileMojo mojo) throws
Exception {
+ void existingPomNotOverwrittenWhenGeneratePomAuto(InstallFileMojo mojo)
throws Exception {
File pom = new File(
localRepo,
"org/apache/maven/test/maven-install-file-test/1.0-SNAPSHOT/maven-install-file-test-1.0-SNAPSHOT.pom");
@@ -551,7 +551,7 @@ public class InstallFileMojoTest {
@MojoParameter(name = "version", value = "0.1")
@MojoParameter(name = "packaging", value = "jar")
@MojoParameter(name = "file", value =
"${basedir}/target/maven-install-test-1.0-SNAPSHOT.jar")
- void
installFileToLocalRepositoryOverrideDoesNotCreateChecksums(InstallFileMojo
mojo) throws Exception {
+ void installFileIntoOverriddenLocalRepositoryNoChecksums(InstallFileMojo
mojo) throws Exception {
File overrideRepo =
tempDir.resolve("target/local-repo").toAbsolutePath().toFile();
setMojoField(mojo, "localRepositoryPath", overrideRepo);
@@ -560,7 +560,7 @@ public class InstallFileMojoTest {
String jarPath = "gid/test/0.1/test-0.1.jar";
assertInstalled(overrideRepo, jarPath);
- assertNoChecksum(overrideRepo, jarPath);
+ InstallTestHelper.assertNoChecksum(overrideRepo, jarPath);
assertFalse(new File(localRepo, jarPath).exists(), "The artifact
should only be installed in " + overrideRepo);
}
@@ -572,8 +572,7 @@ public class InstallFileMojoTest {
@MojoParameter(name = "packaging", value = "jar")
@MojoParameter(name = "generatePom", value = "true")
@MojoParameter(name = "file", value =
"${basedir}/target/maven-install-test-1.0-SNAPSHOT.jar")
- void
installFileToLocalRepositoryOverrideWithGeneratedPomDoesNotCreateChecksums(InstallFileMojo
mojo)
- throws Exception {
+ void
installFileIntoOverriddenLocalRepositoryWithGeneratedPomNoChecksums(InstallFileMojo
mojo) throws Exception {
File overrideRepo =
tempDir.resolve("target/local-repo").toAbsolutePath().toFile();
setMojoField(mojo, "localRepositoryPath", overrideRepo);
@@ -584,8 +583,8 @@ public class InstallFileMojoTest {
String pomPath = "gid/test/0.1/test-0.1.pom";
assertInstalled(overrideRepo, jarPath);
assertInstalled(overrideRepo, pomPath);
- assertNoChecksum(overrideRepo, jarPath);
- assertNoChecksum(overrideRepo, pomPath);
+ InstallTestHelper.assertNoChecksum(overrideRepo, jarPath);
+ InstallTestHelper.assertNoChecksum(overrideRepo, pomPath);
assertFalse(new File(localRepo, jarPath).exists(), "The artifact
should only be installed in " + overrideRepo);
}
@@ -594,13 +593,6 @@ public class InstallFileMojoTest {
assertTrue(installed.isFile(), "Missing installed file: " + installed);
}
- private void assertNoChecksum(File repo, String path) {
- File md5 = new File(repo, path + ".md5");
- File sha1 = new File(repo, path + ".sha1");
- assertFalse(md5.exists(), "Unexpected checksum: " + md5);
- assertFalse(sha1.exists(), "Unexpected checksum: " + sha1);
- }
-
//
-------------------------------------------------------------------------
// Helpers
//
-------------------------------------------------------------------------
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 2e2d332..36ef131 100644
--- a/src/test/java/org/apache/maven/plugins/install/InstallMojoTest.java
+++ b/src/test/java/org/apache/maven/plugins/install/InstallMojoTest.java
@@ -259,7 +259,7 @@ class InstallMojoTest {
@Test
@InjectMojo(goal = "install")
@MojoParameter(name = "skip", value = "true")
- void testSkip(InstallMojo mojo) throws Exception {
+ void skip(InstallMojo mojo) throws Exception {
mojo.setPluginContext(new HashMap<>());
mavenProject.setGroupId("org.apache.maven.its.install.skip");
mavenProject.setArtifactId("test");
@@ -293,19 +293,19 @@ class InstallMojoTest {
@Test
@InjectMojo(goal = "install")
- void installWithNoMainArtifactAndAttachmentsWithoutClassesDir(InstallMojo
mojo) throws Exception {
+ void noMainArtifactWithAttachmentsFailsWhenOutputDirMissing(InstallMojo
mojo) throws Exception {
assertNoMainArtifactWithAttachments(mojo, false);
}
@Test
@InjectMojo(goal = "install")
- void installWithNoMainArtifactAndAttachmentsWithClassesDir(InstallMojo
mojo) throws Exception {
+ void noMainArtifactWithAttachmentsFailsWhenOutputDirPresent(InstallMojo
mojo) throws Exception {
assertNoMainArtifactWithAttachments(mojo, true);
}
@Test
@InjectMojo(goal = "install")
- void installWithAttachedArtifactDoesNotCreateChecksums(InstallMojo mojo)
throws Exception {
+ void attachedJarInstalledWithoutChecksums(InstallMojo mojo) throws
Exception {
mojo.setPluginContext(new HashMap<>());
mavenProject.setGroupId("org.apache.maven.its.install.ajc");
mavenProject.setArtifactId("test");
@@ -330,13 +330,13 @@ class InstallMojoTest {
};
for (String path : installed) {
assertInstalled(localRepo, path);
- assertNoChecksum(localRepo, path);
+ InstallTestHelper.assertNoChecksum(localRepo, path);
}
}
@Test
@InjectMojo(goal = "install")
- void installPomDoesNotCreateChecksums(InstallMojo mojo) throws Exception {
+ void pomPackagingInstalledWithoutChecksums(InstallMojo mojo) throws
Exception {
mojo.setPluginContext(new HashMap<>());
mavenProject.setGroupId("org.apache.maven.its.install.pc");
mavenProject.setArtifactId("test");
@@ -355,7 +355,7 @@ class InstallMojoTest {
for (String path : installed) {
assertInstalled(localRepo, path);
}
- assertNoChecksum(localRepo, versionDir + "test-1.0-SNAPSHOT.pom");
+ InstallTestHelper.assertNoChecksum(localRepo, versionDir +
"test-1.0-SNAPSHOT.pom");
}
private void assertNoMainArtifactWithAttachments(InstallMojo mojo, boolean
classesDirPresent) throws Exception {
@@ -400,13 +400,6 @@ class InstallMojoTest {
assertFalse(installed.isFile(), "File should not be installed: " +
installed);
}
- private void assertNoChecksum(File repo, String path) {
- File md5 = new File(repo, path + ".md5");
- File sha1 = new File(repo, path + ".sha1");
- assertFalse(md5.exists(), "Unexpected checksum: " + md5);
- assertFalse(sha1.exists(), "Unexpected checksum: " + sha1);
- }
-
private String dotToSlashReplacer(String parameter) {
return parameter.replace('.', '/');
}
diff --git
a/src/test/java/org/apache/maven/plugins/install/InstallTestHelper.java
b/src/test/java/org/apache/maven/plugins/install/InstallTestHelper.java
new file mode 100644
index 0000000..bcf03ba
--- /dev/null
+++ b/src/test/java/org/apache/maven/plugins/install/InstallTestHelper.java
@@ -0,0 +1,50 @@
+/*
+ * 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;
+
+import java.io.File;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.stream.Stream;
+
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+class InstallTestHelper {
+ static void assertNoChecksumFiles(Path repositoryRoot) throws Exception {
+ if (!Files.exists(repositoryRoot)) {
+ return;
+ }
+ try (Stream<Path> paths = Files.walk(repositoryRoot)) {
+ assertTrue(
+ paths.noneMatch(p -> {
+ String name = p.getFileName().toString();
+ return name.endsWith(".md5") || name.endsWith(".sha1");
+ }),
+ "no .md5/.sha1 checksum files should be created");
+ }
+ }
+
+ static void assertNoChecksum(File repo, String path) {
+ File md5 = new File(repo, path + ".md5");
+ File sha1 = new File(repo, path + ".sha1");
+ assertFalse(md5.exists(), "Unexpected checksum: " + md5);
+ assertFalse(sha1.exists(), "Unexpected checksum: " + sha1);
+ }
+}