aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-batch
diff options
context:
space:
mode:
authorDavid Gageot <david@gageot.net>2015-07-02 19:29:01 +0200
committerDavid Gageot <david@gageot.net>2015-07-02 19:31:03 +0200
commitc1684e8a22d318ede896b58fb79747ee425cef76 (patch)
tree8b746d6a28db475ab6f1c68be12c61995e39b572 /sonar-batch
parenta4ef4494e4697e6772b0e7acc411da8a3b42c359 (diff)
downloadsonarqube-c1684e8a22d318ede896b58fb79747ee425cef76.tar.gz
sonarqube-c1684e8a22d318ede896b58fb79747ee425cef76.zip
Support // testing
Diffstat (limited to 'sonar-batch')
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/index/AbstractCachesTest.java28
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;
- }
- }
}