diff --git a/test/src/test/java/hudson/model/ViewPropertyTest.java b/test/src/test/java/hudson/model/ViewPropertyTest.java index db682a8a0cd217ac6b9f27ef6823590fd1e2827d..cb04bf277a00e5bcd5d5590a0bc803871a4425a6 100644 --- a/test/src/test/java/hudson/model/ViewPropertyTest.java +++ b/test/src/test/java/hudson/model/ViewPropertyTest.java @@ -25,9 +25,12 @@ package hudson.model; import com.gargoylesoftware.htmlunit.html.HtmlForm; import com.gargoylesoftware.htmlunit.html.HtmlLabel; +import hudson.model.Descriptor.FormException; +import net.sf.json.JSONObject; import org.jvnet.hudson.test.HudsonTestCase; import org.jvnet.hudson.test.TestExtension; import org.kohsuke.stapler.DataBoundConstructor; +import org.kohsuke.stapler.StaplerRequest; /** * @author Kohsuke Kawaguchi @@ -68,4 +71,37 @@ public class ViewPropertyTest extends HudsonTestCase { } } } + + public void testInvisibleProperty() throws Exception { + ListView foo = new ListView("foo"); + hudson.addView(foo); + + // test the rendering (or the lack thereof) of an invisible property + configRoundtrip(foo); + assertNull(foo.getProperties().get(InvisiblePropertyImpl.class)); + + // do the same but now with a configured instance + InvisiblePropertyImpl vp = new InvisiblePropertyImpl(); + foo.getProperties().add(vp); + configRoundtrip(foo); + assertSame(vp,foo.getProperties().get(InvisiblePropertyImpl.class)); + } + + public static class InvisiblePropertyImpl extends ViewProperty { + InvisiblePropertyImpl() { + } + + @Override + public ViewProperty reconfigure(StaplerRequest req, JSONObject form) throws FormException { + return this; + } + + @TestExtension + public static class DescriptorImpl extends ViewPropertyDescriptor { + @Override + public String getDisplayName() { + return null; + } + } + } }