aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2015-08-27 16:58:34 +0200
committerDuarte Meneses <duarte.meneses@sonarsource.com>2015-08-28 15:54:30 +0200
commit22f39e39acdf84be933aab9d6c1b10455e0e4033 (patch)
tree358928c6fc18d197a009300ee49ac7bb863af961
parente6950401a73e7ed1eb5401805528475c6b59f71a (diff)
downloadsonarqube-22f39e39acdf84be933aab9d6c1b10455e0e4033.tar.gz
sonarqube-22f39e39acdf84be933aab9d6c1b10455e0e4033.zip
SONAR-6577 Offline mode in issues mode
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/bootstrap/ExtensionInstallerTest.java8
-rw-r--r--sonar-home/src/main/java/org/sonar/home/cache/PersistentCache.java4
-rw-r--r--sonar-home/src/test/java/org/sonar/home/cache/PersistentCacheTest.java7
3 files changed, 13 insertions, 6 deletions
diff --git a/sonar-batch/src/test/java/org/sonar/batch/bootstrap/ExtensionInstallerTest.java b/sonar-batch/src/test/java/org/sonar/batch/bootstrap/ExtensionInstallerTest.java
index aef314012ca..42adfd1d3fc 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/bootstrap/ExtensionInstallerTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/bootstrap/ExtensionInstallerTest.java
@@ -62,7 +62,7 @@ public class ExtensionInstallerTest {
when(pluginRepository.getPluginInstance("foo")).thenReturn(newPluginInstance(Foo.class, Bar.class));
ComponentContainer container = new ComponentContainer();
- ExtensionInstaller installer = new ExtensionInstaller(pluginRepository, new EnvironmentInformation("ant", "1.7"), mode);
+ ExtensionInstaller installer = new ExtensionInstaller(pluginRepository, new EnvironmentInformation("ant", "1.7"));
installer.install(container, new FooMatcher());
assertThat(container.getComponentByType(Foo.class)).isNotNull();
@@ -74,7 +74,7 @@ public class ExtensionInstallerTest {
when(pluginRepository.getPluginInfos()).thenReturn(Arrays.asList(new PluginInfo("foo")));
when(pluginRepository.getPluginInstance("foo")).thenReturn(newPluginInstance(new FooProvider(), new BarProvider()));
ComponentContainer container = new ComponentContainer();
- ExtensionInstaller installer = new ExtensionInstaller(pluginRepository, new EnvironmentInformation("ant", "1.7"), mode);
+ ExtensionInstaller installer = new ExtensionInstaller(pluginRepository, new EnvironmentInformation("ant", "1.7"));
installer.install(container, new FooMatcher());
@@ -87,7 +87,7 @@ public class ExtensionInstallerTest {
when(pluginRepository.getPluginInfos()).thenReturn(Arrays.asList(new PluginInfo("foo")));
when(pluginRepository.getPluginInstance("foo")).thenReturn(newPluginInstance(new FooBarProvider()));
ComponentContainer container = new ComponentContainer();
- ExtensionInstaller installer = new ExtensionInstaller(pluginRepository, new EnvironmentInformation("ant", "1.7"), mode);
+ ExtensionInstaller installer = new ExtensionInstaller(pluginRepository, new EnvironmentInformation("ant", "1.7"));
installer.install(container, new TrueMatcher());
@@ -100,7 +100,7 @@ public class ExtensionInstallerTest {
when(pluginRepository.getPluginInfos()).thenReturn(Arrays.asList(new PluginInfo("foo")));
when(pluginRepository.getPluginInstance("foo")).thenReturn(newPluginInstance(Foo.class, MavenExtension.class, AntExtension.class, new BarProvider()));
ComponentContainer container = new ComponentContainer();
- ExtensionInstaller installer = new ExtensionInstaller(pluginRepository, new EnvironmentInformation("ant", "1.7"), mode);
+ ExtensionInstaller installer = new ExtensionInstaller(pluginRepository, new EnvironmentInformation("ant", "1.7"));
installer.install(container, new TrueMatcher());
diff --git a/sonar-home/src/main/java/org/sonar/home/cache/PersistentCache.java b/sonar-home/src/main/java/org/sonar/home/cache/PersistentCache.java
index 2193f5a1ba4..c5c45090ed4 100644
--- a/sonar-home/src/main/java/org/sonar/home/cache/PersistentCache.java
+++ b/sonar-home/src/main/java/org/sonar/home/cache/PersistentCache.java
@@ -76,7 +76,9 @@ public class PersistentCache {
@CheckForNull
public synchronized String getString(@Nonnull String obj, @Nullable final PersistentCacheLoader<String> valueLoader) throws IOException {
- byte[] cached = get(obj, new ValueLoaderDecoder(valueLoader));
+ ValueLoaderDecoder decoder = valueLoader != null ? new ValueLoaderDecoder(valueLoader) : null;
+
+ byte[] cached = get(obj, decoder);
if (cached == null) {
return null;
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 72f594bf7d1..9760b096676 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,7 +20,6 @@
package org.sonar.home.cache;
import java.io.File;
-import java.io.IOException;
import org.apache.commons.io.FileUtils;
import org.junit.Before;
@@ -55,6 +54,12 @@ public class PersistentCacheTest {
assertThat(cache.get(URI, null)).isNull();
assertCacheHit(false);
}
+
+ @Test
+ public void testNullLoaderString() throws Exception {
+ assertThat(cache.getString(URI, null)).isNull();
+ assertCacheHit(false);
+ }
@Test
public void testNullValue() throws Exception {