Search in sources :

Example 6 with InMemoryModule

use of com.google.gerrit.testutil.InMemoryModule in project gerrit by GerritCodeReview.

the class LuceneQueryGroupsTest method createInjector.

@Override
protected Injector createInjector() {
    Config luceneConfig = new Config(config);
    InMemoryModule.setDefaults(luceneConfig);
    return Guice.createInjector(new InMemoryModule(luceneConfig, notesMigration));
}
Also used : Config(org.eclipse.jgit.lib.Config) InMemoryModule(com.google.gerrit.testutil.InMemoryModule)

Example 7 with InMemoryModule

use of com.google.gerrit.testutil.InMemoryModule in project gerrit by GerritCodeReview.

the class LuceneQueryChangesTest method createInjector.

@Override
protected Injector createInjector() {
    Config luceneConfig = new Config(config);
    InMemoryModule.setDefaults(luceneConfig);
    return Guice.createInjector(new InMemoryModule(luceneConfig, notesMigration));
}
Also used : Config(org.eclipse.jgit.lib.Config) InMemoryModule(com.google.gerrit.testutil.InMemoryModule)

Example 8 with InMemoryModule

use of com.google.gerrit.testutil.InMemoryModule in project gerrit by GerritCodeReview.

the class GerritPublicKeyCheckerTest method setUpInjector.

@Before
public void setUpInjector() throws Exception {
    Config cfg = InMemoryModule.newDefaultConfig();
    cfg.setInt("receive", null, "maxTrustDepth", 2);
    cfg.setStringList("receive", null, "trustedKey", ImmutableList.of(Fingerprint.toString(keyB().getPublicKey().getFingerprint()), Fingerprint.toString(keyD().getPublicKey().getFingerprint())));
    Injector injector = Guice.createInjector(new InMemoryModule(cfg, new TestNotesMigration()));
    lifecycle = new LifecycleManager();
    lifecycle.add(injector);
    injector.injectMembers(this);
    lifecycle.start();
    db = schemaFactory.open();
    schemaCreator.create(db);
    userId = accountManager.authenticate(AuthRequest.forUser("user")).getAccountId();
    Account userAccount = db.accounts().get(userId);
    // Note: does not match any key in TestKeys.
    userAccount.setPreferredEmail("user@example.com");
    db.accounts().update(ImmutableList.of(userAccount));
    user = reloadUser();
    requestContext.setContext(new RequestContext() {

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

        @Override
        public Provider<ReviewDb> getReviewDbProvider() {
            return Providers.of(db);
        }
    });
    storeRepo = new InMemoryRepository(new DfsRepositoryDescription("repo"));
    store = new PublicKeyStore(storeRepo);
}
Also used : Account(com.google.gerrit.reviewdb.client.Account) InMemoryRepository(org.eclipse.jgit.internal.storage.dfs.InMemoryRepository) CurrentUser(com.google.gerrit.server.CurrentUser) Config(org.eclipse.jgit.lib.Config) LifecycleManager(com.google.gerrit.lifecycle.LifecycleManager) TestNotesMigration(com.google.gerrit.testutil.TestNotesMigration) DfsRepositoryDescription(org.eclipse.jgit.internal.storage.dfs.DfsRepositoryDescription) Provider(com.google.inject.Provider) Injector(com.google.inject.Injector) ThreadLocalRequestContext(com.google.gerrit.server.util.ThreadLocalRequestContext) RequestContext(com.google.gerrit.server.util.RequestContext) InMemoryModule(com.google.gerrit.testutil.InMemoryModule) Before(org.junit.Before)

Example 9 with InMemoryModule

use of com.google.gerrit.testutil.InMemoryModule in project gerrit by GerritCodeReview.

the class LabelNormalizerTest method setUpInjector.

@Before
public void setUpInjector() 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);
    userId = accountManager.authenticate(AuthRequest.forUser("user")).getAccountId();
    user = userFactory.create(userId);
    requestContext.setContext(new RequestContext() {

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

        @Override
        public Provider<ReviewDb> getReviewDbProvider() {
            return Providers.of(db);
        }
    });
    configureProject();
    setUpChange();
}
Also used : CurrentUser(com.google.gerrit.server.CurrentUser) Injector(com.google.inject.Injector) LifecycleManager(com.google.gerrit.lifecycle.LifecycleManager) RequestContext(com.google.gerrit.server.util.RequestContext) ThreadLocalRequestContext(com.google.gerrit.server.util.ThreadLocalRequestContext) InMemoryModule(com.google.gerrit.testutil.InMemoryModule) Provider(com.google.inject.Provider) Before(org.junit.Before)

Example 10 with InMemoryModule

use of com.google.gerrit.testutil.InMemoryModule 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)

Aggregations

InMemoryModule (com.google.gerrit.testutil.InMemoryModule)12 Config (org.eclipse.jgit.lib.Config)7 CurrentUser (com.google.gerrit.server.CurrentUser)6 RequestContext (com.google.gerrit.server.util.RequestContext)6 ThreadLocalRequestContext (com.google.gerrit.server.util.ThreadLocalRequestContext)6 Injector (com.google.inject.Injector)6 Provider (com.google.inject.Provider)6 Before (org.junit.Before)6 LifecycleManager (com.google.gerrit.lifecycle.LifecycleManager)5 Account (com.google.gerrit.reviewdb.client.Account)4 InMemoryRepository (org.eclipse.jgit.internal.storage.dfs.InMemoryRepository)4 Project (com.google.gerrit.reviewdb.client.Project)3 AccountGroup (com.google.gerrit.reviewdb.client.AccountGroup)2 ReviewDb (com.google.gerrit.reviewdb.server.ReviewDb)2 ProjectConfig (com.google.gerrit.server.git.ProjectConfig)2 LabelType (com.google.gerrit.common.data.LabelType)1 IdentifiedUser (com.google.gerrit.server.IdentifiedUser)1 AllProjectsNameProvider (com.google.gerrit.server.config.AllProjectsNameProvider)1 AllUsersNameProvider (com.google.gerrit.server.config.AllUsersNameProvider)1 InMemoryRepositoryManager (com.google.gerrit.testutil.InMemoryRepositoryManager)1