killbill-memoizeit

util: harden clock setup in tests to avoid NPE Signed-off-by:

10/17/2018 5:47:40 AM

Details

diff --git a/util/src/test/java/org/killbill/billing/GuicyKillbillTestSuite.java b/util/src/test/java/org/killbill/billing/GuicyKillbillTestSuite.java
index 651ada0..68b9717 100644
--- a/util/src/test/java/org/killbill/billing/GuicyKillbillTestSuite.java
+++ b/util/src/test/java/org/killbill/billing/GuicyKillbillTestSuite.java
@@ -71,10 +71,11 @@ public class GuicyKillbillTestSuite implements IHookable {
 
     // Variables set in @BeforeSuite
     protected static ImmutableMap<String, String> extraPropertiesForTestSuite;
+    // The clock needs to be setup early, as it is needed when starting the server, but see below
     @VisibleForTesting
-    protected static ClockMock theRealClock;
+    protected static ClockMock theRealClock = new ClockMock();
 
-    protected ClockMock clock;
+    protected ClockMock clock = theRealClock;
     protected KillbillConfigSource configSource;
     protected ConfigSource skifeConfigSource;
 
@@ -211,12 +212,9 @@ public class GuicyKillbillTestSuite implements IHookable {
 
     @BeforeSuite(alwaysRun = true)
     public void globalBeforeSuite() {
-        theRealClock = new ClockMock();
+        theRealClock.resetDeltaFromReality();
 
         extraPropertiesForTestSuite = ImmutableMap.<String, String>of();
-
-        // The clock needs to be setup early in @BeforeSuite, as it is needed when starting the server, but see below
-        clock = theRealClock;
     }
 
     @BeforeClass(alwaysRun = true)