Add ability to mock/fake time intervals in tests System.nanoTime can't be mocked in tests. This change replaces System.nanoTime with Ticker and adds the TestTicker for mocking. Gerrit already has @UseClockStep annotiations, but it works with jgit and can't be reused because it doesn't provide nanoseconds resolution. This change adds minimal implementation which can be used in tests. Later it can be extended with annotations and other features (or combined with @UseClockStep). Change-Id: If7bebc41eae939b1ee1f0849a1927a3f79f4df6b
diff --git a/tools/nongoogle.bzl b/tools/nongoogle.bzl index b1ebb5c..51be39f 100644 --- a/tools/nongoogle.bzl +++ b/tools/nongoogle.bzl
@@ -4,6 +4,8 @@ GUAVA_BIN_SHA1 = "00d0c3ce2311c9e36e73228da25a6e99b2ab826f" +GUAVA_TESTLIB_BIN_SHA1 = "798c3827308605cd69697d8f1596a1735d3ef6e2" + GUAVA_DOC_URL = "https://google.github.io/guava/releases/" + GUAVA_VERSION + "/api/docs/" TESTCONTAINERS_VERSION = "1.15.3" @@ -147,6 +149,12 @@ sha1 = GUAVA_BIN_SHA1, ) + maven_jar( + name = "guava-testlib", + artifact = "com.google.guava:guava-testlib:" + GUAVA_VERSION, + sha1 = GUAVA_TESTLIB_BIN_SHA1, + ) + GUICE_VERS = "5.0.1" maven_jar(