@@ -0,0 +1,2594 @@
+package hudson.model;%0A%0Aimport org.jvnet.hudson.test.HudsonTestCase;%0Aimport com.gargoylesoftware.htmlunit.html.HtmlPage;%0Aimport com.gargoylesoftware.htmlunit.html.HtmlAnchor;%0A%0Aimport java.util.List;%0A%0Aimport hudson.tasks.Publisher;%0Aimport hudson.tasks.BuildStepDescriptor;%0Aimport hudson.tasks.Builder;%0Aimport hudson.model.HelpLinkTest.HelpNotFoundBuilder.DescriptorImpl;%0A%0A/**%0A * Click all the help links and make sure they resolve to some text, not 404.%0A *%0A * @author Kohsuke Kawaguchi%0A */%0Apublic class HelpLinkTest extends HudsonTestCase %7B%0A    public void testSystemConfig() throws Exception %7B%0A        clickAllHelpLinks(new WebClient().goTo(%22configure%22));%0A    %7D%0A%0A    public void testFreestyleConfig() throws Exception %7B%0A        clickAllHelpLinks(createFreeStyleProject());%0A    %7D%0A%0A    public void testMavenConfig() throws Exception %7B%0A        clickAllHelpLinks(createMavenProject());%0A    %7D%0A%0A    public void testMatrixConfig() throws Exception %7B%0A        clickAllHelpLinks(createMatrixProject());%0A    %7D%0A%0A    private void clickAllHelpLinks(Job j) throws Exception %7B%0A        clickAllHelpLinks(new WebClient().getPage(j,%22configure%22));%0A    %7D%0A%0A    private void clickAllHelpLinks(HtmlPage p) throws Exception %7B%0A        List%3C?%3E helpLinks = p.selectNodes(%22//a%5B@class='help-button'%5D%22);%0A        assertTrue(helpLinks.size()%3E0);%0A        System.out.println(%22Clicking %22+helpLinks.size()+%22 help links%22);%0A%0A        for (HtmlAnchor helpLink : (List%3CHtmlAnchor%3E)helpLinks)%0A            helpLink.click();%0A    %7D%0A%0A    public static class HelpNotFoundBuilder extends Builder %7B%0A        public static final class DescriptorImpl extends BuildStepDescriptor %7B%0A            public boolean isApplicable(Class jobType) %7B%0A                return true;%0A            %7D%0A%0A            @Override%0A            public String getHelpFile() %7B%0A                return %22no-such-file/exists%22;%0A            %7D%0A%0A            public String getDisplayName() %7B%0A                return %22I don't have the help file%22;%0A            %7D%0A        %7D%0A    %7D%0A%0A    /**%0A     * Make sure that this test is meaningful.%0A     * Intentionally put 404 and verify that it's detected.%0A     */%0A    public void testNegative() throws Exception %7B%0A        DescriptorImpl d = new DescriptorImpl();%0A        Publisher.all().add(d);%0A        try %7B%0A            clickAllHelpLinks(createFreeStyleProject());%0A            fail(%22should detect a failure%22);%0A        %7D catch(AssertionError e) %7B%0A            if(e.getMessage().contains(d.getHelpFile()))%0A                ; // expected%0A            else%0A                throw e;%0A        %7D finally %7B%0A            Publisher.all().remove(d);%0A        %7D%0A    %7D%0A%7D%0A

verify that help links work in the configuration page