Search in sources :

Example 11 with LifecycleManager

use of com.google.gerrit.lifecycle.LifecycleManager in project gerrit by GerritCodeReview.

the class ProjectControlTest method setUp.

@Before
public void setUp() throws Exception {
    Injector injector = Guice.createInjector(new InMemoryModule());
    injector.injectMembers(this);
    lifecycle = new LifecycleManager();
    lifecycle.add(injector);
    lifecycle.start();
    db = schemaFactory.open();
    schemaCreator.create(db);
    // Need to create at least one user to be admin before creating a "normal"
    // registered user.
    // See AccountManager#create().
    accountManager.authenticate(AuthRequest.forUser("admin")).getAccountId();
    admins = groupCache.get(new AccountGroup.NameKey("Administrators")).getGroupUUID();
    setUpPermissions();
    Account.Id userId = accountManager.authenticate(AuthRequest.forUser("user")).getAccountId();
    user = userFactory.create(userId);
    Project.NameKey name = new Project.NameKey("project");
    InMemoryRepository inMemoryRepo = repoManager.createRepository(name);
    project = new ProjectConfig(name);
    project.load(inMemoryRepo);
    repo = new TestRepository<>(inMemoryRepo);
    requestContext.setContext(new RequestContext() {

        @Override
        public CurrentUser getUser() {
            return user;
        }

        @Override
        public Provider<ReviewDb> getReviewDbProvider() {
            return Providers.of(db);
        }
    });
}
Also used : Account(com.google.gerrit.reviewdb.client.Account) InMemoryRepository(org.eclipse.jgit.internal.storage.dfs.InMemoryRepository) CurrentUser(com.google.gerrit.server.CurrentUser) LifecycleManager(com.google.gerrit.lifecycle.LifecycleManager) Provider(com.google.inject.Provider) ProjectConfig(com.google.gerrit.server.git.ProjectConfig) Project(com.google.gerrit.reviewdb.client.Project) AccountGroup(com.google.gerrit.reviewdb.client.AccountGroup) Injector(com.google.inject.Injector) RequestContext(com.google.gerrit.server.util.RequestContext) ThreadLocalRequestContext(com.google.gerrit.server.util.ThreadLocalRequestContext) InMemoryModule(com.google.gerrit.testutil.InMemoryModule) Before(org.junit.Before)

Example 12 with LifecycleManager

use of com.google.gerrit.lifecycle.LifecycleManager in project gerrit by GerritCodeReview.

the class ProcMetricModuleTest method setup.

@Before
public void setup() {
    Injector injector = Guice.createInjector(new DropWizardMetricMaker.ApiModule());
    LifecycleManager mgr = new LifecycleManager();
    mgr.add(injector);
    mgr.start();
    injector.injectMembers(this);
}
Also used : Injector(com.google.inject.Injector) LifecycleManager(com.google.gerrit.lifecycle.LifecycleManager) DropWizardMetricMaker(com.google.gerrit.metrics.dropwizard.DropWizardMetricMaker) Before(org.junit.Before)

Example 13 with LifecycleManager

use of com.google.gerrit.lifecycle.LifecycleManager in project gerrit by GerritCodeReview.

the class AbstractQueryGroupsTest method setUpInjector.

@Before
public void setUpInjector() throws Exception {
    lifecycle = new LifecycleManager();
    injector = createInjector();
    lifecycle.add(injector);
    injector.injectMembers(this);
    lifecycle.start();
    setUpDatabase();
}
Also used : LifecycleManager(com.google.gerrit.lifecycle.LifecycleManager) Before(org.junit.Before)

Example 14 with LifecycleManager

use of com.google.gerrit.lifecycle.LifecycleManager in project gerrit by GerritCodeReview.

the class SchemaUpdaterTest method setUp.

@Before
public void setUp() throws Exception {
    lifecycle = new LifecycleManager();
    db = InMemoryDatabase.newDatabase(lifecycle);
    lifecycle.start();
}
Also used : LifecycleManager(com.google.gerrit.lifecycle.LifecycleManager) Before(org.junit.Before)

Example 15 with LifecycleManager

use of com.google.gerrit.lifecycle.LifecycleManager in project gerrit by GerritCodeReview.

the class AbstractQueryChangesTest method setUpInjector.

@Before
public void setUpInjector() throws Exception {
    lifecycle = new LifecycleManager();
    injector = createInjector();
    lifecycle.add(injector);
    injector.injectMembers(this);
    lifecycle.start();
    setUpDatabase();
}
Also used : LifecycleManager(com.google.gerrit.lifecycle.LifecycleManager) Before(org.junit.Before)

Aggregations

LifecycleManager (com.google.gerrit.lifecycle.LifecycleManager)15 Before (org.junit.Before)10 Injector (com.google.inject.Injector)7 CurrentUser (com.google.gerrit.server.CurrentUser)5 RequestContext (com.google.gerrit.server.util.RequestContext)5 ThreadLocalRequestContext (com.google.gerrit.server.util.ThreadLocalRequestContext)5 InMemoryModule (com.google.gerrit.testutil.InMemoryModule)5 Provider (com.google.inject.Provider)5 Account (com.google.gerrit.reviewdb.client.Account)4 Project (com.google.gerrit.reviewdb.client.Project)3 ReviewDb (com.google.gerrit.reviewdb.server.ReviewDb)3 InMemoryRepository (org.eclipse.jgit.internal.storage.dfs.InMemoryRepository)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 Stopwatch (com.google.common.base.Stopwatch)1 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 ListeningExecutorService (com.google.common.util.concurrent.ListeningExecutorService)1 DropWizardMetricMaker (com.google.gerrit.metrics.dropwizard.DropWizardMetricMaker)1 AccountGroup (com.google.gerrit.reviewdb.client.AccountGroup)1 IdentifiedUser (com.google.gerrit.server.IdentifiedUser)1