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 67809ca807..fe34bbe998 100644 --- a/test/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java +++ b/test/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java @@ -16,6 +16,7 @@ import org.xml.sax.SAXException; import javax.servlet.ServletContext; import java.io.File; import java.io.IOException; +import java.net.URL; /** * Base class for all Hudson test cases. @@ -114,6 +115,20 @@ public abstract class HudsonTestCase extends TestCase { return this; } + /** + * Declares that this test case expects to start with one of the preset data sets. + * See https://svn.dev.java.net/svn/hudson/trunk/hudson/main/test/src/main/preset-data/ + * for available datasets and what they mean. + */ + protected HudsonTestCase withPresetData(String name) { + name = "/" + name + ".zip"; + URL res = getClass().getResource(name); + if(res==null) throw new IllegalArgumentException("No such data set found: "+name); + + homeLoader = new CopyExisting(res); + return this; + } + /** * Extends {@link com.gargoylesoftware.htmlunit.WebClient} and provide convenience methods * for accessing Hudson.