Search in sources :

Example 36 with Encryption

use of org.sonar.api.config.internal.Encryption 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>", StandardCharsets.UTF_8);
    SensorContextTester context = SensorContextTester.create(basedir);
    Map<String, String> settings = new HashMap<>();
    settings.put(GenericTestExecutionSensor.OLD_UNIT_TEST_REPORT_PATHS_PROPERTY_KEY, "report.xml");
    PropertyDefinitions defs = new PropertyDefinitions(System2.INSTANCE, GenericTestExecutionSensor.properties());
    DefaultConfiguration config = new ProjectConfiguration(defs, new Encryption(null), settings);
    new GenericTestExecutionSensor(mock(TestPlanBuilder.class), config).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");
}
Also used : SensorContextTester(org.sonar.api.batch.sensor.internal.SensorContextTester) PropertyDefinitions(org.sonar.api.config.PropertyDefinitions) HashMap(java.util.HashMap) DefaultConfiguration(org.sonar.scanner.config.DefaultConfiguration) Encryption(org.sonar.api.config.internal.Encryption) File(java.io.File) ProjectConfiguration(org.sonar.scanner.scan.ProjectConfiguration) Test(org.junit.Test)

Aggregations

Encryption (org.sonar.api.config.internal.Encryption)36 Test (org.junit.Test)35 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)30 Rule (org.junit.Rule)30 Mockito.mock (org.mockito.Mockito.mock)30 DbTester (org.sonar.db.DbTester)30 Assertions.assertThatThrownBy (org.assertj.core.api.Assertions.assertThatThrownBy)26 AlmSettingDto (org.sonar.db.alm.setting.AlmSettingDto)26 UserDto (org.sonar.db.user.UserDto)26 UserSessionRule (org.sonar.server.tester.UserSessionRule)26 WsActionTester (org.sonar.server.ws.WsActionTester)26 Tuple.tuple (org.assertj.core.groups.Tuple.tuple)25 WebService (org.sonar.api.server.ws.WebService)25 MultipleAlmFeatureProvider (org.sonar.server.almsettings.MultipleAlmFeatureProvider)25 ComponentFinder (org.sonar.server.component.ComponentFinder)25 ForbiddenException (org.sonar.server.exceptions.ForbiddenException)25 Mockito.when (org.mockito.Mockito.when)20 NotFoundException (org.sonar.server.exceptions.NotFoundException)20 String.format (java.lang.String.format)17 TestRequest (org.sonar.server.ws.TestRequest)17