提交 83a6fad5 编写于 作者: K kohsuke

allow HUDSON_HOME to be decorated.

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@13932 71c3de6d-444a-0410-be80-ed276b4c234a
上级 0e1c45d9
......@@ -93,6 +93,8 @@ public abstract class HudsonTestCase extends TestCase {
*/
protected List<LenientRunnable> tearDowns = new ArrayList<LenientRunnable>();
protected List<Runner> recipes = new ArrayList<Runner>();
/**
* Remember {@link WebClient}s that are created, to release them properly.
*/
......@@ -169,7 +171,10 @@ public abstract class HudsonTestCase extends TestCase {
* you can override it.
*/
protected Hudson newHudson() throws Exception {
return new Hudson(homeLoader.allocate(), createWebServer());
File home = homeLoader.allocate();
for (Runner r : recipes)
r.decorateHome(this,home);
return new Hudson(home, createWebServer());
}
/**
......@@ -359,6 +364,7 @@ public abstract class HudsonTestCase extends TestCase {
Recipe r = a.annotationType().getAnnotation(Recipe.class);
if(r==null) continue;
final Runner runner = r.value().newInstance();
recipes.add(runner);
tearDowns.add(new LenientRunnable() {
public void run() throws Exception {
runner.tearDown(HudsonTestCase.this,a);
......
......@@ -8,8 +8,12 @@ import java.lang.annotation.Retention;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Target;
import java.lang.annotation.Annotation;
import java.io.File;
import junit.framework.TestCase;
import hudson.model.Hudson;
import javax.servlet.ServletContext;
/**
* Meta-annotation for recipe annotations, which controls
......@@ -40,6 +44,13 @@ public @interface Recipe {
* Called during {@link TestCase#setUp()} to prepare the test environment.
*/
public void setup(HudsonTestCase testCase, T recipe) throws Exception {}
/**
* Called right before {@link Hudson#Hudson(File, ServletContext)} is invoked
* to decorate the hudson home directory.
*/
public void decorateHome(HudsonTestCase testCase, File home) throws Exception {}
/**
* Called during {@link TestCase#tearDown()} to shut down the test environment.
*/
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册