提交 8fcb00f2 编写于 作者: K Kohsuke Kawaguchi 提交者: Stephen Connolly

added a test case for invisible ViewProperty

上级 9905132f
......@@ -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;
}
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册