Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn Pearce2010-12-31 21:13:33 +0000
committerCode Review2010-12-31 21:13:33 +0000
commit7cf8b8812f7baa1636c138113f4ed015eed8cc31 (patch)
tree2d410f1622c22d0544a1a567e1599e5cbaf5c4a1 /org.eclipse.jgit.junit
parent4da775eaff5e3328f6c89d8927f0f4cb4338cb6b (diff)
parent797ebba30707259f7a4bc06baa40360ab79d2ff8 (diff)
downloadjgit-7cf8b8812f7baa1636c138113f4ed015eed8cc31.tar.gz
jgit-7cf8b8812f7baa1636c138113f4ed015eed8cc31.tar.xz
jgit-7cf8b8812f7baa1636c138113f4ed015eed8cc31.zip
Merge "Add support for getting the system wide configuration"
Diffstat (limited to 'org.eclipse.jgit.junit')
-rw-r--r--org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/MockSystemReader.java43
1 files changed, 31 insertions, 12 deletions
diff --git a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/MockSystemReader.java b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/MockSystemReader.java
index 5c2e77f673..b53dce2161 100644
--- a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/MockSystemReader.java
+++ b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/MockSystemReader.java
@@ -45,39 +45,50 @@
package org.eclipse.jgit.junit;
+import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.TimeZone;
import org.eclipse.jgit.errors.ConfigInvalidException;
+import org.eclipse.jgit.lib.Config;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.storage.file.FileBasedConfig;
import org.eclipse.jgit.util.FS;
import org.eclipse.jgit.util.SystemReader;
public class MockSystemReader extends SystemReader {
+ private final class MockConfig extends FileBasedConfig {
+ private MockConfig(File cfgLocation, FS fs) {
+ super(cfgLocation, fs);
+ }
+
+ @Override
+ public void load() throws IOException, ConfigInvalidException {
+ // Do nothing
+ }
+
+ @Override
+ public boolean isOutdated() {
+ return false;
+ }
+ }
+
final Map<String, String> values = new HashMap<String, String>();
FileBasedConfig userGitConfig;
+ FileBasedConfig systemGitConfig;
+
public MockSystemReader() {
init(Constants.OS_USER_NAME_KEY);
init(Constants.GIT_AUTHOR_NAME_KEY);
init(Constants.GIT_AUTHOR_EMAIL_KEY);
init(Constants.GIT_COMMITTER_NAME_KEY);
init(Constants.GIT_COMMITTER_EMAIL_KEY);
- userGitConfig = new FileBasedConfig(null, null) {
- @Override
- public void load() throws IOException, ConfigInvalidException {
- // Do nothing
- }
-
- @Override
- public boolean isOutdated() {
- return false;
- }
- };
+ userGitConfig = new MockConfig(null, null);
+ systemGitConfig = new MockConfig(null, null);
}
private void init(final String n) {
@@ -103,11 +114,18 @@ public class MockSystemReader extends SystemReader {
}
@Override
- public FileBasedConfig openUserConfig(FS fs) {
+ public FileBasedConfig openUserConfig(Config parent, FS fs) {
+ assert parent == null || parent == systemGitConfig;
return userGitConfig;
}
@Override
+ public FileBasedConfig openSystemConfig(Config parent, FS fs) {
+ assert parent == null;
+ return systemGitConfig;
+ }
+
+ @Override
public String getHostname() {
return "fake.host.example.com";
}
@@ -121,4 +139,5 @@ public class MockSystemReader extends SystemReader {
public int getTimezone(long when) {
return TimeZone.getTimeZone("GMT-03:30").getOffset(when) / (60 * 1000);
}
+
}

Back to the top