提交 91c2f6f8 编写于 作者: R redsolo

[FIXED HUDSON-2398] Show summary.jelly files for JobProperties in the project page

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@12262 71c3de6d-444a-0410-be80-ed276b4c234a
上级 cc0d11ab
package hudson.model;
import hudson.matrix.MatrixProject;
import hudson.maven.MavenModuleSet;
import org.jvnet.hudson.test.HudsonTestCase;
import com.gargoylesoftware.htmlunit.WebAssert;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
public class JobPropertyTest extends HudsonTestCase {
/**
* Asserts that rfe#2398 is fixed.
*/
public void testJobPropertySummaryIsShownInMavenModuleSetIndexPage() throws Exception {
assertJobPropertySummaryIsShownInIndexPage(MavenModuleSet.DESCRIPTOR);
}
public void testJobPropertySummaryIsShownInMatrixProjectIndexPage() throws Exception {
assertJobPropertySummaryIsShownInIndexPage(MatrixProject.DESCRIPTOR);
}
public void testJobPropertySummaryIsShownInFreeStyleProjectIndexPage() throws Exception {
assertJobPropertySummaryIsShownInIndexPage(FreeStyleProject.DESCRIPTOR);
}
private void assertJobPropertySummaryIsShownInIndexPage(TopLevelItemDescriptor type) throws Exception {
JobPropertyImpl jp = new JobPropertyImpl("NeedleInPage");
Job<?,?> project = (Job<?, ?>) hudson.createProject(type, "job-test-case");
project.addProperty(jp);
HtmlPage page = new WebClient().goTo("job/job-test-case");
WebAssert.assertTextPresent(page, "NeedleInPage");
}
public static class JobPropertyImpl extends JobProperty<Job<?,?>> {
public static DescriptorImpl DESCRIPTOR = new DescriptorImpl();
private final String propertyString;
public JobPropertyImpl(String propertyString) {
this.propertyString = propertyString;
}
public String getPropertyString() {
return propertyString;
}
@Override
public JobPropertyDescriptor getDescriptor() {
return DESCRIPTOR;
}
@SuppressWarnings("unchecked")
private static class DescriptorImpl extends JobPropertyDescriptor {
protected DescriptorImpl() {
super(JobPropertyImpl.class);
}
@Override
public boolean isApplicable(Class<? extends Job> jobType) {
return false;
}
@Override
public String getDisplayName() {
return "Fake job property";
}
}
}
}
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form" xmlns:i="jelly:fmt">
${it.propertyString}
</j:jelly>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册