use of org.sonar.api.config.Settings in project sonarqube by SonarSource.
the class FileExclusionsTest method load_inclusions.
@Test
public void load_inclusions() {
Settings settings = new MapSettings();
settings.setProperty(CoreProperties.PROJECT_INCLUSIONS_PROPERTY, "**/*Foo.java");
settings.setProperty(CoreProperties.PROJECT_TEST_INCLUSIONS_PROPERTY, "**/*FooTest.java");
FileExclusions moduleExclusions = new FileExclusions(settings);
assertThat(moduleExclusions.sourceInclusions()).containsOnly("**/*Foo.java");
assertThat(moduleExclusions.testInclusions()).containsOnly("**/*FooTest.java");
}
use of org.sonar.api.config.Settings in project sonarqube by SonarSource.
the class ProjectScanContainer method doBeforeStart.
@Override
protected void doBeforeStart() {
addBatchComponents();
ProjectLock lock = getComponentByType(ProjectLock.class);
lock.tryLock();
getComponentByType(WorkDirectoryCleaner.class).execute();
addBatchExtensions();
Settings settings = getComponentByType(Settings.class);
if (settings != null && settings.getBoolean(CoreProperties.PROFILING_LOG_PROPERTY)) {
add(PhasesSumUpTimeProfiler.class);
}
if (isTherePreviousAnalysis()) {
addIssueTrackingComponents();
}
}
use of org.sonar.api.config.Settings in project sonarqube by SonarSource.
the class ProjectAnalysisInfoTest method testSimpleDate.
@Test
public void testSimpleDate() {
Settings settings = new MapSettings();
settings.appendProperty(CoreProperties.PROJECT_DATE_PROPERTY, "2017-01-01");
settings.appendProperty(CoreProperties.PROJECT_VERSION_PROPERTY, "version");
System2 system = mock(System2.class);
ProjectAnalysisInfo info = new ProjectAnalysisInfo(settings, system);
info.start();
LocalDate date = LocalDate.of(2017, 1, 1);
assertThat(info.analysisDate()).isEqualTo(Date.from(date.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant()));
assertThat(info.analysisVersion()).isEqualTo("version");
}
use of org.sonar.api.config.Settings in project sonarqube by SonarSource.
the class GenericCoverageSensorTest method migrateOldProperties.
@Test
public void migrateOldProperties() {
Settings settings = new MapSettings(new PropertyDefinitions(GenericCoverageSensor.properties()));
settings.setProperty(GenericCoverageSensor.OLD_REPORT_PATH_PROPERTY_KEY, "old.xml");
settings.setProperty(GenericCoverageSensor.OLD_COVERAGE_REPORT_PATHS_PROPERTY_KEY, "old1.xml,old2.xml");
settings.setProperty(GenericCoverageSensor.OLD_IT_COVERAGE_REPORT_PATHS_PROPERTY_KEY, "old3.xml,old4.xml,old.xml");
settings.setProperty(GenericCoverageSensor.OLD_OVERALL_COVERAGE_REPORT_PATHS_PROPERTY_KEY, "old5.xml,old6.xml");
new GenericCoverageSensor(settings).execute();
assertThat(logTester.logs(LoggerLevel.WARN)).contains("Property 'sonar.genericcoverage.reportPath' is deprecated. Please use 'sonar.coverageReportPaths' instead.", "Property 'sonar.genericcoverage.reportPaths' is deprecated. Please use 'sonar.coverageReportPaths' instead.", "Property 'sonar.genericcoverage.itReportPaths' is deprecated. Please use 'sonar.coverageReportPaths' instead.", "Property 'sonar.genericcoverage.overallReportPaths' is deprecated. Please use 'sonar.coverageReportPaths' instead.");
assertThat(settings.getStringArray(GenericCoverageSensor.REPORT_PATHS_PROPERTY_KEY)).containsOnly("old.xml", "old1.xml", "old2.xml", "old3.xml", "old4.xml", "old5.xml", "old6.xml");
}
use of org.sonar.api.config.Settings in project sonarqube by SonarSource.
the class GenericTestExecutionSensorTest method logWhenDeprecatedPropsAreUsed.
@Test
public void logWhenDeprecatedPropsAreUsed() throws IOException {
File basedir = temp.newFolder();
File report = new File(basedir, "report.xml");
FileUtils.write(report, "<unitTest version=\"1\"><file path=\"A.java\"><testCase name=\"test1\" duration=\"500\"/></file></unitTest>");
SensorContextTester context = SensorContextTester.create(basedir);
Settings settings = new MapSettings(new PropertyDefinitions(GenericTestExecutionSensor.properties()));
settings.setProperty(GenericTestExecutionSensor.OLD_UNIT_TEST_REPORT_PATHS_PROPERTY_KEY, "report.xml");
context.setSettings(settings);
new GenericTestExecutionSensor(mock(TestPlanBuilder.class)).execute(context);
assertThat(logTester.logs(LoggerLevel.WARN)).contains("Using 'unitTest' as root element of the report is deprecated. Please change to 'testExecutions'.", "Property 'sonar.genericcoverage.unitTestReportPaths' is deprecated. Please use 'sonar.testExecutionReportPaths' instead.");
assertThat(logTester.logs(LoggerLevel.INFO)).contains("Imported test execution data for 0 files", "Test execution data ignored for 1 unknown files, including:\nA.java");
}
Aggregations