Source:
<code>public void setUp() throws Exception { root = Files.createTempDirectory("jgit-security").toFile(); <START> <END> permissions.add(new RuntimePermission("*")); permissions.add(new SecurityPermission("*")); permissions.add(new AuthPermission("*")); permissions.add(new ReflectPermission("*")); permissions.add(new PropertyPermission("*", "read,write")); permissions.add(new LoggingPermission("control", null)); permissions.add(new FilePermission( System.getProperty("java.home") + "/-", "read")); String tempDir = System.getProperty("java.io.tmpdir"); permissions.add(new FilePermission(tempDir, "read,write,delete")); permissions .add(new FilePermission(tempDir + "/-", "read,write,delete")); String classPath = System.getProperty("java.class.path"); if (classPath != null) { for (String path : classPath.split(File.pathSeparator)) { permissions.add(new FilePermission(path, "read")); } } String jgitSourcesRoot = new File(System.getProperty("user.dir")) .getParent(); permissions.add(new FilePermission(jgitSourcesRoot + "/-", "read")); permissions.add(new FilePermission(root.getPath() + "/-", "read,write,delete,execute")); String userHome = System.getProperty("user.home"); permissions.add(new FilePermission(userHome, "read")); permissions.add(new FilePermission(userHome + "/-", "read,write")); permissions.add(new FilePermission("/etc/gitconfig", "read")); originalSecurityManager = System.getSecurityManager(); System.setSecurityManager(new SecurityManager() { @Override public void checkPermission(Permission requested) { for (Permission permission : permissions) { if (permission.implies(requested)) { return; } } super.checkPermission(requested); } }); }</code><technical_language>set MockSystemReader ensure a mocked system environment in tests SystemReader.setInstance(new MockSystemReader()); this e.g. ensure user system level gitconfigs underlying system separate files in folder tests run (which moved configuring system property java.io.tmpdir)</technical_language>

Target:
public void setUp() throws Exception { SystemReader.setInstance(new MockSystemReader()); root = Files.createTempDirectory("jgit-security").toFile(); permissions.add(new RuntimePermission("*")); permissions.add(new SecurityPermission("*")); permissions.add(new AuthPermission("*")); permissions.add(new ReflectPermission("*")); permissions.add(new PropertyPermission("*", "read,write")); permissions.add(new LoggingPermission("control", null)); permissions.add(new FilePermission( System.getProperty("java.home") + "/-", "read")); String tempDir = System.getProperty("java.io.tmpdir"); permissions.add(new FilePermission(tempDir, "read,write,delete")); permissions .add(new FilePermission(tempDir + "/-", "read,write,delete")); String classPath = System.getProperty("java.class.path"); if (classPath != null) { for (String path : classPath.split(File.pathSeparator)) { permissions.add(new FilePermission(path, "read")); } } String jgitSourcesRoot = new File(System.getProperty("user.dir")) .getParent(); permissions.add(new FilePermission(jgitSourcesRoot + "/-", "read")); permissions.add(new FilePermission(root.getPath() + "/-", "read,write,delete,execute")); originalSecurityManager = System.getSecurityManager(); System.setSecurityManager(new SecurityManager() { @Override public void checkPermission(Permission requested) { for (Permission permission : permissions) { if (permission.implies(requested)) { return; } } super.checkPermission(requested); } }); }