]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-21195 Convert exception to a warning when no language plugins are installed.
authorDimitris Kavvathas <dimitris.kavvathas@sonarsource.com>
Fri, 5 Jan 2024 14:35:33 +0000 (15:35 +0100)
committersonartech <sonartech@sonarsource.com>
Fri, 5 Jan 2024 20:02:36 +0000 (20:02 +0000)
sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/fs/NoLanguagesPluginsMediumIT.java
sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/SpringProjectScanContainer.java

index d575c39d0e5a377842a69cb89e8f8b42da25bfd9..db2d45e5904081cec1bbaf159501178efa6d8201 100644 (file)
@@ -22,12 +22,15 @@ package org.sonar.scanner.mediumtest.fs;
 import java.io.File;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.filefilter.FileFilterUtils;
+import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.TemporaryFolder;
+import org.slf4j.event.Level;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.scanner.mediumtest.ScannerMediumTester;
 
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.assertj.core.api.Assertions.assertThat;
 
 public class NoLanguagesPluginsMediumIT {
   @Rule
@@ -36,15 +39,23 @@ public class NoLanguagesPluginsMediumIT {
   @Rule
   public ScannerMediumTester tester = new ScannerMediumTester();
 
+  @Rule
+  public LogTester logger = new LogTester();
+
+  @Before
+  public void before() {
+    logger.clear();
+  }
+
   @Test
   public void testNoLanguagePluginsInstalled() throws Exception {
     File projectDir = copyProject("test-resources/mediumtest/xoo/sample");
 
-    assertThatThrownBy(() -> tester
-      .newAnalysis(new File(projectDir, "sonar-project.properties"))
-      .execute())
-      .isInstanceOf(IllegalStateException.class)
-      .hasMessage("No language plugins are installed.");
+    tester.
+      newAnalysis(new File(projectDir, "sonar-project.properties"))
+      .execute();
+
+    assertThat(logger.logs(Level.WARN)).contains("No language plugins are installed.");
   }
 
   private File copyProject(String path) throws Exception {
index 3382d6f25dea63b97f387ef4105400b037b79f08..bef9b1fb6320aa72011f6ef394073915b2676498 100644 (file)
@@ -149,7 +149,7 @@ public class SpringProjectScanContainer extends SpringComponentContainer {
     ScanProperties properties = getComponentByType(ScanProperties.class);
 
     if (getComponentByType(Languages.class).all().length == 0) {
-      throw new IllegalStateException("No language plugins are installed.");
+      LOG.warn("No language plugins are installed.");
     }
 
     // Log detected languages and their profiles after FS is indexed and languages detected