Skip to content
Permalink
Browse files

[JENKINS-27233] Added tests to reproduce JENKINS-27233, exceptions in…

… rebuild pages with non-matrix projects.
  • Loading branch information...
ikedam committed Jun 27, 2015
1 parent 3a20793 commit 6dcc532402ffb0919f5639b83acd17d77a9a670a
@@ -30,6 +30,8 @@
import hudson.matrix.MatrixBuild;
import hudson.matrix.MatrixProject;
import hudson.matrix.TextAxis;
import hudson.model.FreeStyleBuild;
import hudson.model.FreeStyleProject;
import hudson.model.ParametersDefinitionProperty;
import hudson.model.queue.QueueTaskFuture;
import hudson.model.Result;
@@ -442,4 +444,26 @@ public void testBuildPageForBuilding() throws Exception {

f.cancel(true);
}

@Test
public void testAppliedForNonMatrixProject() throws Exception {
FreeStyleProject p = j.createFreeStyleProject();
p.addProperty(new ParametersDefinitionProperty(
new MatrixCombinationsParameterDefinition("combinations", "", "")
));

{
WebClient wc = j.createAllow405WebClient();
HtmlPage page = wc.getPage(p, "build");
j.submit(page.getFormByName("parameters"));

j.waitUntilNoActivity();
FreeStyleBuild b = p.getLastBuild();
assertNotNull(b);
j.assertBuildStatusSuccess(b);
}

// default trigger
j.assertBuildStatusSuccess(p.scheduleBuild2(0));
}
}
@@ -25,14 +25,22 @@
package hudson.plugins.matrix_configuration_parameter;

import static org.junit.Assert.*;

import java.util.Arrays;

import hudson.matrix.AxisList;
import hudson.matrix.MatrixBuild;
import hudson.matrix.MatrixProject;
import hudson.matrix.TextAxis;
import hudson.model.Cause;
import hudson.model.FreeStyleBuild;
import hudson.model.FreeStyleProject;
import hudson.model.ParametersAction;
import hudson.model.ParametersDefinitionProperty;

import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.Bug;
import org.jvnet.hudson.test.JenkinsRule;
import org.jvnet.hudson.test.JenkinsRule.WebClient;

@@ -92,4 +100,23 @@ public void testParametersPageWithDoubleAxis() throws Exception{
assertTrue(((HtmlCheckBoxInput)page.getElementById("checkboxcombinations-axis1-value1-2-axis2-value2-1")).isChecked());
assertTrue(((HtmlCheckBoxInput)page.getElementById("checkboxcombinations-axis1-value1-2-axis2-value2-2")).isChecked());
}

@Bug(27233)
@Test
public void testNonMatrixBuild() throws Exception {
FreeStyleProject p = j.createFreeStyleProject();

@SuppressWarnings("deprecation")
Cause cause = new Cause.UserCause();
FreeStyleBuild b = p.scheduleBuild2(0, cause, Arrays.asList(
new ParametersAction(new MatrixCombinationsParameterValue(
"combinations",
new Boolean[]{ true, false, true },
new String[]{ "axis1=value1", "axis1=value2", "axis1=value3" }
))
)).get();

WebClient wc = j.createWebClient();
wc.getPage(b, "parameters");
}
}
@@ -34,11 +34,15 @@
import hudson.matrix.MatrixProject;
import hudson.matrix.TextAxis;
import hudson.model.Cause;
import hudson.model.FreeStyleBuild;
import hudson.model.FreeStyleProject;
import hudson.model.ParametersAction;
import hudson.model.ParametersDefinitionProperty;
import hudson.model.StringParameterValue;

import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.Bug;
import org.jvnet.hudson.test.JenkinsRule;
import org.jvnet.hudson.test.JenkinsRule.WebClient;

@@ -141,4 +145,35 @@ public void testRebuildTwoAxes() throws Exception {
assertNull(b1.getExactRun(new Combination(p.getAxes(), "value1-1", "value2-2")));
assertNotNull(b1.getExactRun(new Combination(p.getAxes(), "value1-2", "value2-2")));
}

@Bug(27233)
@Test
public void testAppliedForNonMatrixProjectRebuild() throws Exception {
FreeStyleProject p = j.createFreeStyleProject();

@SuppressWarnings("deprecation")
Cause cause = new Cause.UserCause();
FreeStyleBuild b1 = p.scheduleBuild2(0, cause, Arrays.asList(
new ParametersAction(
new MatrixCombinationsParameterValue(
"combinations",
new Boolean[]{ true, false, true },
new String[]{ "axis1=value1", "axis1=value2", "axis1=value3" }
)
// rebuild-plugin causes exception
// when requesting a rebuild with no parameters.
, new StringParameterValue("dummy", "")
)
)).get();

WebClient wc = j.createWebClient();
HtmlPage page = wc.getPage(b1, "rebuild");
HtmlForm form = page.getFormByName("config");
j.submit(form);

j.waitUntilNoActivity();

FreeStyleBuild b2 = p.getLastBuild();
assertNotEquals(b1.getNumber(), b2.getNumber());
}
}

0 comments on commit 6dcc532

Please sign in to comment.
You can’t perform that action at this time.