mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-15 04:52:20 +00:00
Merge pull request #3875 from basil/JENKINS-22566
Test cases for JENKINS-22566
This commit is contained in:
1 file changed
+32
@@ -26,6 +26,7 @@ package hudson.model;
|
||||
import com.gargoylesoftware.htmlunit.Page;
|
||||
import com.gargoylesoftware.htmlunit.WebResponse;
|
||||
import net.sf.json.JSONObject;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.jvnet.hudson.test.Issue;
|
||||
@@ -136,4 +137,35 @@ public class ApiTest {
|
||||
j.createFreeStyleProject();
|
||||
j.createWebClient().assertFails("api/xml?xpath=/hudson/job/name", HttpURLConnection.HTTP_INTERNAL_ERROR);
|
||||
}
|
||||
|
||||
@Issue("JENKINS-22566")
|
||||
@Test
|
||||
public void parameter() throws Exception {
|
||||
FreeStyleProject p = j.createFreeStyleProject("p");
|
||||
p.addProperty(new ParametersDefinitionProperty(new StringParameterDefinition("foo", "")));
|
||||
j.assertBuildStatusSuccess(p.scheduleBuild2(0, new ParametersAction(new StringParameterValue("foo", "bar"))));
|
||||
|
||||
Page page = j.createWebClient().goTo(
|
||||
p.getUrl() + "api/xml?tree=builds[actions[parameters[name,value]]]&xpath=freeStyleProject/build/action/parameter",
|
||||
"application/xml");
|
||||
assertEquals(
|
||||
"<parameter _class=\"hudson.model.StringParameterValue\"><name>foo</name><value>bar</value></parameter>",
|
||||
page.getWebResponse().getContentAsString());
|
||||
}
|
||||
|
||||
@Issue("JENKINS-22566")
|
||||
@Ignore("TODO currently fails with: org.dom4j.DocumentException: Error on line 1 of document : An invalid XML character (Unicode: 0x1b) was found in the element content of the document")
|
||||
@Test
|
||||
public void escapedParameter() throws Exception {
|
||||
FreeStyleProject p = j.createFreeStyleProject("p");
|
||||
p.addProperty(new ParametersDefinitionProperty(new StringParameterDefinition("foo", "")));
|
||||
j.assertBuildStatusSuccess(p.scheduleBuild2(0, new ParametersAction(new StringParameterValue("foo", "bar\u001B"))));
|
||||
|
||||
Page page = j.createWebClient().goTo(
|
||||
p.getUrl() + "api/xml?tree=builds[actions[parameters[name,value]]]&xpath=freeStyleProject/build/action/parameter",
|
||||
"application/xml");
|
||||
assertEquals(
|
||||
"<parameter _class=\"hudson.model.StringParameterValue\"><name>foo</name><value>bar</value></parameter>",
|
||||
page.getWebResponse().getContentAsString());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user