Repository: commons-release-plugin Updated Branches: refs/heads/master 3b666b595 -> 2f945be95
Testing successful detatchment of distributions Project: http://git-wip-us.apache.org/repos/asf/commons-release-plugin/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-release-plugin/commit/2f945be9 Tree: http://git-wip-us.apache.org/repos/asf/commons-release-plugin/tree/2f945be9 Diff: http://git-wip-us.apache.org/repos/asf/commons-release-plugin/diff/2f945be9 Branch: refs/heads/master Commit: 2f945be958256e4bd4e87ee09ab52a346b97c12b Parents: 3b666b5 Author: Rob Tompkins <chtom...@apache.org> Authored: Sun Jan 7 13:50:34 2018 -0500 Committer: Rob Tompkins <chtom...@apache.org> Committed: Sun Jan 7 13:50:34 2018 -0500 ---------------------------------------------------------------------- .../CommonsDistributionDetatchmentMojoTest.java | 21 ++++++++ .../DistributionDetatchmentProjectStub.java | 56 ++++++++++++++++++++ .../detatch-distributions.xml | 3 +- 3 files changed, 79 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/commons-release-plugin/blob/2f945be9/src/test/java/org/apache/commons/release/plugin/mojos/CommonsDistributionDetatchmentMojoTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/release/plugin/mojos/CommonsDistributionDetatchmentMojoTest.java b/src/test/java/org/apache/commons/release/plugin/mojos/CommonsDistributionDetatchmentMojoTest.java index 7e7867d..78809b6 100644 --- a/src/test/java/org/apache/commons/release/plugin/mojos/CommonsDistributionDetatchmentMojoTest.java +++ b/src/test/java/org/apache/commons/release/plugin/mojos/CommonsDistributionDetatchmentMojoTest.java @@ -23,6 +23,7 @@ import org.junit.Test; import java.io.File; import static junit.framework.TestCase.assertTrue; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; /** @@ -50,5 +51,25 @@ public class CommonsDistributionDetatchmentMojoTest { File testPom = new File("src/test/resources/mojos/detatch-distributions/detatch-distributions.xml"); assertNotNull(testPom); assertTrue(testPom.exists()); + mojo = (CommonsDistributionDetatchmentMojo) rule.lookupMojo("detatch-distributions", testPom); + mojo.execute(); + File detachedTarGz = new File("target/commons-release-plugin/mockAttachedTar.tar.gz"); + File detachedTarGzAsc = new File("target/commons-release-plugin/mockAttachedTar.tar.gz.asc"); + File detachedTarMd5 = new File("target/commons-release-plugin/mockAttachedTar.tar.gz.md5"); + File detachedTarGzSha1 = new File("target/commons-release-plugin/mockAttachedTar.tar.gz.sha1"); + File detachedZip = new File("target/commons-release-plugin/mockAttachedZip.zip"); + File detachedZipAsc = new File("target/commons-release-plugin/mockAttachedZip.zip.asc"); + File detachedZipMd5 = new File("target/commons-release-plugin/mockAttachedZip.zip.md5"); + File detachedZipSha1 = new File("target/commons-release-plugin/mockAttachedZip.zip.sha1"); + File notDetatchedMockAttachedFile = new File("target/commons-release-plugin/mockAttachedFile.html"); + assertTrue(detachedTarGz.exists()); + assertTrue(detachedTarGzAsc.exists()); + assertTrue(detachedTarMd5.exists()); + assertTrue(detachedTarGzSha1.exists()); + assertTrue(detachedZip.exists()); + assertTrue(detachedZipAsc.exists()); + assertTrue(detachedZipMd5.exists()); + assertTrue(detachedZipSha1.exists()); + assertFalse(notDetatchedMockAttachedFile.exists()); } } http://git-wip-us.apache.org/repos/asf/commons-release-plugin/blob/2f945be9/src/test/java/org/apache/commons/release/plugin/stubs/DistributionDetatchmentProjectStub.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/release/plugin/stubs/DistributionDetatchmentProjectStub.java b/src/test/java/org/apache/commons/release/plugin/stubs/DistributionDetatchmentProjectStub.java index 9305d02..65f0ac7 100644 --- a/src/test/java/org/apache/commons/release/plugin/stubs/DistributionDetatchmentProjectStub.java +++ b/src/test/java/org/apache/commons/release/plugin/stubs/DistributionDetatchmentProjectStub.java @@ -18,10 +18,13 @@ package org.apache.commons.release.plugin.stubs; import org.apache.commons.release.plugin.mojos.CommonsDistributionDetatchmentMojoTest; import org.apache.maven.artifact.Artifact; +import org.apache.maven.plugin.testing.stubs.ArtifactStub; import org.apache.maven.plugin.testing.stubs.MavenProjectStub; import org.apache.maven.project.MavenProject; import org.apache.maven.project.artifact.AttachedArtifact; +import java.io.File; +import java.util.ArrayList; import java.util.List; /** @@ -33,6 +36,59 @@ public class DistributionDetatchmentProjectStub extends MavenProjectStub { private List<Artifact> attachedArtifacts; + @Override + public List<Artifact> getAttachedArtifacts() { + attachedArtifacts = new ArrayList<>(); + attachedArtifacts.add( + new DistributionDetatchmentArtifactStub( + new File("src/test/resources/mojos/detatch-distributions/target/mockAttachedFile.html"), + "html" + ) + ); + attachedArtifacts.add( + new DistributionDetatchmentArtifactStub( + new File("src/test/resources/mojos/detatch-distributions/target/mockAttachedTar.tar.gz"), + "tar.gz" + ) + ); + attachedArtifacts.add( + new DistributionDetatchmentArtifactStub( + new File("src/test/resources/mojos/detatch-distributions/target/mockAttachedTar.tar.gz.asc"), + "tar.gz.asc" + ) + ); + attachedArtifacts.add( + new DistributionDetatchmentArtifactStub( + new File("src/test/resources/mojos/detatch-distributions/target/mockAttachedZip.zip"), + "zip" + ) + ); + attachedArtifacts.add( + new DistributionDetatchmentArtifactStub( + new File("src/test/resources/mojos/detatch-distributions/target/mockAttachedZip.zip.asc"), + "zip.asc" + ) + ); + return attachedArtifacts; + } + public class DistributionDetatchmentArtifactStub extends ArtifactStub { + private File artifact; + + private String type; + + public DistributionDetatchmentArtifactStub(File file, String type) { + this.artifact = file; + this.type = type; + } + + public File getFile() { + return this.artifact; + } + + public String getType() { + return this.type; + } + } } http://git-wip-us.apache.org/repos/asf/commons-release-plugin/blob/2f945be9/src/test/resources/mojos/detatch-distributions/detatch-distributions.xml ---------------------------------------------------------------------- diff --git a/src/test/resources/mojos/detatch-distributions/detatch-distributions.xml b/src/test/resources/mojos/detatch-distributions/detatch-distributions.xml index c7e399b..c6e5f81 100644 --- a/src/test/resources/mojos/detatch-distributions/detatch-distributions.xml +++ b/src/test/resources/mojos/detatch-distributions/detatch-distributions.xml @@ -42,8 +42,9 @@ <groupId>org.apache.commons</groupId> <artifactId>commons-release-plugin</artifactId> <configuration> + <project implementation="org.apache.commons.release.plugin.stubs.DistributionDetatchmentProjectStub" /> <workingDirectory>target/commons-release-plugin</workingDirectory> - <siteDirectory>${basedir}/target/test-classes/mojos/compress-site/example-site</siteDirectory> + <distSvnStagingUrl>mockDistSvnStagingUrl</distSvnStagingUrl> </configuration> </plugin> </plugins>