Search in sources :

Example 1 with InMemoryRepositoryManager

use of com.google.gerrit.testing.InMemoryRepositoryManager in project gerrit by GerritCodeReview.

the class GerritServer method restartAsSlave.

public static GerritServer restartAsSlave(GerritServer server) throws Exception {
    checkState(server.desc.sandboxed(), "restarting as slave requires @Sandboxed");
    Path site = server.testInjector.getInstance(Key.get(Path.class, SitePath.class));
    Config cfg = server.testInjector.getInstance(Key.get(Config.class, GerritServerConfig.class));
    cfg.setBoolean("container", null, "replica", true);
    InMemoryRepositoryManager inMemoryRepoManager = null;
    if (hasBinding(server.testInjector, InMemoryRepositoryManager.class)) {
        inMemoryRepoManager = server.testInjector.getInstance(InMemoryRepositoryManager.class);
    }
    server.close();
    server.daemon.stop();
    return start(server.desc, cfg, site, null, null, null, inMemoryRepoManager);
}
Also used : Path(java.nio.file.Path) SitePath(com.google.gerrit.server.config.SitePath) GerritServerConfig(com.google.gerrit.server.config.GerritServerConfig) InMemoryRepositoryManager(com.google.gerrit.testing.InMemoryRepositoryManager) Config(org.eclipse.jgit.lib.Config) GlobalPluginConfig(com.google.gerrit.acceptance.config.GlobalPluginConfig) GerritServerConfig(com.google.gerrit.server.config.GerritServerConfig) GerritConfig(com.google.gerrit.acceptance.config.GerritConfig) SitePath(com.google.gerrit.server.config.SitePath)

Example 2 with InMemoryRepositoryManager

use of com.google.gerrit.testing.InMemoryRepositoryManager in project gerrit by GerritCodeReview.

the class AbstractChangeNotesTest method setUpTestEnvironment.

