Skip to content

Commit

Permalink
[FIXED JENKINS-17302] Corrected GET of a View to serialize the View, …
Browse files Browse the repository at this point in the history
…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 c572146
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
3 changes: 3 additions & 0 deletions changelog.html
Expand Up @@ -67,6 +67,9 @@
<li class=bug> <li class=bug>
Provided maven settings.xml in maven builder is lost. Provided maven settings.xml in maven builder is lost.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-15976">issue 15976</a>) (<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> <li class=bug>
Fixed a regression that broke some plugins' form validation Fixed a regression that broke some plugins' form validation
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-18776">issue 18776</a>) (<a href="https://issues.jenkins-ci.org/browse/JENKINS-18776">issue 18776</a>)
Expand Down
3 changes: 2 additions & 1 deletion core/src/main/java/hudson/model/View.java
Expand Up @@ -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 // pity we don't have a handy way to clone Jenkins.XSTREAM to temp add the omit Field
XStream2 xStream2 = new XStream2(); XStream2 xStream2 = new XStream2();
xStream2.omitField(View.class, "owner"); xStream2.omitField(View.class, "owner");
xStream2.toXMLUTF8(this, rsp.getOutputStream()); xStream2.toXMLUTF8(View.this, rsp.getOutputStream());
} }
}; };
} }
Expand Down Expand Up @@ -1091,6 +1091,7 @@ public void updateByXml(Source source) throws IOException {
} finally { } finally {
in.close(); in.close();
} }
save();
} }


public ContextMenu doChildrenContextMenu(StaplerRequest request, StaplerResponse response) throws Exception { public ContextMenu doChildrenContextMenu(StaplerRequest request, StaplerResponse response) throws Exception {
Expand Down
21 changes: 21 additions & 0 deletions test/src/test/java/hudson/model/ViewTest.java
Expand Up @@ -26,14 +26,18 @@
import jenkins.model.Jenkins; import jenkins.model.Jenkins;
import org.jvnet.hudson.test.Bug; import org.jvnet.hudson.test.Bug;
import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException; 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.HtmlAnchor;
import com.gargoylesoftware.htmlunit.html.HtmlForm; import com.gargoylesoftware.htmlunit.html.HtmlForm;
import com.gargoylesoftware.htmlunit.html.HtmlPage; import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.html.HtmlRadioButtonInput; import com.gargoylesoftware.htmlunit.html.HtmlRadioButtonInput;
import hudson.XmlFile;
import org.jvnet.hudson.test.Email; import org.jvnet.hudson.test.Email;
import org.w3c.dom.Text; import org.w3c.dom.Text;


import static hudson.model.Messages.Hudson_ViewName; import static hudson.model.Messages.Hudson_ViewName;
import java.io.File;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import org.junit.Ignore; import org.junit.Ignore;
import org.junit.Rule; import org.junit.Rule;
Expand Down Expand Up @@ -172,4 +176,21 @@ public class ViewTest {
j.submit(j.createWebClient().getPage(view, "configure").getFormByName("viewConfig")); 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.