use of org.sonar.api.config.internal.MapSettings in project sonar-java by SonarSource.
the class SurefireUtilsTest method should_only_use_new_property_if_both_set.
@Test
public void should_only_use_new_property_if_both_set() {
MapSettings settings = new MapSettings();
settings.setProperty("sonar.junit.reportsPath", "../shouldGetReportsPathFromDeprecatedProperty/target/surefire");
settings.setProperty("sonar.junit.reportPaths", "target/surefire,submodule/target/surefire");
DefaultFileSystem fs = new DefaultFileSystem(new File("src/test/resources/org/sonar/plugins/surefire/api/SurefireUtilsTest/shouldGetReportsPathFromProperty"));
PathResolver pathResolver = new PathResolver();
assertThat(logTester.logs(LoggerLevel.INFO)).isEmpty();
List<File> directories = SurefireUtils.getReportsDirectories(settings.asConfig(), fs, pathResolver);
assertThat(directories).hasSize(2);
File directory1 = directories.get(0);
assertThat(directory1.exists()).isTrue();
assertThat(directory1.isDirectory()).isTrue();
File directory2 = directories.get(1);
assertThat(directory2.exists()).isTrue();
assertThat(directory2.isDirectory()).isTrue();
assertThat(logTester.logs(LoggerLevel.DEBUG)).contains("Property 'sonar.junit.reportsPath' is deprecated and will be ignored, as property 'sonar.junit.reportPaths' is also set.");
assertThat(logTester.logs(LoggerLevel.INFO)).doesNotContain("Property 'sonar.junit.reportsPath' is deprecated. Use property 'sonar.junit.reportPaths' instead.");
}
use of org.sonar.api.config.internal.MapSettings in project sonar-java by SonarSource.
the class JaCoCoSensorTest method should_log_when_class_are_not_matching_with_report.
@Test
public void should_log_when_class_are_not_matching_with_report() throws Exception {
String testDir = "/org/sonar/plugins/jacoco/JaCoCoNoMatch/";
outputDir = TestUtils.getResource(testDir);
jacocoExecutionData = new File(outputDir, "jacoco.exec");
Files.copy(TestUtils.getResource(testDir + "org/foo/bar/Example2.class.toCopy"), new File(outputDir, "org/foo/bar/Example2.class"));
Files.copy(TestUtils.getResource(testDir + "Example.class.toCopy"), new File(outputDir, "Example.class"));
DefaultInputFile resource = new TestInputFileBuilder("", "").setLines(10).build();
when(javaResourceLocator.findResourceByClassName(anyString())).thenReturn(resource);
when(javaClasspath.getBinaryDirs()).thenReturn(ImmutableList.of(outputDir));
SensorContextTester context = SensorContextTester.create(outputDir);
context.setRuntime(SonarRuntimeImpl.forSonarQube(SQ_6_7, SonarQubeSide.SCANNER));
context.fileSystem().setWorkDir(temp.newFolder().toPath());
context.setSettings(new MapSettings().setProperty(REPORT_PATHS_PROPERTY, jacocoExecutionData.getAbsolutePath()));
sensor.execute(context);
List<String> warnLogs = logTester.logs(LoggerLevel.WARN);
assertThat(warnLogs).contains("The following class(es) did not match with execution data:", "> 'org/foo/bar/Example2'", "> 'Example'", "In order to have accurate coverage measures, the same class files must be used as at runtime for report generation.");
}
use of org.sonar.api.config.internal.MapSettings in project sonar-go by SonarSource.
the class GoCoverageReportTest method get_report_paths.
@Test
public void get_report_paths() {
SensorContextTester context = SensorContextTester.create(COVERAGE_DIR);
context.setSettings(new MapSettings());
Path coverageFile1 = COVERAGE_DIR.resolve("coverage.linux.relative.out").toAbsolutePath();
context.settings().setProperty("sonar.go.coverage.reportPaths", coverageFile1 + ",coverage.linux.absolute.out");
List<Path> reportPaths = GoCoverageReport.getReportPaths(context);
assertThat(reportPaths).containsExactlyInAnyOrder(coverageFile1, Paths.get("src", "test", "resources", "coverage", "coverage.linux.absolute.out"));
}
use of org.sonar.api.config.internal.MapSettings in project sonar-go by SonarSource.
the class GoLanguageTest method should_have_correct_file_extensions.
@Test
void should_have_correct_file_extensions() {
MapSettings mapSettings = new MapSettings();
GoLanguage typeScriptLanguage = new GoLanguage(mapSettings.asConfig());
assertThat(typeScriptLanguage.getFileSuffixes()).containsExactly(".go");
}
use of org.sonar.api.config.internal.MapSettings in project sonar-go by SonarSource.
the class GoLanguageTest method can_override_file_extensions.
@Test
void can_override_file_extensions() {
MapSettings mapSettings = new MapSettings();
mapSettings.setProperty("sonar.go.file.suffixes", ".go1,.go2");
GoLanguage typeScriptLanguage = new GoLanguage(mapSettings.asConfig());
assertThat(typeScriptLanguage.getFileSuffixes()).containsExactly(".go1", ".go2");
}
Aggregations