Add GerritConfig annotation processing to GerritServerTests
This commits adds GerritConfig annotation processing to GerritServerTests which makes the annotation usable in any test that inherits from GerritServerTests. Change-Id: I6a3afb23925433cb7cb2b449f410ef210e6dc628
This commit is contained in:
@@ -13,6 +13,7 @@ java_library(
|
|||||||
"//lib/mockito",
|
"//lib/mockito",
|
||||||
],
|
],
|
||||||
deps = [
|
deps = [
|
||||||
|
"//java/com/google/gerrit/acceptance/config",
|
||||||
"//java/com/google/gerrit/acceptance/testsuite/project",
|
"//java/com/google/gerrit/acceptance/testsuite/project",
|
||||||
"//java/com/google/gerrit/common:annotations",
|
"//java/com/google/gerrit/common:annotations",
|
||||||
"//java/com/google/gerrit/entities",
|
"//java/com/google/gerrit/entities",
|
||||||
|
|||||||
@@ -14,6 +14,9 @@
|
|||||||
|
|
||||||
package com.google.gerrit.testing;
|
package com.google.gerrit.testing;
|
||||||
|
|
||||||
|
import com.google.gerrit.acceptance.config.ConfigAnnotationParser;
|
||||||
|
import com.google.gerrit.acceptance.config.GerritConfig;
|
||||||
|
import com.google.gerrit.acceptance.config.GerritConfigs;
|
||||||
import org.eclipse.jgit.lib.Config;
|
import org.eclipse.jgit.lib.Config;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.rules.TestRule;
|
import org.junit.rules.TestRule;
|
||||||
@@ -23,16 +26,24 @@ import org.junit.runners.model.Statement;
|
|||||||
@RunWith(ConfigSuite.class)
|
@RunWith(ConfigSuite.class)
|
||||||
public class GerritServerTests {
|
public class GerritServerTests {
|
||||||
@ConfigSuite.Parameter public Config config;
|
@ConfigSuite.Parameter public Config config;
|
||||||
|
|
||||||
@ConfigSuite.Name private String configName;
|
@ConfigSuite.Name private String configName;
|
||||||
|
|
||||||
@Rule
|
@Rule
|
||||||
public TestRule testRunner =
|
public TestRule testRunner =
|
||||||
(base, description) ->
|
(base, description) -> {
|
||||||
new Statement() {
|
GerritConfig gerritConfig = description.getAnnotation(GerritConfig.class);
|
||||||
@Override
|
if (gerritConfig != null) {
|
||||||
public void evaluate() throws Throwable {
|
config = ConfigAnnotationParser.parse(config, gerritConfig);
|
||||||
base.evaluate();
|
}
|
||||||
}
|
GerritConfigs gerritConfigs = description.getAnnotation(GerritConfigs.class);
|
||||||
};
|
if (gerritConfigs != null) {
|
||||||
|
config = ConfigAnnotationParser.parse(config, gerritConfigs);
|
||||||
|
}
|
||||||
|
return new Statement() {
|
||||||
|
@Override
|
||||||
|
public void evaluate() throws Throwable {
|
||||||
|
base.evaluate();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user