Make sure SystemReader is reset after test is run
Otherwise the MockSystemReader from the test setup is active for other tests. Change-Id: I7caf693bd692d06936e29efd4dc4aabb48c1c39b Signed-off-by: Robin Stocker <robin@nibor.org>
This commit is contained in:
parent
057321731e
commit
09711a4bb9
|
@ -170,6 +170,8 @@ public void tearDown() throws Exception {
|
||||||
recursiveDelete(tmp, false, true);
|
recursiveDelete(tmp, false, true);
|
||||||
if (tmp != null && !tmp.exists())
|
if (tmp != null && !tmp.exists())
|
||||||
CleanupThread.removed(tmp);
|
CleanupThread.removed(tmp);
|
||||||
|
|
||||||
|
SystemReader.setInstance(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Increment the {@link #author} and {@link #committer} times. */
|
/** Increment the {@link #author} and {@link #committer} times. */
|
||||||
|
|
|
@ -68,12 +68,19 @@
|
||||||
import org.eclipse.jgit.junit.MockSystemReader;
|
import org.eclipse.jgit.junit.MockSystemReader;
|
||||||
import org.eclipse.jgit.util.FS;
|
import org.eclipse.jgit.util.FS;
|
||||||
import org.eclipse.jgit.util.SystemReader;
|
import org.eclipse.jgit.util.SystemReader;
|
||||||
|
import org.junit.After;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test reading of git config
|
* Test reading of git config
|
||||||
*/
|
*/
|
||||||
public class ConfigTest {
|
public class ConfigTest {
|
||||||
|
|
||||||
|
@After
|
||||||
|
public void tearDown() {
|
||||||
|
SystemReader.setInstance(null);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test001_ReadBareKey() throws ConfigInvalidException {
|
public void test001_ReadBareKey() throws ConfigInvalidException {
|
||||||
final Config c = parse("[foo]\nbar\n");
|
final Config c = parse("[foo]\nbar\n");
|
||||||
|
|
|
@ -48,6 +48,7 @@
|
||||||
import org.eclipse.jgit.junit.MockSystemReader;
|
import org.eclipse.jgit.junit.MockSystemReader;
|
||||||
import org.eclipse.jgit.lib.PersonIdent;
|
import org.eclipse.jgit.lib.PersonIdent;
|
||||||
import org.eclipse.jgit.util.GitDateFormatter.Format;
|
import org.eclipse.jgit.util.GitDateFormatter.Format;
|
||||||
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
@ -70,6 +71,11 @@ public long getCurrentTime() {
|
||||||
.parsePersonIdent("A U Thor <author@example.com> 1316560165 -0400");
|
.parsePersonIdent("A U Thor <author@example.com> 1316560165 -0400");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@After
|
||||||
|
public void tearDown() {
|
||||||
|
SystemReader.setInstance(null);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void DEFAULT() {
|
public void DEFAULT() {
|
||||||
assertEquals("Tue Sep 20 19:09:25 2011 -0400", new GitDateFormatter(
|
assertEquals("Tue Sep 20 19:09:25 2011 -0400", new GitDateFormatter(
|
||||||
|
|
|
@ -50,6 +50,7 @@
|
||||||
import java.util.GregorianCalendar;
|
import java.util.GregorianCalendar;
|
||||||
|
|
||||||
import org.eclipse.jgit.junit.MockSystemReader;
|
import org.eclipse.jgit.junit.MockSystemReader;
|
||||||
|
import org.junit.After;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -61,6 +62,11 @@ public void setUp() {
|
||||||
SystemReader.setInstance(mockSystemReader);
|
SystemReader.setInstance(mockSystemReader);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@After
|
||||||
|
public void tearDown() {
|
||||||
|
SystemReader.setInstance(null);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void yesterday() throws ParseException {
|
public void yesterday() throws ParseException {
|
||||||
GregorianCalendar cal = new GregorianCalendar(SystemReader
|
GregorianCalendar cal = new GregorianCalendar(SystemReader
|
||||||
|
|
|
@ -53,6 +53,7 @@
|
||||||
|
|
||||||
import org.eclipse.jgit.junit.MockSystemReader;
|
import org.eclipse.jgit.junit.MockSystemReader;
|
||||||
import org.eclipse.jgit.util.RelativeDateFormatter;
|
import org.eclipse.jgit.util.RelativeDateFormatter;
|
||||||
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
@ -63,6 +64,11 @@ public void setUp() {
|
||||||
SystemReader.setInstance(new MockSystemReader());
|
SystemReader.setInstance(new MockSystemReader());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@After
|
||||||
|
public void tearDown() {
|
||||||
|
SystemReader.setInstance(null);
|
||||||
|
}
|
||||||
|
|
||||||
private static void assertFormat(long ageFromNow, long timeUnit,
|
private static void assertFormat(long ageFromNow, long timeUnit,
|
||||||
String expectedFormat) {
|
String expectedFormat) {
|
||||||
Date d = new Date(SystemReader.getInstance().getCurrentTime()
|
Date d = new Date(SystemReader.getInstance().getCurrentTime()
|
||||||
|
|
|
@ -137,7 +137,8 @@ public static SystemReader getInstance() {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param newReader
|
* @param newReader
|
||||||
* the new instance to use when accessing properties.
|
* the new instance to use when accessing properties, or null for
|
||||||
|
* the default instance.
|
||||||
*/
|
*/
|
||||||
public static void setInstance(SystemReader newReader) {
|
public static void setInstance(SystemReader newReader) {
|
||||||
if (newReader == null)
|
if (newReader == null)
|
||||||
|
|
Loading…
Reference in New Issue