diff options
Diffstat (limited to 'sonar-batch')
-rw-r--r-- | sonar-batch/src/test/java/org/sonar/batch/index/AbstractCachesTest.java | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/sonar-batch/src/test/java/org/sonar/batch/index/AbstractCachesTest.java b/sonar-batch/src/test/java/org/sonar/batch/index/AbstractCachesTest.java index 357259d7a18..026f816cea4 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/index/AbstractCachesTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/index/AbstractCachesTest.java @@ -20,9 +20,7 @@ package org.sonar.batch.index; import org.junit.After; -import org.junit.AfterClass; import org.junit.Before; -import org.junit.BeforeClass; import org.junit.ClassRule; import org.junit.rules.TemporaryFolder; @@ -30,17 +28,21 @@ public abstract class AbstractCachesTest { @ClassRule public static TemporaryFolder temp = new TemporaryFolder(); - protected Caches caches; - protected static CachesManager cachesManager; + protected static final ThreadLocal<CachesManager> cachesManagers = new ThreadLocal<CachesManager>() { + @Override + protected CachesManager initialValue() { + CachesManager cachesManager = CachesManagerTest.createCacheOnTemp(temp); + cachesManager.start(); + return cachesManager; + } + }; - @BeforeClass - public static void startClass() { - cachesManager = CachesManagerTest.createCacheOnTemp(temp); - cachesManager.start(); - } + protected CachesManager cachesManager; + protected Caches caches; @Before public void start() { + cachesManager = cachesManagers.get(); caches = new Caches(cachesManager); caches.start(); } @@ -52,12 +54,4 @@ public abstract class AbstractCachesTest { caches = null; } } - - @AfterClass - public static void stopClass() { - if (cachesManager != null) { - cachesManager.stop(); - cachesManager = null; - } - } } |