added a convenient test assertion method that makes sure help files for properties exist and render correctly.

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@30036 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
kohsuke committed 2010-04-14 00:48:48 +00:00
1 parent e472afa98e
commit 2ae2e1d28c
1 file changed
+24 -21
@@ -35,10 +35,7 @@ import hudson.EnvVars;
import hudson.ExtensionList;
import hudson.DescriptorExtensionList;
import hudson.Util;
import hudson.model.AbstractBuild;
import hudson.model.Computer;
import hudson.model.Executor;
import hudson.model.Job;
import hudson.model.*;
import hudson.model.Queue.Executable;
import hudson.security.AbstractPasswordBasedSecurityRealm;
import hudson.security.GroupDetails;
@@ -52,23 +49,6 @@ import hudson.matrix.MatrixBuild;
import hudson.matrix.MatrixRun;
import hudson.maven.MavenModuleSet;
import hudson.maven.MavenEmbedder;
import hudson.model.Descriptor;
import hudson.model.DownloadService;
import hudson.model.FreeStyleProject;
import hudson.model.Hudson;
import hudson.model.Item;
import hudson.model.JDK;
import hudson.model.Label;
import hudson.model.Node;
import hudson.model.Result;
import hudson.model.Run;
import hudson.model.Saveable;
import hudson.model.TaskListener;
import hudson.model.UpdateSite;
import hudson.model.AbstractProject;
import hudson.model.View;
import hudson.model.RootAction;
import hudson.model.User;
import hudson.model.Node.Mode;
import hudson.security.csrf.CrumbIssuer;
import hudson.slaves.CommandLauncher;
@@ -818,6 +798,29 @@ public abstract class HudsonTestCase extends TestCase implements RootAction {
}
}
/**
* Asserts that help files exist for the specified properties of the given instance.
*
* @param type
* The describable class type that should have the associated help files.
* @param properties
* ','-separated list of properties whose help files should exist.
*/
public void assertHelpExists(final Class<? extends Describable> type, final String properties) throws Exception {
executeOnServer(new Callable<Object>() {
public Object call() throws Exception {
Descriptor d = hudson.getDescriptor(type);
WebClient wc = createWebClient();
for (String property : properties.split(",")) {
String url = d.getHelpFile(property);
assertNotNull("Help file for the property "+property+" is missing on "+type, url);
wc.goTo(url); // make sure it successfully loads
}
return null;
}
});
}
/**
* Submits the form.
*