// TODO(issue-15517): Fix the JdkObsolete issue with Date once JGit's PersonIdent class supports
// Instants
@SuppressWarnings("JdkObsolete")
@Before
public void setUpTestEnvironment() throws Exception {
    setTimeForTesting();
    serverIdent = new PersonIdent("Gerrit Server", "noreply@gerrit.com", Date.from(TimeUtil.now()), TZ);
    project = Project.nameKey("test-project");
    repoManager = new InMemoryRepositoryManager();
    repo = repoManager.createRepository(project);
    tr = new TestRepository<>(repo);
    rw = tr.getRevWalk();
    accountCache = new FakeAccountCache();
    Account.Builder co = Account.builder(Account.id(1), TimeUtil.now());
    co.setFullName("Change Owner");
    co.setPreferredEmail("change@owner.com");
    accountCache.put(co.build());
    Account.Builder ou = Account.builder(Account.id(2), TimeUtil.now());
    ou.setFullName("Other Account");
    ou.setPreferredEmail("other@account.com");
    accountCache.put(ou.build());
    assertableFanOutExecutor = new AssertableExecutorService();
    injector = Guice.createInjector(new FactoryModule() {

        @Override
        public void configure() {
            install(new GitModule());
            install(new DefaultUrlFormatterModule());
            install(NoteDbModule.forTest());
            bind(AllUsersName.class).toProvider(AllUsersNameProvider.class);
            bind(String.class).annotatedWith(GerritServerId.class).toInstance("gerrit");
            bind(GitRepositoryManager.class).toInstance(repoManager);
            bind(ProjectCache.class).to(NullProjectCache.class);
            bind(Config.class).annotatedWith(GerritServerConfig.class).toInstance(testConfig);
            bind(String.class).annotatedWith(AnonymousCowardName.class).toProvider(AnonymousCowardNameProvider.class);
            bind(String.class).annotatedWith(CanonicalWebUrl.class).toInstance("http://localhost:8080/");
            bind(Boolean.class).annotatedWith(EnablePeerIPInReflogRecord.class).toInstance(Boolean.FALSE);
            bind(Realm.class).to(FakeRealm.class);
            bind(GroupBackend.class).to(SystemGroupBackend.class).in(SINGLETON);
            bind(AccountCache.class).toInstance(accountCache);
            bind(PersonIdent.class).annotatedWith(GerritPersonIdent.class).toInstance(serverIdent);
            bind(GitReferenceUpdated.class).toInstance(GitReferenceUpdated.DISABLED);
            bind(MetricMaker.class).to(DisabledMetricMaker.class);
            bind(ExecutorService.class).annotatedWith(FanOutExecutor.class).toInstance(assertableFanOutExecutor);
            bind(ServiceUserClassifier.class).to(ServiceUserClassifier.NoOp.class);
            bind(InternalChangeQuery.class).toProvider(() -> {
                throw new UnsupportedOperationException();
            });
            bind(PatchSetApprovalUuidGenerator.class).to(TestPatchSetApprovalUuidGenerator.class);
        }
    });
    injector.injectMembers(this);
    repoManager.createRepository(allUsers);
    changeOwner = userFactory.create(co.id());
    otherUser = userFactory.create(ou.id());
    otherUserId = otherUser.getAccountId();
    internalUser = new InternalUser();
}
Also used : MetricMaker(com.google.gerrit.metrics.MetricMaker) DisabledMetricMaker(com.google.gerrit.metrics.DisabledMetricMaker) Account(com.google.gerrit.entities.Account) InMemoryRepositoryManager(com.google.gerrit.testing.InMemoryRepositoryManager) AssertableExecutorService(com.google.gerrit.testing.AssertableExecutorService) InternalUser(com.google.gerrit.server.InternalUser) GerritServerId(com.google.gerrit.server.config.GerritServerId) GitReferenceUpdated(com.google.gerrit.server.extensions.events.GitReferenceUpdated) FakeAccountCache(com.google.gerrit.testing.FakeAccountCache) SystemGroupBackend(com.google.gerrit.server.group.SystemGroupBackend) FakeRealm(com.google.gerrit.server.account.FakeRealm) Realm(com.google.gerrit.server.account.Realm) GerritPersonIdent(com.google.gerrit.server.GerritPersonIdent) GerritServerConfig(com.google.gerrit.server.config.GerritServerConfig) EnablePeerIPInReflogRecord(com.google.gerrit.server.config.EnablePeerIPInReflogRecord) AnonymousCowardName(com.google.gerrit.server.config.AnonymousCowardName) CanonicalWebUrl(com.google.gerrit.server.config.CanonicalWebUrl) FactoryModule(com.google.gerrit.extensions.config.FactoryModule) GitModule(com.google.gerrit.server.git.GitModule) FanOutExecutor(com.google.gerrit.server.FanOutExecutor) GitRepositoryManager(com.google.gerrit.server.git.GitRepositoryManager) ServiceUserClassifier(com.google.gerrit.server.account.ServiceUserClassifier) DefaultUrlFormatterModule(com.google.gerrit.server.config.DefaultUrlFormatter.DefaultUrlFormatterModule) PatchSetApprovalUuidGenerator(com.google.gerrit.server.approval.PatchSetApprovalUuidGenerator) TestPatchSetApprovalUuidGenerator(com.google.gerrit.server.approval.testing.TestPatchSetApprovalUuidGenerator) FakeAccountCache(com.google.gerrit.testing.FakeAccountCache) AccountCache(com.google.gerrit.server.account.AccountCache) ProjectCache(com.google.gerrit.server.project.ProjectCache) NullProjectCache(com.google.gerrit.server.project.NullProjectCache) InternalChangeQuery(com.google.gerrit.server.query.change.InternalChangeQuery) PersonIdent(org.eclipse.jgit.lib.PersonIdent) GerritPersonIdent(com.google.gerrit.server.GerritPersonIdent) AllUsersName(com.google.gerrit.server.config.AllUsersName) Before(org.junit.Before)

Example 3 with InMemoryRepositoryManager

