Skip to content

Commit

Permalink
[JENKINS-25660] - Added a regression test for the issue
Browse files Browse the repository at this point in the history
Signed-off-by: Oleg Nenashev <o.v.nenashev@gmail.com>
  • Loading branch information
oleg-nenashev committed Mar 11, 2015
1 parent 29baeb3 commit 51475b3
Showing 1 changed file with 18 additions and 2 deletions.
Expand Up @@ -6,7 +6,9 @@
import hudson.model.AbstractBuild;
import hudson.model.ParametersDefinitionProperty;
import hudson.model.StringParameterDefinition;
import java.util.Collection;
import java.util.Map;
import org.apache.commons.lang.StringUtils;
import org.junit.Test;
import org.jvnet.hudson.test.Bug;
import org.jvnet.hudson.test.FakeChangeLogSCM;
Expand Down Expand Up @@ -34,6 +36,11 @@ protected void setUp() throws Exception {
MatrixBuild run = buildAndAssertSuccess(p);
assertEquals(3, run.getExactRuns().size());
}

@Bug(25660)
public @Test void testInjectionWithEscaping() throws Exception {
checkAxesSetup(new String[]{"1", "\"2 3\""});
}

/**
* Runs the test, when an environment contributor uses axis values
Expand All @@ -42,16 +49,25 @@ protected void setUp() throws Exception {
*/
@Bug(27243)
public @Test void testInjectionWithAxisValuesUser() throws Exception {
checkAxesSetup(new String[]{"1", "2", "3"});
}

/**
* Sets values from the list and then checks injection results.
* @param values List of values, which should be escaped externally
*/
private void checkAxesSetup(String[] values) throws Exception {
final String valuesString = StringUtils.join(values, " ");
p.addProperty(new ParametersDefinitionProperty(
new StringParameterDefinition("AXIS_VALUES", "1 2 3")));
new StringParameterDefinition("AXIS_VALUES", valuesString)));

// Inject SCM, which implicitly triggers axes rebuild
p.setScm(new AxisValuesUserSCM());

final MatrixBuild run = buildAndAssertSuccess(p);

// No additional values have been injected
assertEquals(3, run.getExactRuns().size());
assertEquals(values.length, run.getExactRuns().size());
}

/**
Expand Down

0 comments on commit 51475b3

Please sign in to comment.