Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Merge pull request #13 from Fiouz/JENKINS-31159
JENKINS-31159 Fix postMatrixBuildSteps
- Loading branch information
Showing
2 changed files
with
65 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
src/test/java/hudson/plugins/release/TestReleasePluginMatrixJob.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package hudson.plugins.release; | ||
|
||
import hudson.matrix.MatrixProject; | ||
import hudson.tasks.ArtifactArchiver; | ||
import hudson.tasks.BuildStep; | ||
import hudson.tasks.Fingerprinter; | ||
import org.junit.After; | ||
import org.junit.Assert; | ||
import org.junit.Before; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.jvnet.hudson.test.Bug; | ||
import org.jvnet.hudson.test.JenkinsRule; | ||
|
||
/** | ||
* Test integration with MatrixProject | ||
*/ | ||
public class TestReleasePluginMatrixJob { | ||
@Rule | ||
public JenkinsRule j = new JenkinsRule(); | ||
|
||
protected MatrixProject job; | ||
|
||
@Before | ||
public void createJob() throws Exception { | ||
job = j.createMatrixProject("foo"); | ||
} | ||
|
||
@After | ||
public void deleteJob() throws Exception { | ||
job.delete(); | ||
} | ||
|
||
/** | ||
* Make sure postBuildSteps and postMatrixBuildSteps behave as expected on save | ||
* | ||
* @throws Exception | ||
*/ | ||
@Test | ||
@Bug(31159) | ||
public void testMatrixStepsSubmission() throws Exception { | ||
// prepare wrapper with some randomly chosen build steps | ||
final ReleaseWrapper originalWrapper = new ReleaseWrapper(); | ||
final BuildStep postBuilder = new ArtifactArchiver("foo/*", "", true); | ||
final BuildStep postMatrixBuilder = new Fingerprinter("bar/*", true); | ||
originalWrapper.getPostBuildSteps().add(postBuilder); | ||
originalWrapper.getPostMatrixBuildSteps().add(postMatrixBuilder); | ||
|
||
job.getBuildWrappersList().add(originalWrapper); | ||
|
||
// submit unmodified form | ||
j.submit(j.createWebClient().getPage(job, "configure").getFormByName("config")); | ||
|
||
// retrieve resulting wrapper | ||
final ReleaseWrapper resultingWrapper = job.getBuildWrappersList().get(ReleaseWrapper.class); | ||
|
||
// assert | ||
Assert.assertTrue("postBuildSteps size is not 1", resultingWrapper.getPostBuildSteps().size() == 1); | ||
Assert.assertTrue("Expected ArtifactArchiver not found in postBuildSteps", resultingWrapper.getPostBuildSteps().iterator().next() instanceof ArtifactArchiver); | ||
Assert.assertTrue("postMatrixBuildSteps size is not 1", resultingWrapper.getPostMatrixBuildSteps().size() == 1); | ||
Assert.assertTrue("Expected Fingerprinter not found in postMatrixBuildSteps", resultingWrapper.getPostMatrixBuildSteps().iterator().next() instanceof Fingerprinter); | ||
} | ||
} |