Make most small tests inherit from GerritBaseTests
One of the main purposes of GerritBaseTests is a place to park the KeyUtil#setEncoderImpl call, which avoids NPEs when calling any gwtorm Key#toString method. Many tests pass today without this base class for one of a few reasons: * They never call Key#toString, or perhaps only call it lazily on test failures. * They transitively load some other class which has setEncoderImpl in its static block, such as Database. * They are run with `bazel test` in the same JVM/classloader as another test class which does inherit GerritBaseTests or otherwise indirectly calls setEncoderImpl. (If any tests exist in this category, then they already fail if run singly in an IDE or with a restricted --test_filter.) In order to avoid having to reason about whether a particular test does or does not depend on setEncoderImpl, just use GerritBaseTests consistently. This will prevent spurious test failures when we start removing classes like Database as we cut out ReviewDb. This change modifies all classes named *Test.java which were not previously inheriting from any base class. Remaining tests will be fixed in followups. Change-Id: I32f5456d2ebc5e545cc89ad65f74139bd3506aaa
This commit is contained in:
@@ -6,6 +6,7 @@ junit_tests(
|
||||
deps = [
|
||||
"//java/com/google/gerrit/acceptance:lib",
|
||||
"//java/com/google/gerrit/server/util/time",
|
||||
"//java/com/google/gerrit/testing:gerrit-test-util",
|
||||
"//lib:guava",
|
||||
"//lib/jgit/org.eclipse.jgit:jgit",
|
||||
"//lib/truth",
|
||||
|
||||
@@ -18,13 +18,14 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import java.io.File;
|
||||
import java.nio.file.Files;
|
||||
import org.eclipse.jgit.lib.Config;
|
||||
import org.eclipse.jgit.util.FS;
|
||||
import org.junit.Test;
|
||||
|
||||
public class MergeableFileBasedConfigTest {
|
||||
public class MergeableFileBasedConfigTest extends GerritBaseTests {
|
||||
@Test
|
||||
public void mergeNull() throws Exception {
|
||||
MergeableFileBasedConfig cfg = newConfig();
|
||||
|
||||
@@ -17,9 +17,10 @@ package com.google.gerrit.common;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import com.google.auto.value.AutoValue;
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import org.junit.Test;
|
||||
|
||||
public class AutoValueTest {
|
||||
public class AutoValueTest extends GerritBaseTests {
|
||||
@AutoValue
|
||||
abstract static class Auto {
|
||||
static Auto create(String val) {
|
||||
|
||||
@@ -12,6 +12,7 @@ junit_tests(
|
||||
"//java/com/google/gerrit/common:version",
|
||||
"//java/com/google/gerrit/launcher",
|
||||
"//java/com/google/gerrit/reviewdb:server",
|
||||
"//java/com/google/gerrit/testing:gerrit-test-util",
|
||||
"//lib:guava",
|
||||
"//lib/auto:auto-value",
|
||||
"//lib/auto:auto-value-annotations",
|
||||
|
||||
@@ -17,6 +17,7 @@ package com.google.gerrit.common.data;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
@@ -25,7 +26,7 @@ import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
||||
public class AccessSectionTest {
|
||||
public class AccessSectionTest extends GerritBaseTests {
|
||||
@Rule public ExpectedException exception = ExpectedException.none();
|
||||
|
||||
private static final String REF_PATTERN = "refs/heads/master";
|
||||
|
||||
@@ -16,9 +16,10 @@ package com.google.gerrit.common.data;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import org.junit.Test;
|
||||
|
||||
public class EncodePathSeparatorTest {
|
||||
public class EncodePathSeparatorTest extends GerritBaseTests {
|
||||
@Test
|
||||
public void defaultBehaviour() {
|
||||
assertThat(new GitwebType().replacePathSeparator("a/b")).isEqualTo("a/b");
|
||||
|
||||
@@ -16,9 +16,10 @@ package com.google.gerrit.common.data;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import org.junit.Test;
|
||||
|
||||
public class FilenameComparatorTest {
|
||||
public class FilenameComparatorTest extends GerritBaseTests {
|
||||
private FilenameComparator comparator = FilenameComparator.INSTANCE;
|
||||
|
||||
@Test
|
||||
|
||||
@@ -18,11 +18,12 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import com.google.gerrit.reviewdb.client.AccountGroup;
|
||||
import com.google.gerrit.reviewdb.client.AccountGroup.UUID;
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
||||
public class GroupReferenceTest {
|
||||
public class GroupReferenceTest extends GerritBaseTests {
|
||||
@Rule public ExpectedException exception = ExpectedException.none();
|
||||
|
||||
@Test
|
||||
|
||||
@@ -23,13 +23,14 @@ import com.google.gerrit.reviewdb.client.LabelId;
|
||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||
import com.google.gerrit.reviewdb.client.PatchSet.Id;
|
||||
import com.google.gerrit.reviewdb.client.PatchSetApproval;
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import java.sql.Date;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.junit.Test;
|
||||
|
||||
public class LabelFunctionTest {
|
||||
public class LabelFunctionTest extends GerritBaseTests {
|
||||
private static final String LABEL_NAME = "Verified";
|
||||
private static final LabelId LABEL_ID = new LabelId(LABEL_NAME);
|
||||
private static final Change.Id CHANGE_ID = new Change.Id(100);
|
||||
|
||||
@@ -17,9 +17,10 @@ package com.google.gerrit.common.data;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import org.junit.Test;
|
||||
|
||||
public class LabelTypeTest {
|
||||
public class LabelTypeTest extends GerritBaseTests {
|
||||
@Test
|
||||
public void sortLabelValues() {
|
||||
LabelValue v0 = new LabelValue((short) 0, "Zero");
|
||||
|
||||
@@ -17,11 +17,12 @@ package com.google.gerrit.common.data;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.junit.Test;
|
||||
|
||||
public class ParameterizedStringTest {
|
||||
public class ParameterizedStringTest extends GerritBaseTests {
|
||||
@Test
|
||||
public void emptyString() {
|
||||
ParameterizedString p = new ParameterizedString("");
|
||||
|
||||
@@ -18,12 +18,13 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import com.google.gerrit.common.data.PermissionRule.Action;
|
||||
import com.google.gerrit.reviewdb.client.AccountGroup;
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
||||
public class PermissionRuleTest {
|
||||
public class PermissionRuleTest extends GerritBaseTests {
|
||||
@Rule public ExpectedException exception = ExpectedException.none();
|
||||
|
||||
private GroupReference groupReference;
|
||||
|
||||
@@ -18,12 +18,13 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.gerrit.reviewdb.client.AccountGroup;
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class PermissionTest {
|
||||
public class PermissionTest extends GerritBaseTests {
|
||||
private static final String PERMISSION_NAME = "foo";
|
||||
|
||||
private Permission permission;
|
||||
|
||||
@@ -16,11 +16,12 @@ package com.google.gerrit.common.data;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import org.junit.Test;
|
||||
|
||||
public class SubmitRecordTest {
|
||||
public class SubmitRecordTest extends GerritBaseTests {
|
||||
private static final SubmitRecord OK_RECORD;
|
||||
private static final SubmitRecord FORCED_RECORD;
|
||||
private static final SubmitRecord NOT_READY_RECORD;
|
||||
|
||||
@@ -86,6 +86,7 @@ junit_tests(
|
||||
tags = ["elastic"],
|
||||
deps = [
|
||||
"//java/com/google/gerrit/elasticsearch",
|
||||
"//java/com/google/gerrit/testing:gerrit-test-util",
|
||||
"//lib:guava",
|
||||
"//lib/guice",
|
||||
"//lib/jgit/org.eclipse.jgit:jgit",
|
||||
|
||||
@@ -27,6 +27,7 @@ import static com.google.gerrit.elasticsearch.ElasticConfiguration.SECTION_ELAST
|
||||
import static java.util.stream.Collectors.toList;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import com.google.inject.ProvisionException;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -35,7 +36,7 @@ import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
||||
public class ElasticConfigurationTest {
|
||||
public class ElasticConfigurationTest extends GerritBaseTests {
|
||||
@Rule public ExpectedException exception = ExpectedException.none();
|
||||
|
||||
@Test
|
||||
|
||||
@@ -16,11 +16,12 @@ package com.google.gerrit.elasticsearch;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
||||
public class ElasticVersionTest {
|
||||
public class ElasticVersionTest extends GerritBaseTests {
|
||||
@Rule public ExpectedException exception = ExpectedException.none();
|
||||
|
||||
@Test
|
||||
|
||||
@@ -7,6 +7,7 @@ junit_tests(
|
||||
deps = [
|
||||
"//java/com/google/gerrit/extensions:api",
|
||||
"//java/com/google/gerrit/extensions/common/testing:common-test-util",
|
||||
"//java/com/google/gerrit/testing:gerrit-test-util",
|
||||
"//lib/guice",
|
||||
"//lib/truth",
|
||||
],
|
||||
|
||||
@@ -16,11 +16,12 @@ package com.google.gerrit.extensions.api.lfs;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import org.junit.Test;
|
||||
|
||||
public class LfsDefinitionsTest {
|
||||
public class LfsDefinitionsTest extends GerritBaseTests {
|
||||
private static final String[] URL_PREFIXES = new String[] {"/", "/a/", "/p/", "/a/p/"};
|
||||
|
||||
@Test
|
||||
|
||||
@@ -16,9 +16,10 @@ package com.google.gerrit.extensions.client;
|
||||
|
||||
import static com.google.gerrit.extensions.common.testing.RangeSubject.assertThat;
|
||||
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import org.junit.Test;
|
||||
|
||||
public class RangeTest {
|
||||
public class RangeTest extends GerritBaseTests {
|
||||
|
||||
@Test
|
||||
public void rangeOverMultipleLinesWithSmallerEndCharacterIsValid() {
|
||||
|
||||
@@ -5,6 +5,7 @@ junit_tests(
|
||||
srcs = glob(["*.java"]),
|
||||
deps = [
|
||||
"//java/com/google/gerrit/extensions:lib",
|
||||
"//java/com/google/gerrit/testing:gerrit-test-util",
|
||||
"//lib/truth",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -20,9 +20,10 @@ import static com.google.gerrit.extensions.conditions.BooleanCondition.or;
|
||||
import static com.google.gerrit.extensions.conditions.BooleanCondition.valueOf;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import org.junit.Test;
|
||||
|
||||
public class BooleanConditionTest {
|
||||
public class BooleanConditionTest extends GerritBaseTests {
|
||||
|
||||
private static final BooleanCondition NO_TRIVIAL_EVALUATION =
|
||||
new BooleanCondition() {
|
||||
|
||||
@@ -17,13 +17,14 @@ package com.google.gerrit.extensions.registration;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static java.util.stream.Collectors.toSet;
|
||||
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import com.google.inject.Key;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.util.Providers;
|
||||
import java.util.Iterator;
|
||||
import org.junit.Test;
|
||||
|
||||
public class DynamicSetTest {
|
||||
public class DynamicSetTest extends GerritBaseTests {
|
||||
// In tests for {@link DynamicSet#contains(Object)}, be sure to avoid
|
||||
// {@code assertThat(ds).contains(...) @} and
|
||||
// {@code assertThat(ds).DoesNotContains(...) @} as (since
|
||||
|
||||
@@ -10,6 +10,7 @@ junit_tests(
|
||||
tags = ["no_windows"],
|
||||
deps = [
|
||||
"//java/com/google/gerrit/git",
|
||||
"//java/com/google/gerrit/testing:gerrit-test-util",
|
||||
"//lib:guava",
|
||||
"//lib:junit",
|
||||
"//lib/jgit/org.eclipse.jgit:jgit",
|
||||
@@ -27,6 +28,7 @@ junit_tests(
|
||||
),
|
||||
deps = [
|
||||
"//java/com/google/gerrit/git",
|
||||
"//java/com/google/gerrit/testing:gerrit-test-util",
|
||||
"//lib:guava",
|
||||
"//lib/jgit/org.eclipse.jgit:jgit",
|
||||
"//lib/truth",
|
||||
|
||||
@@ -19,6 +19,7 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.io.MoreFiles;
|
||||
import com.google.common.io.RecursiveDeleteOption;
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import org.eclipse.jgit.internal.storage.dfs.DfsRepositoryDescription;
|
||||
@@ -35,7 +36,7 @@ import org.junit.runners.Parameterized.Parameter;
|
||||
import org.junit.runners.Parameterized.Parameters;
|
||||
|
||||
@RunWith(Parameterized.class)
|
||||
public class RefUpdateUtilRepoTest {
|
||||
public class RefUpdateUtilRepoTest extends GerritBaseTests {
|
||||
public enum RepoSetup {
|
||||
LOCAL_DISK {
|
||||
@Override
|
||||
|
||||
@@ -19,6 +19,7 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.common.truth.Truth.assert_;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import java.io.IOException;
|
||||
import java.util.function.Consumer;
|
||||
import org.eclipse.jgit.internal.storage.dfs.DfsRepositoryDescription;
|
||||
@@ -32,7 +33,7 @@ import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
|
||||
@RunWith(JUnit4.class)
|
||||
public class RefUpdateUtilTest {
|
||||
public class RefUpdateUtilTest extends GerritBaseTests {
|
||||
private static final Consumer<ReceiveCommand> OK = c -> c.setResult(ReceiveCommand.Result.OK);
|
||||
private static final Consumer<ReceiveCommand> LOCK_FAILURE =
|
||||
c -> c.setResult(ReceiveCommand.Result.LOCK_FAILURE);
|
||||
|
||||
@@ -5,6 +5,7 @@ junit_tests(
|
||||
srcs = glob(["*.java"]),
|
||||
deps = [
|
||||
"//java/com/google/gerrit/git/testing",
|
||||
"//java/com/google/gerrit/testing:gerrit-test-util",
|
||||
"//lib/truth",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -18,9 +18,10 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.gerrit.git.testing.PushResultSubject.parseProcessed;
|
||||
import static com.google.gerrit.git.testing.PushResultSubject.trimMessages;
|
||||
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import org.junit.Test;
|
||||
|
||||
public class PushResultSubjectTest {
|
||||
public class PushResultSubjectTest extends GerritBaseTests {
|
||||
@Test
|
||||
public void testTrimMessages() {
|
||||
assertThat(trimMessages(null)).isNull();
|
||||
|
||||
@@ -44,6 +44,7 @@ import com.google.gerrit.server.account.externalids.ExternalId;
|
||||
import com.google.gerrit.server.schema.ReviewDbSchemaCreator;
|
||||
import com.google.gerrit.server.util.RequestContext;
|
||||
import com.google.gerrit.server.util.ThreadLocalRequestContext;
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import com.google.gerrit.testing.InMemoryDatabase;
|
||||
import com.google.gerrit.testing.InMemoryModule;
|
||||
import com.google.gerrit.testing.NoteDbMode;
|
||||
@@ -69,7 +70,7 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
/** Unit tests for {@link GerritPublicKeyChecker}. */
|
||||
public class GerritPublicKeyCheckerTest {
|
||||
public class GerritPublicKeyCheckerTest extends GerritBaseTests {
|
||||
@Inject @ServerInitiated private Provider<AccountsUpdate> accountsUpdateProvider;
|
||||
|
||||
@Inject private AccountManager accountManager;
|
||||
|
||||
@@ -38,6 +38,7 @@ import static org.bouncycastle.openpgp.PGPSignature.DIRECT_KEY;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import com.google.gerrit.gpg.testing.TestKey;
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -61,7 +62,7 @@ import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
||||
public class PublicKeyCheckerTest {
|
||||
public class PublicKeyCheckerTest extends GerritBaseTests {
|
||||
@Rule public ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
private InMemoryRepository repo;
|
||||
|
||||
@@ -28,6 +28,7 @@ import static org.junit.Assert.assertTrue;
|
||||
|
||||
import com.google.common.collect.Iterators;
|
||||
import com.google.gerrit.gpg.testing.TestKey;
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
@@ -49,7 +50,7 @@ import org.eclipse.jgit.revwalk.RevWalk;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class PublicKeyStoreTest {
|
||||
public class PublicKeyStoreTest extends GerritBaseTests {
|
||||
private TestRepository<?> tr;
|
||||
private PublicKeyStore store;
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import com.google.gerrit.gpg.testing.TestKey;
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.InputStreamReader;
|
||||
@@ -53,7 +54,7 @@ import org.eclipse.jgit.transport.SignedPushConfig;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class PushCertificateCheckerTest {
|
||||
public class PushCertificateCheckerTest extends GerritBaseTests {
|
||||
private InMemoryRepository repo;
|
||||
private PublicKeyStore store;
|
||||
private SignedPushConfig signedPushConfig;
|
||||
|
||||
@@ -21,6 +21,7 @@ import static org.easymock.EasyMock.eq;
|
||||
import com.google.gerrit.extensions.registration.DynamicSet;
|
||||
import com.google.gerrit.extensions.registration.ReloadableRegistrationHandle;
|
||||
import com.google.gerrit.server.plugins.Plugin;
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import com.google.gerrit.util.http.testutil.FakeHttpServletRequest;
|
||||
import com.google.gerrit.util.http.testutil.FakeHttpServletResponse;
|
||||
import com.google.inject.Key;
|
||||
@@ -35,7 +36,7 @@ import org.easymock.IMocksControl;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class AllRequestFilterFilterProxyTest {
|
||||
public class AllRequestFilterFilterProxyTest extends GerritBaseTests {
|
||||
/**
|
||||
* Set of filters for FilterProxy
|
||||
*
|
||||
|
||||
@@ -10,6 +10,7 @@ junit_tests(
|
||||
"//java/com/google/gerrit/httpd",
|
||||
"//java/com/google/gerrit/reviewdb:server",
|
||||
"//java/com/google/gerrit/server",
|
||||
"//java/com/google/gerrit/testing:gerrit-test-util",
|
||||
"//java/com/google/gerrit/util/http",
|
||||
"//javatests/com/google/gerrit/util/http/testutil",
|
||||
"//lib:gson",
|
||||
|
||||
@@ -17,9 +17,10 @@ package com.google.gerrit.httpd;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.gerrit.httpd.RemoteUserUtil.extractUsername;
|
||||
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import org.junit.Test;
|
||||
|
||||
public class RemoteUserUtilTest {
|
||||
public class RemoteUserUtilTest extends GerritBaseTests {
|
||||
@Test
|
||||
public void testExtractUsername() {
|
||||
assertThat(extractUsername(null)).isNull();
|
||||
|
||||
@@ -16,11 +16,12 @@ package com.google.gerrit.httpd.plugins;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import com.google.gerrit.util.http.testutil.FakeHttpServletRequest;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import org.junit.Test;
|
||||
|
||||
public class ContextMapperTest {
|
||||
public class ContextMapperTest extends GerritBaseTests {
|
||||
|
||||
private static final String CONTEXT = "/context";
|
||||
private static final String PLUGIN_NAME = "my-plugin";
|
||||
|
||||
@@ -17,11 +17,12 @@ package com.google.gerrit.httpd.raw;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import com.google.template.soy.data.SoyMapData;
|
||||
import java.net.URISyntaxException;
|
||||
import org.junit.Test;
|
||||
|
||||
public class IndexServletTest {
|
||||
public class IndexServletTest extends GerritBaseTests {
|
||||
static class TestIndexServlet extends IndexServlet {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ import com.google.common.io.ByteStreams;
|
||||
import com.google.common.jimfs.Configuration;
|
||||
import com.google.common.jimfs.Jimfs;
|
||||
import com.google.gerrit.httpd.raw.ResourceServlet.Resource;
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import com.google.gerrit.util.http.testutil.FakeHttpServletRequest;
|
||||
import com.google.gerrit.util.http.testutil.FakeHttpServletResponse;
|
||||
import java.io.ByteArrayInputStream;
|
||||
@@ -44,7 +45,7 @@ import java.util.zip.GZIPInputStream;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class ResourceServletTest {
|
||||
public class ResourceServletTest extends GerritBaseTests {
|
||||
private static Cache<Path, Resource> newCache(int size) {
|
||||
return CacheBuilder.newBuilder().maximumSize(size).recordStats().build();
|
||||
}
|
||||
|
||||
@@ -16,9 +16,10 @@ package com.google.gerrit.httpd.restapi;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import org.junit.Test;
|
||||
|
||||
public class HttpLogRedactTest {
|
||||
public class HttpLogRedactTest extends GerritBaseTests {
|
||||
@Test
|
||||
public void redactAuth() {
|
||||
assertThat(LogRedactUtil.redactQueryString("query=status:open")).isEqualTo("query=status:open");
|
||||
|
||||
@@ -22,13 +22,14 @@ import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.gerrit.extensions.restapi.BadRequestException;
|
||||
import com.google.gerrit.httpd.restapi.ParameterParser.QueryParams;
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import com.google.gerrit.util.http.testutil.FakeHttpServletRequest;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
import org.junit.Test;
|
||||
|
||||
public class ParameterParserTest {
|
||||
public class ParameterParserTest extends GerritBaseTests {
|
||||
@Test
|
||||
public void convertFormToJson() throws BadRequestException {
|
||||
JsonObject obj =
|
||||
|
||||
@@ -9,6 +9,7 @@ junit_tests(
|
||||
"//antlr3:query_parser",
|
||||
"//java/com/google/gerrit/index",
|
||||
"//java/com/google/gerrit/index:query_exception",
|
||||
"//java/com/google/gerrit/testing:gerrit-test-util",
|
||||
"//lib:guava",
|
||||
"//lib:junit",
|
||||
"//lib/antlr:java-runtime",
|
||||
|
||||
@@ -19,13 +19,14 @@ import static com.google.gerrit.index.SchemaUtil.getNameParts;
|
||||
import static com.google.gerrit.index.SchemaUtil.getPersonParts;
|
||||
import static com.google.gerrit.index.SchemaUtil.schema;
|
||||
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import java.util.Map;
|
||||
import org.eclipse.jgit.lib.PersonIdent;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
||||
public class SchemaUtilTest {
|
||||
public class SchemaUtilTest extends GerritBaseTests {
|
||||
@Rule public ExpectedException exception = ExpectedException.none();
|
||||
|
||||
static class TestSchemas {
|
||||
|
||||
@@ -16,10 +16,11 @@ package com.google.gerrit.index.query;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import org.antlr.runtime.tree.Tree;
|
||||
import org.junit.Test;
|
||||
|
||||
public class QueryParserTest {
|
||||
public class QueryParserTest extends GerritBaseTests {
|
||||
@Test
|
||||
public void projectBare() throws QueryParseException {
|
||||
Tree r;
|
||||
|
||||
@@ -18,6 +18,7 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
import com.google.gerrit.reviewdb.client.Comment;
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import java.sql.Timestamp;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
@@ -25,7 +26,7 @@ import java.util.List;
|
||||
import org.junit.Ignore;
|
||||
|
||||
@Ignore
|
||||
public class AbstractParserTest {
|
||||
public class AbstractParserTest extends GerritBaseTests {
|
||||
protected static final String CHANGE_URL =
|
||||
"https://gerrit-review.googlesource.com/c/project/+/123";
|
||||
|
||||
|
||||
@@ -16,13 +16,14 @@ package com.google.gerrit.mail;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.Month;
|
||||
import java.time.ZoneOffset;
|
||||
import org.junit.Test;
|
||||
|
||||
public class MailHeaderParserTest {
|
||||
public class MailHeaderParserTest extends GerritBaseTests {
|
||||
@Test
|
||||
public void parseMetadataFromHeader() {
|
||||
// This tests if the metadata parser is able to parse metadata from the
|
||||
|
||||
@@ -16,9 +16,10 @@ package com.google.gerrit.mail;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import org.junit.Test;
|
||||
|
||||
public class ParserUtilTest {
|
||||
public class ParserUtilTest extends GerritBaseTests {
|
||||
@Test
|
||||
public void trimQuotationLineOnMessageWithoutQuoatationLine() throws Exception {
|
||||
assertThat(ParserUtil.trimQuotation("One line")).isEqualTo("One line");
|
||||
|
||||
@@ -7,6 +7,7 @@ junit_tests(
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//java/com/google/gerrit/metrics/dropwizard",
|
||||
"//java/com/google/gerrit/testing:gerrit-test-util",
|
||||
"//lib/truth",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -16,9 +16,10 @@ package com.google.gerrit.metrics.dropwizard;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import org.junit.Test;
|
||||
|
||||
public class DropWizardMetricMakerTest {
|
||||
public class DropWizardMetricMakerTest extends GerritBaseTests {
|
||||
DropWizardMetricMaker metrics =
|
||||
new DropWizardMetricMaker(null /* MetricRegistry unused in tests */);
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ junit_tests(
|
||||
"//java/com/google/gerrit/lifecycle",
|
||||
"//java/com/google/gerrit/metrics",
|
||||
"//java/com/google/gerrit/metrics/dropwizard",
|
||||
"//java/com/google/gerrit/testing:gerrit-test-util",
|
||||
"//lib/dropwizard:dropwizard-core",
|
||||
"//lib/guice",
|
||||
"//lib/truth",
|
||||
|
||||
@@ -30,6 +30,7 @@ import com.google.gerrit.metrics.Description.FieldOrdering;
|
||||
import com.google.gerrit.metrics.Field;
|
||||
import com.google.gerrit.metrics.MetricMaker;
|
||||
import com.google.gerrit.metrics.dropwizard.DropWizardMetricMaker;
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Injector;
|
||||
@@ -40,7 +41,7 @@ import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
||||
public class ProcMetricModuleTest {
|
||||
public class ProcMetricModuleTest extends GerritBaseTests {
|
||||
@Rule public ExpectedException exception = ExpectedException.none();
|
||||
|
||||
@Inject MetricMaker metrics;
|
||||
|
||||
@@ -21,12 +21,13 @@ import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import com.google.gerrit.pgm.init.api.ConsoleUI;
|
||||
import com.google.gerrit.server.config.SitePaths;
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import com.google.inject.Provider;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Collections;
|
||||
import org.junit.Test;
|
||||
|
||||
public class LibrariesTest {
|
||||
public class LibrariesTest extends GerritBaseTests {
|
||||
@Test
|
||||
public void create() throws Exception {
|
||||
final SitePaths site = new SitePaths(Paths.get("."));
|
||||
|
||||
@@ -4,6 +4,7 @@ junit_tests(
|
||||
name = "proto_tests",
|
||||
srcs = glob(["*.java"]),
|
||||
deps = [
|
||||
"//java/com/google/gerrit/testing:gerrit-test-util",
|
||||
"//lib/truth:truth-proto-extension",
|
||||
"//proto:reviewdb_java_proto",
|
||||
|
||||
|
||||
@@ -18,9 +18,10 @@ import static com.google.common.truth.extensions.proto.ProtoTruth.assertThat;
|
||||
|
||||
import com.google.gerrit.proto.reviewdb.Reviewdb.Change;
|
||||
import com.google.gerrit.proto.reviewdb.Reviewdb.Change_Id;
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import org.junit.Test;
|
||||
|
||||
public class ReviewDbProtoTest {
|
||||
public class ReviewDbProtoTest extends GerritBaseTests {
|
||||
@Test
|
||||
public void generatedProtoApi() {
|
||||
Change c1 = Change.newBuilder().setChangeId(Change_Id.newBuilder().setId(1234).build()).build();
|
||||
|
||||
@@ -16,10 +16,11 @@ package com.google.gerrit.server;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import java.util.regex.Pattern;
|
||||
import org.junit.Test;
|
||||
|
||||
public class ChangeUtilTest {
|
||||
public class ChangeUtilTest extends GerritBaseTests {
|
||||
@Test
|
||||
public void changeMessageUuid() throws Exception {
|
||||
Pattern pat = Pattern.compile("^[0-9a-f]{8}_[0-9a-f]{8}$");
|
||||
|
||||
@@ -31,6 +31,7 @@ import com.google.gerrit.server.group.SystemGroupBackend;
|
||||
import com.google.gerrit.server.util.time.TimeUtil;
|
||||
import com.google.gerrit.testing.ConfigSuite;
|
||||
import com.google.gerrit.testing.FakeAccountCache;
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Inject;
|
||||
@@ -44,7 +45,7 @@ import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@RunWith(ConfigSuite.class)
|
||||
public class IdentifiedUserTest {
|
||||
public class IdentifiedUserTest extends GerritBaseTests {
|
||||
@ConfigSuite.Parameter public Config config;
|
||||
|
||||
private IdentifiedUser identifiedUser;
|
||||
|
||||
@@ -17,12 +17,13 @@ package com.google.gerrit.server.account;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import org.junit.Test;
|
||||
|
||||
public class AuthorizedKeysTest {
|
||||
public class AuthorizedKeysTest extends GerritBaseTests {
|
||||
private static final String KEY1 =
|
||||
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQCgug5VyMXQGnem2H1KVC4/HcRcD4zzBqS"
|
||||
+ "uJBRWVonSSoz3RoAZ7bWXCVVGwchtXwUURD689wFYdiPecOrWOUgeeyRq754YWRhU+W28"
|
||||
|
||||
@@ -17,10 +17,11 @@ package com.google.gerrit.server.account;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import com.google.gerrit.reviewdb.client.AccountGroup;
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import org.eclipse.jgit.lib.PersonIdent;
|
||||
import org.junit.Test;
|
||||
|
||||
public class GroupUUIDTest {
|
||||
public class GroupUUIDTest extends GerritBaseTests {
|
||||
@Test
|
||||
public void createdUuidsForSameInputShouldBeDifferent() {
|
||||
String groupName = "Users";
|
||||
|
||||
@@ -17,10 +17,11 @@ package com.google.gerrit.server.account;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import org.apache.commons.codec.DecoderException;
|
||||
import org.junit.Test;
|
||||
|
||||
public class HashedPasswordTest {
|
||||
public class HashedPasswordTest extends GerritBaseTests {
|
||||
|
||||
@Test
|
||||
public void encodeOneLine() throws Exception {
|
||||
|
||||
@@ -25,12 +25,13 @@ import com.google.gerrit.reviewdb.client.Account;
|
||||
import com.google.gerrit.server.account.externalids.AllExternalIds.Serializer;
|
||||
import com.google.gerrit.server.cache.proto.Cache.AllExternalIdsProto;
|
||||
import com.google.gerrit.server.cache.proto.Cache.AllExternalIdsProto.ExternalIdProto;
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import com.google.inject.TypeLiteral;
|
||||
import java.util.Arrays;
|
||||
import org.eclipse.jgit.lib.ObjectId;
|
||||
import org.junit.Test;
|
||||
|
||||
public class AllExternalIdsTest {
|
||||
public class AllExternalIdsTest extends GerritBaseTests {
|
||||
@Test
|
||||
public void serializeEmptyExternalIds() throws Exception {
|
||||
assertRoundTrip(allExternalIds(), AllExternalIdsProto.getDefaultInstance());
|
||||
|
||||
@@ -5,6 +5,7 @@ junit_tests(
|
||||
srcs = glob(["*.java"]),
|
||||
deps = [
|
||||
"//java/com/google/gerrit/server",
|
||||
"//java/com/google/gerrit/testing:gerrit-test-util",
|
||||
"//lib:junit",
|
||||
"//lib/truth",
|
||||
],
|
||||
|
||||
@@ -16,12 +16,13 @@ package com.google.gerrit.server.cache;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import java.util.function.Supplier;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
||||
public class PerThreadCacheTest {
|
||||
public class PerThreadCacheTest extends GerritBaseTests {
|
||||
@Rule public ExpectedException exception = ExpectedException.none();
|
||||
|
||||
@Test
|
||||
|
||||
@@ -6,6 +6,7 @@ junit_tests(
|
||||
deps = [
|
||||
"//java/com/google/gerrit/server/cache/serialize",
|
||||
"//java/com/google/gerrit/server/cache/testing",
|
||||
"//java/com/google/gerrit/testing:gerrit-test-util",
|
||||
"//lib:guava",
|
||||
"//lib:gwtorm",
|
||||
"//lib:junit",
|
||||
|
||||
@@ -18,10 +18,11 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.common.truth.Truth.assert_;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import com.google.protobuf.TextFormat;
|
||||
import org.junit.Test;
|
||||
|
||||
public class BooleanCacheSerializerTest {
|
||||
public class BooleanCacheSerializerTest extends GerritBaseTests {
|
||||
@Test
|
||||
public void serialize() throws Exception {
|
||||
assertThat(BooleanCacheSerializer.INSTANCE.serialize(true))
|
||||
|
||||
@@ -18,9 +18,10 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.common.truth.Truth.assert_;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import org.junit.Test;
|
||||
|
||||
public class EnumCacheSerializerTest {
|
||||
public class EnumCacheSerializerTest extends GerritBaseTests {
|
||||
@Test
|
||||
public void serialize() throws Exception {
|
||||
assertRoundTrip(MyEnum.FOO);
|
||||
|
||||
@@ -17,11 +17,12 @@ package com.google.gerrit.server.cache.serialize;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.common.truth.Truth.assert_;
|
||||
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import com.google.gwtorm.client.IntKey;
|
||||
import com.google.gwtorm.client.Key;
|
||||
import org.junit.Test;
|
||||
|
||||
public class IntKeyCacheSerializerTest {
|
||||
public class IntKeyCacheSerializerTest extends GerritBaseTests {
|
||||
|
||||
private static class MyIntKey extends IntKey<Key<?>> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -19,10 +19,11 @@ import static com.google.common.truth.Truth.assert_;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.primitives.Bytes;
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import com.google.protobuf.TextFormat;
|
||||
import org.junit.Test;
|
||||
|
||||
public class IntegerCacheSerializerTest {
|
||||
public class IntegerCacheSerializerTest extends GerritBaseTests {
|
||||
@Test
|
||||
public void serialize() throws Exception {
|
||||
for (int i :
|
||||
|
||||
@@ -17,10 +17,11 @@ package com.google.gerrit.server.cache.serialize;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import com.google.auto.value.AutoValue;
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import java.io.Serializable;
|
||||
import org.junit.Test;
|
||||
|
||||
public class JavaCacheSerializerTest {
|
||||
public class JavaCacheSerializerTest extends GerritBaseTests {
|
||||
@Test
|
||||
public void builtInTypes() throws Exception {
|
||||
assertRoundTrip("foo");
|
||||
|
||||
@@ -18,10 +18,11 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.common.truth.Truth.assert_;
|
||||
import static com.google.gerrit.server.cache.testing.CacheSerializerTestUtil.byteArray;
|
||||
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import org.eclipse.jgit.lib.ObjectId;
|
||||
import org.junit.Test;
|
||||
|
||||
public class ObjectIdCacheSerializerTest {
|
||||
public class ObjectIdCacheSerializerTest extends GerritBaseTests {
|
||||
@Test
|
||||
public void serialize() {
|
||||
ObjectId id = ObjectId.fromString("aabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
|
||||
|
||||
@@ -22,11 +22,12 @@ import static com.google.gerrit.server.cache.testing.CacheSerializerTestUtil.byt
|
||||
import com.google.gerrit.server.cache.proto.Cache.ChangeNotesKeyProto;
|
||||
import com.google.gerrit.server.cache.proto.Cache.ChangeNotesStateProto;
|
||||
import com.google.gerrit.server.cache.serialize.ProtoCacheSerializers.ObjectIdConverter;
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import com.google.protobuf.ByteString;
|
||||
import org.eclipse.jgit.lib.ObjectId;
|
||||
import org.junit.Test;
|
||||
|
||||
public class ProtoCacheSerializersTest {
|
||||
public class ProtoCacheSerializersTest extends GerritBaseTests {
|
||||
@Test
|
||||
public void objectIdFromByteString() {
|
||||
ObjectIdConverter idConverter = ObjectIdConverter.create();
|
||||
|
||||
@@ -17,11 +17,12 @@ package com.google.gerrit.server.cache.serialize;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.common.truth.Truth.assert_;
|
||||
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import java.nio.charset.CharacterCodingException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import org.junit.Test;
|
||||
|
||||
public class StringCacheSerializerTest {
|
||||
public class StringCacheSerializerTest extends GerritBaseTests {
|
||||
@Test
|
||||
public void serialize() {
|
||||
assertThat(StringCacheSerializer.INSTANCE.serialize("")).isEmpty();
|
||||
|
||||
@@ -23,10 +23,11 @@ import com.google.common.collect.ImmutableMap;
|
||||
import com.google.gerrit.server.cache.proto.Cache.ChangeKindKeyProto;
|
||||
import com.google.gerrit.server.cache.serialize.CacheSerializer;
|
||||
import com.google.gerrit.server.change.ChangeKindCacheImpl.Key;
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import org.eclipse.jgit.lib.ObjectId;
|
||||
import org.junit.Test;
|
||||
|
||||
public class ChangeKindCacheImplTest {
|
||||
public class ChangeKindCacheImplTest extends GerritBaseTests {
|
||||
@Test
|
||||
public void keySerializer() throws Exception {
|
||||
ChangeKindCacheImpl.Key key =
|
||||
|
||||
@@ -17,9 +17,10 @@ package com.google.gerrit.server.change;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import org.junit.Test;
|
||||
|
||||
public class HashtagsTest {
|
||||
public class HashtagsTest extends GerritBaseTests {
|
||||
@Test
|
||||
public void emptyCommitMessage() throws Exception {
|
||||
assertThat(HashtagsUtil.extractTags("")).isEmpty();
|
||||
|
||||
@@ -48,6 +48,7 @@ import com.google.gerrit.server.schema.ReviewDbSchemaCreator;
|
||||
import com.google.gerrit.server.util.RequestContext;
|
||||
import com.google.gerrit.server.util.ThreadLocalRequestContext;
|
||||
import com.google.gerrit.server.util.time.TimeUtil;
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import com.google.gerrit.testing.InMemoryDatabase;
|
||||
import com.google.gerrit.testing.InMemoryModule;
|
||||
import com.google.inject.Guice;
|
||||
@@ -62,7 +63,7 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
/** Unit tests for {@link LabelNormalizer}. */
|
||||
public class LabelNormalizerTest {
|
||||
public class LabelNormalizerTest extends GerritBaseTests {
|
||||
@Inject private AccountManager accountManager;
|
||||
@Inject private AllProjectsName allProjects;
|
||||
@Inject private GitRepositoryManager repoManager;
|
||||
|
||||
@@ -22,10 +22,11 @@ import static com.google.gerrit.server.cache.testing.SerializedClassSubject.asse
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.gerrit.extensions.client.SubmitType;
|
||||
import com.google.gerrit.server.cache.proto.Cache.MergeabilityKeyProto;
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import org.eclipse.jgit.lib.ObjectId;
|
||||
import org.junit.Test;
|
||||
|
||||
public class MergeabilityCacheImplTest {
|
||||
public class MergeabilityCacheImplTest extends GerritBaseTests {
|
||||
@Test
|
||||
public void keySerializer() throws Exception {
|
||||
MergeabilityCacheImpl.EntryKey key =
|
||||
|
||||
@@ -22,13 +22,14 @@ import static java.util.concurrent.TimeUnit.MINUTES;
|
||||
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||
|
||||
import com.google.gerrit.extensions.client.Theme;
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import org.eclipse.jgit.lib.Config;
|
||||
import org.junit.Test;
|
||||
|
||||
public class ConfigUtilTest {
|
||||
public class ConfigUtilTest extends GerritBaseTests {
|
||||
private static final String SECT = "foo";
|
||||
private static final String SUB = "bar";
|
||||
|
||||
|
||||
@@ -16,9 +16,10 @@ package com.google.gerrit.server.config;
|
||||
|
||||
import static com.google.common.truth.Truth.assertWithMessage;
|
||||
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import org.junit.Test;
|
||||
|
||||
public class GitwebConfigTest {
|
||||
public class GitwebConfigTest extends GerritBaseTests {
|
||||
private static final String VALID_CHARACTERS = "*()";
|
||||
private static final String SOME_INVALID_CHARACTERS = "09AZaz$-_.+!',";
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.google.gerrit.server.CurrentUser;
|
||||
import com.google.gerrit.server.permissions.PermissionBackend;
|
||||
import com.google.gerrit.server.restapi.config.ListCapabilities;
|
||||
import com.google.gerrit.server.restapi.config.ListCapabilities.CapabilityInfo;
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
@@ -33,7 +34,7 @@ import java.util.Map;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class ListCapabilitiesTest {
|
||||
public class ListCapabilitiesTest extends GerritBaseTests {
|
||||
private Injector injector;
|
||||
|
||||
@Before
|
||||
|
||||
@@ -20,6 +20,7 @@ import static com.google.common.truth.Truth8.assertThat;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.gerrit.extensions.client.SubmitType;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.List;
|
||||
@@ -27,7 +28,7 @@ import org.eclipse.jgit.lib.Config;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class RepositoryConfigTest {
|
||||
public class RepositoryConfigTest extends GerritBaseTests {
|
||||
|
||||
private Config cfg;
|
||||
private RepositoryConfig repoCfg;
|
||||
|
||||
@@ -22,6 +22,7 @@ import static java.util.concurrent.TimeUnit.MILLISECONDS;
|
||||
import static java.util.concurrent.TimeUnit.MINUTES;
|
||||
|
||||
import com.google.gerrit.server.config.ScheduleConfig.Schedule;
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.Month;
|
||||
import java.time.ZoneOffset;
|
||||
@@ -31,7 +32,7 @@ import java.util.concurrent.TimeUnit;
|
||||
import org.eclipse.jgit.lib.Config;
|
||||
import org.junit.Test;
|
||||
|
||||
public class ScheduleConfigTest {
|
||||
public class ScheduleConfigTest extends GerritBaseTests {
|
||||
|
||||
// Friday June 13, 2014 10:00 UTC
|
||||
private static final ZonedDateTime NOW =
|
||||
|
||||
@@ -20,9 +20,10 @@ import com.google.gerrit.reviewdb.client.Account;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||
import com.google.gerrit.reviewdb.client.RefNames;
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import org.junit.Test;
|
||||
|
||||
public class ChangeEditTest {
|
||||
public class ChangeEditTest extends GerritBaseTests {
|
||||
@Test
|
||||
public void changeEditRef() throws Exception {
|
||||
Account.Id accountId = new Account.Id(1000042);
|
||||
|
||||
@@ -20,11 +20,12 @@ import com.google.common.base.Supplier;
|
||||
import com.google.common.base.Suppliers;
|
||||
import com.google.gerrit.server.data.AccountAttribute;
|
||||
import com.google.gerrit.server.data.RefUpdateAttribute;
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import org.junit.Test;
|
||||
|
||||
public class EventDeserializerTest {
|
||||
public class EventDeserializerTest extends GerritBaseTests {
|
||||
|
||||
@Test
|
||||
public void refUpdatedEvent() {
|
||||
|
||||
@@ -16,9 +16,10 @@ package com.google.gerrit.server.events;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import org.junit.Test;
|
||||
|
||||
public class EventTypesTest {
|
||||
public class EventTypesTest extends GerritBaseTests {
|
||||
public static class TestEvent extends Event {
|
||||
private static final String TYPE = "test-event";
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ import com.google.gerrit.server.permissions.PermissionBackend.RefFilterOptions;
|
||||
import com.google.gerrit.server.permissions.PermissionBackendCondition;
|
||||
import com.google.gerrit.server.permissions.PermissionBackendException;
|
||||
import com.google.gerrit.server.permissions.ProjectPermission;
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@@ -38,7 +39,7 @@ import org.eclipse.jgit.lib.Ref;
|
||||
import org.eclipse.jgit.lib.Repository;
|
||||
import org.junit.Test;
|
||||
|
||||
public class UiActionsTest {
|
||||
public class UiActionsTest extends GerritBaseTests {
|
||||
|
||||
private static class FakeForProject extends ForProject {
|
||||
private boolean allowValueQueries = true;
|
||||
|
||||
@@ -26,6 +26,7 @@ import com.google.gerrit.reviewdb.client.FixReplacement;
|
||||
import com.google.gerrit.server.change.FileContentUtil;
|
||||
import com.google.gerrit.server.edit.tree.TreeModification;
|
||||
import com.google.gerrit.server.project.ProjectState;
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
@@ -37,7 +38,7 @@ import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
||||
public class FixReplacementInterpreterTest {
|
||||
public class FixReplacementInterpreterTest extends GerritBaseTests {
|
||||
|
||||
@Rule public ExpectedException expectedException = ExpectedException.none();
|
||||
|
||||
|
||||
@@ -16,11 +16,12 @@ package com.google.gerrit.server.fixes;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
||||
public class LineIdentifierTest {
|
||||
public class LineIdentifierTest extends GerritBaseTests {
|
||||
|
||||
@Rule public ExpectedException expectedException = ExpectedException.none();
|
||||
|
||||
|
||||
@@ -16,12 +16,13 @@ package com.google.gerrit.server.fixes;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
||||
public class StringModifierTest {
|
||||
public class StringModifierTest extends GerritBaseTests {
|
||||
|
||||
@Rule public ExpectedException expectedException = ExpectedException.none();
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.SortedSetMultimap;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import org.eclipse.jgit.internal.storage.dfs.DfsRepositoryDescription;
|
||||
import org.eclipse.jgit.internal.storage.dfs.InMemoryRepository;
|
||||
import org.eclipse.jgit.junit.TestRepository;
|
||||
@@ -31,7 +32,7 @@ import org.eclipse.jgit.revwalk.RevWalk;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class GroupCollectorTest {
|
||||
public class GroupCollectorTest extends GerritBaseTests {
|
||||
private TestRepository<?> tr;
|
||||
|
||||
@Before
|
||||
|
||||
@@ -21,9 +21,10 @@ import static com.google.gerrit.server.cache.testing.SerializedClassSubject.asse
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
import com.google.gerrit.server.cache.proto.Cache.TagSetHolderProto;
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TagSetHolderTest {
|
||||
public class TagSetHolderTest extends GerritBaseTests {
|
||||
@Test
|
||||
public void serializerWithTagSet() throws Exception {
|
||||
TagSetHolder holder = new TagSetHolder(new Project.NameKey("project"));
|
||||
|
||||
@@ -30,6 +30,7 @@ import com.google.gerrit.server.cache.proto.Cache.TagSetHolderProto.TagSetProto.
|
||||
import com.google.gerrit.server.cache.proto.Cache.TagSetHolderProto.TagSetProto.TagProto;
|
||||
import com.google.gerrit.server.git.TagSet.CachedRef;
|
||||
import com.google.gerrit.server.git.TagSet.Tag;
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import com.google.inject.TypeLiteral;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Arrays;
|
||||
@@ -42,7 +43,7 @@ import org.eclipse.jgit.lib.ObjectId;
|
||||
import org.eclipse.jgit.lib.ObjectIdOwnerMap;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TagSetTest {
|
||||
public class TagSetTest extends GerritBaseTests {
|
||||
@Test
|
||||
public void roundTripToProto() {
|
||||
HashMap<String, CachedRef> refs = new HashMap<>();
|
||||
|
||||
@@ -27,6 +27,7 @@ import com.google.gerrit.reviewdb.client.Project;
|
||||
import com.google.gerrit.server.extensions.events.GitReferenceUpdated;
|
||||
import com.google.gerrit.server.git.meta.VersionedMetaData.BatchMetaDataUpdate;
|
||||
import com.google.gerrit.server.util.time.TimeUtil;
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import com.google.gerrit.testing.TestTimeUtil;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
@@ -50,7 +51,7 @@ import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class VersionedMetaDataTest {
|
||||
public class VersionedMetaDataTest extends GerritBaseTests {
|
||||
// If you're considering fleshing out this test and making it more comprehensive, please consider
|
||||
// instead coming up with a replacement interface for
|
||||
// VersionedMetaData/BatchMetaDataUpdate/MetaDataUpdate that is easier to use correctly.
|
||||
|
||||
@@ -32,6 +32,7 @@ import com.google.gerrit.server.git.meta.MetaDataUpdate;
|
||||
import com.google.gerrit.server.group.InternalGroup;
|
||||
import com.google.gerrit.server.group.testing.InternalGroupSubject;
|
||||
import com.google.gerrit.server.util.time.TimeUtil;
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import com.google.gerrit.truth.OptionalSubject;
|
||||
import com.google.gwtorm.client.KeyUtil;
|
||||
import com.google.gwtorm.server.StandardKeyEncoder;
|
||||
@@ -57,7 +58,7 @@ import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
||||
public class GroupConfigTest {
|
||||
public class GroupConfigTest extends GerritBaseTests {
|
||||
static {
|
||||
// Necessary so that toString() methods of ReviewDb entities work correctly.
|
||||
KeyUtil.setEncoderImpl(new StandardKeyEncoder());
|
||||
|
||||
@@ -36,6 +36,7 @@ import com.google.gerrit.server.config.AllUsersNameProvider;
|
||||
import com.google.gerrit.server.extensions.events.GitReferenceUpdated;
|
||||
import com.google.gerrit.server.git.meta.MetaDataUpdate;
|
||||
import com.google.gerrit.server.util.time.TimeUtil;
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import com.google.gerrit.testing.GitTestUtil;
|
||||
import com.google.gerrit.testing.TestTimeUtil;
|
||||
import com.google.gerrit.truth.ListSubject;
|
||||
@@ -70,7 +71,7 @@ import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
||||
public class GroupNameNotesTest {
|
||||
public class GroupNameNotesTest extends GerritBaseTests {
|
||||
static {
|
||||
KeyUtil.setEncoderImpl(new StandardKeyEncoder());
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ junit_tests(
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//java/com/google/gerrit/server/ioutil",
|
||||
"//java/com/google/gerrit/testing:gerrit-test-util",
|
||||
"//lib:guava",
|
||||
"//lib/truth",
|
||||
"//lib/truth:truth-java8-extension",
|
||||
|
||||
@@ -23,13 +23,14 @@ import static com.google.gerrit.server.ioutil.BasicSerialization.writeVarInt32;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import org.junit.Test;
|
||||
|
||||
public class BasicSerializationTest {
|
||||
public class BasicSerializationTest extends GerritBaseTests {
|
||||
@Test
|
||||
public void testReadVarInt32() throws IOException {
|
||||
assertEquals(0x00000000, readVarInt32(r(b(0))));
|
||||
|
||||
@@ -14,12 +14,13 @@
|
||||
|
||||
package com.google.gerrit.server.ioutil;
|
||||
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class ColumnFormatterTest {
|
||||
public class ColumnFormatterTest extends GerritBaseTests {
|
||||
/**
|
||||
* Holds an in-memory {@link java.io.PrintWriter} object and allows comparisons of its contents to
|
||||
* a supplied string via an assert statement.
|
||||
|
||||
@@ -16,9 +16,10 @@ package com.google.gerrit.server.ioutil;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import org.junit.Test;
|
||||
|
||||
public class HexFormatTest {
|
||||
public class HexFormatTest extends GerritBaseTests {
|
||||
|
||||
@Test
|
||||
public void fromInt() {
|
||||
|
||||
@@ -18,10 +18,11 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.common.truth.Truth8.assertThat;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import java.util.List;
|
||||
import org.junit.Test;
|
||||
|
||||
public class RegexListSearcherTest {
|
||||
public class RegexListSearcherTest extends GerritBaseTests {
|
||||
private static final ImmutableList<String> EMPTY = ImmutableList.of();
|
||||
|
||||
@Test
|
||||
|
||||
@@ -16,9 +16,10 @@ package com.google.gerrit.server.ioutil;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import org.junit.Test;
|
||||
|
||||
public class StringUtilTest {
|
||||
public class StringUtilTest extends GerritBaseTests {
|
||||
/** Test the boundary condition that the first character of a string should be escaped. */
|
||||
@Test
|
||||
public void escapeFirstChar() {
|
||||
|
||||
@@ -17,6 +17,7 @@ package com.google.gerrit.server.logging;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import com.google.common.truth.Expect;
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import java.util.SortedMap;
|
||||
import java.util.SortedSet;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
@@ -24,7 +25,7 @@ import java.util.concurrent.Executors;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
public class LoggingContextAwareExecutorServiceTest {
|
||||
public class LoggingContextAwareExecutorServiceTest extends GerritBaseTests {
|
||||
@Rule public final Expect expect = Expect.create();
|
||||
|
||||
@Test
|
||||
|
||||
@@ -20,13 +20,14 @@ import static com.google.common.truth.Truth.assert_;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.ImmutableSetMultimap;
|
||||
import com.google.gerrit.testing.GerritBaseTests;
|
||||
import java.util.Map;
|
||||
import java.util.SortedMap;
|
||||
import java.util.SortedSet;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class MutableTagsTest {
|
||||
public class MutableTagsTest extends GerritBaseTests {
|
||||
private MutableTags tags;
|
||||
|
||||
@Before
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user