Search in sources :

Example 1 with SystemReader

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);
        }
    });
}
Also used : Config(org.eclipse.jgit.lib.Config) FileBasedConfig(org.eclipse.jgit.storage.file.FileBasedConfig) SystemReader(org.eclipse.jgit.util.SystemReader) FileBasedConfig(org.eclipse.jgit.storage.file.FileBasedConfig) FS(org.eclipse.jgit.util.FS) BeforeClass(org.junit.BeforeClass)

Example 2 with SystemReader

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;
}
Also used : DelegateSystemReader(com.google.gerrit.server.util.git.DelegateSystemReader) Config(org.eclipse.jgit.lib.Config) FileBasedConfig(org.eclipse.jgit.storage.file.FileBasedConfig) DelegateSystemReader(com.google.gerrit.server.util.git.DelegateSystemReader) SystemReader(org.eclipse.jgit.util.SystemReader) FileBasedConfig(org.eclipse.jgit.storage.file.FileBasedConfig) FS(org.eclipse.jgit.util.FS) File(java.io.File)

Example 3 with SystemReader

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;
}
Also used : DelegateSystemReader(com.google.gerrit.server.util.git.DelegateSystemReader) Config(org.eclipse.jgit.lib.Config) BooleanProjectConfig(com.google.gerrit.entities.BooleanProjectConfig) FileBasedConfig(org.eclipse.jgit.storage.file.FileBasedConfig) ProjectConfig(com.google.gerrit.server.project.ProjectConfig) GerritServerConfig(com.google.gerrit.server.config.GerritServerConfig) SystemReader(org.eclipse.jgit.util.SystemReader) DelegateSystemReader(com.google.gerrit.server.util.git.DelegateSystemReader) FileBasedConfig(org.eclipse.jgit.storage.file.FileBasedConfig) FS(org.eclipse.jgit.util.FS) File(java.io.File)

Example 4 with SystemReader

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));
    }
}
Also used : SystemReader(org.eclipse.jgit.util.SystemReader) DelegateSystemReader(com.google.gerrit.server.util.git.DelegateSystemReader) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

SystemReader (org.eclipse.jgit.util.SystemReader)4 DelegateSystemReader (com.google.gerrit.server.util.git.DelegateSystemReader)3 Config (org.eclipse.jgit.lib.Config)3 FileBasedConfig (org.eclipse.jgit.storage.file.FileBasedConfig)3 FS (org.eclipse.jgit.util.FS)3 File (java.io.File)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 BooleanProjectConfig (com.google.gerrit.entities.BooleanProjectConfig)1 GerritServerConfig (com.google.gerrit.server.config.GerritServerConfig)1 ProjectConfig (com.google.gerrit.server.project.ProjectConfig)1 BeforeClass (org.junit.BeforeClass)1