use of com.google.gerrit.testing.InMemoryRepositoryManager in project gerrit by GerritCodeReview.

the class WalkSorterTest method setUp.

@Before
public void setUp() {
    userId = Account.id(1);
    repoManager = new InMemoryRepositoryManager();
}
Also used : InMemoryRepositoryManager(com.google.gerrit.testing.InMemoryRepositoryManager) Before(org.junit.Before)

Example 4 with InMemoryRepositoryManager

use of com.google.gerrit.testing.InMemoryRepositoryManager in project gerrit by GerritCodeReview.

the class NoteDbSchemaVersionManagerTest method setUp.

@Before
public void setUp() throws Exception {
    AllProjectsName allProjectsName = new AllProjectsName("The-Projects");
    GitRepositoryManager repoManager = new InMemoryRepositoryManager();
    tr = new TestRepository<>(repoManager.createRepository(allProjectsName));
    manager = new NoteDbSchemaVersionManager(allProjectsName, repoManager);
}
Also used : AllProjectsName(com.google.gerrit.server.config.AllProjectsName) InMemoryRepositoryManager(com.google.gerrit.testing.InMemoryRepositoryManager) GitRepositoryManager(com.google.gerrit.server.git.GitRepositoryManager) Before(org.junit.Before)

Example 5 with InMemoryRepositoryManager

use of com.google.gerrit.testing.InMemoryRepositoryManager in project gerrit by GerritCodeReview.

the class AbstractGroupTest method abstractGroupTestSetUp.

// TODO(issue-15517): Fix the JdkObsolete issue with Date once JGit's PersonIdent class supports
// Instants
@SuppressWarnings("JdkObsolete")
@Before
public void abstractGroupTestSetUp() throws Exception {
    allUsersName = new AllUsersName(AllUsersNameProvider.DEFAULT);
    repoManager = new InMemoryRepositoryManager();
    allUsersRepo = repoManager.createRepository(allUsersName);
    serverAccountId = Account.id(SERVER_ACCOUNT_NUMBER);
    serverIdent = new PersonIdent(SERVER_NAME, SERVER_EMAIL, Date.from(TimeUtil.now()), TZ);
    userId = Account.id(USER_ACCOUNT_NUMBER);
    userIdent = newPersonIdent(userId, serverIdent);
}
Also used : InMemoryRepositoryManager(com.google.gerrit.testing.InMemoryRepositoryManager) PersonIdent(org.eclipse.jgit.lib.PersonIdent) AllUsersName(com.google.gerrit.server.config.AllUsersName) Before(org.junit.Before)

Aggregations

InMemoryRepositoryManager (com.google.gerrit.testing.InMemoryRepositoryManager)12 Before (org.junit.Before)9 GerritServerConfig (com.google.gerrit.server.config.GerritServerConfig)3 GitRepositoryManager (com.google.gerrit.server.git.GitRepositoryManager)3 PersonIdent (org.eclipse.jgit.lib.PersonIdent)3 GerritConfig (com.google.gerrit.acceptance.config.GerritConfig)2 GlobalPluginConfig (com.google.gerrit.acceptance.config.GlobalPluginConfig)2 Project (com.google.gerrit.entities.Project)2 AllProjectsName (com.google.gerrit.server.config.AllProjectsName)2 AllUsersName (com.google.gerrit.server.config.AllUsersName)2 SitePath (com.google.gerrit.server.config.SitePath)2 Path (java.nio.file.Path)2 Config (org.eclipse.jgit.lib.Config)2 Account (com.google.gerrit.entities.Account)1 FactoryModule (com.google.gerrit.extensions.config.FactoryModule)1 DisabledMetricMaker (com.google.gerrit.metrics.DisabledMetricMaker)1 MetricMaker (com.google.gerrit.metrics.MetricMaker)1 FanOutExecutor (com.google.gerrit.server.FanOutExecutor)1 GerritPersonIdent (com.google.gerrit.server.GerritPersonIdent)1 InternalUser (com.google.gerrit.server.InternalUser)1