diff --git a/test/src/test/java/hudson/model/ApiTest.java b/test/src/test/java/hudson/model/ApiTest.java
index cffde63571..754b5862f7 100644
--- a/test/src/test/java/hudson/model/ApiTest.java
+++ b/test/src/test/java/hudson/model/ApiTest.java
@@ -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(
+ "foobar",
+ 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(
+ "foobar",
+ page.getWebResponse().getContentAsString());
+ }
}