Ensure we use MockSystemReader in tests
If we use the default system reader FileStoreAttributes cannot persist attributes in userConfig when tests run in Bazel due to sandboxing. Hence we need to ensure that all tests use MockSystemReader (and especially a mocked userConfig). Change-Id: Ic1ad8e2ec5a150c5433434a5f6667d6c4674c87d Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
This commit is contained in:
parent
65cee6ccbf
commit
12d03a97d8
|
@ -74,6 +74,7 @@
|
||||||
import org.apache.http.impl.client.HttpClientBuilder;
|
import org.apache.http.impl.client.HttpClientBuilder;
|
||||||
import org.eclipse.jetty.servlet.ServletContextHandler;
|
import org.eclipse.jetty.servlet.ServletContextHandler;
|
||||||
import org.eclipse.jetty.servlet.ServletHolder;
|
import org.eclipse.jetty.servlet.ServletHolder;
|
||||||
|
import org.eclipse.jgit.junit.MockSystemReader;
|
||||||
import org.eclipse.jgit.junit.http.AppServer;
|
import org.eclipse.jgit.junit.http.AppServer;
|
||||||
import org.eclipse.jgit.lfs.errors.LfsException;
|
import org.eclipse.jgit.lfs.errors.LfsException;
|
||||||
import org.eclipse.jgit.lfs.lib.AnyLongObjectId;
|
import org.eclipse.jgit.lfs.lib.AnyLongObjectId;
|
||||||
|
@ -85,6 +86,7 @@
|
||||||
import org.eclipse.jgit.util.FS;
|
import org.eclipse.jgit.util.FS;
|
||||||
import org.eclipse.jgit.util.FileUtils;
|
import org.eclipse.jgit.util.FileUtils;
|
||||||
import org.eclipse.jgit.util.IO;
|
import org.eclipse.jgit.util.IO;
|
||||||
|
import org.eclipse.jgit.util.SystemReader;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
|
||||||
|
@ -119,6 +121,7 @@ public Path getDir() {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() throws Exception {
|
public void setup() throws Exception {
|
||||||
|
SystemReader.setInstance(new MockSystemReader());
|
||||||
tmp = Files.createTempDirectory("jgit_test_");
|
tmp = Files.createTempDirectory("jgit_test_");
|
||||||
|
|
||||||
// measure timer resolution before the test to avoid time critical tests
|
// measure timer resolution before the test to avoid time critical tests
|
||||||
|
|
|
@ -62,6 +62,7 @@
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import org.eclipse.jgit.junit.MockSystemReader;
|
||||||
import org.eclipse.jgit.util.FS;
|
import org.eclipse.jgit.util.FS;
|
||||||
import org.eclipse.jgit.util.FS.FileStoreAttributes;
|
import org.eclipse.jgit.util.FS.FileStoreAttributes;
|
||||||
import org.eclipse.jgit.util.FileUtils;
|
import org.eclipse.jgit.util.FileUtils;
|
||||||
|
@ -84,6 +85,7 @@ public class FileSnapshotTest {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
|
SystemReader.setInstance(new MockSystemReader());
|
||||||
trash = Files.createTempDirectory("tmp_");
|
trash = Files.createTempDirectory("tmp_");
|
||||||
// measure timer resolution before the test to avoid time critical tests
|
// measure timer resolution before the test to avoid time critical tests
|
||||||
// are affected by time needed for measurement
|
// are affected by time needed for measurement
|
||||||
|
|
|
@ -55,9 +55,11 @@
|
||||||
import java.nio.file.StandardOpenOption;
|
import java.nio.file.StandardOpenOption;
|
||||||
|
|
||||||
import org.eclipse.jgit.errors.ConfigInvalidException;
|
import org.eclipse.jgit.errors.ConfigInvalidException;
|
||||||
|
import org.eclipse.jgit.junit.MockSystemReader;
|
||||||
import org.eclipse.jgit.util.FS;
|
import org.eclipse.jgit.util.FS;
|
||||||
import org.eclipse.jgit.util.FileUtils;
|
import org.eclipse.jgit.util.FileUtils;
|
||||||
import org.eclipse.jgit.util.IO;
|
import org.eclipse.jgit.util.IO;
|
||||||
|
import org.eclipse.jgit.util.SystemReader;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -82,6 +84,7 @@ public class FileBasedConfigTest {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
|
SystemReader.setInstance(new MockSystemReader());
|
||||||
trash = Files.createTempDirectory("tmp_");
|
trash = Files.createTempDirectory("tmp_");
|
||||||
FS.getFileStoreAttributes(trash.getParent());
|
FS.getFileStoreAttributes(trash.getParent());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue