Plugin integration test infrastructure was added in: I689bb71413. For
test purpose there should be access to the plugin guice injectors to
allow to test plugin specific functionality.
Non plugin tests can achieve this by injecting needed classes in the
test class and the acceptance test framework ensures that the instances
of those classes are injected in the test class. This is possible, while
the GerritServer is started before the test class instance is created.
Given that the plugin loading, and guice injector creation initiated
from LightweightPluginDaemonTest#setUp method, plugin test classes
cannot use that nice feature and just inject the needed plugin class
instances, because the plugin specific guice injectors were not created
at the class instantiation time.
To overcome this problem, we expose TestServerPlugin instance from the
base class that has access to system, http and ssh guice injectors.
When a plugin test needs access to some plugin class instances, say
from system injector, the right idiom is (reviewers plugin example):
private ReviewersConfig reviewersConfig() {
return plugin.getSysInjector().getInstance(ReviewersConfig.class);
}
Change-Id: I8a4c1db92d65f49bd5c0fbc265944a16a619f714