Search in sources :

Example 11 with ScannerReportWriter

use of org.sonar.scanner.protocol.output.ScannerReportWriter in project sonarqube by SonarSource.

the class MetadataPublisherTest method write_project_organization.

@Test
public void write_project_organization() throws Exception {
    settings.setProperty(CoreProperties.PROJECT_ORGANIZATION_PROPERTY, "SonarSource");
    File outputDir = temp.newFolder();
    ScannerReportWriter writer = new ScannerReportWriter(outputDir);
    underTest.publish(writer);
    ScannerReportReader reader = new ScannerReportReader(outputDir);
    ScannerReport.Metadata metadata = reader.readMetadata();
    assertThat(metadata.getOrganizationKey()).isEqualTo("SonarSource");
}
Also used : ScannerReportReader(org.sonar.scanner.protocol.output.ScannerReportReader) ScannerReport(org.sonar.scanner.protocol.output.ScannerReport) ScannerReportWriter(org.sonar.scanner.protocol.output.ScannerReportWriter) File(java.io.File) Test(org.junit.Test)

Example 12 with ScannerReportWriter

use of org.sonar.scanner.protocol.output.ScannerReportWriter in project sonarqube by SonarSource.

the class SourcePublisherTest method prepare.

@Before
public void prepare() throws IOException {
    File baseDir = temp.newFolder();
    sourceFile = new File(baseDir, "src/Foo.php");
    String moduleKey = "foo";
    inputFile = new TestInputFileBuilder(moduleKey, "src/Foo.php").setLines(5).setModuleBaseDir(baseDir.toPath()).setCharset(StandardCharsets.ISO_8859_1).build();
    InputComponentStore componentStore = new InputComponentStore(new PathResolver());
    componentStore.put(TestInputFileBuilder.newDefaultInputModule(moduleKey, baseDir));
    componentStore.put(inputFile);
    publisher = new SourcePublisher(componentStore);
    File outputDir = temp.newFolder();
    writer = new ScannerReportWriter(outputDir);
}
Also used : TestInputFileBuilder(org.sonar.api.batch.fs.internal.TestInputFileBuilder) InputComponentStore(org.sonar.scanner.scan.filesystem.InputComponentStore) PathResolver(org.sonar.api.scan.filesystem.PathResolver) ScannerReportWriter(org.sonar.scanner.protocol.output.ScannerReportWriter) DefaultInputFile(org.sonar.api.batch.fs.internal.DefaultInputFile) File(java.io.File) Before(org.junit.Before)

Example 13 with ScannerReportWriter

use of org.sonar.scanner.protocol.output.ScannerReportWriter in project sonarqube by SonarSource.

the class AnalysisContextReportPublisherTest method dumpServerSideGlobalProps.

@Test
public void dumpServerSideGlobalProps() throws Exception {
    logTester.setLevel(LoggerLevel.DEBUG);
    ScannerReportWriter writer = new ScannerReportWriter(temp.newFolder());
    when(globalSettings.getServerSideSettings()).thenReturn(ImmutableMap.of(COM_FOO, "bar", SONAR_SKIP, "true"));
    publisher.init(writer);
    String content = FileUtils.readFileToString(writer.getFileStructure().analysisLog());
    assertThat(content).containsOnlyOnce(COM_FOO);
    assertThat(content).containsOnlyOnce(SONAR_SKIP);
}
Also used : ScannerReportWriter(org.sonar.scanner.protocol.output.ScannerReportWriter) Test(org.junit.Test)

Example 14 with ScannerReportWriter

use of org.sonar.scanner.protocol.output.ScannerReportWriter in project sonarqube by SonarSource.

the class AnalysisContextReportPublisherTest method shouldNotDumpSQPropsInSystemProps.

@Test
public void shouldNotDumpSQPropsInSystemProps() throws Exception {
    logTester.setLevel(LoggerLevel.DEBUG);
    ScannerReportWriter writer = new ScannerReportWriter(temp.newFolder());
    Properties props = new Properties();
    props.setProperty(COM_FOO, "bar");
    props.setProperty(SONAR_SKIP, "true");
    when(system2.properties()).thenReturn(props);
    publisher.init(writer);
    String content = FileUtils.readFileToString(writer.getFileStructure().analysisLog());
    assertThat(content).containsOnlyOnce(COM_FOO);
    assertThat(content).doesNotContain(SONAR_SKIP);
    publisher.dumpModuleSettings(ProjectDefinition.create().setProperty("sonar.projectKey", "foo").setProperty(COM_FOO, "bar").setProperty(SONAR_SKIP, "true"));
    content = FileUtils.readFileToString(writer.getFileStructure().analysisLog());
    assertThat(content).containsOnlyOnce(COM_FOO);
    assertThat(content).containsOnlyOnce(SONAR_SKIP);
}
Also used : ScannerReportWriter(org.sonar.scanner.protocol.output.ScannerReportWriter) Properties(java.util.Properties) Test(org.junit.Test)

Example 15 with ScannerReportWriter

use of org.sonar.scanner.protocol.output.ScannerReportWriter in project sonarqube by SonarSource.

the class BatchReportReaderImplTest method setUp.

@Before
public void setUp() {
    BatchReportDirectoryHolder holder = new ImmutableBatchReportDirectoryHolder(tempFolder.newDir());
    underTest = new BatchReportReaderImpl(holder);
    writer = new ScannerReportWriter(holder.getDirectory());
}
Also used : ScannerReportWriter(org.sonar.scanner.protocol.output.ScannerReportWriter) Before(org.junit.Before)

Aggregations

ScannerReportWriter (org.sonar.scanner.protocol.output.ScannerReportWriter)24 Test (org.junit.Test)14 File (java.io.File)9 Before (org.junit.Before)7 ScannerReportReader (org.sonar.scanner.protocol.output.ScannerReportReader)6 DefaultInputFile (org.sonar.api.batch.fs.internal.DefaultInputFile)5 ScannerReport (org.sonar.scanner.protocol.output.ScannerReport)4 PathResolver (org.sonar.api.scan.filesystem.PathResolver)3 InputComponentStore (org.sonar.scanner.scan.filesystem.InputComponentStore)3 Matchers.anyString (org.mockito.Matchers.anyString)2 InputFile (org.sonar.api.batch.fs.InputFile)2 TextRange (org.sonar.api.batch.fs.TextRange)2 TestInputFileBuilder (org.sonar.api.batch.fs.internal.TestInputFileBuilder)2 MapSettings (org.sonar.api.config.MapSettings)2 ReportPublisher (org.sonar.scanner.report.ReportPublisher)2 MeasureCache (org.sonar.scanner.scan.measure.MeasureCache)2 Date (java.util.Date)1 HashMap (java.util.HashMap)1 Properties (java.util.Properties)1 ProjectDefinition (org.sonar.api.batch.bootstrap.ProjectDefinition)1