diff options
author | Duarte Meneses <duarte.meneses@sonarsource.com> | 2015-10-01 18:10:47 +0200 |
---|---|---|
committer | Duarte Meneses <duarte.meneses@sonarsource.com> | 2015-10-01 18:10:47 +0200 |
commit | 5f1b48e1589a03fee9910f4d338be57a9c84bffa (patch) | |
tree | 7fac95632e0fe3624a21250ac4cac8bc547dd49f /sonar-batch | |
parent | 01ac3cca26ddb38857fa0dbc93559ef180894988 (diff) | |
download | sonarqube-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.java | 27 |
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"); + } } |