use of org.hudsonci.inject.internal.SmoothieContainerBootstrap in project hudson-2.x by hudson.
the class SmoothieTestSupport method setUp.
@Before
public void setUp() throws Exception {
SmoothieUtil.reset();
new SmoothieContainerBootstrap().bootstrap(getClass().getClassLoader(), Smoothie.class, getClass());
}
use of org.hudsonci.inject.internal.SmoothieContainerBootstrap in project hudson-2.x by hudson.
the class HudsonTestCase method setUp.
@Override
protected void setUp() throws Exception {
//System.setProperty("hudson.PluginStrategy", "hudson.ClassicPluginStrategy");
env.pin();
recipe();
AbstractProject.WORKSPACE.toString();
User.clear();
// Bootstrap the container with details about our testing classes, so it can figure out what to scan/include
// force-reset, some tests may not properly hit the tear-down to reset so do it again here
SmoothieUtil.reset();
new SmoothieContainerBootstrap().bootstrap(getClass().getClassLoader(), Hudson.class, Smoothie.class, HudsonTestCase.class, getClass());
try {
hudson = newHudson();
} catch (Exception e) {
// if Hudson instance fails to initialize, it leaves the instance field non-empty and break all the rest of the tests, so clean that up.
Field f = Hudson.class.getDeclaredField("theInstance");
f.setAccessible(true);
f.set(null, null);
throw e;
}
// collecting usage stats from tests are pointless.
hudson.setNoUsageStatistics(true);
hudson.setCrumbIssuer(new TestCrumbIssuer());
final WebAppController controller = WebAppController.get();
try {
controller.setContext(hudson.servletContext);
} catch (IllegalStateException e) {
// handle tests which run several times inside the same JVM
Field f = WebAppController.class.getDeclaredField("context");
f.setAccessible(true);
f.set(controller, hudson.servletContext);
}
try {
controller.setInstallStrategy(new DefaultInstallStrategy());
} catch (IllegalStateException e) {
// strategy already set ignore
}
controller.install(hudson);
hudson.servletContext.setAttribute("version", "?");
WebAppMain.installExpressionFactory(new ServletContextEvent(hudson.servletContext));
// set a default JDK to be the one that the harness is using.
hudson.getJDKs().add(new JDK("default", System.getProperty("java.home")));
configureUpdateCenter();
// expose the test instance as a part of URL tree.
// this allows tests to use a part of the URL space for itself.
hudson.getActions().add(this);
// cause all the descriptors to reload.
// ideally we'd like to reset them to properly emulate the behavior, but that's not possible.
Mailer.descriptor().setHudsonUrl(null);
for (Descriptor d : hudson.getExtensionList(Descriptor.class)) d.load();
}
Aggregations