]> source.dussan.org Git - jgit.git/commitdiff
Make sure SystemReader is reset after test is run 16/17616/1
authorRobin Stocker <robin@nibor.org>
Mon, 21 Oct 2013 22:37:56 +0000 (00:37 +0200)
committerRobin Stocker <robin@nibor.org>
Mon, 21 Oct 2013 22:37:56 +0000 (00:37 +0200)
Otherwise the MockSystemReader from the test setup is active for other
tests.

Change-Id: I7caf693bd692d06936e29efd4dc4aabb48c1c39b
Signed-off-by: Robin Stocker <robin@nibor.org>
org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/LocalDiskRepositoryTestCase.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/util/GitDateFormatterTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/util/GitDateParserTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/util/RelativeDateFormatterTest.java
org.eclipse.jgit/src/org/eclipse/jgit/util/SystemReader.java

index 7c53e8d1b2462aa7abb8b676824e71d8101e8d24..053751f8ab2b525e1547988fd7f7aac42e2a1c95 100644 (file)
@@ -170,6 +170,8 @@ public abstract class LocalDiskRepositoryTestCase {
                        recursiveDelete(tmp, false, true);
                if (tmp != null && !tmp.exists())
                        CleanupThread.removed(tmp);
+
+               SystemReader.setInstance(null);
        }
 
        /** Increment the {@link #author} and {@link #committer} times. */
index e5e1e7ad6eecc06c1bd260eb8f50ff0885e2eeb4..6ebef6cbf9ffebf4ba4f87b93609de937e030ab7 100644 (file)
@@ -68,12 +68,19 @@ import org.eclipse.jgit.errors.ConfigInvalidException;
 import org.eclipse.jgit.junit.MockSystemReader;
 import org.eclipse.jgit.util.FS;
 import org.eclipse.jgit.util.SystemReader;
+import org.junit.After;
 import org.junit.Test;
 
 /**
  * Test reading of git config
  */
 public class ConfigTest {
+
+       @After
+       public void tearDown() {
+               SystemReader.setInstance(null);
+       }
+
        @Test
        public void test001_ReadBareKey() throws ConfigInvalidException {
                final Config c = parse("[foo]\nbar\n");
index a818107f665307c264ed0ec0b9899cfe75b9fd20..d52166f2bade885da95ef5955f49eedb648cfab8 100644 (file)
@@ -48,6 +48,7 @@ import static org.junit.Assert.assertEquals;
 import org.eclipse.jgit.junit.MockSystemReader;
 import org.eclipse.jgit.lib.PersonIdent;
 import org.eclipse.jgit.util.GitDateFormatter.Format;
+import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -70,6 +71,11 @@ public class GitDateFormatterTest {
                                .parsePersonIdent("A U Thor <author@example.com> 1316560165 -0400");
        }
 
+       @After
+       public void tearDown() {
+               SystemReader.setInstance(null);
+       }
+
        @Test
        public void DEFAULT() {
                assertEquals("Tue Sep 20 19:09:25 2011 -0400", new GitDateFormatter(
index 6b0632aef083a93308c68c6f843728cdd5435a9d..570f4999dd0830868ab8dfc82ab25fad1c6690b3 100644 (file)
@@ -50,6 +50,7 @@ import java.util.Date;
 import java.util.GregorianCalendar;
 
 import org.eclipse.jgit.junit.MockSystemReader;
+import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
@@ -61,6 +62,11 @@ public class GitDateParserTest {
                SystemReader.setInstance(mockSystemReader);
        }
 
+       @After
+       public void tearDown() {
+               SystemReader.setInstance(null);
+       }
+
        @Test
        public void yesterday() throws ParseException {
                GregorianCalendar cal = new GregorianCalendar(SystemReader
index 0bf78f390086d71f3b819509c11324f0e7854144..2901c938854f40f2edcba0713c2b36744a4bc73e 100644 (file)
@@ -53,6 +53,7 @@ import java.util.Date;
 
 import org.eclipse.jgit.junit.MockSystemReader;
 import org.eclipse.jgit.util.RelativeDateFormatter;
+import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -63,6 +64,11 @@ public class RelativeDateFormatterTest {
                SystemReader.setInstance(new MockSystemReader());
        }
 
+       @After
+       public void tearDown() {
+               SystemReader.setInstance(null);
+       }
+
        private static void assertFormat(long ageFromNow, long timeUnit,
                        String expectedFormat) {
                Date d = new Date(SystemReader.getInstance().getCurrentTime()
index cfd6fea7d3726298347f547203f617d0fca7b78f..b6028610bf8f028eb5c70bbe55efc8e4615ddf57 100644 (file)
@@ -137,7 +137,8 @@ public abstract class SystemReader {
 
        /**
         * @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) {
                if (newReader == null)