diff --git a/core/src/main/java/hudson/model/Descriptor.java b/core/src/main/java/hudson/model/Descriptor.java index 5ad9830a75..fd196e1429 100644 --- a/core/src/main/java/hudson/model/Descriptor.java +++ b/core/src/main/java/hudson/model/Descriptor.java @@ -279,7 +279,7 @@ public abstract class Descriptor> implements Saveable { * (If we do that in the base class, the derived class won't * get a chance to set default values.) */ - protected synchronized void load() { + public synchronized void load() { XmlFile file = getConfigFile(); if(!file.exists()) return; diff --git a/test/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java b/test/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java index 2f84628209..a266012d01 100644 --- a/test/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java +++ b/test/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java @@ -5,10 +5,7 @@ import com.gargoylesoftware.htmlunit.Page; import com.gargoylesoftware.htmlunit.javascript.host.Stylesheet; import com.gargoylesoftware.htmlunit.html.HtmlForm; import com.gargoylesoftware.htmlunit.html.HtmlPage; -import hudson.model.FreeStyleProject; -import hudson.model.Hudson; -import hudson.model.Item; -import hudson.model.UpdateCenter; +import hudson.model.*; import junit.framework.TestCase; import org.jvnet.hudson.test.HudsonHomeLoader.CopyExisting; import org.jvnet.hudson.test.recipes.Recipe; @@ -75,6 +72,10 @@ public abstract class HudsonTestCase extends TestCase { hudson = newHudson(); hudson.servletContext.setAttribute("app",hudson); hudson.servletContext.setAttribute("version","?"); + // cause all the descriptors to reload. + // ideally we'd like to reset them to properly emulate the behavior, but that's not possible. + for( Descriptor d : Descriptor.ALL ) + d.load(); } protected void tearDown() throws Exception { @@ -85,6 +86,10 @@ public abstract class HudsonTestCase extends TestCase { env.dispose(); } + /** + * Creates a new instance of {@link Hudson}. If the derived class wants to create it in a different way, + * you can override it. + */ protected Hudson newHudson() throws Exception { return new Hudson(homeLoader.allocate(), createWebServer()); }