use of org.eclipse.jgit.util.SystemReader in project gitblit by gitblit.
the class SshUnitTest method startGitblit.
@BeforeClass
public static void startGitblit() throws Exception {
generator = SecurityUtils.getKeyPairGenerator("RSA");
started.set(GitBlitSuite.startGitblit());
final SystemReader dsr = SystemReader.getInstance();
SystemReader.setInstance(new SystemReader() {
final SystemReader defaultsr = dsr;
@Override
public String getHostname() {
return defaultsr.getHostname();
}
@Override
public String getenv(String variable) {
if ("GIT_SSH".equalsIgnoreCase(variable)) {
return null;
}
return defaultsr.getenv(variable);
}
@Override
public String getProperty(String key) {
return defaultsr.getProperty(key);
}
@Override
public FileBasedConfig openUserConfig(Config parent, FS fs) {
return defaultsr.openUserConfig(parent, fs);
}
@Override
public FileBasedConfig openSystemConfig(Config parent, FS fs) {
return defaultsr.openSystemConfig(parent, fs);
}
@Override
public long getCurrentTime() {
return defaultsr.getCurrentTime();
}
@Override
public int getTimezone(long when) {
return defaultsr.getTimezone(when);
}
});
}
use of org.eclipse.jgit.util.SystemReader in project gerrit by GerritCodeReview.
the class StandaloneSiteTest method setFakeSystemReader.
private static SystemReader setFakeSystemReader(File tempDir) {
SystemReader oldSystemReader = SystemReader.getInstance();
SystemReader.setInstance(new DelegateSystemReader(oldSystemReader) {
@Override
public FileBasedConfig openJGitConfig(Config parent, FS fs) {
return new FileBasedConfig(parent, new File(tempDir, "jgit.config"), FS.detect());
}
@Override
public FileBasedConfig openUserConfig(Config parent, FS fs) {
return new FileBasedConfig(parent, new File(tempDir, "user.config"), FS.detect());
}
@Override
public FileBasedConfig openSystemConfig(Config parent, FS fs) {
return new FileBasedConfig(parent, new File(tempDir, "system.config"), FS.detect());
}
});
return oldSystemReader;
}
use of org.eclipse.jgit.util.SystemReader in project gerrit by GerritCodeReview.
the class AbstractDaemonTest method setFakeSystemReader.
private static SystemReader setFakeSystemReader(File tempDir) {
SystemReader oldSystemReader = SystemReader.getInstance();
SystemReader.setInstance(new DelegateSystemReader(oldSystemReader) {
@Override
public FileBasedConfig openJGitConfig(Config parent, FS fs) {
return new FileBasedConfig(parent, new File(tempDir, "jgit.config"), FS.detect());
}
@Override
public FileBasedConfig openUserConfig(Config parent, FS fs) {
return new FileBasedConfig(parent, new File(tempDir, "user.config"), FS.detect());
}
@Override
public FileBasedConfig openSystemConfig(Config parent, FS fs) {
return new FileBasedConfig(parent, new File(tempDir, "system.config"), FS.detect());
}
});
return oldSystemReader;
}
use of org.eclipse.jgit.util.SystemReader in project gerrit by GerritCodeReview.
the class TimeUtil method setCurrentMillisSupplier.
@VisibleForTesting
public static void setCurrentMillisSupplier(LongSupplier customCurrentMillisSupplier) {
currentMillisSupplier = customCurrentMillisSupplier;
SystemReader oldSystemReader = SystemReader.getInstance();
if (!(oldSystemReader instanceof GerritSystemReader)) {
SystemReader.setInstance(new GerritSystemReader(oldSystemReader));
}
}
Aggregations