use of com.google.gerrit.server.patch.DiffExecutor in project gerrit by GerritCodeReview.
the class InMemoryModule method configure.
@Override
protected void configure() {
// Do NOT bind @RemotePeer, as it is bound in a child injector of
// ChangeMergeQueue (bound via GerritGlobalModule below), so there cannot be
// a binding in the parent injector. If you need @RemotePeer, you must bind
// it in a child injector of the one containing InMemoryModule. But unless
// you really need to test something request-scoped, you likely don't
// actually need it.
// For simplicity, don't create child injectors, just use this one to get a
// few required modules.
Injector cfgInjector = Guice.createInjector(new AbstractModule() {
@Override
protected void configure() {
bind(Config.class).annotatedWith(GerritServerConfig.class).toInstance(cfg);
}
});
bind(GerritRuntime.class).toInstance(GerritRuntime.DAEMON);
bind(MetricMaker.class).to(DisabledMetricMaker.class);
install(cfgInjector.getInstance(GerritGlobalModule.class));
AuthConfig authConfig = cfgInjector.getInstance(AuthConfig.class);
install(new AuthModule(authConfig));
install(new GerritApiModule());
factory(PluginUser.Factory.class);
install(new PluginApiModule());
install(new DefaultPermissionBackendModule());
install(new SearchingChangeCacheImplModule());
factory(GarbageCollection.Factory.class);
install(new AuditModule());
install(new SubscriptionGraphModule());
install(new SuperprojectUpdateSubmissionListenerModule());
bindScope(RequestScoped.class, PerThreadRequestScope.REQUEST);
// It would be nice to use Jimfs for the SitePath, but the biggest blocker is that JGit does not
// support Path-based Configs, only FileBasedConfig.
bind(Path.class).annotatedWith(SitePath.class).toInstance(Paths.get("."));
bind(Config.class).annotatedWith(GerritServerConfig.class).toInstance(cfg);
bind(GerritOptions.class).toInstance(new GerritOptions(false, false));
bind(AllProjectsConfigProvider.class).to(FileBasedAllProjectsConfigProvider.class);
bind(GlobalPluginConfigProvider.class).to(FileBasedGlobalPluginConfigProvider.class);
bind(GitRepositoryManager.class).to(InMemoryRepositoryManager.class);
bind(InMemoryRepositoryManager.class).in(SINGLETON);
bind(TrackingFooters.class).toProvider(TrackingFootersProvider.class).in(SINGLETON);
bind(SecureStore.class).to(DefaultSecureStore.class);
install(new InMemorySchemaModule());
install(NoSshKeyCache.module());
install(new GerritInstanceNameModule());
install(new GerritInstanceIdModule());
install(new CanonicalWebUrlModule() {
@Override
protected Class<? extends Provider<String>> provider() {
return CanonicalWebUrlProvider.class;
}
});
install(new DefaultUrlFormatterModule());
// Replacement of DiffExecutorModule to not use thread pool in the tests
install(new AbstractModule() {
@Override
protected void configure() {
}
@Provides
@Singleton
@DiffExecutor
public ExecutorService createDiffExecutor() {
return newDirectExecutorService();
}
});
install(new DefaultMemoryCacheModule());
install(new H2CacheModule());
install(new FakeEmailSenderModule());
install(new SignedTokenEmailTokenVerifierModule());
install(new GpgModule(cfg));
install(new LocalMergeSuperSetComputationModule());
bind(AllAccountsIndexer.class).toProvider(Providers.of(null));
bind(AllChangesIndexer.class).toProvider(Providers.of(null));
bind(AllGroupsIndexer.class).toProvider(Providers.of(null));
String indexTypeCfg = cfg.getString("index", null, "type");
IndexType indexType = new IndexType(indexTypeCfg != null ? indexTypeCfg : "fake");
// For custom index types, callers must provide their own module.
if (indexType.isLucene()) {
install(luceneIndexModule());
} else if (indexType.isFake()) {
install(fakeIndexModule());
}
bind(ServerInformationImpl.class);
bind(ServerInformation.class).to(ServerInformationImpl.class);
install(new RestApiModule());
install(new OAuthRestModule());
install(new DefaultProjectNameLockManagerModule());
install(new FileInfoJsonModule());
install(new ConfigExperimentFeaturesModule());
bind(ProjectOperations.class).to(ProjectOperationsImpl.class);
}
use of com.google.gerrit.server.patch.DiffExecutor in project gerrit by GerritCodeReview.
the class InMemoryModule method configure.
@Override
protected void configure() {
// Do NOT bind @RemotePeer, as it is bound in a child injector of
// ChangeMergeQueue (bound via GerritGlobalModule below), so there cannot be
// a binding in the parent injector. If you need @RemotePeer, you must bind
// it in a child injector of the one containing InMemoryModule. But unless
// you really need to test something request-scoped, you likely don't
// actually need it.
// For simplicity, don't create child injectors, just use this one to get a
// few required modules.
Injector cfgInjector = Guice.createInjector(new AbstractModule() {
@Override
protected void configure() {
bind(Config.class).annotatedWith(GerritServerConfig.class).toInstance(cfg);
}
});
bind(MetricMaker.class).to(DisabledMetricMaker.class);
install(cfgInjector.getInstance(GerritGlobalModule.class));
install(new DefaultPermissionBackendModule());
install(new SearchingChangeCacheImpl.Module());
factory(GarbageCollection.Factory.class);
bindScope(RequestScoped.class, PerThreadRequestScope.REQUEST);
// TODO(dborowitz): Use jimfs.
bind(Path.class).annotatedWith(SitePath.class).toInstance(Paths.get("."));
bind(Config.class).annotatedWith(GerritServerConfig.class).toInstance(cfg);
bind(GerritOptions.class).toInstance(new GerritOptions(cfg, false, false, false));
bind(PersonIdent.class).annotatedWith(GerritPersonIdent.class).toProvider(GerritPersonIdentProvider.class);
bind(String.class).annotatedWith(AnonymousCowardName.class).toProvider(AnonymousCowardNameProvider.class);
bind(String.class).annotatedWith(GerritServerId.class).toInstance("gerrit");
bind(AllProjectsName.class).toProvider(AllProjectsNameProvider.class);
bind(AllUsersName.class).toProvider(AllUsersNameProvider.class);
bind(GitRepositoryManager.class).to(InMemoryRepositoryManager.class);
bind(InMemoryRepositoryManager.class).in(SINGLETON);
bind(TrackingFooters.class).toProvider(TrackingFootersProvider.class).in(SINGLETON);
bind(NotesMigration.class).toInstance(notesMigration);
bind(ListeningExecutorService.class).annotatedWith(ChangeUpdateExecutor.class).toInstance(MoreExecutors.newDirectExecutorService());
bind(DataSourceType.class).to(InMemoryH2Type.class);
bind(ChangeBundleReader.class).to(GwtormChangeBundleReader.class);
bind(SecureStore.class).to(DefaultSecureStore.class);
TypeLiteral<SchemaFactory<ReviewDb>> schemaFactory = new TypeLiteral<SchemaFactory<ReviewDb>>() {
};
bind(schemaFactory).to(NotesMigrationSchemaFactory.class);
bind(Key.get(schemaFactory, ReviewDbFactory.class)).to(InMemoryDatabase.class);
install(NoSshKeyCache.module());
install(new CanonicalWebUrlModule() {
@Override
protected Class<? extends Provider<String>> provider() {
return CanonicalWebUrlProvider.class;
}
});
//Replacement of DiffExecutorModule to not use thread pool in the tests
install(new AbstractModule() {
@Override
protected void configure() {
}
@Provides
@Singleton
@DiffExecutor
public ExecutorService createDiffExecutor() {
return MoreExecutors.newDirectExecutorService();
}
});
install(new DefaultCacheFactory.Module());
install(new FakeEmailSender.Module());
install(new SignedTokenEmailTokenVerifier.Module());
install(new GpgModule(cfg));
install(new H2AccountPatchReviewStore.InMemoryModule());
bind(AllAccountsIndexer.class).toProvider(Providers.of(null));
bind(AllChangesIndexer.class).toProvider(Providers.of(null));
bind(AllGroupsIndexer.class).toProvider(Providers.of(null));
IndexType indexType = null;
try {
indexType = cfg.getEnum("index", null, "type", IndexType.LUCENE);
} catch (IllegalArgumentException e) {
// Custom index type, caller must provide their own module.
}
if (indexType != null) {
switch(indexType) {
case LUCENE:
install(luceneIndexModule());
break;
case ELASTICSEARCH:
install(elasticIndexModule());
break;
default:
throw new ProvisionException("index type unsupported in tests: " + indexType);
}
}
}
Aggregations