Skip to content
Permalink
Browse files

[FIXED JENKINS-17302] Corrected GET of a View to serialize the View, …

…not an anonymous inner class.

Also ensuring that Jenkins configuration is saved after new XML is POSTed.
  • Loading branch information
jglick committed Jul 18, 2013
1 parent 504dadc commit c572146b260616788ef5332799362e03d5746f9e
Showing with 26 additions and 1 deletion.
  1. +3 −0 changelog.html
  2. +2 −1 core/src/main/java/hudson/model/View.java
  3. +21 −0 test/src/test/java/hudson/model/ViewTest.java
@@ -67,6 +67,9 @@
<li class=bug>
Provided maven settings.xml in maven builder is lost.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-15976">issue 15976</a>)
<li class=bug>
Since 1.477 GET on <code>/view/…/config.xml</code> included a spurious wrapper element.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-17302">issue 17302</a>)
<li class=bug>
Fixed a regression that broke some plugins' form validation
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-18776">issue 18776</a>)
@@ -1045,7 +1045,7 @@ public void generateResponse(StaplerRequest req, StaplerResponse rsp, Object nod
// pity we don't have a handy way to clone Jenkins.XSTREAM to temp add the omit Field
XStream2 xStream2 = new XStream2();
xStream2.omitField(View.class, "owner");
xStream2.toXMLUTF8(this, rsp.getOutputStream());
xStream2.toXMLUTF8(View.this, rsp.getOutputStream());
}
};
}
@@ -1091,6 +1091,7 @@ public void updateByXml(Source source) throws IOException {
} finally {
in.close();
}
save();
}

public ContextMenu doChildrenContextMenu(StaplerRequest request, StaplerResponse response) throws Exception {
@@ -26,14 +26,18 @@
import jenkins.model.Jenkins;
import org.jvnet.hudson.test.Bug;
import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException;
import com.gargoylesoftware.htmlunit.HttpMethod;
import com.gargoylesoftware.htmlunit.WebRequestSettings;
import com.gargoylesoftware.htmlunit.html.HtmlAnchor;
import com.gargoylesoftware.htmlunit.html.HtmlForm;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.html.HtmlRadioButtonInput;
import hudson.XmlFile;
import org.jvnet.hudson.test.Email;
import org.w3c.dom.Text;

import static hudson.model.Messages.Hudson_ViewName;
import java.io.File;
import static org.junit.Assert.*;
import org.junit.Ignore;
import org.junit.Rule;
@@ -172,4 +176,21 @@
j.submit(j.createWebClient().getPage(view, "configure").getFormByName("viewConfig"));
}

@Bug(17302)
@Test public void doConfigDotXml() throws Exception {
ListView view = new ListView("v", j.jenkins);
view.description = "one";
j.jenkins.addView(view);
WebClient wc = j.createWebClient();
String xml = wc.goToXml("view/v/config.xml").getContent();
assertTrue(xml, xml.contains("<description>one</description>"));
xml = xml.replace("<description>one</description>", "<description>two</description>");
WebRequestSettings req = new WebRequestSettings(wc.createCrumbedUrl("view/v/config.xml"), HttpMethod.POST);
req.setRequestBody(xml);
wc.getPage(req);
assertEquals("two", view.getDescription());
xml = new XmlFile(Jenkins.XSTREAM, new File(j.jenkins.getRootDir(), "config.xml")).asString();
assertTrue(xml, xml.contains("<description>two</description>"));
}

}

0 comments on commit c572146

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