This is an automated email from the ASF dual-hosted git repository.

garydgregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-release-plugin.git


The following commit(s) were added to refs/heads/master by this push:
     new b08b700  Add 
CommonsDistributionDetachmentMojoTest.testSha512PropertiesInVoteTxt()
b08b700 is described below

commit b08b700118022c11b7d5a93d824b045169939b5a
Author: Gary Gregory <[email protected]>
AuthorDate: Sun Nov 8 10:33:09 2026 -0500

    Add CommonsDistributionDetachmentMojoTest.testSha512PropertiesInVoteTxt()
---
 .../CommonsDistributionDetachmentMojoTest.java     | 64 ++++++++++++++++++++++
 1 file changed, 64 insertions(+)

diff --git 
a/src/test/java/org/apache/commons/release/plugin/mojos/CommonsDistributionDetachmentMojoTest.java
 
b/src/test/java/org/apache/commons/release/plugin/mojos/CommonsDistributionDetachmentMojoTest.java
index 81002ec..4f9a181 100644
--- 
a/src/test/java/org/apache/commons/release/plugin/mojos/CommonsDistributionDetachmentMojoTest.java
+++ 
b/src/test/java/org/apache/commons/release/plugin/mojos/CommonsDistributionDetachmentMojoTest.java
@@ -18,14 +18,26 @@ package org.apache.commons.release.plugin.mojos;
 
 import static junit.framework.TestCase.assertTrue;
 import static org.junit.Assert.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import java.io.File;
+import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.security.MessageDigest;
+import java.util.Properties;
 
+import org.apache.commons.codec.binary.Hex;
 import org.apache.maven.api.plugin.testing.InjectMojo;
 import org.apache.maven.api.plugin.testing.MojoTest;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.ProjectHelper;
+import org.apache.tools.ant.taskdefs.ExecTask;
 import org.codehaus.plexus.util.FileUtils;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
 
 /**
  * Unit tests for {@link CommonsDistributionDetachmentMojo}.
@@ -33,6 +45,17 @@ import org.junit.jupiter.api.Test;
 @MojoTest
 public class CommonsDistributionDetachmentMojoTest {
 
+    /**
+     * Replaces the vote target's external SVN and Git commands.
+     */
+    public static class StubExecTask extends ExecTask {
+
+        @Override
+        public void execute() {
+            // Repository metadata is unrelated to checksum rendering.
+        }
+    }
+
     private static final String COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH = 
"target/testing-commons-release-plugin";
 
     @BeforeEach
@@ -51,6 +74,47 @@ public class CommonsDistributionDetachmentMojoTest {
         assertFalse(testingDirectory.exists());
     }
 
+    @Test
+    @InjectMojo(goal = "detach-distributions", pom = 
"src/test/resources/mojos/detach-distributions/detach-distributions.xml")
+    public void testSha512PropertiesInVoteTxt(final 
CommonsDistributionDetachmentMojo mojo, @TempDir final Path directory) throws 
Exception {
+        mojo.execute();
+        final Path sha512File = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH, 
"sha512.properties").toPath();
+        final Properties actual = new Properties();
+        try (InputStream input = Files.newInputStream(sha512File)) {
+            actual.load(input);
+        }
+        final Properties expected = new Properties();
+        final String[] suffixes = {"-bin.tar.gz", "-bin.zip", "-src.tar.gz", 
"-src.zip", ".jar", ".pom", "-javadoc.jar", "-sources.jar"};
+        for (final String suffix : suffixes) {
+            final String name = "commons-text-1.4" + suffix;
+            final Path artifact = new 
File("src/test/resources/mojos/detach-distributions/target", name).toPath();
+            expected.setProperty(name, 
Hex.encodeHexString(MessageDigest.getInstance("SHA-512").digest(Files.readAllBytes(artifact))));
+        }
+        // Exact equality also excludes signatures and unexpected artifacts.
+        assertEquals(expected, actual);
+
+        final Path voteChecksums = 
directory.resolve("target/commons-release-plugin/sha512.properties");
+        Files.createDirectories(voteChecksums.getParent());
+        Files.copy(sha512File, voteChecksums);
+        final Project project = new Project();
+        project.init();
+        ProjectHelper.configureProject(project, new 
File("src/main/scripts/generate-xdocs.build.xml"));
+        project.setBaseDir(directory.toFile());
+        project.addTaskDefinition("exec", StubExecTask.class);
+        project.setProperty("commons.nexus.repo.id", "1234");
+        project.setProperty("project.groupId", "org.apache.commons");
+        project.setProperty("project.artifactId", "commons-text");
+        project.setProperty("svn.rc.revision", "12345");
+        project.setProperty("git.tag.commit", "test-commit");
+        project.executeTarget("vote-txt");
+
+        final String vote = new 
String(Files.readAllBytes(directory.resolve("target/VOTE.txt")), 
StandardCharsets.UTF_8);
+        final String checksums = new String(Files.readAllBytes(sha512File), 
StandardCharsets.ISO_8859_1);
+        assertTrue(vote.contains(checksums));
+        assertFalse(vote.contains("@SHA512LIST@"));
+        assertFalse(vote.contains("${commons.sha512list}"));
+    }
+
     @Test
     @InjectMojo(goal = "detach-distributions", pom = 
"src/test/resources/mojos/detach-distributions/detach-distributions.xml")
     public void testSuccess(final CommonsDistributionDetachmentMojo mojo) 
throws Exception {

Reply via email to