]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-6577 Offline mode in issues mode
authorDuarte Meneses <duarte.meneses@sonarsource.com>
Thu, 27 Aug 2015 14:58:34 +0000 (16:58 +0200)
committerDuarte Meneses <duarte.meneses@sonarsource.com>
Fri, 28 Aug 2015 13:54:30 +0000 (15:54 +0200)
sonar-batch/src/test/java/org/sonar/batch/bootstrap/ExtensionInstallerTest.java
sonar-home/src/main/java/org/sonar/home/cache/PersistentCache.java
sonar-home/src/test/java/org/sonar/home/cache/PersistentCacheTest.java

index aef314012cacb137cdabb464f48e739ce6b1125c..42adfd1d3fc94aa7a3363f0081c5f226ae9179d3 100644 (file)
@@ -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());
 
index 2193f5a1ba454893e4fefe51e5fd4724c856fe2f..c5c45090ed477cb2699ccb82dc008d5fda5c2526 100644 (file)
@@ -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;
index 72f594bf7d1df68869bffc1829dac4409611c901..9760b0966769c6273e546f287c0d4251073a80da 100644 (file)
@@ -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 {