Search in sources :

Example 11 with InMemoryModule

use of com.google.gerrit.testing.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));
}
Also used : Config(org.eclipse.jgit.lib.Config) IndexConfig(com.google.gerrit.testing.IndexConfig) InMemoryModule(com.google.gerrit.testing.InMemoryModule)

Example 12 with InMemoryModule

use of com.google.gerrit.testing.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));
}
Also used : Config(org.eclipse.jgit.lib.Config) InMemoryModule(com.google.gerrit.testing.InMemoryModule)

Example 13 with InMemoryModule

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

the class RefControlTest method setUp.

@Before
public void setUp() throws Exception {
    Injector injector = Guice.createInjector(new InMemoryModule());
    injector.injectMembers(this);
    // Tests previously used ProjectConfig.Factory to create ProjectConfigs without going through
    // the ProjectCache, which was wrong. Manually call getInstance so we don't store it in a
    // field that is accessible to test methods.
    ProjectConfig.Factory projectConfigFactory = injector.getInstance(ProjectConfig.Factory.class);
    singleVersionListener.start();
    try {
        schemaCreator.create();
    } finally {
        singleVersionListener.stop();
    }
    // changing defaults in SchemaCreator or ProjectCreator.
    try (Repository allProjectsRepo = repoManager.createRepository(allProjectsName);
        TestRepository<Repository> tr = new TestRepository<>(allProjectsRepo)) {
        tr.delete(REFS_CONFIG);
        try (MetaDataUpdate md = metaDataUpdateFactory.create(allProjectsName)) {
            ProjectConfig allProjectsConfig = projectConfigFactory.create(allProjectsName);
            allProjectsConfig.load(md);
            LabelType cr = TestLabels.codeReview();
            allProjectsConfig.upsertLabelType(cr);
            allProjectsConfig.commit(md);
        }
    }
    repoManager.createRepository(parentKey).close();
    repoManager.createRepository(localKey).close();
    try (MetaDataUpdate md = metaDataUpdateFactory.create(localKey)) {
        ProjectConfig newLocal = projectConfigFactory.create(localKey);
        newLocal.load(md);
        newLocal.updateProject(p -> p.setParent(parentKey));
        newLocal.commit(md);
    }
    requestContext.setContext(() -> null);
}
Also used : ProjectConfig(com.google.gerrit.server.project.ProjectConfig) TestRepository(org.eclipse.jgit.junit.TestRepository) Repository(org.eclipse.jgit.lib.Repository) TestRepository(org.eclipse.jgit.junit.TestRepository) Injector(com.google.inject.Injector) LabelType(com.google.gerrit.entities.LabelType) InMemoryModule(com.google.gerrit.testing.InMemoryModule) MetaDataUpdate(com.google.gerrit.server.git.meta.MetaDataUpdate) Before(org.junit.Before)

Example 14 with InMemoryModule

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

the class PerformanceLogContextTest method setup.

@Before
public void setup() {
    Injector injector = Guice.createInjector(new InMemoryModule());
    injector.injectMembers(this);
    testPerformanceLogger = new TestPerformanceLogger();
    performanceLoggerRegistrationHandle = performanceLoggers.add("gerrit", testPerformanceLogger);
}
Also used : Injector(com.google.inject.Injector) InMemoryModule(com.google.gerrit.testing.InMemoryModule) Before(org.junit.Before)

Example 15 with InMemoryModule

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

the class LoggingContextAwareExecutorServiceTest method setup.

@Before
public void setup() {
    Injector injector = Guice.createInjector(new InMemoryModule());
    injector.injectMembers(this);
    testPerformanceLogger = new PerformanceLogger() {

        @Override
        public void log(String operation, long durationMs, Metadata metadata) {
        // do nothing
        }
    };
    performanceLoggerRegistrationHandle = performanceLoggers.add("gerrit", testPerformanceLogger);
}
Also used : Injector(com.google.inject.Injector) InMemoryModule(com.google.gerrit.testing.InMemoryModule) Before(org.junit.Before)

Aggregations

InMemoryModule (com.google.gerrit.testing.InMemoryModule)19 Before (org.junit.Before)11 Injector (com.google.inject.Injector)9 Config (org.eclipse.jgit.lib.Config)9 IndexConfig (com.google.gerrit.testing.IndexConfig)6 LifecycleManager (com.google.gerrit.lifecycle.LifecycleManager)2 Repository (org.eclipse.jgit.lib.Repository)2 ImmutableSet (com.google.common.collect.ImmutableSet)1 Account (com.google.gerrit.entities.Account)1 AccountGroup (com.google.gerrit.entities.AccountGroup)1 LabelType (com.google.gerrit.entities.LabelType)1 CacheModule (com.google.gerrit.server.cache.CacheModule)1 MetaDataUpdate (com.google.gerrit.server.git.meta.MetaDataUpdate)1 ProjectConfig (com.google.gerrit.server.project.ProjectConfig)1 TypeLiteral (com.google.inject.TypeLiteral)1 Optional (java.util.Optional)1 Set (java.util.Set)1 DfsRepositoryDescription (org.eclipse.jgit.internal.storage.dfs.DfsRepositoryDescription)1 InMemoryRepository (org.eclipse.jgit.internal.storage.dfs.InMemoryRepository)1 TestRepository (org.eclipse.jgit.junit.TestRepository)1