summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.junit
diff options
context:
space:
mode:
authorTerry Parker <tparker@google.com>2016-03-25 13:55:48 -0700
committerTerry Parker <tparker@google.com>2016-03-25 14:03:40 -0700
commit10135580d0842972c61daa3aa52493ea4c7d4485 (patch)
treed0e5b885970fcf34f69b6d7481da1bcd7b10f430 /org.eclipse.jgit.junit
parent09810d013c8366f3f174438e8537d397b158906a (diff)
downloadjgit-10135580d0842972c61daa3aa52493ea4c7d4485.tar.gz
jgit-10135580d0842972c61daa3aa52493ea4c7d4485.zip
In TestRepository, use a consistent clock
The default author and committer objects in TestRepository were initialized statically and did not use the MockSystemReader passed into the TestRepository ctor. Make these fields non-static and initialize them with a consistent clock. Also make the author and commiter name and email strings public for tests that want to verify against them. Change-Id: I88b444b96e22743001b32824d8e4e03c2239aa86 Signed-off-by: Terry Parker <tparker@google.com>
Diffstat (limited to 'org.eclipse.jgit.junit')
-rw-r--r--org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java25
1 files changed, 12 insertions, 13 deletions
diff --git a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java
index e259156c31..1119e63824 100644
--- a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java
+++ b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java
@@ -112,23 +112,18 @@ import org.eclipse.jgit.util.io.SafeBufferedOutputStream;
* type of Repository the test data is stored on.
*/
public class TestRepository<R extends Repository> {
- private static final PersonIdent defaultAuthor;
- private static final PersonIdent defaultCommitter;
+ public static final String AUTHOR = "J. Author";
- static {
- final MockSystemReader m = new MockSystemReader();
- final long now = m.getCurrentTime();
- final int tz = m.getTimezone(now);
+ public static final String AUTHOR_EMAIL = "jauthor@example.com";
- final String an = "J. Author";
- final String ae = "jauthor@example.com";
- defaultAuthor = new PersonIdent(an, ae, now, tz);
+ public static final String COMMITTER = "J. Committer";
- final String cn = "J. Committer";
- final String ce = "jcommitter@example.com";
- defaultCommitter = new PersonIdent(cn, ce, now, tz);
- }
+ public static final String COMMITTER_EMAIL = "jcommitter@example.com";
+
+ private final PersonIdent defaultAuthor;
+
+ private final PersonIdent defaultCommitter;
private final R db;
@@ -184,6 +179,10 @@ public class TestRepository<R extends Repository> {
this.pool = rw;
this.inserter = db.newObjectInserter();
this.mockSystemReader = reader;
+ long now = mockSystemReader.getCurrentTime();
+ int tz = mockSystemReader.getTimezone(now);
+ defaultAuthor = new PersonIdent(AUTHOR, AUTHOR_EMAIL, now, tz);
+ defaultCommitter = new PersonIdent(COMMITTER, COMMITTER_EMAIL, now, tz);
}
/** @return the repository this helper class operates against. */