use of com.google.gerrit.server.config.GerritServerConfig in project gerrit by GerritCodeReview.
the class GerritServer method createTestInjector.
private static Injector createTestInjector(Daemon daemon) throws Exception {
Injector sysInjector = getInjector(daemon, "sysInjector");
Module module = new FactoryModule() {
@Override
protected void configure() {
bindConstant().annotatedWith(SshEnabled.class).to(daemon.getEnableSshd());
bind(AccountCreator.class);
bind(AccountOperations.class).to(AccountOperationsImpl.class);
bind(GroupOperations.class).to(GroupOperationsImpl.class);
bind(ProjectOperations.class).to(ProjectOperationsImpl.class);
bind(RequestScopeOperations.class).to(RequestScopeOperationsImpl.class);
bind(ChangeOperations.class).to(ChangeOperationsImpl.class);
factory(PerPatchsetOperationsImpl.Factory.class);
factory(PerCommentOperationsImpl.Factory.class);
factory(PerDraftCommentOperationsImpl.Factory.class);
factory(PerRobotCommentOperationsImpl.Factory.class);
factory(PushOneCommit.Factory.class);
install(InProcessProtocol.module());
install(new NoSshModule());
install(new AsyncReceiveCommitsModule());
factory(ProjectResetter.Builder.Factory.class);
}
@Provides
@Singleton
@Nullable
@TestSshServerAddress
InetSocketAddress getSshAddress(@GerritServerConfig Config cfg) {
String addr = cfg.getString("sshd", null, "listenAddress");
// We do not use InitSshd.isOff to avoid coupling GerritServer to the SSH code.
return !"off".equalsIgnoreCase(addr) ? SocketUtil.resolve(cfg.getString("sshd", null, "listenAddress"), 0) : null;
}
};
return sysInjector.createChildInjector(module);
}
Aggregations