Search in sources :

Example 1 with LogOutputRecorder

use of org.sonar.scanner.mediumtest.LogOutputRecorder in project sonarqube by SonarSource.

the class FileSystemMediumTest method stop.

@After
public void stop() {
    tester.stop();
    logs = new LogOutputRecorder();
}
Also used : LogOutputRecorder(org.sonar.scanner.mediumtest.LogOutputRecorder) After(org.junit.After)

Example 2 with LogOutputRecorder

use of org.sonar.scanner.mediumtest.LogOutputRecorder in project sonarqube by SonarSource.

the class FileSystemMediumTest method createIssueOnAnyFile.

@Test
public void createIssueOnAnyFile() throws IOException {
    LogOutputRecorder logs = new LogOutputRecorder();
    ScannerMediumTester tester2 = ScannerMediumTester.builder().registerPlugin("xoo", new XooPlugin()).addDefaultQProfile("xoo", "Sonar Way").addRules(new XooRulesDefinition()).setLogOutput(logs).addActiveRule("xoo", "OneIssuePerUnknownFile", null, "OneIssuePerUnknownFile", "MAJOR", null, "xoo").build();
    tester2.start();
    builder = createBuilder();
    File srcDir = new File(baseDir, "src");
    srcDir.mkdir();
    File xooFile = new File(srcDir, "sample.unknown");
    FileUtils.write(xooFile, "Sample xoo\ncontent");
    TaskResult result = tester2.newTask().properties(builder.put("sonar.sources", "src").build()).start();
    assertThat(logs.getAllAsString()).contains("1 file indexed");
    assertThat(logs.getAllAsString()).contains("'src/sample.unknown' indexed with language 'null'");
    assertThat(logs.getAllAsString()).contains("'src/sample.unknown' generated metadata");
    DefaultInputFile javaInputFile = (DefaultInputFile) result.inputFile("src/sample.unknown");
    assertThat(result.getReportComponent(javaInputFile.key())).isNotNull();
    tester2.stop();
}
Also used : XooPlugin(org.sonar.xoo.XooPlugin) DefaultInputFile(org.sonar.api.batch.fs.internal.DefaultInputFile) XooRulesDefinition(org.sonar.xoo.rule.XooRulesDefinition) ScannerMediumTester(org.sonar.scanner.mediumtest.ScannerMediumTester) TaskResult(org.sonar.scanner.mediumtest.TaskResult) LogOutputRecorder(org.sonar.scanner.mediumtest.LogOutputRecorder) InputFile(org.sonar.api.batch.fs.InputFile) DefaultInputFile(org.sonar.api.batch.fs.internal.DefaultInputFile) File(java.io.File) Test(org.junit.Test)

Aggregations

LogOutputRecorder (org.sonar.scanner.mediumtest.LogOutputRecorder)2 File (java.io.File)1 After (org.junit.After)1 Test (org.junit.Test)1 InputFile (org.sonar.api.batch.fs.InputFile)1 DefaultInputFile (org.sonar.api.batch.fs.internal.DefaultInputFile)1 ScannerMediumTester (org.sonar.scanner.mediumtest.ScannerMediumTester)1 TaskResult (org.sonar.scanner.mediumtest.TaskResult)1 XooPlugin (org.sonar.xoo.XooPlugin)1 XooRulesDefinition (org.sonar.xoo.rule.XooRulesDefinition)1