From 9ebfce95b7ef5d8b353d46a42956ef6aa297891e Mon Sep 17 00:00:00 2001 From: David Ostrovsky Date: Sat, 17 Mar 2018 21:25:18 +0100 Subject: [PATCH] LightweightPluginDaemonTest: Expose plugin guice injectors 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 --- .../google/gerrit/acceptance/LightweightPluginDaemonTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gerrit-acceptance-framework/src/test/java/com/google/gerrit/acceptance/LightweightPluginDaemonTest.java b/gerrit-acceptance-framework/src/test/java/com/google/gerrit/acceptance/LightweightPluginDaemonTest.java index 7f932c3a73..62cc8ce489 100644 --- a/gerrit-acceptance-framework/src/test/java/com/google/gerrit/acceptance/LightweightPluginDaemonTest.java +++ b/gerrit-acceptance-framework/src/test/java/com/google/gerrit/acceptance/LightweightPluginDaemonTest.java @@ -30,7 +30,7 @@ public class LightweightPluginDaemonTest extends AbstractDaemonTest { @Rule public TemporaryFolder tempDataDir = new TemporaryFolder(); - private TestServerPlugin plugin; + protected TestServerPlugin plugin; @Before public void setUp() throws Exception {