aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-batch
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2015-10-01 18:10:47 +0200
committerDuarte Meneses <duarte.meneses@sonarsource.com>2015-10-01 18:10:47 +0200
commit5f1b48e1589a03fee9910f4d338be57a9c84bffa (patch)
tree7fac95632e0fe3624a21250ac4cac8bc547dd49f /sonar-batch
parent01ac3cca26ddb38857fa0dbc93559ef180894988 (diff)
downloadsonarqube-5f1b48e1589a03fee9910f4d338be57a9c84bffa.tar.gz
sonarqube-5f1b48e1589a03fee9910f4d338be57a9c84bffa.zip
Improve quality
Diffstat (limited to 'sonar-batch')
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/cache/GlobalPersistentCacheProviderTest.java27
1 files changed, 27 insertions, 0 deletions
diff --git a/sonar-batch/src/test/java/org/sonar/batch/cache/GlobalPersistentCacheProviderTest.java b/sonar-batch/src/test/java/org/sonar/batch/cache/GlobalPersistentCacheProviderTest.java
index e009ddcc795..b34e6fcd7f5 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/cache/GlobalPersistentCacheProviderTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/cache/GlobalPersistentCacheProviderTest.java
@@ -21,8 +21,11 @@ package org.sonar.batch.cache;
import org.sonar.home.cache.PersistentCache;
+import java.nio.file.Path;
+import java.nio.file.Paths;
import java.util.HashMap;
+import static org.junit.Assert.*;
import static org.assertj.core.api.Assertions.assertThat;
import org.sonar.batch.bootstrap.GlobalProperties;
import org.junit.Before;
@@ -53,4 +56,28 @@ public class GlobalPersistentCacheProviderTest {
.resolve("http%3A%2F%2Flocalhost%3A9000")
.resolve("global"));
}
+
+ @Test
+ public void test_singleton() {
+ assertTrue(provider.provide(globalProperties) == provider.provide(globalProperties));
+ }
+
+ @Test
+ public void test_without_sonar_home() {
+ globalProperties = new GlobalProperties(new HashMap<String, String>());
+ PersistentCache cache = provider.provide(globalProperties);
+ assertThat(cache.getDirectory().toAbsolutePath().toString()).startsWith(findHome().toAbsolutePath().toString());
+
+ }
+
+ private static Path findHome() {
+ String home = System.getenv("SONAR_USER_HOME");
+
+ if (home != null) {
+ return Paths.get(home);
+ }
+
+ home = System.getProperty("user.home");
+ return Paths.get(home, ".sonar");
+ }
}