aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-home/src/test
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2015-07-31 10:08:36 +0200
committerDuarte Meneses <duarte.meneses@sonarsource.com>2015-07-31 12:04:26 +0200
commit187b5f6f59454df662b29692fb86b0be552b6372 (patch)
tree678281b49bcf548a9ebcfffeeea0c42f5fabec4b /sonar-home/src/test
parent6cd87655c83490cc9f80f10c71a12a09e05378f2 (diff)
downloadsonarqube-187b5f6f59454df662b29692fb86b0be552b6372.tar.gz
sonarqube-187b5f6f59454df662b29692fb86b0be552b6372.zip
Improve quality
Diffstat (limited to 'sonar-home/src/test')
-rw-r--r--sonar-home/src/test/java/org/sonar/home/cache/PersistentCacheTest.java27
1 files changed, 22 insertions, 5 deletions
diff --git a/sonar-home/src/test/java/org/sonar/home/cache/PersistentCacheTest.java b/sonar-home/src/test/java/org/sonar/home/cache/PersistentCacheTest.java
index c327ff7c5eb..72f594bf7d1 100644
--- a/sonar-home/src/test/java/org/sonar/home/cache/PersistentCacheTest.java
+++ b/sonar-home/src/test/java/org/sonar/home/cache/PersistentCacheTest.java
@@ -20,12 +20,13 @@
package org.sonar.home.cache;
import java.io.File;
+import java.io.IOException;
+
import org.apache.commons.io.FileUtils;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
-
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
@@ -66,6 +67,16 @@ public class PersistentCacheTest {
@Test
public void testClean() throws Exception {
+ // puts entry
+ assertCacheHit(false);
+ // negative time to make sure it is expired
+ cache = new PersistentCache(tmp.getRoot().toPath(), -100, mock(Logger.class), null);
+ cache.clean();
+ assertCacheHit(false);
+ }
+
+ @Test
+ public void testClear() throws Exception {
assertCacheHit(false);
cache.clear();
assertCacheHit(false);
@@ -78,6 +89,12 @@ public class PersistentCacheTest {
}
@Test
+ public void testPut() throws Exception {
+ cache.put(URI, VALUE.getBytes());
+ assertCacheHit(true);
+ }
+
+ @Test
public void testReconfigure() throws Exception {
cache = new PersistentCache(tmp.getRoot().toPath(), Long.MAX_VALUE, mock(Logger.class), null);
assertCacheHit(false);
@@ -101,22 +118,22 @@ public class PersistentCacheTest {
assertCacheHit(false);
assertCacheHit(false);
}
-
+
@Test
public void testDifferentServerVersions() throws Exception {
assertCacheHit(false);
assertCacheHit(true);
-
+
PersistentCache cache2 = new PersistentCache(tmp.getRoot().toPath(), Long.MAX_VALUE, mock(Logger.class), "5.2");
assertCacheHit(cache2, false);
assertCacheHit(cache2, true);
-
+
}
private void assertCacheHit(boolean hit) throws Exception {
assertCacheHit(cache, hit);
}
-
+
private void assertCacheHit(PersistentCache pCache, boolean hit) throws Exception {
CacheFillerString c = new CacheFillerString();
assertThat(pCache.getString(URI, c)).isEqualTo(VALUE);