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
@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 {
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