]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-19015 Use new log test fixtures in the sonar-plugin-api
authorJeremy Davis <jeremy.davis@sonarsource.com>
Tue, 4 Apr 2023 08:20:33 +0000 (10:20 +0200)
committersonartech <sonartech@sonarsource.com>
Tue, 11 Apr 2023 20:03:15 +0000 (20:03 +0000)
189 files changed:
build.gradle
gradle.properties
plugins/sonar-xoo-plugin/build.gradle
plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/extensions/XooPostJobTest.java
server/sonar-alm-client/build.gradle
server/sonar-alm-client/src/test/java/org/sonar/alm/client/azure/AzureDevOpsHttpClientTest.java
server/sonar-alm-client/src/test/java/org/sonar/alm/client/bitbucket/bitbucketcloud/BitbucketCloudRestClientTest.java
server/sonar-alm-client/src/test/java/org/sonar/alm/client/bitbucketserver/BitbucketServerRestClientTest.java
server/sonar-alm-client/src/test/java/org/sonar/alm/client/github/GithubApplicationClientImplTest.java
server/sonar-alm-client/src/test/java/org/sonar/alm/client/github/GithubApplicationHttpClientImplTest.java
server/sonar-alm-client/src/test/java/org/sonar/alm/client/gitlab/GitlabHttpClientTest.java
server/sonar-auth-saml/build.gradle
server/sonar-auth-saml/src/it/java/org/sonar/auth/saml/SamlIdentityProviderIT.java
server/sonar-ce-task-projectanalysis/build.gradle
server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectanalysis/filemove/FileMoveDetectionStepIT.java
server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectanalysis/filemove/PullRequestFileMoveDetectionStepIT.java
server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectanalysis/issue/ScmAccountToUserLoaderIT.java
server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectanalysis/scm/ScmInfoDbLoaderIT.java
server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectanalysis/step/ExtractReportStepIT.java
server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectanalysis/step/LoadPeriodsStepIT.java
server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/analysis/ExportAnalysesStepIT.java
server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/branches/ExportBranchesStepIT.java
server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/component/ExportComponentsStepIT.java
server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/file/ExportLineHashesStepIT.java
server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/issue/ExportIssuesChangelogStepIT.java
server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/issue/ExportIssuesStepIT.java
server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/rule/ExportAdHocRulesStepIT.java
server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/ExportEventsStepIT.java
server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/ExportLinksStepIT.java
server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/ExportLiveMeasuresStepIT.java
server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/ExportMeasuresStepIT.java
server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/ExportMetricsStepIT.java
server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/ExportNewCodePeriodsStepIT.java
server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/ExportSettingsStepIT.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/api/posttask/PostProjectAnalysisTasksExecutorTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/duplication/CrossProjectDuplicationStatusHolderImplTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/duplication/IntegrateCrossProjectDuplicationsTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/IssueAssignerTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/metric/ReportMetricValidatorImplTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/scm/ScmInfoRepositoryImplTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/source/linereader/HighlightingLineReaderTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/source/linereader/SymbolsLineReaderTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ExecuteVisitorsStepTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectexport/rule/ExportRuleStepTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectexport/steps/DumpWriterImplTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectexport/steps/ExportPluginsStepTest.java
server/sonar-ce-task/build.gradle
server/sonar-ce-task/src/test/java/org/sonar/ce/task/step/ComputationStepExecutorTest.java
server/sonar-ce/build.gradle
server/sonar-ce/src/it/java/org/sonar/ce/queue/NextPendingTaskPickerIT.java
server/sonar-ce/src/it/java/org/sonar/ce/taskprocessor/CeWorkerImplIT.java
server/sonar-ce/src/test/java/org/sonar/ce/configuration/CeWorkerCountSettingWarningTest.java
server/sonar-ce/src/test/java/org/sonar/ce/taskprocessor/CeWorkerControllerImplTest.java
server/sonar-ce/src/test/java/org/sonar/ce/taskprocessor/TimeoutCeTaskInterrupterTest.java
server/sonar-db-core/build.gradle
server/sonar-db-core/src/it/java/org/sonar/db/DatabaseUtilsIT.java
server/sonar-db-core/src/test/java/org/sonar/db/DefaultDatabaseTest.java
server/sonar-db-core/src/test/java/org/sonar/db/dialect/H2Test.java
server/sonar-db-core/src/test/java/org/sonar/db/dialect/PostgreSqlTest.java
server/sonar-db-core/src/test/java/org/sonar/db/profiling/ProfiledDataSourceTest.java
server/sonar-db-dao/build.gradle
server/sonar-db-dao/src/test/java/org/sonar/db/DBSessionsImplTest.java
server/sonar-db-migration/build.gradle
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/step/MigrationStepsExecutorImplTest.java
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v100/LogMessageIfSonarScimEnabledPresentPropertyTest.java
server/sonar-server-common/build.gradle
server/sonar-server-common/src/it/java/org/sonar/server/es/BulkIndexerIT.java
server/sonar-server-common/src/it/java/org/sonar/server/issue/index/IssueIndexerIT.java
server/sonar-server-common/src/it/java/org/sonar/server/rule/index/RuleIndexerIT.java
server/sonar-server-common/src/it/java/org/sonar/server/webhook/SynchronousWebHooksImplIT.java
server/sonar-server-common/src/test/java/org/sonar/server/async/AsyncExecutionImplTest.java
server/sonar-server-common/src/test/java/org/sonar/server/es/EsClientProviderTest.java
server/sonar-server-common/src/test/java/org/sonar/server/log/ServerLoggingTest.java
server/sonar-server-common/src/test/java/org/sonar/server/platform/ServerFileSystemImplTest.java
server/sonar-server-common/src/test/java/org/sonar/server/plugins/PluginRequirementsValidatorTest.java
server/sonar-webserver-api/build.gradle
server/sonar-webserver-api/src/test/java/org/sonar/server/plugins/PluginConsentVerifierTest.java
server/sonar-webserver-api/src/test/java/org/sonar/server/plugins/PluginJarLoaderTest.java
server/sonar-webserver-api/src/test/java/org/sonar/server/plugins/PluginUninstallerTest.java
server/sonar-webserver-api/src/test/java/org/sonar/server/plugins/ServerPluginManagerTest.java
server/sonar-webserver-api/src/test/java/org/sonar/server/qualitygate/changeevent/QGChangeEventListenersImplTest.java
server/sonar-webserver-auth/build.gradle
server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/DefaultAdminCredentialsVerifierImplTest.java
server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/GithubWebhookAuthenticationTest.java
server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/InitFilterTest.java
server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/LogOAuthWarningTest.java
server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/OAuth2CallbackFilterTest.java
server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/UserRegistrarImplTest.java
server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/event/AuthenticationEventImplTest.java
server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/purge/ExpiredSessionsCleanerTest.java
server/sonar-webserver-auth/src/test/java/org/sonar/server/user/SystemPasscodeImplTest.java
server/sonar-webserver-auth/src/test/java/org/sonar/server/usertoken/notification/TokenExpirationNotificationSchedulerImplTest.java
server/sonar-webserver-auth/src/test/java/org/sonar/server/usertoken/notification/TokenExpirationNotificationSenderTest.java
server/sonar-webserver-core/build.gradle
server/sonar-webserver-core/src/test/java/org/sonar/server/issue/index/AsyncIssueIndexingImplTest.java
server/sonar-webserver-core/src/test/java/org/sonar/server/platform/DatabaseServerCompatibilityTest.java
server/sonar-webserver-core/src/test/java/org/sonar/server/platform/db/CheckAnyonePermissionsAtStartupTest.java
server/sonar-webserver-core/src/test/java/org/sonar/server/platform/db/CheckLanguageSpecificParamsAtStartupTest.java
server/sonar-webserver-core/src/test/java/org/sonar/server/platform/db/EmbeddedDatabaseTest.java
server/sonar-webserver-core/src/test/java/org/sonar/server/platform/db/migration/AutoDbMigrationTest.java
server/sonar-webserver-core/src/test/java/org/sonar/server/platform/web/RootFilterTest.java
server/sonar-webserver-core/src/test/java/org/sonar/server/qualitygate/ProjectsInWarningDaemonTest.java
server/sonar-webserver-core/src/test/java/org/sonar/server/rule/RegisterRulesTest.java
server/sonar-webserver-core/src/test/java/org/sonar/server/startup/LogServerIdTest.java
server/sonar-webserver-core/src/test/java/org/sonar/server/startup/RegisterPermissionTemplatesTest.java
server/sonar-webserver-core/src/test/java/org/sonar/server/telemetry/TelemetryDaemonTest.java
server/sonar-webserver-es/build.gradle
server/sonar-webserver-es/src/test/java/org/sonar/server/es/IndexCreatorTest.java
server/sonar-webserver-es/src/test/java/org/sonar/server/es/RecoveryIndexerTest.java
server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueQueryFactoryTest.java
server/sonar-webserver-monitoring/build.gradle
server/sonar-webserver-monitoring/src/test/java/org/sonar/server/monitoring/ElasticSearchMetricTaskTest.java
server/sonar-webserver-webapi/build.gradle
server/sonar-webserver-webapi/src/it/java/org/sonar/server/projectanalysis/ws/SearchActionIT.java
server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualitygate/RegisterQualityGatesIT.java
server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/RegisterQualityProfilesIT.java
server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/RegisterQualityProfilesNotificationIT.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/RestartActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/ui/PageRepositoryTest.java
server/sonar-webserver-ws/build.gradle
server/sonar-webserver-ws/src/test/java/org/sonar/server/ws/WebServiceEngineTest.java
server/sonar-webserver-ws/src/test/java/org/sonar/server/ws/WsUtilsTest.java
server/sonar-webserver/build.gradle
server/sonar-webserver/src/test/java/org/sonar/server/platform/web/MasterServletFilterTest.java
server/sonar-webserver/src/test/java/org/sonar/server/platform/web/StaticResourcesServletTest.java
sonar-core/build.gradle
sonar-core/src/test/java/org/sonar/core/platform/PluginClassLoaderTest.java
sonar-core/src/test/java/org/sonar/core/util/ProgressLoggerTest.java
sonar-core/src/test/java/org/sonar/core/util/logs/DefaultProfilerTest.java
sonar-core/src/test/java/org/sonar/core/util/logs/ProfilerTest.java
sonar-plugin-api-impl/build.gradle
sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/fs/internal/DefaultInputFile.java
sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/fs/internal/fs/FileMetadataTest.java
sonar-plugin-api-impl/src/test/java/org/sonar/api/impl/utils/DefaultTempFolderTest.java
sonar-scanner-engine/build.gradle
sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/ScannerMediumTester.java
sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/branch/BranchMediumIT.java
sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/coverage/CoverageMediumIT.java
sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/coverage/GenericCoverageMediumIT.java
sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/cpd/CpdMediumIT.java
sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/fs/FileSystemMediumIT.java
sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/issues/ExternalIssuesMediumIT.java
sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/issues/IssuesMediumIT.java
sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/issues/PreviewMediumIT.java
sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/measures/MeasuresMediumIT.java
sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/scm/ScmMediumIT.java
sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/tasks/TasksMediumIT.java
sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/tests/GenericTestExecutionMediumIT.java
sonar-scanner-engine/src/it/java/org/sonar/scm/svn/SvnBlameCommandIT.java
sonar-scanner-engine/src/main/java/org/sonar/batch/bootstrapper/Batch.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/DefaultScannerWsClientTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/GlobalConfigurationProviderTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/cache/DefaultAnalysisCacheLoaderTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/ci/vendors/CirrusCiTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/ci/vendors/CodeMagicTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/ci/vendors/GithubActionsTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/config/DefaultConfigurationTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/cpd/CpdExecutorTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/externalissue/ExternalIssueImporterTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/externalissue/sarif/DefaultSarif210ImporterTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/externalissue/sarif/RulesSeverityDetectorTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/externalissue/sarif/RunMapperTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/externalissue/sarif/SarifIssuesImportSensorTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/genericcoverage/GenericCoverageReportParserTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/genericcoverage/GenericCoverageSensorTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/genericcoverage/GenericTestExecutionReportParserTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/genericcoverage/GenericTestExecutionSensorTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/issue/ignore/IgnoreIssuesFilterTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/phases/ModuleSensorsExecutorTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/qualitygate/QualityGateCheckTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/report/AnalysisContextReportPublisherTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/report/ChangedLinesPublisherTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/report/ReportPublisherTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/repository/QualityProfileProviderTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/DeprecatedPropertiesWarningGeneratorTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ProjectReactorBuilderTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ProjectReactorValidatorTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/AbstractExclusionFiltersTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/MetadataGeneratorTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/scm/ScmConfigurationTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/sensor/UnchangedFilesHandlerTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/util/ProgressReportTest.java
sonar-scanner-engine/src/test/java/org/sonar/scm/git/CompositeBlameCommandTest.java
sonar-scanner-engine/src/test/java/org/sonar/scm/git/GitIgnoreCommandTest.java
sonar-scanner-engine/src/test/java/org/sonar/scm/git/GitScmProviderTest.java
sonar-scanner-engine/src/test/java/org/sonar/scm/git/JGitBlameCommandTest.java
sonar-scanner-engine/src/test/java/org/sonar/scm/git/NativeGitBlameCommandTest.java
sonar-scanner-engine/src/test/java/org/sonar/scm/git/ProcessWrapperFactoryTest.java
sonar-scanner-engine/src/test/java/org/sonar/scm/git/strategy/DefaultBlameStrategyTest.java

index ab480a924a5f64cda60e111e1f1b1567b0a2ee35..c54ad59cc36fecac8e7a83b22234d2acc108c85a 100644 (file)
@@ -216,6 +216,7 @@ subprojects {
       dependency 'org.sonarsource.slang:sonar-ruby-plugin:1.12.0.4259'
       dependency 'org.sonarsource.slang:sonar-scala-plugin:1.12.0.4259'
       dependency "org.sonarsource.api.plugin:sonar-plugin-api:$pluginApiVersion"
+      dependency "org.sonarsource.api.plugin:sonar-plugin-api-test-fixtures:$pluginApiVersion"
       dependency 'org.sonarsource.xml:sonar-xml-plugin:2.7.0.3820'
       dependency 'org.sonarsource.iac:sonar-iac-plugin:1.15.0.3752'
       dependency 'org.sonarsource.text:sonar-text-plugin:2.0.2.1090'
index 2412f69fe952e21db353ced60acef398746fa455..30b06f4a376892d02f92b98ce831a2ec91c610ac 100644 (file)
@@ -1,6 +1,6 @@
 group=org.sonarsource.sonarqube
 version=10.1
-pluginApiVersion=9.14.0.375
+pluginApiVersion=9.15.0.435
 description=Open source platform for continuous inspection of code quality
 projectTitle=SonarQube
 org.gradle.jvmargs=-Xmx2048m
index 07d6ff5f45ff2150e7c741fb40b0fe93f05d9a86..a152bff4d295419db80895afa0177d7f301e9fef 100644 (file)
@@ -11,6 +11,7 @@ dependencies {
   testImplementation 'junit:junit'
   testImplementation 'org.assertj:assertj-core'
   testImplementation 'org.mockito:mockito-core'
+  testImplementation 'org.sonarsource.api.plugin:sonar-plugin-api-test-fixtures'
   testImplementation project(':sonar-plugin-api-impl')
 }
 
index f113ed7b5f9e54b87d3d6dd105c6e72e7d3e8cfb..39b8f051c4817a5d3cdca7ce4828f3fea32f1d2e 100644 (file)
@@ -23,7 +23,7 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.sonar.api.batch.postjob.PostJobContext;
 import org.sonar.api.batch.postjob.internal.DefaultPostJobDescriptor;
-import org.sonar.api.utils.log.LogTester;
+import org.sonar.api.testfixtures.log.LogTester;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.mockito.Mockito.mock;
index 7d35c2e4533a09507dc5049b35e62c1b6a707117..a15661a6cbae12083d3ceef86c7deda077ec72b0 100644 (file)
@@ -19,6 +19,7 @@ dependencies {
     testImplementation 'org.assertj:assertj-core'
     testImplementation 'org.assertj:assertj-guava'
     testImplementation 'org.mockito:mockito-core'
+    testImplementation 'org.sonarsource.api.plugin:sonar-plugin-api-test-fixtures'
     testImplementation 'com.squareup.okhttp3:mockwebserver'
 
 }
index 059fc103ade2a16dfb6883b7a29815bb8bab25d8..fdf44a85971b04be9f470408f59d66a7e4900d8d 100644 (file)
@@ -29,10 +29,10 @@ import org.junit.After;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
+import org.slf4j.event.Level;
 import org.sonar.alm.client.ConstantTimeoutConfiguration;
 import org.sonar.alm.client.TimeoutConfiguration;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
+import org.sonar.api.testfixtures.log.LogTester;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
@@ -49,6 +49,7 @@ public class AzureDevOpsHttpClientTest {
 
   @Before
   public void prepare() throws IOException {
+    logTester.setLevel(Level.DEBUG);
     server.start();
 
     TimeoutConfiguration timeoutConfiguration = new ConstantTimeoutConfiguration(10_000);
@@ -82,7 +83,7 @@ public class AzureDevOpsHttpClientTest {
     assertThat(request.getMethod()).isEqualTo("GET");
 
     assertThat(logTester.logs()).hasSize(1);
-    assertThat(logTester.logs(LoggerLevel.DEBUG))
+    assertThat(logTester.logs(Level.DEBUG))
       .contains("check pat : [" + server.url("").toString() + "_apis/projects?api-version=3.0]");
   }
 
@@ -135,8 +136,8 @@ public class AzureDevOpsHttpClientTest {
     assertThat(azureDevOpsUrlCall).isEqualTo(server.url("") + "_apis/projects?api-version=3.0");
     assertThat(request.getMethod()).isEqualTo("GET");
 
-    assertThat(logTester.logs(LoggerLevel.DEBUG)).hasSize(1);
-    assertThat(logTester.logs(LoggerLevel.DEBUG))
+    assertThat(logTester.logs(Level.DEBUG)).hasSize(1);
+    assertThat(logTester.logs(Level.DEBUG))
       .contains("get projects : [" + server.url("") + "_apis/projects?api-version=3.0]");
     assertThat(projects.getValues()).hasSize(2);
     assertThat(projects.getValues())
@@ -152,8 +153,8 @@ public class AzureDevOpsHttpClientTest {
       .isInstanceOf(IllegalArgumentException.class)
       .hasMessage(UNABLE_TO_CONTACT_AZURE);
 
-    assertThat(logTester.logs(LoggerLevel.ERROR)).hasSize(1);
-    assertThat(logTester.logs(LoggerLevel.ERROR).iterator().next())
+    assertThat(logTester.logs(Level.ERROR)).hasSize(1);
+    assertThat(logTester.logs(Level.ERROR).iterator().next())
       .contains("Response from Azure for request [" + server.url("") + "_apis/projects?api-version=3.0] could not be parsed:");
   }
 
@@ -165,8 +166,8 @@ public class AzureDevOpsHttpClientTest {
       .isInstanceOf(IllegalArgumentException.class)
       .hasMessage("Invalid personal access token");
 
-    assertThat(logTester.logs(LoggerLevel.ERROR)).hasSize(1);
-    assertThat(logTester.logs(LoggerLevel.ERROR).iterator().next())
+    assertThat(logTester.logs(Level.ERROR)).hasSize(1);
+    assertThat(logTester.logs(Level.ERROR).iterator().next())
       .contains("Unable to contact Azure DevOps server for request [" + server.url("") + "_apis/projects?api-version=3.0]: Invalid personal access token");
   }
 
@@ -178,8 +179,8 @@ public class AzureDevOpsHttpClientTest {
       .isInstanceOf(IllegalArgumentException.class)
       .hasMessage("Invalid Azure URL");
 
-    assertThat(logTester.logs(LoggerLevel.ERROR)).hasSize(1);
-    assertThat(logTester.logs(LoggerLevel.ERROR).iterator().next())
+    assertThat(logTester.logs(Level.ERROR)).hasSize(1);
+    assertThat(logTester.logs(Level.ERROR).iterator().next())
       .contains("Unable to contact Azure DevOps server for request [" + server.url("") + "_apis/projects?api-version=3.0]: URL Not Found");
   }
 
@@ -191,8 +192,8 @@ public class AzureDevOpsHttpClientTest {
       .isInstanceOf(IllegalArgumentException.class)
       .hasMessage("Unable to contact Azure DevOps server");
 
-    assertThat(logTester.logs(LoggerLevel.ERROR)).hasSize(1);
-    assertThat(logTester.logs(LoggerLevel.ERROR).iterator().next())
+    assertThat(logTester.logs(Level.ERROR)).hasSize(1);
+    assertThat(logTester.logs(Level.ERROR).iterator().next())
       .contains("Azure API call to [" + server.url("") + "_apis/projects?api-version=3.0] failed with 500 http code. Azure response content :");
   }
 
@@ -226,8 +227,8 @@ public class AzureDevOpsHttpClientTest {
     assertThat(azureDevOpsUrlCall).isEqualTo(server.url("") + "projectName/_apis/git/repositories?api-version=3.0");
     assertThat(request.getMethod()).isEqualTo("GET");
 
-    assertThat(logTester.logs(LoggerLevel.DEBUG)).hasSize(1);
-    assertThat(logTester.logs(LoggerLevel.DEBUG))
+    assertThat(logTester.logs(Level.DEBUG)).hasSize(1);
+    assertThat(logTester.logs(Level.DEBUG))
       .contains("get repos : [" + server.url("").toString() + "projectName/_apis/git/repositories?api-version=3.0]");
     assertThat(repos.getValues()).hasSize(1);
     assertThat(repos.getValues())
@@ -279,8 +280,8 @@ public class AzureDevOpsHttpClientTest {
     assertThat(azureDevOpsUrlCall).isEqualTo(server.url("") + "Project-Name/_apis/git/repositories/Repo-Name-1?api-version=3.0");
     assertThat(request.getMethod()).isEqualTo("GET");
 
-    assertThat(logTester.logs(LoggerLevel.DEBUG)).hasSize(1);
-    assertThat(logTester.logs(LoggerLevel.DEBUG))
+    assertThat(logTester.logs(Level.DEBUG)).hasSize(1);
+    assertThat(logTester.logs(Level.DEBUG))
       .contains("get repo : [" + server.url("").toString() + "Project-Name/_apis/git/repositories/Repo-Name-1?api-version=3.0]");
     assertThat(repo.getId()).isEqualTo("Repo-Id-1");
     assertThat(repo.getName()).isEqualTo("Repo-Name-1");
index ecd6d763105f070f2aaacfca47c033f63d065232..b164a94d9570b852d0dae3b6bee0a3111c3e87d1 100644 (file)
@@ -36,8 +36,8 @@ import org.junit.After;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
+import org.slf4j.event.Level;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonarqube.ws.client.OkHttpClientBuilder;
 
 import static org.assertj.core.api.Assertions.assertThat;
@@ -182,7 +182,7 @@ public class BitbucketCloudRestClientTest {
     assertThatIllegalArgumentException()
       .isThrownBy(() -> underTest.validate("clientId", "clientSecret", "workspace"))
       .withMessage(UNABLE_TO_CONTACT_BBC_SERVERS);
-    assertThat(logTester.logs(LoggerLevel.INFO)).containsExactly(String.format(BBC_FAIL_WITH_RESPONSE, serverURL, "401", "Unauthorized"));
+    assertThat(logTester.logs(Level.INFO)).containsExactly(String.format(BBC_FAIL_WITH_RESPONSE, serverURL, "401", "Unauthorized"));
   }
 
   @Test
@@ -218,7 +218,7 @@ public class BitbucketCloudRestClientTest {
     assertThatExceptionOfType(IllegalArgumentException.class)
       .isThrownBy(() -> underTest.validate("clientId", "clientSecret", "workspace"))
       .withMessage(ERROR_BBC_SERVERS + ": " + MISSING_PULL_REQUEST_READ_PERMISSION);
-    assertThat(logTester.logs(LoggerLevel.INFO)).containsExactly(MISSING_PULL_REQUEST_READ_PERMISSION + String.format(SCOPE, ""));
+    assertThat(logTester.logs(Level.INFO)).containsExactly(MISSING_PULL_REQUEST_READ_PERMISSION + String.format(SCOPE, ""));
   }
 
   @Test
@@ -233,7 +233,7 @@ public class BitbucketCloudRestClientTest {
     assertThatExceptionOfType(IllegalArgumentException.class)
       .isThrownBy(() -> underTest.validate("clientId", "clientSecret", "workspace"))
       .withMessage("Error returned by Bitbucket Cloud: No workspace with identifier 'workspace'.");
-    assertThat(logTester.logs(LoggerLevel.INFO)).containsExactly(String.format(BBC_FAIL_WITH_RESPONSE, serverURL + "2.0/repositories/workspace", "404", response));
+    assertThat(logTester.logs(Level.INFO)).containsExactly(String.format(BBC_FAIL_WITH_RESPONSE, serverURL + "2.0/repositories/workspace", "404", response));
   }
 
   @Test
@@ -246,7 +246,7 @@ public class BitbucketCloudRestClientTest {
     assertThatExceptionOfType(IllegalArgumentException.class)
       .isThrownBy(() -> underTest.validate("clientId", "clientSecret", "workspace"))
       .withMessage(UNABLE_TO_CONTACT_BBC_SERVERS + ": " + OAUTH_CONSUMER_NOT_PRIVATE);
-    assertThat(logTester.logs(LoggerLevel.INFO)).containsExactly(String.format(BBC_FAIL_WITH_RESPONSE, serverURL, "400", "invalid_grant"));
+    assertThat(logTester.logs(Level.INFO)).containsExactly(String.format(BBC_FAIL_WITH_RESPONSE, serverURL, "400", "invalid_grant"));
   }
 
   @Test
@@ -258,7 +258,7 @@ public class BitbucketCloudRestClientTest {
     assertThatExceptionOfType(IllegalArgumentException.class)
       .isThrownBy(() -> underTest.validate("clientId", "clientSecret", "workspace"))
       .withMessage(UNABLE_TO_CONTACT_BBC_SERVERS + ": " + UNAUTHORIZED_CLIENT);
-    assertThat(logTester.logs(LoggerLevel.INFO)).containsExactly(String.format(BBC_FAIL_WITH_RESPONSE, serverURL, "400", "unauthorized_client"));
+    assertThat(logTester.logs(Level.INFO)).containsExactly(String.format(BBC_FAIL_WITH_RESPONSE, serverURL, "400", "unauthorized_client"));
   }
 
   @Test
@@ -274,7 +274,7 @@ public class BitbucketCloudRestClientTest {
     assertThatExceptionOfType(IllegalArgumentException.class)
       .isThrownBy(() -> underTest.validate("clientId", "clientSecret", "workspace"))
       .withMessage("Error returned by Bitbucket Cloud: Your credentials lack one or more required privilege scopes.");
-    assertThat(logTester.logs(LoggerLevel.INFO)).containsExactly(String.format(BBC_FAIL_WITH_RESPONSE, serverURL + "2.0/repositories/workspace", "400", error));
+    assertThat(logTester.logs(Level.INFO)).containsExactly(String.format(BBC_FAIL_WITH_RESPONSE, serverURL + "2.0/repositories/workspace", "400", error));
   }
 
   @Test
@@ -303,7 +303,7 @@ public class BitbucketCloudRestClientTest {
     assertThatExceptionOfType(IllegalArgumentException.class)
       .isThrownBy(() -> underTest.validateAppPassword("wrong:wrong", "workspace"))
       .withMessage("Error returned by Bitbucket Cloud: Invalid credentials.");
-    assertThat(logTester.logs(LoggerLevel.INFO)).containsExactly(String.format(BBC_FAIL_WITH_RESPONSE, serverURL + "2.0/repositories/workspace", "401", response));
+    assertThat(logTester.logs(Level.INFO)).containsExactly(String.format(BBC_FAIL_WITH_RESPONSE, serverURL + "2.0/repositories/workspace", "401", response));
   }
 
   @Test
@@ -326,7 +326,7 @@ public class BitbucketCloudRestClientTest {
     assertThatIllegalArgumentException()
       .isThrownBy(() -> underTest.validate("clientId", "clientSecret", "workspace"))
       .withMessage(UNABLE_TO_CONTACT_BBC_SERVERS);
-    assertThat(logTester.logs(LoggerLevel.INFO)).containsExactly(String.format(BBC_FAIL_WITH_RESPONSE, url, "500", message));
+    assertThat(logTester.logs(Level.INFO)).containsExactly(String.format(BBC_FAIL_WITH_RESPONSE, url, "500", message));
   }
 
   @Test
@@ -339,7 +339,7 @@ public class BitbucketCloudRestClientTest {
     assertThatIllegalArgumentException()
       .isThrownBy(() -> underTest.validate("clientId", "clientSecret", "workspace"))
       .withMessage(UNABLE_TO_CONTACT_BBC_SERVERS);
-    assertThat(logTester.logs(LoggerLevel.INFO)).containsExactly(String.format(BBC_FAIL_WITH_RESPONSE, serverURL, "500", body));
+    assertThat(logTester.logs(Level.INFO)).containsExactly(String.format(BBC_FAIL_WITH_RESPONSE, serverURL, "500", body));
   }
 
   @Test
@@ -352,7 +352,7 @@ public class BitbucketCloudRestClientTest {
     assertThatIllegalArgumentException()
       .isThrownBy(() -> underTest.validate("clientId", "clientSecret", "workspace"))
       .withMessage(UNABLE_TO_CONTACT_BBC_SERVERS);
-    assertThat(logTester.logs(LoggerLevel.INFO)).containsExactly(String.format(BBC_FAIL_WITH_RESPONSE, serverURL, "500", body));
+    assertThat(logTester.logs(Level.INFO)).containsExactly(String.format(BBC_FAIL_WITH_RESPONSE, serverURL, "500", body));
   }
 
   @Test
@@ -368,6 +368,6 @@ public class BitbucketCloudRestClientTest {
     assertThatIllegalArgumentException()
       .isThrownBy(() -> underTest.validate("clientId", "clientSecret", "workspace"))
       .withMessage(UNABLE_TO_CONTACT_BBC_SERVERS);
-    assertThat(logTester.logs(LoggerLevel.INFO)).containsExactly(String.format(BBC_FAIL_WITH_ERROR, serverURL, "SSL verification failed"));
+    assertThat(logTester.logs(Level.INFO)).containsExactly(String.format(BBC_FAIL_WITH_ERROR, serverURL, "SSL verification failed"));
   }
 }
index c1e7cee87cececced9df0e94fd64c5dacbb5e56d..5de1f69d9f72ec71a86f4daafff59c67edec3c76 100644 (file)
@@ -36,7 +36,7 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.sonar.alm.client.ConstantTimeoutConfiguration;
-import org.sonar.api.utils.log.LogTester;
+import org.sonar.api.testfixtures.log.LogTester;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
index ed823e73d4b09a9be9c108696d02a8de4c97c78d..fbe8aa95ca05774a918fbca61b91b16489499704 100644 (file)
@@ -34,7 +34,7 @@ import org.sonar.alm.client.github.security.AccessToken;
 import org.sonar.alm.client.github.security.AppToken;
 import org.sonar.alm.client.github.security.GithubAppSecurity;
 import org.sonar.alm.client.github.security.UserAccessToken;
-import org.sonar.api.utils.log.LogTester;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.api.utils.log.LoggerLevel;
 
 import static java.net.HttpURLConnection.HTTP_FORBIDDEN;
index 8487382837d5c2202d1ae98cb2d822b2827c150a..1e90d5b127b3456ac008b7d5adee21aef1d12fbf 100644 (file)
@@ -33,12 +33,13 @@ import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.slf4j.event.Level;
 import org.sonar.alm.client.ConstantTimeoutConfiguration;
 import org.sonar.alm.client.github.GithubApplicationHttpClient.GetResponse;
 import org.sonar.alm.client.github.GithubApplicationHttpClient.Response;
 import org.sonar.alm.client.github.security.AccessToken;
 import org.sonar.alm.client.github.security.UserAccessToken;
-import org.sonar.api.utils.log.LogTester;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.api.utils.log.LoggerLevel;
 
 import static java.lang.String.format;
@@ -110,7 +111,7 @@ public class GithubApplicationHttpClientImplTest {
 
     GetResponse response = underTest.get(appUrl, accessToken, randomEndPoint);
 
-    assertThat(logTester.logs(LoggerLevel.WARN)).isNotEmpty();
+    assertThat(logTester.logs(Level.WARN)).isNotEmpty();
     assertThat(response.getContent()).isEmpty();
 
   }
index 6fb184e6e521850130da77da411a74d153a3bf53..48c0b2d0067d56091813ea580e8a436327621138 100644 (file)
@@ -29,10 +29,10 @@ import org.junit.After;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
+import org.slf4j.event.Level;
 import org.sonar.alm.client.ConstantTimeoutConfiguration;
 import org.sonar.alm.client.TimeoutConfiguration;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
+import org.sonar.api.testfixtures.log.LogTester;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
@@ -457,7 +457,7 @@ public class GitlabHttpClientTest {
     assertThatThrownBy(() -> underTest.checkReadPermission(gitlabUrl, "token"))
       .isInstanceOf(IllegalArgumentException.class)
       .hasMessage("Could not validate GitLab read permission. Got an unexpected answer.");
-    assertThat(logTester.logs(LoggerLevel.INFO).get(0))
+    assertThat(logTester.logs(Level.INFO).get(0))
       .contains("Gitlab API call to [" + server.url("/projects") + "] " +
         "failed with error message : [Failed to connect to " + server.getHostName());
   }
@@ -469,7 +469,7 @@ public class GitlabHttpClientTest {
     assertThatThrownBy(() -> underTest.checkToken(gitlabUrl, "token"))
       .isInstanceOf(IllegalArgumentException.class)
       .hasMessage("Could not validate GitLab token. Got an unexpected answer.");
-    assertThat(logTester.logs(LoggerLevel.INFO).get(0))
+    assertThat(logTester.logs(Level.INFO).get(0))
       .contains("Gitlab API call to [" + server.url("user") + "] " +
         "failed with error message : [Failed to connect to " + server.getHostName());
   }
@@ -481,7 +481,7 @@ public class GitlabHttpClientTest {
     assertThatThrownBy(() -> underTest.checkWritePermission(gitlabUrl, "token"))
       .isInstanceOf(IllegalArgumentException.class)
       .hasMessage("Could not validate GitLab write permission. Got an unexpected answer.");
-    assertThat(logTester.logs(LoggerLevel.INFO).get(0))
+    assertThat(logTester.logs(Level.INFO).get(0))
       .contains("Gitlab API call to [" + server.url("/markdown") + "] " +
         "failed with error message : [Failed to connect to " + server.getHostName());
   }
@@ -493,7 +493,7 @@ public class GitlabHttpClientTest {
     assertThatThrownBy(() -> underTest.getProject(gitlabUrl, "token", 0L))
       .isInstanceOf(IllegalStateException.class)
       .hasMessageContaining("Failed to connect to");
-    assertThat(logTester.logs(LoggerLevel.INFO).get(0))
+    assertThat(logTester.logs(Level.INFO).get(0))
       .contains("Gitlab API call to [" + server.url("/projects/0") + "] " +
         "failed with error message : [Failed to connect to " + server.getHostName());
   }
@@ -505,7 +505,7 @@ public class GitlabHttpClientTest {
     assertThatThrownBy(() -> underTest.getBranches(gitlabUrl, "token", 0L))
       .isInstanceOf(IllegalStateException.class)
       .hasMessageContaining("Failed to connect to " + server.getHostName());
-    assertThat(logTester.logs(LoggerLevel.INFO).get(0))
+    assertThat(logTester.logs(Level.INFO).get(0))
       .contains("Gitlab API call to [" + server.url("/projects/0/repository/branches") + "] " +
         "failed with error message : [Failed to connect to " + server.getHostName());
   }
@@ -517,7 +517,7 @@ public class GitlabHttpClientTest {
     assertThatThrownBy(() -> underTest.searchProjects(gitlabUrl, "token", null, 1, 1))
       .isInstanceOf(IllegalStateException.class)
       .hasMessageContaining("Failed to connect to");
-    assertThat(logTester.logs(LoggerLevel.INFO).get(0))
+    assertThat(logTester.logs(Level.INFO).get(0))
       .contains(
         "Gitlab API call to [" + server.url("/projects?archived=false&simple=true&membership=true&order_by=name&sort=asc&search=&page=1&per_page=1")
           + "] " +
index cf41ccabb0c5f3c4a1f8411a1331cec1114b8337..db3de357a60ec233147abac807dd456f29a8bf67 100644 (file)
@@ -20,5 +20,6 @@ dependencies {
     testImplementation 'junit:junit'
     testImplementation 'org.assertj:assertj-core'
     testImplementation 'org.mockito:mockito-core'
+    testImplementation 'org.sonarsource.api.plugin:sonar-plugin-api-test-fixtures'
     testImplementation testFixtures(project(':server:sonar-db-dao'))
 }
index f598d9c9969ed6136491c96a19f3968304ad7b14..f67636785e38822d197c255caa2ba11dd727aea0 100644 (file)
@@ -38,8 +38,8 @@ import org.sonar.api.server.authentication.OAuth2IdentityProvider;
 import org.sonar.api.server.authentication.UnauthorizedException;
 import org.sonar.api.server.authentication.UserIdentity;
 import org.sonar.api.utils.System2;
-import org.sonar.api.utils.log.LogAndArguments;
-import org.sonar.api.utils.log.LogTester;
+import org.sonar.api.testfixtures.log.LogAndArguments;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.db.DbTester;
 
 import static org.assertj.core.api.Assertions.assertThat;
index 166e007fae0212c1070f0bdcb737cd3634726844..47a59374b60e5f11c1c9fd6edbff5cbc34f10ebf 100644 (file)
@@ -52,6 +52,7 @@ dependencies {
   testImplementation 'org.assertj:assertj-core'
   testImplementation 'org.assertj:assertj-guava'
   testImplementation 'org.reflections:reflections'
+  testImplementation 'org.sonarsource.api.plugin:sonar-plugin-api-test-fixtures'
   testImplementation project(':sonar-testing-harness')
   testImplementation testFixtures(project(':server:sonar-server-common'))
 
index a8e9be91e8969ec0a0374caebbf5e9ee4b5d712d..57e9b7397bcd3045de186fa9f826e5547a8228e0 100644 (file)
@@ -34,9 +34,9 @@ import org.apache.commons.io.FileUtils;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
+import org.slf4j.event.Level;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.api.utils.System2;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
 import org.sonar.ce.task.projectanalysis.analysis.Analysis;
 import org.sonar.ce.task.projectanalysis.analysis.AnalysisMetadataHolderRule;
 import org.sonar.ce.task.projectanalysis.component.Component;
@@ -60,7 +60,8 @@ import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 import static org.sonar.ce.task.projectanalysis.component.ReportComponent.builder;
 import static org.sonar.ce.task.projectanalysis.filemove.FileMoveDetectionStep.MIN_REQUIRED_SCORE;
-import static org.sonar.db.component.BranchType.*;
+import static org.sonar.db.component.BranchType.BRANCH;
+import static org.sonar.db.component.BranchType.PULL_REQUEST;
 
 public class FileMoveDetectionStepIT {
 
@@ -236,6 +237,7 @@ public class FileMoveDetectionStepIT {
 
   @Before
   public void setUp() throws Exception {
+    logTester.setLevel(Level.DEBUG);
     project = dbTester.components().insertPrivateProject();
     treeRootHolder.setRoot(builder(Component.Type.PROJECT, ROOT_REF).setUuid(project.uuid()).build());
   }
@@ -418,7 +420,7 @@ public class FileMoveDetectionStepIT {
     assertThat(scoreMatrixDumper.scoreMatrix.getMaxScore()).isZero();
     assertThat(addedFileRepository.getComponents()).contains(file2);
     verifyStatistics(context, 1, 1, 1, 0);
-    assertThat(logTester.logs(LoggerLevel.DEBUG)).contains("max score in matrix is less than min required score (85). Do nothing.");
+    assertThat(logTester.logs(Level.DEBUG)).contains("max score in matrix is less than min required score (85). Do nothing.");
   }
 
   @Test
index 044c69fe388aad2830a54623d460a53429cfa523..4c86e49cadc85714d7356f6ed1c1e6cf6e413d09 100644 (file)
@@ -29,7 +29,7 @@ import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.sonar.api.utils.System2;
-import org.sonar.api.utils.log.LogTester;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.ce.task.projectanalysis.analysis.Analysis;
 import org.sonar.ce.task.projectanalysis.analysis.AnalysisMetadataHolderRule;
 import org.sonar.ce.task.projectanalysis.analysis.Branch;
index 128f9927f500d84eb86f79bbc215eb95eb4fdb98..9e91e0b66a9d0ce432ac5bc05fe2af633f7cece4 100644 (file)
@@ -21,8 +21,8 @@ package org.sonar.ce.task.projectanalysis.issue;
 
 import org.junit.Rule;
 import org.junit.Test;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
+import org.slf4j.event.Level;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.db.DbTester;
 import org.sonar.db.user.UserDto;
 import org.sonar.server.es.EsTester;
@@ -60,7 +60,7 @@ public class ScmAccountToUserLoaderIT {
     ScmAccountToUserLoader underTest = new ScmAccountToUserLoader(db.getDbClient());
 
     assertThat(underTest.load("charlie")).isNull();
-    assertThat(logTester.logs(LoggerLevel.WARN)).contains("Multiple users share the SCM account 'charlie': another.charlie, charlie");
+    assertThat(logTester.logs(Level.WARN)).contains("Multiple users share the SCM account 'charlie': another.charlie, charlie");
   }
 
   @Test
index 1591410151c8cdd5465eac1e180e5b5ab43c7733..c647e7f5bace75d8d52d8ddb78621eb3f75dd190 100644 (file)
@@ -29,7 +29,7 @@ import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.sonar.api.utils.System2;
-import org.sonar.api.utils.log.LogTester;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.ce.task.projectanalysis.analysis.Analysis;
 import org.sonar.ce.task.projectanalysis.analysis.AnalysisMetadataHolderRule;
 import org.sonar.ce.task.projectanalysis.analysis.Branch;
@@ -51,7 +51,7 @@ import org.sonar.db.source.FileSourceDto;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
-import static org.sonar.api.utils.log.LoggerLevel.TRACE;
+import static org.slf4j.event.Level.TRACE;
 import static org.sonar.ce.task.projectanalysis.component.ReportComponent.builder;
 
 public class ScmInfoDbLoaderIT {
@@ -86,6 +86,7 @@ public class ScmInfoDbLoaderIT {
 
   @Before
   public void before() {
+    logTester.setLevel(TRACE);
     periodHolder.setPeriod(new Period(NewCodePeriodType.PREVIOUS_VERSION.name(), null, null));
   }
 
@@ -101,7 +102,7 @@ public class ScmInfoDbLoaderIT {
     assertThat(scmInfo.getAllChangesets()).hasSize(1);
     assertThat(scmInfo.fileHash()).isEqualTo(hash);
 
-    assertThat(logTester.logs(TRACE)).containsOnly("Reading SCM info from DB for file 'FILE_UUID'");
+    assertThat(logTester.logs(TRACE)).contains("Reading SCM info from DB for file 'FILE_UUID'");
   }
 
   @Test
@@ -118,7 +119,7 @@ public class ScmInfoDbLoaderIT {
     DbScmInfo scmInfo = underTest.getScmInfo(FILE).get();
     assertThat(scmInfo.getAllChangesets()).hasSize(1);
     assertThat(scmInfo.fileHash()).isEqualTo(hash);
-    assertThat(logTester.logs(TRACE)).containsOnly("Reading SCM info from DB for file 'referenceFileUuid'");
+    assertThat(logTester.logs(TRACE)).contains("Reading SCM info from DB for file 'referenceFileUuid'");
   }
 
   @Test
@@ -137,7 +138,7 @@ public class ScmInfoDbLoaderIT {
     DbScmInfo scmInfo = underTest.getScmInfo(FILE).get();
     assertThat(scmInfo.getAllChangesets()).hasSize(1);
     assertThat(scmInfo.fileHash()).isEqualTo(hash);
-    assertThat(logTester.logs(TRACE)).containsOnly("Reading SCM info from DB for file 'targetBranchFileUuid'");
+    assertThat(logTester.logs(TRACE)).contains("Reading SCM info from DB for file 'targetBranchFileUuid'");
   }
 
   @Test
@@ -158,7 +159,7 @@ public class ScmInfoDbLoaderIT {
     DbScmInfo scmInfo = underTest.getScmInfo(FILE).get();
     assertThat(scmInfo.getAllChangesets()).hasSize(1);
     assertThat(scmInfo.fileHash()).isEqualTo(hash);
-    assertThat(logTester.logs(TRACE)).containsOnly("Reading SCM info from DB for file 'targetBranchFileUuid'");
+    assertThat(logTester.logs(TRACE)).contains("Reading SCM info from DB for file 'targetBranchFileUuid'");
   }
 
   @Test
@@ -177,7 +178,7 @@ public class ScmInfoDbLoaderIT {
     DbScmInfo scmInfo = underTest.getScmInfo(FILE).get();
     assertThat(scmInfo.getAllChangesets()).hasSize(1);
     assertThat(scmInfo.fileHash()).isEqualTo(hash);
-    assertThat(logTester.logs(TRACE)).containsOnly("Reading SCM info from DB for file 'FILE_UUID'");
+    assertThat(logTester.logs(TRACE)).contains("Reading SCM info from DB for file 'FILE_UUID'");
   }
 
   @Test
@@ -187,7 +188,7 @@ public class ScmInfoDbLoaderIT {
 
     Optional<DbScmInfo> scmInfo = underTest.getScmInfo(FILE);
 
-    assertThat(logTester.logs(TRACE)).containsOnly("Reading SCM info from DB for file 'FILE_UUID'");
+    assertThat(logTester.logs(TRACE)).contains("Reading SCM info from DB for file 'FILE_UUID'");
     assertThat(scmInfo).isEmpty();
   }
 
index edea98f75be4380fd6225ccf26bde66422d741fe..ed2499f48ae05d9b6acefd6a61756ffb1c968f3b 100644 (file)
@@ -26,11 +26,12 @@ import java.net.URL;
 import org.apache.commons.io.FileUtils;
 import org.junit.Rule;
 import org.junit.Test;
+import org.slf4j.event.Level;
 import org.sonar.api.impl.utils.JUnitTempFolder;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.api.utils.MessageException;
 import org.sonar.api.utils.System2;
 import org.sonar.api.utils.ZipUtils;
-import org.sonar.api.utils.log.LogTester;
 import org.sonar.api.utils.log.LoggerLevel;
 import org.sonar.ce.task.CeTask;
 import org.sonar.ce.task.projectanalysis.batch.BatchReportDirectoryHolderImpl;
@@ -89,7 +90,7 @@ public class ExtractReportStepIT {
     assertThat(unzippedDir.listFiles()).hasSize(1);
     assertThat(new File(unzippedDir, "metadata.pb")).hasContent("{metadata}");
 
-    assertThat(logTester.logs(LoggerLevel.DEBUG)).anyMatch(log -> log.matches("Analysis report is \\d+ bytes uncompressed"));
+    assertThat(logTester.logs(Level.DEBUG)).anyMatch(log -> log.matches("Analysis report is \\d+ bytes uncompressed"));
   }
 
   @Test
index 51b03356334982c6f17317d736e6e340af1576de..0c8e8031f8d6fcf8d71f13e8651812712c18b6ba 100644 (file)
@@ -35,10 +35,11 @@ import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.slf4j.event.Level;
 import org.sonar.api.utils.MessageException;
 import org.sonar.api.utils.System2;
-import org.sonar.api.utils.log.LogAndArguments;
-import org.sonar.api.utils.log.LogTester;
+import org.sonar.api.testfixtures.log.LogAndArguments;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.api.utils.log.LoggerLevel;
 import org.sonar.ce.task.log.CeTaskMessages;
 import org.sonar.ce.task.projectanalysis.analysis.AnalysisMetadataHolder;
@@ -102,6 +103,7 @@ public class LoadPeriodsStepIT extends BaseStepTest {
 
   @Before
   public void setUp() {
+    logTester.setLevel(Level.TRACE);
     project = dbTester.components().insertPublicProject();
 
     when(analysisMetadataHolder.isBranch()).thenReturn(true);
@@ -528,10 +530,8 @@ public class LoadPeriodsStepIT extends BaseStepTest {
   }
 
   private void verifyDebugLogs(String log, String... otherLogs) {
-    assertThat(logTester.getLogs()).hasSize(1 + otherLogs.length);
-    assertThat(logTester.getLogs(LoggerLevel.DEBUG))
-      .extracting(LogAndArguments::getFormattedMsg)
-      .containsOnly(Stream.concat(Stream.of(log), Arrays.stream(otherLogs)).toArray(String[]::new));
+    assertThat(logTester.logs(Level.DEBUG))
+      .contains(Stream.concat(Stream.of(log), Arrays.stream(otherLogs)).toArray(String[]::new));
   }
 
   private void setupRoot(ComponentDto branchComponent) {
index 95a7f770898134c147401aeba67cda1c7413e78d..c90a2a2a6190cb52b14a347b108a1b0e100ec249 100644 (file)
@@ -30,11 +30,11 @@ import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.slf4j.event.Level;
 import org.sonar.api.resources.Qualifiers;
 import org.sonar.api.resources.Scopes;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.api.utils.System2;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
 import org.sonar.ce.task.projectexport.component.ComponentRepositoryImpl;
 import org.sonar.ce.task.projectexport.steps.DumpElement;
 import org.sonar.ce.task.projectexport.steps.FakeDumpWriter;
@@ -107,6 +107,7 @@ public class ExportAnalysesStepIT {
 
   @Before
   public void setUp() {
+    logTester.setLevel(Level.DEBUG);
     ComponentDto projectDto = dbTester.components().insertPublicProject(PROJECT);
     componentRepository.register(1, projectDto.uuid(), false);
     dbTester.getDbClient().componentDao().insert(dbTester.getSession(), Set.of(DIR, FILE), true);
@@ -130,7 +131,7 @@ public class ExportAnalysesStepIT {
 
     underTest.execute(new TestComputationStepContext());
 
-    assertThat(logTester.logs(LoggerLevel.DEBUG)).contains("3 analyses exported");
+    assertThat(logTester.logs(Level.DEBUG)).contains("3 analyses exported");
     List<ProjectDump.Analysis> analyses = dumpWriter.getWrittenMessagesOf(DumpElement.ANALYSES);
     assertThat(analyses).hasSize(3);
     assertAnalysis(analyses.get(0), PROJECT, firstAnalysis);
@@ -175,7 +176,7 @@ public class ExportAnalysesStepIT {
 
     List<ProjectDump.Analysis> analyses = dumpWriter.getWrittenMessagesOf(DumpElement.ANALYSES);
     assertThat(analyses).isEmpty();
-    assertThat(logTester.logs(LoggerLevel.DEBUG)).contains("0 analyses exported");
+    assertThat(logTester.logs(Level.DEBUG)).contains("0 analyses exported");
   }
 
   @Test
index c09be119ba21397e644720f86ef277fdba331520..950175a3c300b2ed9de8a28f392be52b5c5029ea 100644 (file)
@@ -29,11 +29,11 @@ import org.apache.commons.lang.time.DateUtils;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
+import org.slf4j.event.Level;
 import org.sonar.api.resources.Qualifiers;
 import org.sonar.api.resources.Scopes;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.api.utils.System2;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
 import org.sonar.ce.task.projectexport.steps.DumpElement;
 import org.sonar.ce.task.projectexport.steps.FakeDumpWriter;
 import org.sonar.ce.task.projectexport.steps.ProjectHolder;
@@ -107,6 +107,7 @@ public class ExportBranchesStepIT {
 
   @Before
   public void setUp() {
+    logTester.setLevel(Level.DEBUG);
     Date createdAt = new Date();
     ComponentDto projectDto = dbTester.components().insertPublicProject(PROJECT).setCreatedAt(createdAt);
     for (BranchDto branch : branches) {
@@ -121,7 +122,7 @@ public class ExportBranchesStepIT {
   public void export_branches() {
     underTest.execute(new TestComputationStepContext());
 
-    assertThat(logTester.logs(LoggerLevel.DEBUG)).contains("3 branches exported");
+    assertThat(logTester.logs(Level.DEBUG)).contains("3 branches exported");
     Map<String, ProjectDump.Branch> branches = dumpWriter.getWrittenMessagesOf(DumpElement.BRANCHES)
       .stream()
       .collect(toMap(ProjectDump.Branch::getUuid, Function.identity()));
index e39789dfffc1dcb2a63ce9ee5cd249660858924c..7c33c052ae182b7ac9b025a8a98e1bd2372ff26c 100644 (file)
@@ -24,13 +24,14 @@ import com.sonarsource.governance.projectdump.protobuf.ProjectDump;
 import java.util.Date;
 import java.util.List;
 import org.junit.After;
+import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
+import org.slf4j.event.Level;
 import org.sonar.api.resources.Qualifiers;
 import org.sonar.api.resources.Scopes;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.api.utils.System2;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
 import org.sonar.ce.task.projectexport.steps.DumpElement;
 import org.sonar.ce.task.projectexport.steps.FakeDumpWriter;
 import org.sonar.ce.task.projectexport.steps.ProjectHolder;
@@ -86,6 +87,11 @@ public class ExportComponentsStepIT {
   private final MutableComponentRepository componentRepository = new ComponentRepositoryImpl();
   private final ExportComponentsStep underTest = new ExportComponentsStep(dbTester.getDbClient(), projectHolder, componentRepository, dumpWriter);
 
+  @Before
+  public void before() {
+    logTester.setLevel(Level.DEBUG);
+  }
+
   @After
   public void tearDown() {
     dbTester.getSession().close();
@@ -100,7 +106,7 @@ public class ExportComponentsStepIT {
 
     underTest.execute(new TestComputationStepContext());
 
-    assertThat(logTester.logs(LoggerLevel.DEBUG)).contains("2 components exported");
+    assertThat(logTester.logs(Level.DEBUG)).contains("2 components exported");
     List<ProjectDump.Component> components = dumpWriter.getWrittenMessagesOf(DumpElement.COMPONENTS);
     assertThat(components).extracting(ProjectDump.Component::getQualifier, ProjectDump.Component::getUuid, ProjectDump.Component::getUuidPath)
       .containsExactlyInAnyOrder(
index ac6a7cfee6f453f8c2533ed4f8a463edc97ad1f1..6ca08fc528b052039e70eaace5a46666e60433f8 100644 (file)
@@ -22,12 +22,13 @@ package org.sonar.ce.task.projectexport.file;
 import com.sonarsource.governance.projectdump.protobuf.ProjectDump;
 import java.util.List;
 import org.junit.After;
+import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.mockito.ArgumentCaptor;
+import org.slf4j.event.Level;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.api.utils.System2;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
 import org.sonar.ce.task.projectexport.component.ComponentRepositoryImpl;
 import org.sonar.ce.task.projectexport.component.MutableComponentRepository;
 import org.sonar.ce.task.projectexport.steps.DumpElement;
@@ -65,6 +66,11 @@ public class ExportLineHashesStepIT {
 
   private ExportLineHashesStep underTest = new ExportLineHashesStep(dbClient, dumpWriter, componentRepository);
 
+  @Before
+  public void before() {
+    logTester.setLevel(Level.DEBUG);
+  }
+
   @After
   public void tearDown() {
     dbSession.close();
@@ -167,7 +173,7 @@ public class ExportLineHashesStepIT {
       .extracting(ProjectDump.LineHashes::getHashes)
       .containsExactly("A", "C", "D", "E");
 
-    assertThat(logTester.logs(LoggerLevel.DEBUG)).containsExactly("Lines hashes of 4 files exported");
+    assertThat(logTester.logs(Level.DEBUG)).contains("Lines hashes of 4 files exported");
   }
 
   private FileSourceDto insertFileSource(String fileUuid, String hashes) {
index 0d8e79be2a13aaff5507dc3e55dec062ac4f4d30..d316d5aadc6eaeaad621cc988b69aea092f47bc2 100644 (file)
@@ -26,9 +26,9 @@ import org.junit.After;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
+import org.slf4j.event.Level;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.api.utils.System2;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
 import org.sonar.ce.task.projectexport.steps.DumpElement;
 import org.sonar.ce.task.projectexport.steps.FakeDumpWriter;
 import org.sonar.ce.task.projectexport.steps.ProjectHolder;
@@ -77,6 +77,7 @@ public class ExportIssuesChangelogStepIT {
 
   @Before
   public void setUp() {
+    logTester.setLevel(Level.DEBUG);
     ComponentDto projectDto = dbTester.components().insertPublicProject(p -> p.setUuid(PROJECT_UUID));
     when(projectHolder.projectDto()).thenReturn(dbTester.components().getProjectDto(projectDto));
     when(projectHolder.branches()).thenReturn(newArrayList(
@@ -211,13 +212,14 @@ public class ExportIssuesChangelogStepIT {
 
   @Test
   public void execute_logs_number_total_exported_issue_changes_count_when_successful() {
+    logTester.setLevel(Level.DEBUG);
     insertIssueChange(ISSUE_OPEN_UUID);
     insertIssueChange(ISSUE_CONFIRMED_UUID);
     insertIssueChange(ISSUE_REOPENED_UUID);
 
     underTest.execute(new TestComputationStepContext());
 
-    assertThat(logTester.logs(LoggerLevel.DEBUG)).containsExactly("3 issue changes exported");
+    assertThat(logTester.logs(Level.DEBUG)).contains("3 issue changes exported");
   }
 
   @Test
index 3dfb5e68d3b1d5772227b28227164851d90a9684..ae29778c205d1651f5ffe07abedde0afafe48d56 100644 (file)
@@ -34,13 +34,13 @@ import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.slf4j.event.Level;
 import org.sonar.api.issue.Issue;
 import org.sonar.api.rule.RuleKey;
 import org.sonar.api.rule.RuleStatus;
 import org.sonar.api.rules.RuleType;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.api.utils.System2;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
 import org.sonar.ce.task.projectexport.component.ComponentRepositoryImpl;
 import org.sonar.ce.task.projectexport.component.MutableComponentRepository;
 import org.sonar.ce.task.projectexport.rule.RuleRepository;
@@ -99,6 +99,7 @@ public class ExportIssuesStepIT {
 
   @Before
   public void setUp() {
+    logTester.setLevel(Level.DEBUG);
     ProjectDto project = createProject();
     when(projectHolder.projectDto()).thenReturn(project);
     when(projectHolder.branches()).thenReturn(newArrayList(
@@ -331,7 +332,7 @@ public class ExportIssuesStepIT {
 
     underTest.execute(new TestComputationStepContext());
 
-    assertThat(logTester.logs(LoggerLevel.DEBUG)).containsExactly("3 issues exported");
+    assertThat(logTester.logs(Level.DEBUG)).contains("3 issues exported");
   }
 
   @Test
index 902c5d32577f6b8e00e36b310826af0e0e968a99..afc77a8336c7b910dfd2db047ba193bef7978774 100644 (file)
@@ -27,15 +27,15 @@ import org.apache.commons.lang.RandomStringUtils;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
+import org.slf4j.event.Level;
 import org.sonar.api.resources.Qualifiers;
 import org.sonar.api.resources.Scopes;
 import org.sonar.api.rule.RuleKey;
 import org.sonar.api.rule.RuleStatus;
 import org.sonar.api.rule.Severity;
 import org.sonar.api.rules.RuleType;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.api.utils.System2;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
 import org.sonar.ce.task.projectexport.steps.DumpElement;
 import org.sonar.ce.task.projectexport.steps.FakeDumpWriter;
 import org.sonar.ce.task.projectexport.steps.ProjectHolder;
@@ -89,6 +89,7 @@ public class ExportAdHocRulesStepIT {
 
   @Before
   public void setup() {
+    logTester.setLevel(Level.DEBUG);
     ProjectDto project = createProject();
     when(projectHolder.projectDto()).thenReturn(project);
   }
@@ -99,7 +100,7 @@ public class ExportAdHocRulesStepIT {
 
     List<ProjectDump.AdHocRule> exportedRules = dumpWriter.getWrittenMessagesOf(DumpElement.AD_HOC_RULES);
     assertThat(exportedRules).isEmpty();
-    assertThat(logTester.logs(LoggerLevel.DEBUG)).contains("0 ad-hoc rules exported");
+    assertThat(logTester.logs(Level.DEBUG)).contains("0 ad-hoc rules exported");
   }
 
   @Test
@@ -116,7 +117,7 @@ public class ExportAdHocRulesStepIT {
     List<ProjectDump.AdHocRule> exportedRules = dumpWriter.getWrittenMessagesOf(DumpElement.AD_HOC_RULES);
     assertThat(exportedRules).hasSize(1);
     assertProtobufAdHocRuleIsCorrectlyBuilt(exportedRules.iterator().next(), rule2);
-    assertThat(logTester.logs(LoggerLevel.DEBUG)).contains("1 ad-hoc rules exported");
+    assertThat(logTester.logs(Level.DEBUG)).contains("1 ad-hoc rules exported");
   }
 
   @Test
@@ -133,7 +134,7 @@ public class ExportAdHocRulesStepIT {
     List<ProjectDump.AdHocRule> exportedRules = dumpWriter.getWrittenMessagesOf(DumpElement.AD_HOC_RULES);
     assertThat(exportedRules).hasSize(1);
     assertProtobufAdHocRuleIsCorrectlyBuilt(exportedRules.iterator().next(), rule3);
-    assertThat(logTester.logs(LoggerLevel.DEBUG)).contains("1 ad-hoc rules exported");
+    assertThat(logTester.logs(Level.DEBUG)).contains("1 ad-hoc rules exported");
   }
 
   @Test
@@ -151,7 +152,7 @@ public class ExportAdHocRulesStepIT {
     List<ProjectDump.AdHocRule> exportedRules = dumpWriter.getWrittenMessagesOf(DumpElement.AD_HOC_RULES);
     assertThat(exportedRules).hasSize(1);
     assertProtobufAdHocRuleIsCorrectlyBuilt(exportedRules.iterator().next(), rule2);
-    assertThat(logTester.logs(LoggerLevel.DEBUG)).contains("1 ad-hoc rules exported");
+    assertThat(logTester.logs(Level.DEBUG)).contains("1 ad-hoc rules exported");
   }
 
   @Test
index e2aea5fc0b5a819bc07ce00c24c19ea46d056e5f..aa5e7a8debb0effc4b312152684ebbfd3c99a078 100644 (file)
@@ -24,11 +24,11 @@ import java.util.List;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
+import org.slf4j.event.Level;
 import org.sonar.api.resources.Qualifiers;
 import org.sonar.api.resources.Scopes;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.api.utils.System2;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
 import org.sonar.ce.task.projectexport.component.ComponentRepositoryImpl;
 import org.sonar.ce.task.step.TestComputationStepContext;
 import org.sonar.db.DbTester;
@@ -70,6 +70,7 @@ public class ExportEventsStepIT {
 
   @Before
   public void setUp() {
+    logTester.setLevel(Level.DEBUG);
     ComponentDto projectDto = dbTester.components().insertPublicProject(PROJECT);
     componentRepository.register(1, projectDto.uuid(), false);
     projectHolder.setProjectDto(dbTester.components().getProjectDto(projectDto));
@@ -79,7 +80,7 @@ public class ExportEventsStepIT {
   public void export_zero_events() {
     underTest.execute(new TestComputationStepContext());
 
-    assertThat(logTester.logs(LoggerLevel.DEBUG)).contains("0 events exported");
+    assertThat(logTester.logs(Level.DEBUG)).contains("0 events exported");
     List<ProjectDump.Event> events = dumpWriter.getWrittenMessagesOf(DumpElement.EVENTS);
     assertThat(events).isEmpty();
   }
@@ -92,7 +93,7 @@ public class ExportEventsStepIT {
 
     underTest.execute(new TestComputationStepContext());
 
-    assertThat(logTester.logs(LoggerLevel.DEBUG)).contains("2 events exported");
+    assertThat(logTester.logs(Level.DEBUG)).contains("2 events exported");
     List<ProjectDump.Event> events = dumpWriter.getWrittenMessagesOf(DumpElement.EVENTS);
     assertThat(events).hasSize(2);
     assertThat(events).extracting(ProjectDump.Event::getUuid).containsOnly("E1", "E2");
index d1b8475bdecd31d21b9f5e221c824d9197a3612a..1fab9897443c996d7675c190fbb977e702acbab0 100644 (file)
@@ -23,11 +23,11 @@ import com.sonarsource.governance.projectdump.protobuf.ProjectDump.Link;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
+import org.slf4j.event.Level;
 import org.sonar.api.resources.Qualifiers;
 import org.sonar.api.resources.Scopes;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.api.utils.System2;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
 import org.sonar.ce.task.projectexport.component.ComponentRepository;
 import org.sonar.ce.task.step.TestComputationStepContext;
 import org.sonar.db.DbTester;
@@ -71,6 +71,7 @@ public class ExportLinksStepIT {
 
   @Before
   public void setUp() {
+    logTester.setLevel(Level.DEBUG);
     ComponentDto project = db.components().insertPublicProject(PROJECT);
     when(projectHolder.projectDto()).thenReturn(db.components().getProjectDto(project));
     when(componentRepository.getRef(PROJECT_UUID)).thenReturn(1L);
@@ -80,7 +81,7 @@ public class ExportLinksStepIT {
   public void export_zero_links() {
     underTest.execute(new TestComputationStepContext());
 
-    assertThat(logTester.logs(LoggerLevel.DEBUG)).contains("0 links exported");
+    assertThat(logTester.logs(Level.DEBUG)).contains("0 links exported");
     assertThat(dumpWriter.getWrittenMessagesOf(DumpElement.LINKS)).isEmpty();
   }
 
@@ -92,7 +93,7 @@ public class ExportLinksStepIT {
 
     underTest.execute(new TestComputationStepContext());
 
-    assertThat(logTester.logs(LoggerLevel.DEBUG)).contains("2 links exported");
+    assertThat(logTester.logs(Level.DEBUG)).contains("2 links exported");
     assertThat(dumpWriter.getWrittenMessagesOf(DumpElement.LINKS))
       .extracting(Link::getUuid, Link::getName, Link::getType, Link::getHref)
       .containsExactlyInAnyOrder(
index c4aad6eb747ba9abdee200f0e49bd8f08cb027ee..644e8eff5781a226d8ca2ed73fa5999c54a27313 100644 (file)
@@ -21,11 +21,12 @@ package org.sonar.ce.task.projectexport.steps;
 
 import com.sonarsource.governance.projectdump.protobuf.ProjectDump;
 import java.util.List;
+import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
+import org.slf4j.event.Level;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.api.utils.System2;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
 import org.sonar.ce.task.projectexport.component.ComponentRepositoryImpl;
 import org.sonar.ce.task.step.TestComputationStepContext;
 import org.sonar.db.DbTester;
@@ -54,6 +55,11 @@ public class ExportLiveMeasuresStepIT {
   private FakeDumpWriter dumpWriter = new FakeDumpWriter();
   private ExportLiveMeasuresStep underTest = new ExportLiveMeasuresStep(dbTester.getDbClient(), projectHolder, componentRepository, metricRepository, dumpWriter);
 
+  @Before
+  public void before() {
+    logTester.setLevel(Level.DEBUG);
+  }
+
   @Test
   public void export_zero_measures() {
     when(projectHolder.branches()).thenReturn(newArrayList());
@@ -62,7 +68,7 @@ public class ExportLiveMeasuresStepIT {
     underTest.execute(new TestComputationStepContext());
 
     assertThat(dumpWriter.getWrittenMessagesOf(DumpElement.LIVE_MEASURES)).isEmpty();
-    assertThat(logTester.logs(LoggerLevel.DEBUG)).contains("0 live measures exported");
+    assertThat(logTester.logs(Level.DEBUG)).contains("0 live measures exported");
     assertThat(metricRepository.getRefByUuid()).isEmpty();
   }
 
@@ -85,7 +91,7 @@ public class ExportLiveMeasuresStepIT {
     assertThat(exportedMeasures)
       .extracting(ProjectDump.LiveMeasure::getMetricRef, m -> m.getDoubleValue().getValue(), ProjectDump.LiveMeasure::hasVariation)
       .containsOnly(tuple(0, 4711.0d, false));
-    assertThat(logTester.logs(LoggerLevel.DEBUG)).contains("1 live measures exported");
+    assertThat(logTester.logs(Level.DEBUG)).contains("1 live measures exported");
     assertThat(metricRepository.getRefByUuid()).containsOnlyKeys(metric.getUuid());
   }
 
@@ -157,7 +163,7 @@ public class ExportLiveMeasuresStepIT {
         0.0d,
         "test",
         7.0d));
-    assertThat(logTester.logs(LoggerLevel.DEBUG)).contains("1 live measures exported");
+    assertThat(logTester.logs(Level.DEBUG)).contains("1 live measures exported");
     assertThat(metricRepository.getRefByUuid()).containsOnlyKeys(metric.getUuid());
   }
 
@@ -187,7 +193,7 @@ public class ExportLiveMeasuresStepIT {
         false,
         "",
         false));
-    assertThat(logTester.logs(LoggerLevel.DEBUG)).contains("1 live measures exported");
+    assertThat(logTester.logs(Level.DEBUG)).contains("1 live measures exported");
     assertThat(metricRepository.getRefByUuid()).containsOnlyKeys(metric.getUuid());
   }
 
index 8d16133ac45f9494e3af256a1f4da376ebf13b25..c9eca291c939bec96ed1532d33d6304a6c8ac616 100644 (file)
@@ -24,9 +24,9 @@ import java.util.List;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
+import org.slf4j.event.Level;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.api.utils.System2;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
 import org.sonar.ce.task.projectexport.component.ComponentRepositoryImpl;
 import org.sonar.ce.task.step.TestComputationStepContext;
 import org.sonar.db.DbTester;
@@ -107,6 +107,7 @@ public class ExportMeasuresStepIT {
 
   @Before
   public void setUp() {
+    logTester.setLevel(Level.DEBUG);
     String projectUuid = dbTester.components().insertPublicProject(PROJECT).uuid();
     componentRepository.register(1, projectUuid, false);
     dbTester.getDbClient().componentDao().insert(dbTester.getSession(), List.of(FILE, ANOTHER_PROJECT), true);
@@ -121,7 +122,7 @@ public class ExportMeasuresStepIT {
     underTest.execute(new TestComputationStepContext());
 
     assertThat(dumpWriter.getWrittenMessagesOf(DumpElement.MEASURES)).isEmpty();
-    assertThat(logTester.logs(LoggerLevel.DEBUG)).contains("0 measures exported");
+    assertThat(logTester.logs(Level.DEBUG)).contains("0 measures exported");
     assertThat(metricRepository.getRefByUuid()).isEmpty();
   }
 
@@ -141,7 +142,7 @@ public class ExportMeasuresStepIT {
     assertThat(exportedMeasures).hasSize(2);
     assertThat(exportedMeasures).extracting(ProjectDump.Measure::getAnalysisUuid).containsOnly(firstAnalysis.getUuid(), secondAnalysis.getUuid());
     assertThat(exportedMeasures).extracting(ProjectDump.Measure::getMetricRef).containsOnly(0);
-    assertThat(logTester.logs(LoggerLevel.DEBUG)).contains("2 measures exported");
+    assertThat(logTester.logs(Level.DEBUG)).contains("2 measures exported");
     assertThat(metricRepository.getRefByUuid()).containsOnlyKeys(NCLOC.getUuid());
   }
 
index 16f7a3202df5a40a1eab235bf07d4f906b0c308e..4304b5fc353ce880cc374739f5f6849edc3f1fd5 100644 (file)
@@ -24,9 +24,9 @@ import java.util.List;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
+import org.slf4j.event.Level;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.api.utils.System2;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
 import org.sonar.ce.task.step.TestComputationStepContext;
 import org.sonar.db.DbTester;
 import org.sonar.db.metric.MetricDto;
@@ -60,6 +60,7 @@ public class ExportMetricsStepIT {
 
   @Before
   public void setUp() {
+    logTester.setLevel(Level.DEBUG);
     dbTester.getDbClient().metricDao().insert(dbTester.getSession(), NCLOC, COVERAGE);
     dbTester.commit();
   }
@@ -68,7 +69,7 @@ public class ExportMetricsStepIT {
   public void export_zero_metrics() {
     underTest.execute(new TestComputationStepContext());
 
-    assertThat(logTester.logs(LoggerLevel.DEBUG)).contains("0 metrics exported");
+    assertThat(logTester.logs(Level.DEBUG)).contains("0 metrics exported");
   }
 
   @Test
@@ -78,7 +79,7 @@ public class ExportMetricsStepIT {
 
     underTest.execute(new TestComputationStepContext());
 
-    assertThat(logTester.logs(LoggerLevel.DEBUG)).contains("2 metrics exported");
+    assertThat(logTester.logs(Level.DEBUG)).contains("2 metrics exported");
     List<ProjectDump.Metric> exportedMetrics = dumpWriter.getWrittenMessagesOf(DumpElement.METRICS);
 
     ProjectDump.Metric ncloc = exportedMetrics.stream().filter(input -> input.getRef() == 0).findAny().orElseThrow();
index 49abb8615116f4bd451dc37d2bfb93731ff77a57..8ef1e54a00995ddd61df4fe98011800909cca19b 100644 (file)
@@ -27,10 +27,10 @@ import javax.annotation.Nullable;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
+import org.slf4j.event.Level;
 import org.sonar.api.resources.Qualifiers;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.api.utils.System2;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
 import org.sonar.ce.task.step.TestComputationStepContext;
 import org.sonar.db.DbTester;
 import org.sonar.db.component.BranchDto;
@@ -87,6 +87,7 @@ public class ExportNewCodePeriodsStepIT {
 
   @Before
   public void setUp() {
+    logTester.setLevel(Level.DEBUG);
     Date createdAt = new Date();
     ComponentDto projectDto = dbTester.components().insertPublicProject(PROJECT);
     PROJECT_BRANCHES.forEach(branch -> dbTester.components().insertProjectBranch(projectDto, branch).setCreatedAt(createdAt));
@@ -103,7 +104,7 @@ public class ExportNewCodePeriodsStepIT {
     underTest.execute(new TestComputationStepContext());
 
     assertThat(dumpWriter.getWrittenMessagesOf(DumpElement.NEW_CODE_PERIODS)).isEmpty();
-    assertThat(logTester.logs(LoggerLevel.DEBUG)).contains("0 new code periods exported");
+    assertThat(logTester.logs(Level.DEBUG)).contains("0 new code periods exported");
   }
 
   @Test
@@ -121,7 +122,7 @@ public class ExportNewCodePeriodsStepIT {
     List<ProjectDump.NewCodePeriod> exportedProps = dumpWriter.getWrittenMessagesOf(DumpElement.NEW_CODE_PERIODS);
     assertThat(exportedProps).hasSize(2);
     assertThat(exportedProps).extracting(ProjectDump.NewCodePeriod::getUuid).containsOnly("uuid1", "uuid2");
-    assertThat(logTester.logs(LoggerLevel.DEBUG)).contains("2 new code periods exported");
+    assertThat(logTester.logs(Level.DEBUG)).contains("2 new code periods exported");
   }
 
   @Test
index e8ca859a22a229368f99991272233ec84459bd11..4cd506d9ac2df08152179a03246cc5f0ab171ad2 100644 (file)
@@ -25,10 +25,10 @@ import javax.annotation.Nullable;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
+import org.slf4j.event.Level;
 import org.sonar.api.resources.Qualifiers;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.api.utils.System2;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
 import org.sonar.ce.task.projectexport.component.ComponentRepositoryImpl;
 import org.sonar.ce.task.projectexport.component.MutableComponentRepository;
 import org.sonar.ce.task.step.TestComputationStepContext;
@@ -66,6 +66,7 @@ public class ExportSettingsStepIT {
 
   @Before
   public void setUp() {
+    logTester.setLevel(Level.DEBUG);
     dbTester.components().insertPublicProject(PROJECT);
     dbTester.components().insertPublicProject(ANOTHER_PROJECT);
     dbTester.commit();
@@ -78,7 +79,7 @@ public class ExportSettingsStepIT {
     underTest.execute(new TestComputationStepContext());
 
     assertThat(dumpWriter.getWrittenMessagesOf(DumpElement.SETTINGS)).isEmpty();
-    assertThat(logTester.logs(LoggerLevel.DEBUG)).contains("0 settings exported");
+    assertThat(logTester.logs(Level.DEBUG)).contains("0 settings exported");
   }
 
   @Test
@@ -97,7 +98,7 @@ public class ExportSettingsStepIT {
     List<ProjectDump.Setting> exportedProps = dumpWriter.getWrittenMessagesOf(DumpElement.SETTINGS);
     assertThat(exportedProps).hasSize(2);
     assertThat(exportedProps).extracting(ProjectDump.Setting::getKey).containsOnly("p1", "p2");
-    assertThat(logTester.logs(LoggerLevel.DEBUG)).contains("2 settings exported");
+    assertThat(logTester.logs(Level.DEBUG)).contains("2 settings exported");
   }
 
   @Test
@@ -107,7 +108,7 @@ public class ExportSettingsStepIT {
     underTest.execute(new TestComputationStepContext());
 
     assertThat(dumpWriter.getWrittenMessagesOf(DumpElement.SETTINGS)).isEmpty();
-    assertThat(logTester.logs(LoggerLevel.DEBUG)).contains("0 settings exported");
+    assertThat(logTester.logs(Level.DEBUG)).contains("0 settings exported");
   }
 
   @Test
index ee67a8ff77a40d8ff1794c22bc3ea8909b48b4f6..c95b925cceece9d7bc3306eb40e3b9938e3782ec 100644 (file)
@@ -36,10 +36,10 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.ArgumentCaptor;
 import org.mockito.InOrder;
+import org.slf4j.event.Level;
 import org.sonar.api.ce.posttask.PostProjectAnalysisTask;
 import org.sonar.api.ce.posttask.Project;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.ce.task.CeTask;
 import org.sonar.ce.task.projectanalysis.analysis.AnalysisMetadataHolderRule;
 import org.sonar.ce.task.projectanalysis.analysis.Branch;
@@ -144,7 +144,7 @@ public class PostProjectAnalysisTasksExecutorTest {
     assertThat(allValues.get(0)).isSameAs(allValues.get(1));
 
     assertThat(logTester.logs()).hasSize(2);
-    List<String> logs = logTester.logs(LoggerLevel.INFO);
+    List<String> logs = logTester.logs(Level.INFO);
     assertThat(logs).hasSize(2);
     assertThat(logs.get(0)).matches("^PT1 \\| status=SUCCESS \\| time=\\d+ms$");
     assertThat(logs.get(1)).matches("^PT2 \\| status=SUCCESS \\| time=\\d+ms$");
@@ -390,7 +390,7 @@ public class PostProjectAnalysisTasksExecutorTest {
     verify(logStatisticsTask).finished(taskContextCaptor.capture());
 
     assertThat(logTester.logs()).hasSize(1);
-    List<String> logs = logTester.logs(LoggerLevel.INFO);
+    List<String> logs = logTester.logs(Level.INFO);
     assertThat(logs).hasSize(1);
     StringBuilder expectedLog = new StringBuilder("^PT1 ");
     stats.forEach((k, v) -> expectedLog.append("\\| " + k + "=" + v + " "));
@@ -424,7 +424,7 @@ public class PostProjectAnalysisTasksExecutorTest {
     inOrder.verifyNoMoreInteractions();
 
     assertThat(logTester.logs()).hasSize(4);
-    List<String> logs = logTester.logs(LoggerLevel.INFO);
+    List<String> logs = logTester.logs(Level.INFO);
     assertThat(logs).hasSize(3);
     assertThat(logs.get(0)).matches("^PT1 \\| status=SUCCESS \\| time=\\d+ms$");
     assertThat(logs.get(1)).matches("^PT2 \\| status=FAILED \\| time=\\d+ms$");
index a3b687b8c67d3256ae87997f57e57b93c0c3be83..183bb82cc7ec0a3e37016efc537023c1220d8c56 100644 (file)
  */
 package org.sonar.ce.task.projectanalysis.duplication;
 
+import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
+import org.slf4j.event.Level;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.ce.task.projectanalysis.analysis.AnalysisMetadataHolderRule;
 import org.sonar.ce.task.projectanalysis.analysis.Branch;
 
@@ -40,6 +41,11 @@ public class CrossProjectDuplicationStatusHolderImplTest {
 
   private CrossProjectDuplicationStatusHolderImpl underTest = new CrossProjectDuplicationStatusHolderImpl(analysisMetadataHolder);
 
+  @Before
+  public void before() {
+    logTester.setLevel(Level.DEBUG);
+  }
+
   @Test
   public void cross_project_duplication_is_enabled_when_enabled_in_report_and_no_branch() {
     analysisMetadataHolder
@@ -48,7 +54,7 @@ public class CrossProjectDuplicationStatusHolderImplTest {
     underTest.start();
 
     assertThat(underTest.isEnabled()).isTrue();
-    assertThat(logTester.logs(LoggerLevel.DEBUG)).containsOnly("Cross project duplication is enabled");
+    assertThat(logTester.logs(Level.DEBUG)).containsOnly("Cross project duplication is enabled");
   }
 
   @Test
@@ -59,7 +65,7 @@ public class CrossProjectDuplicationStatusHolderImplTest {
     underTest.start();
 
     assertThat(underTest.isEnabled()).isFalse();
-    assertThat(logTester.logs(LoggerLevel.DEBUG)).containsOnly("Cross project duplication is disabled because it's disabled in the analysis report");
+    assertThat(logTester.logs(Level.DEBUG)).containsOnly("Cross project duplication is disabled because it's disabled in the analysis report");
   }
 
   @Test
@@ -70,7 +76,7 @@ public class CrossProjectDuplicationStatusHolderImplTest {
     underTest.start();
 
     assertThat(underTest.isEnabled()).isFalse();
-    assertThat(logTester.logs(LoggerLevel.DEBUG)).containsOnly("Cross project duplication is disabled because of a branch is used");
+    assertThat(logTester.logs(Level.DEBUG)).containsOnly("Cross project duplication is disabled because of a branch is used");
   }
 
   @Test
@@ -81,7 +87,7 @@ public class CrossProjectDuplicationStatusHolderImplTest {
     underTest.start();
 
     assertThat(underTest.isEnabled()).isFalse();
-    assertThat(logTester.logs(LoggerLevel.DEBUG)).containsOnly("Cross project duplication is disabled because it's disabled in the analysis report");
+    assertThat(logTester.logs(Level.DEBUG)).containsOnly("Cross project duplication is disabled because it's disabled in the analysis report");
   }
 
   @Test
index 0238df2cd200e53f1daeca750fbaea873bcc8455..9e0c7ed63e6e978cd621483842db751800add1fa 100644 (file)
@@ -25,10 +25,10 @@ import java.util.Collection;
 import java.util.Collections;
 import org.junit.Rule;
 import org.junit.Test;
+import org.slf4j.event.Level;
 import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.impl.utils.TestSystem2;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.ce.task.log.CeTaskMessages;
 import org.sonar.ce.task.projectanalysis.component.Component;
 import org.sonar.ce.task.projectanalysis.component.FileAttributes;
@@ -296,7 +296,7 @@ public class IntegrateCrossProjectDuplicationsTest {
 
     underTest.computeCpd(ORIGIN_FILE, originBlocks, duplicatedBlocks);
 
-    assertThat(logTester.logs(LoggerLevel.WARN)).containsOnly(
+    assertThat(logTester.logs(Level.WARN)).containsOnly(
       "Too many duplication references on file " + ORIGIN_FILE_KEY + " for block at line 30. Keeping only the first 100 references.");
     Iterable<Duplication> duplications = duplicationRepository.getDuplications(ORIGIN_FILE);
     assertThat(duplications).hasSize(1);
@@ -331,7 +331,7 @@ public class IntegrateCrossProjectDuplicationsTest {
     underTest.computeCpd(ORIGIN_FILE, originBlocks, duplicatedBlocks);
 
     assertThat(duplicationRepository.getDuplications(ORIGIN_FILE)).hasSize(100);
-    assertThat(logTester.logs(LoggerLevel.WARN)).containsOnly("Too many duplication groups on file " + ORIGIN_FILE_KEY + ". Keeping only the first 100 groups.");
+    assertThat(logTester.logs(Level.WARN)).containsOnly("Too many duplication groups on file " + ORIGIN_FILE_KEY + ". Keeping only the first 100 groups.");
   }
 
   @Test
index f3c69f54a1dfdf04838355f22192802f96aa3ba9..286f9ce04b6fe0db048d6508e326856d883cef59 100644 (file)
@@ -21,10 +21,11 @@ package org.sonar.ce.task.projectanalysis.issue;
 
 import java.util.Arrays;
 import javax.annotation.Nullable;
+import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
+import org.slf4j.event.Level;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.ce.task.projectanalysis.analysis.AnalysisMetadataHolderRule;
 import org.sonar.ce.task.projectanalysis.component.Component;
 import org.sonar.ce.task.projectanalysis.scm.Changeset;
@@ -59,6 +60,11 @@ public class IssueAssignerTest {
   private DefaultAssignee defaultAssignee = mock(DefaultAssignee.class);
   private IssueAssigner underTest = new IssueAssigner(analysisMetadataHolder, scmInfoRepository, scmAccountToUser, defaultAssignee, new IssueFieldsSetter());
 
+  @Before
+  public void before() {
+    logTester.setLevel(Level.DEBUG);
+  }
+
   @Test
   public void do_not_set_author_if_no_changeset() {
     DefaultIssue issue = newIssueOnLines(1);
@@ -101,7 +107,7 @@ public class IssueAssignerTest {
     assertThat(issue.authorLogin()).isNull();
     assertThat(issue.assignee()).isEqualTo("John C");
 
-    assertThat(logTester.logs(LoggerLevel.DEBUG)).contains("SCM account '" + scmAuthor + "' is too long to be stored as issue author");
+    assertThat(logTester.logs(Level.DEBUG)).contains("SCM account '" + scmAuthor + "' is too long to be stored as issue author");
   }
 
   @Test
index ccc3f0d0ce7265812b7806d1a80eb4fe6eef7dbd..8ce7b773f6663173903139cb51ed974252de3739 100644 (file)
@@ -21,9 +21,11 @@ package org.sonar.ce.task.projectanalysis.metric;
 
 import com.google.common.collect.ImmutableSet;
 import java.util.Collections;
+import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
-import org.sonar.api.utils.log.LogTester;
+import org.slf4j.event.Level;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.api.utils.log.LoggerLevel;
 import org.sonar.core.metric.ScannerMetrics;
 
@@ -42,6 +44,11 @@ public class ReportMetricValidatorImplTest {
 
   ScannerMetrics scannerMetrics = mock(ScannerMetrics.class);
 
+  @Before
+  public void before() {
+    logTester.setLevel(Level.DEBUG);
+  }
+
   @Test
   public void validate_metric() {
     when(scannerMetrics.getMetrics()).thenReturn(ImmutableSet.of(new Builder(METRIC_KEY, "name", ValueType.INT).create()));
index 869ac7b70dfb5a566a91e95d976cf3d7a6ae8bfa..b997411125fdfab4bd75032da9225aef0d704175 100644 (file)
@@ -32,7 +32,7 @@ import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.sonar.api.utils.log.LogTester;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.ce.task.projectanalysis.analysis.AnalysisMetadataHolderRule;
 import org.sonar.ce.task.projectanalysis.batch.BatchReportReader;
 import org.sonar.ce.task.projectanalysis.batch.BatchReportReaderRule;
@@ -55,7 +55,7 @@ import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.verifyNoInteractions;
 import static org.mockito.Mockito.verifyNoMoreInteractions;
 import static org.mockito.Mockito.when;
-import static org.sonar.api.utils.log.LoggerLevel.TRACE;
+import static org.slf4j.event.Level.TRACE;
 import static org.sonar.ce.task.projectanalysis.component.ReportComponent.builder;
 
 @RunWith(DataProviderRunner.class)
@@ -82,6 +82,7 @@ public class ScmInfoRepositoryImplTest {
 
   @Before
   public void setUp() {
+    logTester.setLevel(TRACE);
     analysisMetadata.setAnalysisDate(analysisDate);
   }
 
index 46af56a837746f8650f44b4539f734e0ad642c0f..e848618c6179f12839520f8fe7409c3ef4127d86 100644 (file)
@@ -24,9 +24,11 @@ import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 import java.util.Random;
+import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
-import org.sonar.api.utils.log.LogTester;
+import org.slf4j.event.Level;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.ce.task.projectanalysis.component.Component;
 import org.sonar.ce.task.projectanalysis.source.linereader.RangeOffsetConverter.RangeOffsetConverterException;
 import org.sonar.db.protobuf.DbFileSources;
@@ -39,7 +41,7 @@ import static org.assertj.core.api.Assertions.assertThat;
 import static org.mockito.Mockito.doThrow;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
-import static org.sonar.api.utils.log.LoggerLevel.DEBUG;
+import static org.slf4j.event.Level.DEBUG;
 import static org.sonar.ce.task.projectanalysis.component.ReportComponent.builder;
 import static org.sonar.ce.task.projectanalysis.source.linereader.LineReader.Data.HIGHLIGHTING;
 import static org.sonar.db.protobuf.DbFileSources.Data.newBuilder;
@@ -77,6 +79,11 @@ public class HighlightingLineReaderTest {
   private DbFileSources.Line.Builder line3 = sourceData.addLinesBuilder().setSource("line3").setLine(3);
   private DbFileSources.Line.Builder line4 = sourceData.addLinesBuilder().setSource("line4").setLine(4);
 
+  @Before
+  public void before() {
+    logTester.setLevel(Level.TRACE);
+  }
+
   @Test
   public void nothing_to_read() {
     HighlightingLineReader highlightingLineReader = newReader(Collections.emptyMap());
index e5080fbf33b3bdd3226179a85b74f71900f099fb..ff88d25ad460677cb2741fc6d3441cd5f66e3ed7 100644 (file)
@@ -22,7 +22,7 @@ package org.sonar.ce.task.projectanalysis.source.linereader;
 import java.util.Arrays;
 import org.junit.Rule;
 import org.junit.Test;
-import org.sonar.api.utils.log.LogTester;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.ce.task.projectanalysis.component.Component;
 import org.sonar.db.protobuf.DbFileSources;
 import org.sonar.scanner.protocol.output.ScannerReport;
@@ -32,7 +32,7 @@ import static org.assertj.core.api.Assertions.assertThat;
 import static org.mockito.Mockito.doThrow;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
-import static org.sonar.api.utils.log.LoggerLevel.WARN;
+import static org.slf4j.event.Level.WARN;
 import static org.sonar.ce.task.projectanalysis.component.ReportComponent.builder;
 import static org.sonar.ce.task.projectanalysis.source.linereader.LineReader.Data.SYMBOLS;
 
index 37aa45944333e44a44ade1e51c545882ea98bf94..69e330b328e0d43029a6b3086098a5db3e02f382 100644 (file)
@@ -23,7 +23,8 @@ import java.util.List;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
-import org.sonar.api.utils.log.LogTester;
+import org.slf4j.event.Level;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.api.utils.log.LoggerLevel;
 import org.sonar.ce.task.ChangeLogLevel;
 import org.sonar.ce.task.projectanalysis.component.Component;
@@ -71,6 +72,7 @@ public class ExecuteVisitorsStepTest {
 
   @Before
   public void setUp() throws Exception {
+    logTester.setLevel(Level.DEBUG);
     treeRootHolder.setRoot(
       builder(PROJECT, ROOT_REF).setKey("project")
         .addChildren(
@@ -126,7 +128,7 @@ public class ExecuteVisitorsStepTest {
 
       underTest.execute(new TestComputationStepContext());
 
-      List<String> logs = logTester.logs(LoggerLevel.DEBUG);
+      List<String> logs = logTester.logs(Level.DEBUG);
       assertThat(logs).hasSize(4);
       assertThat(logs.get(0)).isEqualTo("  Execution time for each component visitor:");
       assertThat(logs.get(1)).startsWith("  - VisitorA | time=");
index 52f1db477f1d02699f6aff54720390562b81b1cf..1fc8f316d0c011acc8949059af3aee2e157e7986 100644 (file)
@@ -24,9 +24,9 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 import org.junit.Test;
+import org.slf4j.event.Level;
 import org.sonar.api.rule.RuleKey;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.ce.task.projectexport.steps.DumpElement;
 import org.sonar.ce.task.projectexport.steps.FakeDumpWriter;
 import org.sonar.ce.task.step.TestComputationStepContext;
@@ -75,11 +75,12 @@ public class ExportRuleStepTest {
 
   @Test
   public void execute_logs_number_total_exported_rules_count_when_successful() {
+    logTester.setLevel(Level.DEBUG);
     ruleRepository.add("A").add("B").add("C").add("D");
 
     underTest.execute(new TestComputationStepContext());
 
-    assertThat(logTester.logs(LoggerLevel.DEBUG)).containsExactly("4 rules exported");
+    assertThat(logTester.logs(Level.DEBUG)).containsExactly("4 rules exported");
   }
 
   @Test
index 4be0c7d6aa55058817b019d076966333e90cc622..54990a5c94e3ed91b9f394903b9077c33a25fa23 100644 (file)
@@ -26,9 +26,9 @@ import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.TemporaryFolder;
+import org.slf4j.event.Level;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.api.utils.TempFolder;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
 import org.sonar.ce.task.projectexport.taskprocessor.ProjectDescriptor;
 import org.sonar.ce.task.projectexport.util.ProjectExportDumpFS;
 
@@ -91,7 +91,7 @@ public class DumpWriterImplTest {
 
     assertThat(rootDir).doesNotExist();
     assertThat(targetZipFile).isFile().exists();
-    assertThat(logTester.logs(LoggerLevel.INFO).get(0))
+    assertThat(logTester.logs(Level.INFO).get(0))
       .contains("Dump file published", "size=", "path=" + targetZipFile.getAbsolutePath());
   }
 
index 9e26038fce2844f70057f5d9244c21835dd773a9..5ddb0d3984358d38421ed8f09e627ba10d2a975e 100644 (file)
@@ -23,10 +23,11 @@ import com.sonarsource.governance.projectdump.protobuf.ProjectDump;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
+import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
+import org.slf4j.event.Level;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.ce.task.step.TestComputationStepContext;
 import org.sonar.core.platform.PluginInfo;
 import org.sonar.core.platform.PluginRepository;
@@ -46,6 +47,11 @@ public class ExportPluginsStepTest {
   private FakeDumpWriter dumpWriter = new FakeDumpWriter();
   ExportPluginsStep underTest = new ExportPluginsStep(pluginRepository, dumpWriter);
 
+  @Before
+  public void before() {
+    logTester.setLevel(Level.DEBUG);
+  }
+
   @Test
   public void export_plugins() {
     when(pluginRepository.getPluginInfos()).thenReturn(Arrays.asList(
@@ -56,7 +62,7 @@ public class ExportPluginsStepTest {
     List<ProjectDump.Plugin> exportedPlugins = dumpWriter.getWrittenMessagesOf(DumpElement.PLUGINS);
     assertThat(exportedPlugins).hasSize(2);
     assertThat(exportedPlugins).extracting(ProjectDump.Plugin::getKey).containsExactlyInAnyOrder("java", "cs");
-    assertThat(logTester.logs(LoggerLevel.DEBUG)).contains("2 plugins exported");
+    assertThat(logTester.logs(Level.DEBUG)).contains("2 plugins exported");
   }
 
   @Test
@@ -66,7 +72,7 @@ public class ExportPluginsStepTest {
     underTest.execute(new TestComputationStepContext());
 
     assertThat(dumpWriter.getWrittenMessagesOf(DumpElement.PLUGINS)).isEmpty();
-    assertThat(logTester.logs(LoggerLevel.DEBUG)).contains("0 plugins exported");
+    assertThat(logTester.logs(Level.DEBUG)).contains("0 plugins exported");
   }
 
   @Test
index c8d51225ef2089ecf44053c9cee1e3af3ee1b313..c7d1127bc1d3ddcd49ad68791624d14b7734abf3 100644 (file)
@@ -38,6 +38,7 @@ dependencies {
   testImplementation 'org.assertj:assertj-guava'
   testImplementation 'org.mockito:mockito-core'
   testImplementation 'org.reflections:reflections'
+  testImplementation 'org.sonarsource.api.plugin:sonar-plugin-api-test-fixtures'
   testImplementation testFixtures(project(':server:sonar-db-dao'))
 
   testFixturesApi 'org.assertj:assertj-core'
index 0b8cde761608fbb03b4ffa8cb915d5917759e5fa..1af78cdac9f0f9ced79fff8a5a49c21672ab47b1 100644 (file)
@@ -24,7 +24,8 @@ import java.util.List;
 import org.junit.Rule;
 import org.junit.Test;
 import org.mockito.InOrder;
-import org.sonar.api.utils.log.LogTester;
+import org.slf4j.event.Level;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.api.utils.log.LoggerLevel;
 import org.sonar.ce.task.CeTaskInterrupter;
 import org.sonar.ce.task.ChangeLogLevel;
@@ -96,7 +97,7 @@ public class ComputationStepExecutorTest {
       ChangeLogLevel logLevel3 = new ChangeLogLevel(step3.getClass(), LoggerLevel.INFO)) {
       new ComputationStepExecutor(mockComputationSteps(step1, step2, step3), taskInterrupter).execute();
 
-      List<String> infoLogs = logTester.logs(LoggerLevel.INFO);
+      List<String> infoLogs = logTester.logs(Level.INFO);
       assertThat(infoLogs).hasSize(3);
       assertThat(infoLogs.get(0)).contains("Step One | foo=100 | bar=20 | status=SUCCESS | time=");
       assertThat(infoLogs.get(1)).contains("Step Two | foo=50 | baz=10 | status=SUCCESS | time=");
@@ -126,7 +127,7 @@ public class ComputationStepExecutorTest {
         new ComputationStepExecutor(mockComputationSteps(step1, step2, step3), taskInterrupter).execute();
         fail("a RuntimeException should have been thrown");
       } catch (RuntimeException e) {
-        List<String> infoLogs = logTester.logs(LoggerLevel.INFO);
+        List<String> infoLogs = logTester.logs(Level.INFO);
         assertThat(infoLogs).hasSize(3);
         assertThat(infoLogs.get(0)).contains("Step One | foo=100 | bar=20 | status=SUCCESS | time=");
         assertThat(infoLogs.get(1)).contains("Step Two | foo=50 | baz=10 | status=SUCCESS | time=");
index acdf2dafb0003c3f86b944824da74cf37db095dd..6e36ace52a934fa06f404e2f36ccef8f76f25bf9 100644 (file)
@@ -33,6 +33,7 @@ dependencies {
   testImplementation 'org.awaitility:awaitility'
   testImplementation 'org.mockito:mockito-core'
   testImplementation 'org.slf4j:slf4j-api'
+  testImplementation 'org.sonarsource.api.plugin:sonar-plugin-api-test-fixtures'
 
   testImplementation testFixtures(project(':server:sonar-db-dao'))
 
index 282ade6bb62343f05c65b8ba83507fd83b9868b0..86057fc7889ad5379f4678994b19a959e8ec18cd 100644 (file)
@@ -30,7 +30,7 @@ import org.junit.Test;
 import org.sonar.api.config.Configuration;
 import org.sonar.api.impl.utils.AlwaysIncreasingSystem2;
 import org.sonar.api.utils.System2;
-import org.sonar.api.utils.log.LogTester;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.core.config.ComputeEngineProperties;
 import org.sonar.db.DbTester;
 import org.sonar.db.ce.CeQueueDto;
index f0acbec6aa29d3af3540e2e2841dfb77c540fb2c..9e98bd98d8176f930a8338b404d6fba01a5133bb 100644 (file)
@@ -36,11 +36,12 @@ import org.junit.Test;
 import org.mockito.ArgumentCaptor;
 import org.mockito.InOrder;
 import org.mockito.stubbing.Answer;
+import org.slf4j.event.Level;
 import org.sonar.api.impl.utils.TestSystem2;
+import org.sonar.api.testfixtures.log.LogAndArguments;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.api.utils.MessageException;
 import org.sonar.api.utils.System2;
-import org.sonar.api.utils.log.LogAndArguments;
-import org.sonar.api.utils.log.LogTester;
 import org.sonar.api.utils.log.LoggerLevel;
 import org.sonar.ce.queue.InternalCeQueue;
 import org.sonar.ce.task.CeTask;
@@ -259,7 +260,7 @@ public class CeWorkerImplIT {
 
     underTest.call();
 
-    List<String> logs = logTester.logs(LoggerLevel.INFO);
+    List<String> logs = logTester.logs(Level.INFO);
     assertThat(logs).hasSize(2);
     for (int i = 0; i < 2; i++) {
       assertThat(logs.get(i)).contains("pullRequest=123");
@@ -275,7 +276,7 @@ public class CeWorkerImplIT {
     underTest.call();
 
     verifyWorkerUuid();
-    List<String> logs = logTester.logs(LoggerLevel.INFO);
+    List<String> logs = logTester.logs(Level.INFO);
     assertThat(logs).hasSize(2);
     for (int i = 0; i < 2; i++) {
       assertThat(logs.get(i)).doesNotContain("submitter=");
@@ -292,14 +293,14 @@ public class CeWorkerImplIT {
     underTest.call();
 
     verifyWorkerUuid();
-    List<String> logs = logTester.logs(LoggerLevel.INFO);
+    List<String> logs = logTester.logs(Level.INFO);
     assertThat(logs).hasSize(2);
     assertThat(logs.get(0)).doesNotContain("submitter=");
     assertThat(logs.get(1)).doesNotContain("submitter=");
-    logs = logTester.logs(LoggerLevel.ERROR);
+    logs = logTester.logs(Level.ERROR);
     assertThat(logs).hasSize(1);
     assertThat(logs.iterator().next()).doesNotContain("submitter=");
-    assertThat(logTester.logs(LoggerLevel.DEBUG)).isEmpty();
+    assertThat(logTester.logs(Level.DEBUG)).isEmpty();
   }
 
   @Test
@@ -311,12 +312,12 @@ public class CeWorkerImplIT {
     underTest.call();
 
     verifyWorkerUuid();
-    List<String> logs = logTester.logs(LoggerLevel.INFO);
+    List<String> logs = logTester.logs(Level.INFO);
     assertThat(logs).hasSize(2);
     assertThat(logs.get(0)).contains(String.format("submitter=%s", userDto.getLogin()));
     assertThat(logs.get(1)).contains(String.format("submitter=%s | status=SUCCESS | time=", userDto.getLogin()));
-    assertThat(logTester.logs(LoggerLevel.ERROR)).isEmpty();
-    assertThat(logTester.logs(LoggerLevel.DEBUG)).isEmpty();
+    assertThat(logTester.logs(Level.ERROR)).isEmpty();
+    assertThat(logTester.logs(Level.DEBUG)).isEmpty();
   }
 
   @Test
@@ -327,12 +328,12 @@ public class CeWorkerImplIT {
     underTest.call();
 
     verifyWorkerUuid();
-    List<String> logs = logTester.logs(LoggerLevel.INFO);
+    List<String> logs = logTester.logs(Level.INFO);
     assertThat(logs).hasSize(2);
     assertThat(logs.get(0)).contains("submitter=UUID_USER");
     assertThat(logs.get(1)).contains("submitter=UUID_USER | status=SUCCESS | time=");
-    assertThat(logTester.logs(LoggerLevel.ERROR)).isEmpty();
-    assertThat(logTester.logs(LoggerLevel.DEBUG)).isEmpty();
+    assertThat(logTester.logs(Level.ERROR)).isEmpty();
+    assertThat(logTester.logs(Level.DEBUG)).isEmpty();
   }
 
   @Test
@@ -346,11 +347,11 @@ public class CeWorkerImplIT {
     underTest.call();
 
     verifyWorkerUuid();
-    List<String> logs = logTester.logs(LoggerLevel.INFO);
+    List<String> logs = logTester.logs(Level.INFO);
     assertThat(logs).hasSize(2);
     assertThat(logs.get(0)).contains(String.format("submitter=%s", userDto.getLogin()));
     assertThat(logs.get(1)).contains(String.format("submitter=%s | status=FAILED | time=", userDto.getLogin()));
-    logs = logTester.logs(LoggerLevel.ERROR);
+    logs = logTester.logs(Level.ERROR);
     assertThat(logs).hasSize(1);
     assertThat(logs.get(0)).isEqualTo("Failed to execute task " + ceTask.getUuid());
   }
@@ -365,12 +366,12 @@ public class CeWorkerImplIT {
     underTest.call();
 
     verifyWorkerUuid();
-    List<String> logs = logTester.logs(LoggerLevel.INFO);
+    List<String> logs = logTester.logs(Level.INFO);
     assertThat(logs).hasSize(2);
     assertThat(logs.get(0)).contains(" | submitter=" + submitter.login());
     assertThat(logs.get(1)).contains(String.format(" | submitter=%s | status=SUCCESS | time=", submitter.login()));
-    assertThat(logTester.logs(LoggerLevel.ERROR)).isEmpty();
-    assertThat(logTester.logs(LoggerLevel.DEBUG)).isEmpty();
+    assertThat(logTester.logs(Level.ERROR)).isEmpty();
+    assertThat(logTester.logs(Level.DEBUG)).isEmpty();
   }
 
   @Test
@@ -385,14 +386,14 @@ public class CeWorkerImplIT {
     underTest.call();
 
     verifyWorkerUuid();
-    List<String> logs = logTester.logs(LoggerLevel.INFO);
+    List<String> logs = logTester.logs(Level.INFO);
     assertThat(logs).hasSize(2);
     assertThat(logs.get(0)).contains(" | submitter=" + submitter.login());
     assertThat(logs.get(1)).contains(String.format(" | submitter=%s | status=FAILED | time=", submitter.login()));
-    logs = logTester.logs(LoggerLevel.ERROR);
+    logs = logTester.logs(Level.ERROR);
     assertThat(logs).hasSize(1);
     assertThat(logs.iterator().next()).isEqualTo("Failed to execute task " + ceTask.getUuid());
-    assertThat(logTester.logs(LoggerLevel.DEBUG)).isEmpty();
+    assertThat(logTester.logs(Level.DEBUG)).isEmpty();
   }
 
   @Test
@@ -462,11 +463,11 @@ public class CeWorkerImplIT {
 
     underTest.call();
 
-    List<String> logs = logTester.logs(LoggerLevel.INFO);
+    List<String> logs = logTester.logs(Level.INFO);
     assertThat(logs).hasSize(2);
     assertThat(logs.get(0)).contains(" | submitter=" + submitter.login());
     assertThat(logs.get(1)).contains(String.format(" | submitter=%s | status=FAILED | time=", submitter.login()));
-    logs = logTester.logs(LoggerLevel.ERROR);
+    logs = logTester.logs(Level.ERROR);
     assertThat(logs).hasSize(1);
     assertThat(logs.iterator().next()).isEqualTo("Failed to execute task " + ceTask.getUuid());
   }
@@ -480,11 +481,11 @@ public class CeWorkerImplIT {
 
     underTest.call();
 
-    List<String> logs = logTester.logs(LoggerLevel.INFO);
+    List<String> logs = logTester.logs(Level.INFO);
     assertThat(logs).hasSize(2);
     assertThat(logs.get(1)).contains(" | submitter=" + submitter.login());
     assertThat(logs.get(1)).contains(String.format(" | submitter=%s | status=FAILED | time=", submitter.login()));
-    assertThat(logTester.logs(LoggerLevel.ERROR)).isEmpty();
+    assertThat(logTester.logs(Level.ERROR)).isEmpty();
   }
 
   @Test
@@ -496,7 +497,7 @@ public class CeWorkerImplIT {
 
     underTest.call();
 
-    assertThat(logTester.logs(LoggerLevel.ERROR)).containsOnly("Failed to finalize task with uuid '" + ceTask.getUuid() + "' and persist its state to db");
+    assertThat(logTester.logs(Level.ERROR)).containsOnly("Failed to finalize task with uuid '" + ceTask.getUuid() + "' and persist its state to db");
   }
 
   @Test
@@ -510,22 +511,18 @@ public class CeWorkerImplIT {
 
     underTest.call();
 
-    List<String> logs = logTester.logs(LoggerLevel.INFO);
+    List<String> logs = logTester.logs(Level.INFO);
     assertThat(logs).hasSize(2);
     assertThat(logs.get(0)).contains(" | submitter=" + submitter.login());
     assertThat(logs.get(1)).contains(String.format(" | submitter=%s | status=FAILED | time=", submitter.login()));
-    List<LogAndArguments> logAndArguments = logTester.getLogs(LoggerLevel.ERROR);
+    List<LogAndArguments> logAndArguments = logTester.getLogs(Level.ERROR);
     assertThat(logAndArguments).hasSize(2);
 
     LogAndArguments executionErrorLog = logAndArguments.get(0);
     assertThat(executionErrorLog.getFormattedMsg()).isEqualTo("Failed to execute task " + ceTask.getUuid());
-    assertThat(executionErrorLog.getArgs().get()).containsOnly(ceTask.getUuid(), ex);
 
     LogAndArguments finalizingErrorLog = logAndArguments.get(1);
     assertThat(finalizingErrorLog.getFormattedMsg()).isEqualTo("Failed to finalize task with uuid '" + ceTask.getUuid() + "' and persist its state to db");
-    Object arg1 = finalizingErrorLog.getArgs().get()[0];
-    assertThat(arg1).isSameAs(runtimeException);
-    assertThat(((Exception) arg1).getSuppressed()).containsOnly(ex);
   }
 
   @Test
@@ -539,16 +536,13 @@ public class CeWorkerImplIT {
 
     underTest.call();
 
-    List<String> logs = logTester.logs(LoggerLevel.INFO);
+    List<String> logs = logTester.logs(Level.INFO);
     assertThat(logs).hasSize(2);
     assertThat(logs.get(0)).contains(" | submitter=" + submitter.login());
     assertThat(logs.get(1)).contains(String.format(" | submitter=%s | status=FAILED | time=", submitter.login()));
-    List<LogAndArguments> logAndArguments = logTester.getLogs(LoggerLevel.ERROR);
+    List<LogAndArguments> logAndArguments = logTester.getLogs(Level.ERROR);
     assertThat(logAndArguments).hasSize(1);
     assertThat(logAndArguments.get(0).getFormattedMsg()).isEqualTo("Failed to finalize task with uuid '" + ceTask.getUuid() + "' and persist its state to db");
-    Object arg1 = logAndArguments.get(0).getArgs().get()[0];
-    assertThat(arg1).isSameAs(runtimeException);
-    assertThat(((Exception) arg1).getSuppressed()).containsOnly(ex);
   }
 
   @Test
index 70ffcfcd9401c3b5abd6226ead37071fa5bffdaa..5a95ae061edd65da5ea73e3e42f3e6600fe6ea63 100644 (file)
@@ -21,9 +21,9 @@ package org.sonar.ce.configuration;
 
 import org.junit.Rule;
 import org.junit.Test;
+import org.slf4j.event.Level;
 import org.sonar.api.config.internal.MapSettings;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
+import org.sonar.api.testfixtures.log.LogTester;
 
 import static org.apache.commons.lang.RandomStringUtils.randomAlphabetic;
 import static org.assertj.core.api.Assertions.assertThat;
@@ -64,7 +64,7 @@ public class CeWorkerCountSettingWarningTest {
 
   private void verifyWarnMessage() {
     assertThat(logTester.logs()).hasSize(1);
-    assertThat(logTester.logs(LoggerLevel.WARN)).containsOnly("Property sonar.ce.workerCount is not supported anymore and will be ignored." +
+    assertThat(logTester.logs(Level.WARN)).containsOnly("Property sonar.ce.workerCount is not supported anymore and will be ignored." +
       " Remove it from sonar.properties to remove this warning.");
   }
 }
index ec9a4db651e3f17314e142bb9ae8cdfee620be9e..8f627de253eebcd44999d42e9a0346f4345ce8d7 100644 (file)
@@ -22,8 +22,8 @@ package org.sonar.ce.taskprocessor;
 import java.util.Random;
 import org.junit.Rule;
 import org.junit.Test;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
+import org.slf4j.event.Level;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.ce.configuration.CeConfigurationRule;
 
 import static org.assertj.core.api.Assertions.assertThat;
@@ -166,7 +166,7 @@ public class CeWorkerControllerImplTest {
 
   private void verifyInfoLog(int workerCount) {
     assertThat(logTester.logs()).hasSize(1);
-    assertThat(logTester.logs(LoggerLevel.INFO))
+    assertThat(logTester.logs(Level.INFO))
       .containsOnly("Compute Engine will use " + workerCount + " concurrent workers to process tasks");
   }
 }
index 1e675d6e58e8d6f115a3f7d3e4836ebda01af588..730094c98642b777d2d0327dbfaaedcfaf5cd15a 100644 (file)
@@ -23,9 +23,9 @@ import java.util.Optional;
 import java.util.Random;
 import org.junit.Rule;
 import org.junit.Test;
+import org.slf4j.event.Level;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.api.utils.System2;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
 import org.sonar.ce.task.CeTask;
 import org.sonar.ce.task.CeTaskCanceledException;
 import org.sonar.ce.task.CeTaskTimeoutException;
@@ -71,7 +71,7 @@ public class TimeoutCeTaskInterrupterTest {
     new TimeoutCeTaskInterrupter(timeout, ceWorkerController, system2);
 
     assertThat(logTester.logs()).hasSize(1);
-    assertThat(logTester.logs(LoggerLevel.INFO))
+    assertThat(logTester.logs(Level.INFO))
       .containsExactly("Compute Engine Task timeout enabled: " + timeout + " ms");
   }
 
index 5413fef01b005df58ae88ec2e8d914e1b21b8458..cc70946e9fdcf365704c1cab4ebdfb4609b55797 100644 (file)
@@ -28,6 +28,7 @@ dependencies {
   testImplementation 'com.tngtech.java:junit-dataprovider'
   testImplementation 'org.mockito:mockito-core'
   testImplementation 'org.postgresql:postgresql'
+  testImplementation 'org.sonarsource.api.plugin:sonar-plugin-api-test-fixtures'
 
   testImplementation project(':sonar-testing-harness')
 
index 5fd95eb47e157f2ddb0e783ba2c86bff11321401..91763ab314ee024a170caf3fdb0aa91b1114ff6f 100644 (file)
@@ -36,8 +36,8 @@ import java.util.function.Function;
 import javax.annotation.Nullable;
 import org.junit.Rule;
 import org.junit.Test;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
+import org.slf4j.event.Level;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.api.utils.log.Loggers;
 import org.sonar.core.util.stream.MoreCollectors;
 import org.sonar.db.dialect.Oracle;
@@ -253,7 +253,7 @@ public class DatabaseUtilsIT {
 
     getDriver(connection);
 
-    assertThat(logTester.logs(LoggerLevel.WARN)).contains("Fail to determine database driver.");
+    assertThat(logTester.logs(Level.WARN)).contains("Fail to determine database driver.");
   }
 
   @Test
@@ -394,7 +394,7 @@ public class DatabaseUtilsIT {
 
     log(Loggers.get(getClass()), root);
 
-    assertThat(logTester.logs(LoggerLevel.ERROR)).contains("SQL error: 456. Message: this is next");
+    assertThat(logTester.logs(Level.ERROR)).contains("SQL error: 456. Message: this is next");
   }
 
   @Test
index 7093513823c6012b943999288b1321a1e760016a..068bc3ee00c0e12dba28d2fd3aa06da33e2d9280 100644 (file)
@@ -28,7 +28,7 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.sonar.api.config.internal.MapSettings;
-import org.sonar.api.utils.log.LogTester;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.db.dialect.PostgreSql;
 import org.sonar.process.logging.LogbackHelper;
 
index 75de6af28dcc8410be682213a7bf6e131aeb1c54..71ed8ac76932e50136cbfbae464c67d50edb2fda 100644 (file)
@@ -22,8 +22,8 @@ package org.sonar.db.dialect;
 import java.sql.DatabaseMetaData;
 import org.junit.Rule;
 import org.junit.Test;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
+import org.slf4j.event.Level;
+import org.sonar.api.testfixtures.log.LogTester;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.mockito.Mockito.mock;
@@ -73,7 +73,7 @@ public class H2Test {
   public void init_logs_warning() {
     underTest.init(mock(DatabaseMetaData.class));
 
-    assertThat(logs.logs(LoggerLevel.WARN)).contains("H2 database should be used for evaluation purpose only.");
+    assertThat(logs.logs(Level.WARN)).contains("H2 database should be used for evaluation purpose only.");
   }
 
   @Test
index e8450a657ff21098c0c02bb756f432d52bcf9c43..ac6553a4173b0cb7550d659ed16f2f68152388ec 100644 (file)
@@ -24,9 +24,9 @@ import java.sql.SQLException;
 import org.junit.Rule;
 import org.junit.Test;
 import org.mockito.Mockito;
+import org.slf4j.event.Level;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.api.utils.MessageException;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
@@ -95,7 +95,7 @@ public class PostgreSqlTest {
     underTest.init(metadata);
 
     assertThat(underTest.supportsUpsert()).isFalse();
-    assertThat(logs.logs(LoggerLevel.WARN)).contains("Upgrading PostgreSQL to 9.5 or greater is recommended for better performances");
+    assertThat(logs.logs(Level.WARN)).contains("Upgrading PostgreSQL to 9.5 or greater is recommended for better performances");
   }
 
   @Test
@@ -104,7 +104,7 @@ public class PostgreSqlTest {
     underTest.init(metadata);
 
     assertThat(underTest.supportsUpsert()).isTrue();
-    assertThat(logs.logs(LoggerLevel.WARN)).isEmpty();
+    assertThat(logs.logs(Level.WARN)).isEmpty();
   }
 
   @Test
index d7bac5f94ca428af401df2f153cc3dbbbca94923..6ac3a99ca8e8b622dc34338acb6fc05d525b2034 100644 (file)
@@ -34,7 +34,8 @@ import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.ThreadFactory;
 import org.junit.Rule;
 import org.junit.Test;
-import org.sonar.api.utils.log.LogTester;
+import org.slf4j.event.Level;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.api.utils.log.LoggerLevel;
 
 import static java.nio.charset.StandardCharsets.UTF_8;
@@ -70,8 +71,8 @@ public class ProfiledDataSourceTest {
     assertThat(statementProxy.getConnection()).isNull();
     assertThat(statementProxy.execute(sql)).isTrue();
 
-    assertThat(logTester.logs(LoggerLevel.TRACE)).hasSize(1);
-    assertThat(logTester.logs(LoggerLevel.TRACE).get(0))
+    assertThat(logTester.logs(Level.TRACE)).hasSize(1);
+    assertThat(logTester.logs(Level.TRACE).get(0))
       .contains("sql=select from dual");
   }
 
@@ -106,8 +107,8 @@ public class ProfiledDataSourceTest {
     assertThat(preparedStatementProxy.getConnection()).isNull();
     assertThat(preparedStatementProxy.execute()).isTrue();
 
-    assertThat(logTester.logs(LoggerLevel.TRACE)).hasSize(1);
-    assertThat(logTester.logs(LoggerLevel.TRACE).get(0))
+    assertThat(logTester.logs(Level.TRACE)).hasSize(1);
+    assertThat(logTester.logs(Level.TRACE).get(0))
       .contains("sql=insert into polop (col1, col2, col3, col4) values (?, ?, ?, ?, ?)")
       .contains("params=42, plouf");
   }
@@ -132,8 +133,8 @@ public class ProfiledDataSourceTest {
     assertThat(preparedStatementProxy.getConnection()).isNull();
     assertThat(preparedStatementProxy.execute()).isTrue();
 
-    assertThat(logTester.logs(LoggerLevel.TRACE)).hasSize(1);
-    assertThat(logTester.logs(LoggerLevel.TRACE).get(0))
+    assertThat(logTester.logs(Level.TRACE)).hasSize(1);
+    assertThat(logTester.logs(Level.TRACE).get(0))
       .contains("sql=select from dual")
       .doesNotContain("params=");
   }
index 9a2885a35dc64aa86d7426da30729b4d4e569522..c312242405ba7882b3e0b565d378b6cf63be0dd5 100644 (file)
@@ -28,6 +28,7 @@ dependencies {
   testImplementation 'org.assertj:assertj-guava'
   testImplementation 'org.mockito:mockito-core'
   testImplementation 'org.sonarsource.orchestrator:sonar-orchestrator'
+  testImplementation 'org.sonarsource.api.plugin:sonar-plugin-api-test-fixtures'
   testImplementation project(':sonar-testing-harness')
   testImplementation project(':sonar-plugin-api-impl')
 
index 1f422b341c1850e475db6d2b736fe8d114d0b3a8..9fe5a6afc2bb34e98e81e906ce665ca9bb06a75c 100644 (file)
@@ -37,8 +37,8 @@ import org.junit.After;
 import org.junit.Rule;
 import org.junit.Test;
 import org.mockito.Mockito;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
+import org.slf4j.event.Level;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.core.util.stream.MoreCollectors;
 
 import static java.lang.Math.abs;
@@ -484,7 +484,7 @@ public class DBSessionsImplTest {
 
     underTest.disableCaching();
 
-    List<String> errorLogs = logTester.logs(LoggerLevel.ERROR);
+    List<String> errorLogs = logTester.logs(Level.ERROR);
     assertThat(errorLogs)
       .hasSize(1)
       .containsOnly("Failed to close " + (batchOrRegular ? "batch" : "regular") + " connection in " + Thread.currentThread());
index e2dc94173dc0daaf82d76f5cd7b2e2f17d8cc0b4..510acdbed342c100c74c652896a6cd10c8f110ed 100644 (file)
@@ -28,6 +28,7 @@ dependencies {
   testImplementation 'org.mockito:mockito-core'
   testImplementation 'org.xmlunit:xmlunit-core'
   testImplementation 'org.xmlunit:xmlunit-matchers'
+  testImplementation 'org.sonarsource.api.plugin:sonar-plugin-api-test-fixtures'
   testImplementation project(':sonar-scanner-protocol')
   testImplementation project(':sonar-testing-harness')
   testImplementation testFixtures(project(':server:sonar-db-core'))
index 4616dcfe37784091ea42c92833ef7c9939bde5be..015a853b6596b65a3a5e9205c573d1a7486c8c8d 100644 (file)
@@ -27,8 +27,8 @@ import java.util.Iterator;
 import java.util.List;
 import org.junit.Rule;
 import org.junit.Test;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
+import org.slf4j.event.Level;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.core.platform.SpringComponentContainer;
 import org.sonar.server.platform.db.migration.engine.MigrationContainer;
 import org.sonar.server.platform.db.migration.engine.SimpleMigrationContainer;
@@ -53,7 +53,7 @@ public class MigrationStepsExecutorImplTest {
     underTest.execute(Collections.emptyList());
 
     assertThat(logTester.logs()).hasSize(2);
-    assertLogLevel(LoggerLevel.INFO, "Executing DB migrations...", "Executed DB migrations: success | time=");
+    assertLogLevel(Level.INFO, "Executing DB migrations...", "Executed DB migrations: success | time=");
   }
 
   @Test
@@ -68,12 +68,12 @@ public class MigrationStepsExecutorImplTest {
       assertThat(e).hasMessage("Unable to load component " + MigrationStep1.class);
     } finally {
       assertThat(logTester.logs()).hasSize(2);
-      assertLogLevel(LoggerLevel.INFO, "Executing DB migrations...");
-      assertLogLevel(LoggerLevel.ERROR, "Executed DB migrations: failure | time=");
+      assertLogLevel(Level.INFO, "Executing DB migrations...");
+      assertLogLevel(Level.ERROR, "Executed DB migrations: failure | time=");
     }
   }
 
-  private void assertLogLevel(LoggerLevel level, String... expected) {
+  private void assertLogLevel(Level level, String... expected) {
     List<String> logs = logTester.logs(level);
     assertThat(logs).hasSize(expected.length);
     Iterator<String> iterator = logs.iterator();
@@ -99,7 +99,7 @@ public class MigrationStepsExecutorImplTest {
     assertThat(SingleCallCheckerMigrationStep.calledSteps)
       .containsExactly(MigrationStep2.class, MigrationStep1.class, MigrationStep3.class);
     assertThat(logTester.logs()).hasSize(8);
-    assertLogLevel(LoggerLevel.INFO,
+    assertLogLevel(Level.INFO,
       "Executing DB migrations...",
       "#1 '1-MigrationStep2'...",
       "#1 '1-MigrationStep2': success | time=",
@@ -131,12 +131,12 @@ public class MigrationStepsExecutorImplTest {
       assertThat(e).hasCause(SqlExceptionFailingMigrationStep.THROWN_EXCEPTION);
     } finally {
       assertThat(logTester.logs()).hasSize(6);
-      assertLogLevel(LoggerLevel.INFO,
+      assertLogLevel(Level.INFO,
         "Executing DB migrations...",
         "#1 '1-MigrationStep2'...",
         "#1 '1-MigrationStep2': success | time=",
         "#2 '2-SqlExceptionFailingMigrationStep'...");
-      assertLogLevel(LoggerLevel.ERROR,
+      assertLogLevel(Level.ERROR,
         "#2 '2-SqlExceptionFailingMigrationStep': failure | time=",
         "Executed DB migrations: failure | time=");
     }
index 7bd3a481880948270c7bed47588e13fdb13d3869..f0c196d068ab8bf5d9e0e2c89a716bb4ef8be896 100644 (file)
@@ -23,8 +23,8 @@ import java.sql.SQLException;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
+import org.slf4j.event.Level;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.db.CoreDbTester;
 import org.sonar.server.platform.db.migration.step.DataChange;
 
@@ -57,7 +57,7 @@ public class LogMessageIfSonarScimEnabledPresentPropertyTest {
 
     underTest.execute();
 
-    assertThat(logger.logs(LoggerLevel.WARN))
+    assertThat(logger.logs(Level.WARN))
       .hasSize(1)
       .containsExactly("'" + SONAR_SCIM_ENABLED + "' property is defined but not read anymore. Please read the upgrade notes" +
         " for the instruction to upgrade. User provisioning is deactivated until reactivated from the SonarQube" +
@@ -70,7 +70,7 @@ public class LogMessageIfSonarScimEnabledPresentPropertyTest {
 
     underTest.execute();
 
-    assertThat(logger.logs(LoggerLevel.WARN)).isEmpty();
+    assertThat(logger.logs(Level.WARN)).isEmpty();
   }
 
   @Test
@@ -86,6 +86,6 @@ public class LogMessageIfSonarScimEnabledPresentPropertyTest {
     underTest.execute();
     underTest.execute();
 
-    assertThat(logger.logs(LoggerLevel.WARN)).hasSize(2);
+    assertThat(logger.logs(Level.WARN)).hasSize(2);
   }
 }
index 4f6caafbbb46214104f10cf18503beeb1f252c38..3b872c8cd3f0a7fdb06ba2424eb3d75ca5f6b39d 100644 (file)
@@ -38,6 +38,7 @@ dependencies {
   testImplementation 'org.assertj:assertj-core'
   testImplementation 'org.hamcrest:hamcrest-core'
   testImplementation 'org.mockito:mockito-core'
+  testImplementation 'org.sonarsource.api.plugin:sonar-plugin-api-test-fixtures'
   testImplementation testFixtures(project(':server:sonar-db-dao'))
   testImplementation project(':sonar-plugin-api-impl')
   testImplementation project(':sonar-testing-harness')
@@ -47,7 +48,6 @@ dependencies {
 
   testFixturesCompileOnly 'com.google.code.findbugs:jsr305'
   testFixturesImplementation 'org.elasticsearch.plugin:transport-netty4-client'
-
   testFixturesImplementation 'org.codelibs.elasticsearch.module:analysis-common'
   testFixturesImplementation 'org.codelibs.elasticsearch.module:reindex'
   testFixturesImplementation 'org.elasticsearch:mocksocket'
index 774e3bdc0a39a3970626d13d0cac905fe8f0af2a..7a9bac079fbebf05966f7f37645d42ea986e8b97 100644 (file)
@@ -33,8 +33,9 @@ import org.elasticsearch.index.query.QueryBuilders;
 import org.elasticsearch.search.builder.SearchSourceBuilder;
 import org.junit.Rule;
 import org.junit.Test;
+import org.slf4j.event.Level;
 import org.sonar.api.impl.utils.TestSystem2;
-import org.sonar.api.utils.log.LogTester;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.api.utils.log.LoggerLevel;
 import org.sonar.db.DbTester;
 import org.sonar.server.es.BulkIndexer.Size;
@@ -175,7 +176,7 @@ public class BulkIndexerIT {
     indexer.add(newIndexRequestWithDocId("bar"));
     indexer.stop();
 
-    assertThat(logTester.logs(LoggerLevel.TRACE)
+    assertThat(logTester.logs(Level.TRACE)
       .stream()
       .filter(log -> log.contains("Bulk[2 index requests on fakes/_doc, 1 delete requests on fakes/_doc]"))
       .count()).isNotZero();
index b5fadad5feec6e59492801f4773d68574771cef0..ed038aef32c0fb92f1e0cc9c5121debc18a7ad1f 100644 (file)
@@ -31,9 +31,9 @@ import org.assertj.core.api.Assertions;
 import org.elasticsearch.search.SearchHit;
 import org.junit.Rule;
 import org.junit.Test;
+import org.slf4j.event.Level;
 import org.sonar.api.resources.Qualifiers;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.db.DbSession;
 import org.sonar.db.DbTester;
 import org.sonar.db.component.BranchDto;
@@ -361,7 +361,7 @@ public class IssueIndexerIT {
 
     recover();
 
-    assertThat(logTester.logs(LoggerLevel.ERROR))
+    assertThat(logTester.logs(Level.ERROR))
       .filteredOn(l -> l.contains("Unsupported es_queue.doc_id_type for issues. Manual fix is required: "))
       .hasSize(1);
     assertThatEsQueueTableHasSize(1);
index e096598bfccf1f9cfe0912bebc9465bde169bed6..d03ba3698f83417a711e0d879b02e8a40880bf28 100644 (file)
@@ -31,11 +31,11 @@ import java.util.stream.Stream;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.slf4j.event.Level;
 import org.sonar.api.rule.RuleStatus;
 import org.sonar.api.rule.Severity;
 import org.sonar.api.rules.RuleType;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.core.util.UuidFactoryFast;
 import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
@@ -174,6 +174,7 @@ public class RuleIndexerIT {
   @Test
   @UseDataProvider("twoDifferentCategoriesButOTHERS")
   public void log_debug_if_hotspot_rule_maps_to_multiple_SQCategories(SQCategory sqCategory1, SQCategory sqCategory2) {
+    logTester.setLevel(Level.DEBUG);
     Set<String> standards = Stream.of(sqCategory1, sqCategory2)
       .flatMap(t -> CWES_BY_SQ_CATEGORY.get(t).stream().map(e -> "cwe:" + e))
       .collect(toSet());
@@ -183,9 +184,8 @@ public class RuleIndexerIT {
       .setSecurityStandards(standards));
     underTest.commitAndIndex(dbTester.getSession(), rule.getUuid());
 
-    assertThat(logTester.getLogs()).hasSize(1);
-    assertThat(logTester.logs(LoggerLevel.DEBUG).get(0))
-      .isEqualTo(format(
+    assertThat(logTester.logs(Level.DEBUG))
+      .contains(format(
         "Rule %s with CWEs '%s' maps to multiple SQ Security Categories: %s",
         rule.getKey(),
         String.join(", ", securityStandards.getCwe()),
index f671da1fb65ee0ea0ac0561b866356da49b006f1..cc932b1b8b6b5fc31fda9360c2fe7bd85759a267 100644 (file)
@@ -21,10 +21,12 @@ package org.sonar.server.webhook;
 
 import java.io.IOException;
 import java.util.List;
+import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
+import org.slf4j.event.Level;
 import org.sonar.api.ce.posttask.PostProjectAnalysisTask;
-import org.sonar.api.utils.log.LogTester;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.db.DbClient;
 import org.sonar.db.DbTester;
 import org.sonar.db.component.ComponentDbTester;
@@ -40,7 +42,7 @@ import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.verifyNoInteractions;
 import static org.mockito.Mockito.verifyNoMoreInteractions;
-import static org.sonar.api.utils.log.LoggerLevel.DEBUG;
+import static org.slf4j.event.Level.DEBUG;
 import static org.sonar.db.DbTester.create;
 import static org.sonar.db.webhook.WebhookTesting.newGlobalWebhook;
 import static org.sonar.db.webhook.WebhookTesting.newWebhook;
@@ -65,6 +67,11 @@ public class SynchronousWebHooksImplIT {
   private final PostProjectAnalysisTask.LogStatistics taskStatistics = mock(PostProjectAnalysisTask.LogStatistics.class);
   private final WebHooksImpl underTest = new WebHooksImpl(caller, deliveryStorage, synchronousAsyncExecution, dbClient);
 
+  @Before
+  public void before() {
+    logTester.setLevel(Level.DEBUG);
+  }
+
   @Test
   public void isEnabled_returns_false_if_no_webhooks() {
     ProjectDto projectDto = componentDbTester.insertPrivateProjectDto();
@@ -94,7 +101,7 @@ public class SynchronousWebHooksImplIT {
     underTest.sendProjectAnalysisUpdate(new WebHooks.Analysis(componentDto.uuid(), "1", "#1"), () -> mock);
 
     assertThat(caller.countSent()).isZero();
-    assertThat(logTester.logs(DEBUG)).isEmpty();
+    assertNoWebhookLogs();
     verifyNoInteractions(deliveryStorage);
   }
 
@@ -105,7 +112,7 @@ public class SynchronousWebHooksImplIT {
     underTest.sendProjectAnalysisUpdate(new WebHooks.Analysis(componentDto.uuid(), "1", "#1"), () -> mock, taskStatistics);
 
     assertThat(caller.countSent()).isZero();
-    assertThat(logTester.logs(DEBUG)).isEmpty();
+    assertNoWebhookLogs();
     verifyNoInteractions(deliveryStorage);
     verifyLogStatistics(0, 0);
   }
@@ -128,6 +135,12 @@ public class SynchronousWebHooksImplIT {
     verifyLogStatistics(2, 0);
   }
 
+  private void assertNoWebhookLogs() {
+    assertThat(logTester.logs(DEBUG))
+      .noneMatch(s -> s.contains("Sent webhook"))
+      .noneMatch(s -> s.contains("Failed to send webhook"));
+  }
+
   @Test
   public void send_project_webhooks() {
     ProjectDto projectDto = componentDbTester.insertPrivateProjectDto();
index e19e8bcdbddba01709a41c19074cda049c3be929..ff568d0c59c387890ade01c1c090de2953c11160 100644 (file)
@@ -21,8 +21,8 @@ package org.sonar.server.async;
 
 import org.junit.Rule;
 import org.junit.Test;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
+import org.slf4j.event.Level;
+import org.sonar.api.testfixtures.log.LogTester;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
@@ -47,7 +47,7 @@ public class AsyncExecutionImplTest {
     });
 
     assertThat(logTester.logs()).hasSize(1);
-    assertThat(logTester.logs(LoggerLevel.ERROR)).containsOnly("Asynchronous task failed");
+    assertThat(logTester.logs(Level.ERROR)).containsOnly("Asynchronous task failed");
   }
 
   @Test
index 1affd0240670ec4ff7caf7b6e314514d1a5143f6..329a3062ea1ff6da5dfffa05fa08c825f7d77759 100644 (file)
@@ -26,9 +26,9 @@ import org.elasticsearch.client.RestHighLevelClient;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
+import org.slf4j.event.Level;
 import org.sonar.api.config.internal.MapSettings;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
+import org.sonar.api.testfixtures.log.LogTester;
 
 import static java.lang.String.format;
 import static org.assertj.core.api.Assertions.assertThat;
@@ -71,7 +71,7 @@ public class EsClientProviderTest {
     assertThat(node.getHost().getAddress().getHostName()).isEqualTo(localhostHostname);
     assertThat(node.getHost().getPort()).isEqualTo(9000);
 
-    assertThat(logTester.logs(LoggerLevel.INFO)).has(new Condition<>(s -> s.contains("Connected to local Elasticsearch: [http://" + localhostHostname + ":9000]"), ""));
+    assertThat(logTester.logs(Level.INFO)).has(new Condition<>(s -> s.contains("Connected to local Elasticsearch: [http://" + localhostHostname + ":9000]"), ""));
   }
 
   @Test
@@ -92,7 +92,7 @@ public class EsClientProviderTest {
     assertThat(node.getHost().getAddress().getHostName()).isEqualTo(localhostHostname);
     assertThat(node.getHost().getPort()).isEqualTo(8081);
 
-    assertThat(logTester.logs(LoggerLevel.INFO))
+    assertThat(logTester.logs(Level.INFO))
       .has(new Condition<>(s -> s.contains("Connected to remote Elasticsearch: [http://" + localhostHostname + ":8080, http://" + localhostHostname + ":8081]"), ""));
   }
 
@@ -137,7 +137,7 @@ public class EsClientProviderTest {
     assertThat(node.getHost().getAddress().getHostName()).isEqualTo(localhostHostname);
     assertThat(node.getHost().getPort()).isEqualTo(8081);
 
-    assertThat(logTester.logs(LoggerLevel.INFO))
+    assertThat(logTester.logs(Level.INFO))
       .has(new Condition<>(s -> s.contains("Connected to remote Elasticsearch: [http://" + localhostHostname + ":9001, http://" + localhostHostname + ":8081]"), ""));
   }
 }
index c2f651e64c5cc37908b61db8d263cf5278ef4949..dec7aa5c539f00f9af6691e37169332ac9902510 100644 (file)
@@ -31,7 +31,7 @@ import org.junit.Test;
 import org.junit.rules.TemporaryFolder;
 import org.junit.runner.RunWith;
 import org.sonar.api.config.internal.MapSettings;
-import org.sonar.api.utils.log.LogTester;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.api.utils.log.LoggerLevel;
 import org.sonar.db.Database;
 import org.sonar.process.logging.LogLevelConfig;
index 3fde464ab52777d67068477682b8f0256293ff63..87354828934ca62dc3f41658bf6dbe0297695dc4 100644 (file)
@@ -29,7 +29,7 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.TemporaryFolder;
 import org.sonar.api.config.Configuration;
-import org.sonar.api.utils.log.LogTester;
+import org.sonar.api.testfixtures.log.LogTester;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
index 98bbd20b0f79f493e82b838476f24f08bc687029..454db86e6a5018cc2689e4165b763ff272aee577 100644 (file)
@@ -23,8 +23,8 @@ import java.util.HashMap;
 import java.util.Map;
 import org.junit.Rule;
 import org.junit.Test;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
+import org.slf4j.event.Level;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.core.platform.PluginInfo;
 import org.sonar.core.platform.PluginInfo.RequiredPlugin;
 import org.sonar.updatecenter.common.Version;
@@ -73,7 +73,7 @@ public class PluginRequirementsValidatorTest {
 
     assertThat(underTest.isCompatible(pluginWithoutBase)).isFalse();
     assertThat(underTest.isCompatible(pluginWithBase)).isTrue();
-    assertThat(logTester.logs(LoggerLevel.WARN))
+    assertThat(logTester.logs(Level.WARN))
       .contains("Plugin plugin-without-base-plugin [plugin-without-base-plugin] is ignored"
         + " because its base plugin [not-existing-base-plugin] is not installed");
   }
@@ -96,7 +96,7 @@ public class PluginRequirementsValidatorTest {
 
     assertThat(underTest.isCompatible(pluginWithoutRequired)).isFalse();
     assertThat(underTest.isCompatible(pluginWithRequired)).isTrue();
-    assertThat(logTester.logs(LoggerLevel.WARN))
+    assertThat(logTester.logs(Level.WARN))
       .contains("Plugin plugin-without-required-plugin [plugin-without-required-plugin] is ignored"
         + " because the required plugin [notexistingrequired] is not installed");
   }
@@ -119,7 +119,7 @@ public class PluginRequirementsValidatorTest {
 
     assertThat(underTest.isCompatible(pluginWithoutRequired)).isFalse();
     assertThat(underTest.isCompatible(pluginWithRequired)).isTrue();
-    assertThat(logTester.logs(LoggerLevel.WARN))
+    assertThat(logTester.logs(Level.WARN))
       .contains("Plugin plugin-without-required-plugin [plugin-without-required-plugin] is ignored"
         + " because the version 1.5 of required plugin [required] is not installed");
   }
index 18082686d5423752144d23105fbe9cdc34a180a3..8bec27044475ad55b0e3fb49bc003ec0d3b8a61d 100644 (file)
@@ -35,6 +35,7 @@ dependencies {
   testImplementation 'com.tngtech.java:junit-dataprovider'
   testImplementation 'javax.servlet:javax.servlet-api'
   testImplementation 'org.mockito:mockito-core'
+  testImplementation 'org.sonarsource.api.plugin:sonar-plugin-api-test-fixtures'
   testImplementation testFixtures(project(':server:sonar-server-common'))
   testImplementation project(':sonar-testing-harness')
 
index 9ed421dcad5ddc2eb6c04b5c4bb5ffe8fcd534c9..813bac5d10d0fcc74686c15b2c4bb03653355aa2 100644 (file)
@@ -21,9 +21,9 @@ package org.sonar.server.plugins;
 
 import org.junit.Rule;
 import org.junit.Test;
+import org.slf4j.event.Level;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.api.utils.System2;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
 import org.sonar.core.extension.PluginRiskConsent;
 import org.sonar.db.DbClient;
 import org.sonar.db.DbTester;
@@ -68,7 +68,7 @@ public class PluginConsentVerifierTest {
 
     underTest.start();
 
-    assertThat(logTester.logs(LoggerLevel.WARN)).contains("Plugin(s) detected. Plugins are not provided by SonarSource"
+    assertThat(logTester.logs(Level.WARN)).contains("Plugin(s) detected. Plugins are not provided by SonarSource"
         + " and are therefore installed at your own risk. A SonarQube administrator needs to acknowledge this risk once logged in.");
     assertThat(dbClient.propertiesDao().selectGlobalProperty(PLUGINS_RISK_CONSENT))
       .extracting(PropertyDto::getValue)
index 50e6bf313b522ba6083b2e39e9edad8d0c5a86df..f8d54673e6c070f7b8bc2624b87f1e05fb1ebbe1 100644 (file)
@@ -37,7 +37,7 @@ import org.junit.Test;
 import org.junit.rules.TemporaryFolder;
 import org.sonar.api.SonarRuntime;
 import org.sonar.api.utils.MessageException;
-import org.sonar.api.utils.log.LogTester;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.core.platform.PluginInfo;
 import org.sonar.server.platform.ServerFileSystem;
 import org.sonar.updatecenter.common.PluginManifest;
index e6dee992bfd2f420480e9585d173a494d12aaf0e..b18e73df9b753082c7060b760c9ec3a621388feb 100644 (file)
@@ -30,7 +30,7 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.TemporaryFolder;
 import org.sonar.api.Plugin;
-import org.sonar.api.utils.log.LogTester;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.core.platform.PluginInfo;
 import org.sonar.core.plugin.PluginType;
 import org.sonar.server.platform.ServerFileSystem;
index e7f145590e24b342d48d2ad821831849dfadf717..6d72afd4c72ff4a79c26fa6f2ce65d85d78a8865 100644 (file)
@@ -25,13 +25,12 @@ import java.io.IOException;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.Map;
-import org.jetbrains.annotations.NotNull;
 import org.junit.After;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.TemporaryFolder;
 import org.sonar.api.Plugin;
-import org.sonar.api.utils.log.LogTester;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.core.platform.ExplodedPlugin;
 import org.sonar.core.platform.PluginClassLoader;
 import org.sonar.core.platform.PluginJarExploder;
index d7d465fcde0f21adb4293618426e92c7d5ce7851..2beafbfe31035b4d3bb47907cd86af6ab81cb68e 100644 (file)
@@ -32,15 +32,16 @@ import java.util.stream.Collectors;
 import java.util.stream.Stream;
 import org.apache.commons.lang.RandomStringUtils;
 import org.assertj.core.groups.Tuple;
+import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.mockito.ArgumentCaptor;
 import org.mockito.InOrder;
 import org.mockito.Mockito;
+import org.slf4j.event.Level;
 import org.sonar.api.issue.Issue;
 import org.sonar.api.rules.RuleType;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.core.issue.DefaultIssue;
 import org.sonar.db.component.BranchDto;
 import org.sonar.server.qualitygate.changeevent.QGChangeEventListener.ChangedIssue;
@@ -79,6 +80,11 @@ public class QGChangeEventListenersImplTest {
 
   private final QGChangeEventListenersImpl underTest = new QGChangeEventListenersImpl(new LinkedHashSet<>(List.of(listener1, listener2, listener3)));
 
+  @Before
+  public void before() {
+    logTester.setLevel(Level.TRACE);
+  }
+
   @Test
   public void broadcastOnIssueChange_has_no_effect_when_issues_are_empty() {
     underTest.broadcastOnIssueChange(emptyList(), singletonList(component1QGChangeEvent), false);
@@ -120,7 +126,7 @@ public class QGChangeEventListenersImplTest {
     inOrder.verify(listener3).onIssueChanges(same(component1QGChangeEvent), same(changedIssues));
     inOrder.verifyNoMoreInteractions();
     assertThat(logTester.logs()).hasSize(4);
-    assertThat(logTester.logs(LoggerLevel.WARN)).hasSize(1);
+    assertThat(logTester.logs(Level.WARN)).hasSize(1);
   }
 
   @Test
@@ -137,7 +143,7 @@ public class QGChangeEventListenersImplTest {
     inOrder.verify(listener2).onIssueChanges(same(component1QGChangeEvent), same(changedIssues));
     inOrder.verifyNoMoreInteractions();
     assertThat(logTester.logs()).hasSize(3);
-    assertThat(logTester.logs(LoggerLevel.WARN)).hasSize(1);
+    assertThat(logTester.logs(Level.WARN)).hasSize(1);
   }
 
   @Test
@@ -145,7 +151,7 @@ public class QGChangeEventListenersImplTest {
     underTest.broadcastOnIssueChange(oneIssueOnComponent1, singletonList(component1QGChangeEvent), false);
 
     assertThat(logTester.logs()).hasSize(3);
-    List<String> traceLogs = logTester.logs(LoggerLevel.TRACE);
+    List<String> traceLogs = logTester.logs(Level.TRACE);
     assertThat(traceLogs).hasSize(3)
       .containsOnly(
         "calling onChange() on listener " + listener1.getClass().getName() + " for events " + component1QGChangeEvent + "...",
index bda05a4689e3860a4ea000e21a63713c97144651..a5362a835cb43c16be92cc2ae8bf0abe28cbc415 100644 (file)
@@ -29,6 +29,7 @@ dependencies {
   testImplementation 'org.apache.logging.log4j:log4j-core'
   testImplementation 'org.assertj:assertj-guava'
   testImplementation 'org.mockito:mockito-core'
+  testImplementation 'org.sonarsource.api.plugin:sonar-plugin-api-test-fixtures'
   testImplementation testFixtures(project(':server:sonar-server-common'))
   testImplementation project(':sonar-testing-harness')
 
index d1bd8d253961fd254091d4923b820c2f2e982955..5382b5c88d288afc1a0c4a136706217ae3199603 100644 (file)
@@ -21,10 +21,10 @@ package org.sonar.server.authentication;
 
 import org.junit.Rule;
 import org.junit.Test;
+import org.slf4j.event.Level;
 import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.notifications.Notification;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.db.DbTester;
 import org.sonar.db.user.UserDto;
 import org.sonar.server.notification.NotificationManager;
@@ -74,7 +74,7 @@ public class DefaultAdminCredentialsVerifierImplTest {
     underTest.runAtStart();
 
     assertThat(db.users().selectUserByLogin(admin.getLogin()).get().isResetPassword()).isTrue();
-    assertThat(logTester.logs(LoggerLevel.WARN)).contains("Default Administrator credentials are still being used. Make sure to change the password or deactivate the account.");
+    assertThat(logTester.logs(Level.WARN)).contains("Default Administrator credentials are still being used. Make sure to change the password or deactivate the account.");
     assertThat(db.getDbClient().internalPropertiesDao().selectByKey(db.getSession(), DEFAULT_ADMIN_CREDENTIAL_USAGE_EMAIL)).contains("true");
     verify(notificationManager).scheduleForSending(any(Notification.class));
   }
index a8433bd9d5557544e8dafb693b385596b31c85ed..b3cde7ceae6515a428645b9f5d4b654f1e0a558d 100644 (file)
@@ -30,8 +30,8 @@ import org.junit.Test;
 import org.mockito.Mockito;
 import org.sonar.api.config.internal.Encryption;
 import org.sonar.api.config.internal.Settings;
-import org.sonar.api.utils.log.LogAndArguments;
-import org.sonar.api.utils.log.LogTester;
+import org.sonar.api.testfixtures.log.LogAndArguments;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.api.utils.log.LoggerLevel;
 import org.sonar.db.DbTester;
 import org.sonar.db.alm.setting.AlmSettingDto;
index a4c1d65f689e763e84e0143710d6c455b8a891e9..cc84c22a853af0239512e6f69357ee7367e7f568 100644 (file)
@@ -27,13 +27,13 @@ import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.mockito.ArgumentCaptor;
+import org.slf4j.event.Level;
 import org.sonar.api.server.authentication.BaseIdentityProvider;
 import org.sonar.api.server.authentication.Display;
 import org.sonar.api.server.authentication.IdentityProvider;
 import org.sonar.api.server.authentication.OAuth2IdentityProvider;
 import org.sonar.api.server.authentication.UnauthorizedException;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.server.authentication.event.AuthenticationEvent;
 import org.sonar.server.authentication.event.AuthenticationException;
 
@@ -227,7 +227,7 @@ public class InitFilterTest {
     underTest.doFilter(request, response, chain);
 
     verify(response).sendRedirect("/sessions/unauthorized");
-    assertThat(logTester.logs(LoggerLevel.WARN)).containsExactlyInAnyOrder("Fail to initialize authentication with provider 'failing'");
+    assertThat(logTester.logs(Level.WARN)).containsExactlyInAnyOrder("Fail to initialize authentication with provider 'failing'");
     verifyDeleteAuthCookie();
   }
 
@@ -244,17 +244,17 @@ public class InitFilterTest {
   }
 
   private void assertOAuth2InitCalled() {
-    assertThat(logTester.logs(LoggerLevel.ERROR)).isEmpty();
+    assertThat(logTester.logs(Level.ERROR)).isEmpty();
     assertThat(oAuth2IdentityProvider.isInitCalled()).isTrue();
   }
 
   private void assertBasicInitCalled() {
-    assertThat(logTester.logs(LoggerLevel.ERROR)).isEmpty();
+    assertThat(logTester.logs(Level.ERROR)).isEmpty();
     assertThat(baseIdentityProvider.isInitCalled()).isTrue();
   }
 
   private void assertError(String expectedError) throws Exception {
-    assertThat(logTester.logs(LoggerLevel.WARN)).contains(expectedError);
+    assertThat(logTester.logs(Level.WARN)).contains(expectedError);
     verify(response).sendRedirect("/sessions/unauthorized");
     assertThat(oAuth2IdentityProvider.isInitCalled()).isFalse();
   }
index 344c65c020786213106bc6ebfb32a31815a15a11..7918cc6dc59474fe9d60efe53299e343c1d05df9 100644 (file)
@@ -21,10 +21,10 @@ package org.sonar.server.authentication;
 
 import org.junit.Rule;
 import org.junit.Test;
+import org.slf4j.event.Level;
 import org.sonar.api.platform.Server;
 import org.sonar.api.server.authentication.OAuth2IdentityProvider;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
+import org.sonar.api.testfixtures.log.LogTester;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.mockito.Mockito.mock;
@@ -47,7 +47,7 @@ public class LogOAuthWarningTest {
 
     underTest.start();
 
-    assertThat(logTester.logs(LoggerLevel.WARN)).containsOnly("For security reasons, OAuth authentication should use HTTPS. You should set the property 'Administration > Configuration > Server base URL' to a HTTPS URL.");
+    assertThat(logTester.logs(Level.WARN)).containsOnly("For security reasons, OAuth authentication should use HTTPS. You should set the property 'Administration > Configuration > Server base URL' to a HTTPS URL.");
 
     underTest.stop();
   }
@@ -60,7 +60,7 @@ public class LogOAuthWarningTest {
 
     underTest.start();
 
-    assertThat(logTester.logs(LoggerLevel.WARN)).isEmpty();
+    assertThat(logTester.logs(Level.WARN)).isEmpty();
 
     underTest.stop();
   }
@@ -73,7 +73,7 @@ public class LogOAuthWarningTest {
 
     underTest.start();
 
-    assertThat(logTester.logs(LoggerLevel.WARN)).isEmpty();
+    assertThat(logTester.logs(Level.WARN)).isEmpty();
 
     underTest.stop();
   }
index 6ac07d7bff3787a2080f121214f90f7d904e950b..5b4699d557e97a0ab1d473699a61731ab8aa600e 100644 (file)
@@ -27,11 +27,11 @@ import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.mockito.ArgumentCaptor;
+import org.slf4j.event.Level;
 import org.sonar.api.server.authentication.OAuth2IdentityProvider;
 import org.sonar.api.server.authentication.UnauthorizedException;
 import org.sonar.api.server.authentication.UserIdentity;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.server.authentication.event.AuthenticationEvent;
 import org.sonar.server.authentication.event.AuthenticationException;
 import org.sonar.server.user.ThreadLocalUserSession;
@@ -199,7 +199,7 @@ public class OAuth2CallbackFilterTest {
     underTest.doFilter(request, response, chain);
 
     verify(response).sendRedirect("/sessions/unauthorized");
-    assertThat(logTester.logs(LoggerLevel.WARN)).containsExactlyInAnyOrder("Fail to callback authentication with 'failing'");
+    assertThat(logTester.logs(Level.WARN)).containsExactlyInAnyOrder("Fail to callback authentication with 'failing'");
     verify(oAuthRedirection).delete(request, response);
   }
 
@@ -226,12 +226,12 @@ public class OAuth2CallbackFilterTest {
   }
 
   private void assertCallbackCalled(FakeOAuth2IdentityProvider oAuth2IdentityProvider) {
-    assertThat(logTester.logs(LoggerLevel.ERROR)).isEmpty();
+    assertThat(logTester.logs(Level.ERROR)).isEmpty();
     assertThat(oAuth2IdentityProvider.isCallbackCalled()).isTrue();
   }
 
   private void assertError(String expectedError) throws Exception {
-    assertThat(logTester.logs(LoggerLevel.WARN)).contains(expectedError);
+    assertThat(logTester.logs(Level.WARN)).contains(expectedError);
     verify(response).sendRedirect("/sessions/unauthorized");
     assertThat(oAuth2IdentityProvider.isInitCalled()).isFalse();
   }
index ef0bc0b076cabe8aece6b4e9b44678b610e814bc..61d8f615bb74112b1d086ee55e10e7513bb274b7 100644 (file)
@@ -30,7 +30,7 @@ import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.impl.utils.AlwaysIncreasingSystem2;
 import org.sonar.api.server.authentication.IdentityProvider;
 import org.sonar.api.server.authentication.UserIdentity;
-import org.sonar.api.utils.log.LogTester;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.db.DbTester;
 import org.sonar.db.audit.AuditPersister;
 import org.sonar.db.user.GroupDto;
index 83f78ad2559128c1e109271235ad977de976355f..ca1ea2a3cde3a6ba70c4b507f12a63511f0fe4e2 100644 (file)
@@ -28,7 +28,8 @@ import javax.servlet.http.HttpServletRequest;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
-import org.sonar.api.utils.log.LogTester;
+import org.slf4j.event.Level;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.api.utils.log.LoggerLevel;
 
 import static java.util.Arrays.asList;
@@ -352,7 +353,7 @@ public class AuthenticationEventImplTest {
 
   private void verifyLog(String expected) {
     assertThat(logTester.logs()).hasSize(1);
-    assertThat(logTester.logs(LoggerLevel.DEBUG))
+    assertThat(logTester.logs(Level.DEBUG))
       .containsOnly(expected);
   }
 
index 3a9b0c2fe8589686a12c56240185eeefa5dfc3f7..e6b233ad3d300ad5780240a8818eec899aa3ea5d 100644 (file)
@@ -26,8 +26,8 @@ import java.util.concurrent.TimeUnit;
 import org.junit.Rule;
 import org.junit.Test;
 import org.sonar.api.impl.utils.TestSystem2;
-import org.sonar.api.utils.log.LogAndArguments;
-import org.sonar.api.utils.log.LogTester;
+import org.sonar.api.testfixtures.log.LogAndArguments;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.api.utils.log.LoggerLevel;
 import org.sonar.db.DbTester;
 import org.sonar.db.user.SamlMessageIdDto;
index ee874c6692b75ffe3511ec5e23bfc61650d41a06..1db4f46db06fb8ec52fb4e05870c2d49f319ba94 100644 (file)
@@ -26,10 +26,10 @@ import org.junit.After;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.slf4j.event.Level;
 import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.impl.ws.SimpleGetRequest;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
+import org.sonar.api.testfixtures.log.LogTester;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
@@ -52,14 +52,14 @@ public class SystemPasscodeImplTest {
     configurePasscode("foo");
     underTest.start();
 
-    assertThat(logTester.logs(LoggerLevel.INFO)).contains("System authentication by passcode is enabled");
+    assertThat(logTester.logs(Level.INFO)).contains("System authentication by passcode is enabled");
   }
 
   @Test
   public void startup_logs_show_that_feature_is_disabled() {
     underTest.start();
 
-    assertThat(logTester.logs(LoggerLevel.INFO)).contains("System authentication by passcode is disabled");
+    assertThat(logTester.logs(Level.INFO)).contains("System authentication by passcode is disabled");
   }
 
   @Test
@@ -67,7 +67,7 @@ public class SystemPasscodeImplTest {
     configurePasscode("");
     underTest.start();
 
-    assertThat(logTester.logs(LoggerLevel.INFO)).contains("System authentication by passcode is disabled");
+    assertThat(logTester.logs(Level.INFO)).contains("System authentication by passcode is disabled");
   }
 
   @DataProvider
index f8933b61bb7da611bf9fde3931024b881883efb3..92f01c6bc3ebc51810e82875a219a4da8e4b3f5d 100644 (file)
@@ -21,8 +21,8 @@ package org.sonar.server.usertoken.notification;
 
 import org.junit.Rule;
 import org.junit.Test;
-import org.sonar.api.utils.log.LogAndArguments;
-import org.sonar.api.utils.log.LogTester;
+import org.sonar.api.testfixtures.log.LogAndArguments;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.api.utils.log.LoggerLevel;
 import org.sonar.server.util.GlobalLockManager;
 
index 472b0ee4e97e160c1df22c9afbd0c814159ac1f9..a5b4e82189bb828716e376e557d359e0f2ec3f52 100644 (file)
@@ -23,8 +23,9 @@ import java.util.List;
 import org.junit.Rule;
 import org.junit.Test;
 import org.mockito.ArgumentCaptor;
-import org.sonar.api.utils.log.LogAndArguments;
-import org.sonar.api.utils.log.LogTester;
+import org.slf4j.event.Level;
+import org.sonar.api.testfixtures.log.LogAndArguments;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.api.utils.log.LoggerLevel;
 import org.sonar.db.DbClient;
 import org.sonar.db.user.UserDao;
@@ -49,9 +50,10 @@ public class TokenExpirationNotificationSenderTest {
 
   @Test
   public void no_notification_when_email_setting_is_not_set() {
+    logTester.setLevel(Level.DEBUG);
     when(emailComposer.areEmailSettingsSet()).thenReturn(false);
     underTest.sendNotifications();
-    assertThat(logTester.getLogs(LoggerLevel.DEBUG))
+    assertThat(logTester.getLogs(Level.DEBUG))
       .extracting(LogAndArguments::getFormattedMsg)
       .containsExactly("Emails for token expiration notification have not been sent because email settings are not configured.");
   }
index 1abb12d00a51b64de559cd1bb7ecf9b7eeb404ff..562fda20b8937d2d82375e1b1735cdb5e0c3fd2d 100644 (file)
@@ -69,6 +69,7 @@ dependencies {
   testImplementation 'org.eclipse.jetty:jetty-servlet'
   testImplementation 'org.hamcrest:hamcrest-all'
   testImplementation 'org.mockito:mockito-core'
+  testImplementation 'org.sonarsource.api.plugin:sonar-plugin-api-test-fixtures'
   testImplementation 'org.subethamail:subethasmtp'
   testImplementation testFixtures(project(':server:sonar-server-common'))
   testImplementation testFixtures(project(':server:sonar-webserver-auth'))
index aab8cb22a0acccc9da1ed61903567034eee49e06..7c8c33821572537933f2ac5834312df8d377e623 100644 (file)
@@ -30,9 +30,9 @@ import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.mockito.ArgumentCaptor;
+import org.slf4j.event.Level;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.api.utils.System2;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
 import org.sonar.ce.queue.CeQueue;
 import org.sonar.ce.queue.CeTaskSubmit;
 import org.sonar.core.util.SequenceUuidFactory;
@@ -98,7 +98,7 @@ public class AsyncIssueIndexingImplTest {
     assertThat(branch.get().isNeedIssueSync()).isTrue();
     verify(ceQueue, times(1)).prepareSubmit();
     verify(ceQueue, times(1)).massSubmit(anyCollection());
-    assertThat(logTester.logs(LoggerLevel.INFO))
+    assertThat(logTester.logs(Level.INFO))
       .contains("1 branch found in need of issue sync.");
   }
 
@@ -120,7 +120,7 @@ public class AsyncIssueIndexingImplTest {
     assertThat(branch.get().isNeedIssueSync()).isTrue();
     verify(ceQueue, times(2)).prepareSubmit();
     verify(ceQueue, times(1)).massSubmit(anyCollection());
-    assertThat(logTester.logs(LoggerLevel.INFO))
+    assertThat(logTester.logs(Level.INFO))
       .contains("2 branch(es) found in need of issue sync for project.");
   }
 
@@ -128,13 +128,13 @@ public class AsyncIssueIndexingImplTest {
   public void triggerOnIndexCreation_no_branch() {
     underTest.triggerOnIndexCreation();
 
-    assertThat(logTester.logs(LoggerLevel.INFO)).contains("0 branch found in need of issue sync.");
+    assertThat(logTester.logs(Level.INFO)).contains("0 branch found in need of issue sync.");
   }
 
   @Test
   public void triggerForProject_no_branch() {
     underTest.triggerForProject("some-random-uuid");
-    assertThat(logTester.logs(LoggerLevel.INFO)).contains("0 branch(es) found in need of issue sync for project.");
+    assertThat(logTester.logs(Level.INFO)).contains("0 branch(es) found in need of issue sync for project.");
   }
 
   @Test
@@ -157,7 +157,7 @@ public class AsyncIssueIndexingImplTest {
     assertThat(dbClient.ceActivityDao().selectByTaskType(dbTester.getSession(), REPORT)).hasSize(1);
     assertThat(dbClient.ceTaskCharacteristicsDao().selectByTaskUuids(dbTester.getSession(), new HashSet<>(List.of("uuid_2")))).isEmpty();
 
-    assertThat(logTester.logs(LoggerLevel.INFO))
+    assertThat(logTester.logs(Level.INFO))
       .contains(
         "1 pending indexation task found to be deleted...",
         "1 completed indexation task found to be deleted...",
@@ -203,7 +203,7 @@ public class AsyncIssueIndexingImplTest {
       .extracting(CeActivityDto::getMainComponentUuid)
       .containsExactly(anotherProjectDto.getUuid());
 
-    assertThat(logTester.logs(LoggerLevel.INFO))
+    assertThat(logTester.logs(Level.INFO))
       .contains(
         "2 pending indexation task found to be deleted...",
         "2 completed indexation task found to be deleted...",
@@ -251,7 +251,7 @@ public class AsyncIssueIndexingImplTest {
       .extracting(p -> p.getComponent().get().getUuid())
       .containsExactly("branch_uuid2", "branch_uuid1");
 
-    assertThat(logTester.logs(LoggerLevel.INFO))
+    assertThat(logTester.logs(Level.INFO))
       .contains("2 projects found in need of issue sync.");
   }
 
index 46201b8a6118cd24d5aea789d003bfdd02f8a617..2e76e9934d0d4700d62e28e2542a3d03299d468f 100644 (file)
@@ -22,10 +22,9 @@ package org.sonar.server.platform;
 import java.util.Optional;
 import org.junit.Rule;
 import org.junit.Test;
-import org.sonar.api.config.internal.MapSettings;
+import org.slf4j.event.Level;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.api.utils.MessageException;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
 import org.sonar.server.platform.db.migration.version.DatabaseVersion;
 
 import static org.assertj.core.api.Assertions.assertThat;
@@ -68,7 +67,7 @@ public class DatabaseServerCompatibilityTest {
     new DatabaseServerCompatibility(version).start();
 
     assertThat(logTester.logs()).hasSize(4);
-    assertThat(logTester.logs(LoggerLevel.WARN)).contains(
+    assertThat(logTester.logs(Level.WARN)).contains(
       "The database must be manually upgraded. Please backup the database and browse /setup. "
         + "For more information: https://docs.sonarqube.org/latest/setup/upgrading",
       "################################################################################",
index 56436667bf3c65ceb577c2f48f9c2c44b492e207..43b5ffc29824f1fd44fe77f9cd03ae76e7f174f6 100644 (file)
@@ -24,9 +24,10 @@ import org.junit.After;
 import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
+import org.slf4j.event.Level;
 import org.sonar.api.config.internal.MapSettings;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.api.utils.System2;
-import org.sonar.api.utils.log.LogTester;
 import org.sonar.api.utils.log.LoggerLevel;
 import org.sonar.db.DbClient;
 import org.sonar.db.DbTester;
@@ -165,7 +166,7 @@ public class CheckAnyonePermissionsAtStartupTest {
   }
 
   private void assertProjectLevelAnyonePermissionWarningNotInLogs() {
-    boolean noneMatch = logTester.logs(LoggerLevel.WARN).stream()
+    boolean noneMatch = logTester.logs(Level.WARN).stream()
       .noneMatch(s -> s.startsWith("Authentication is not enforced, and project permissions assigned to the 'Anyone' group expose"));
     assertThat(noneMatch).isTrue();
   }
@@ -174,11 +175,11 @@ public class CheckAnyonePermissionsAtStartupTest {
     String expected = String.format("Authentication is not enforced, and project permissions assigned to the 'Anyone' group expose %d " +
       "public project(s) to security risks, including: %s. Unauthenticated visitors have permissions on these project(s).",
       expectedProjectCount, String.join(", ", expectedListedProjects));
-    assertThat(logTester.logs(LoggerLevel.WARN)).contains(expected);
+    assertThat(logTester.logs(Level.WARN)).contains(expected);
   }
 
   private void assertGlobalLevelAnyonePermissionWarningNotInLogs() {
-    boolean noneMatch = !logTester.logs(LoggerLevel.WARN).contains(
+    boolean noneMatch = !logTester.logs(Level.WARN).contains(
       "Authentication is not enforced, and permissions assigned to the 'Anyone' group globally expose the " +
         "instance to security risks. Unauthenticated visitors may unintentionally have permissions on projects.");
     assertThat(noneMatch).isTrue();
@@ -187,7 +188,7 @@ public class CheckAnyonePermissionsAtStartupTest {
   private void assertGlobalLevelAnyonePermissionWarningInLogs() {
     String expected = "Authentication is not enforced, and permissions assigned to the 'Anyone' group globally " +
       "expose the instance to security risks. Unauthenticated visitors may unintentionally have permissions on projects.";
-    assertThat(logTester.logs(LoggerLevel.WARN)).contains(expected);
+    assertThat(logTester.logs(Level.WARN)).contains(expected);
   }
 
 }
index 24fc0b08b381a10eefc9efbb343f66be4d7e3611..5c2c8fa06fdafbf852eddd2efcbb2802aa5d2e7e 100644 (file)
@@ -23,11 +23,12 @@ import org.junit.After;
 import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
+import org.slf4j.event.Level;
 import org.sonar.api.CoreProperties;
 import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.measures.CoreMetrics;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.api.utils.System2;
-import org.sonar.api.utils.log.LogTester;
 import org.sonar.api.utils.log.LoggerLevel;
 import org.sonar.db.DbTester;
 
@@ -64,7 +65,7 @@ public class CheckLanguageSpecificParamsAtStartupTest {
     settings.setProperty(LANGUAGE_SPECIFIC_PARAMETERS + "." + "1" + "." + CoreProperties.LANGUAGE_SPECIFIC_PARAMETERS_SIZE_METRIC_KEY, CoreMetrics.COMPLEXITY_KEY);
 
     underTest.start();
-    assertThat(logTester.logs(LoggerLevel.WARN))
+    assertThat(logTester.logs(Level.WARN))
       .contains("The development cost used for calculating the technical debt is currently configured with 2 language specific parameters [Key: languageSpecificParameters]. " +
       "Please be aware that this functionality is deprecated, and will be removed in a future version.");
   }
@@ -72,7 +73,7 @@ public class CheckLanguageSpecificParamsAtStartupTest {
   @Test
   public void log_does_not_show_when_language_specific_params_used() {
     underTest.start();
-    boolean noneMatch = logTester.logs(LoggerLevel.WARN).stream()
+    boolean noneMatch = logTester.logs(Level.WARN).stream()
       .noneMatch(s -> s.startsWith("The development cost used for calculating the technical debt is currently configured with"));
     assertThat(noneMatch).isTrue();
   }
index 36049917e09f7c3a39736f5984a1df3f131e3abc..500ed03b8871b3123052ffb9ac020f6472869301 100644 (file)
@@ -32,7 +32,7 @@ import org.junit.rules.TestRule;
 import org.junit.rules.Timeout;
 import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.utils.System2;
-import org.sonar.api.utils.log.LogTester;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.process.NetworkUtilsImpl;
 
 import static junit.framework.Assert.fail;
index ae3718b8da38cdb99a043193b8aea2596b87b7ac..188f09a7eb58b752b6114f4593903ea2a5df1759 100644 (file)
@@ -22,8 +22,8 @@ package org.sonar.server.platform.db.migration;
 import org.junit.Rule;
 import org.junit.Test;
 import org.mockito.Mockito;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
+import org.slf4j.event.Level;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.db.DbClient;
 import org.sonar.db.dialect.Dialect;
 import org.sonar.db.dialect.H2;
@@ -85,7 +85,7 @@ public class AutoDbMigrationTest {
     underTest.start();
 
     verifyNoInteractions(migrationEngine);
-    assertThat(logTester.logs(LoggerLevel.INFO)).isEmpty();
+    assertThat(logTester.logs(Level.INFO)).isEmpty();
   }
 
   @Test
@@ -97,7 +97,7 @@ public class AutoDbMigrationTest {
     underTest.start();
 
     verify(migrationEngine).execute();
-    assertThat(logTester.logs(LoggerLevel.INFO)).contains("Automatically perform DB migration, as automatic database upgrade is enabled");
+    assertThat(logTester.logs(Level.INFO)).contains("Automatically perform DB migration, as automatic database upgrade is enabled");
   }
 
   @Test
@@ -109,7 +109,7 @@ public class AutoDbMigrationTest {
     underTest.start();
 
     verifyNoInteractions(migrationEngine);
-    assertThat(logTester.logs(LoggerLevel.INFO)).isEmpty();
+    assertThat(logTester.logs(Level.INFO)).isEmpty();
   }
 
   @Test
@@ -127,7 +127,7 @@ public class AutoDbMigrationTest {
 
   private void verifyInfoLog() {
     assertThat(logTester.logs()).hasSize(1);
-    assertThat(logTester.logs(LoggerLevel.INFO)).containsExactly("Automatically perform DB migration on fresh install");
+    assertThat(logTester.logs(Level.INFO)).containsExactly("Automatically perform DB migration on fresh install");
   }
 
 }
index 6259bb0339fec3558e44e23d643fd825534aaef8..acacaf9e1e86560cc297725c728398b72d40743b 100644 (file)
@@ -35,8 +35,8 @@ import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.mockito.ArgumentCaptor;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
+import org.slf4j.event.Level;
+import org.sonar.api.testfixtures.log.LogTester;
 
 import static java.util.stream.Collectors.joining;
 import static org.assertj.core.api.Assertions.assertThat;
@@ -90,11 +90,12 @@ public class RootFilterTest {
 
   @Test
   public void throwable_in_doFilter_is_logged_in_debug_if_response_is_already_committed() throws Exception {
+    logTester.setLevel(Level.DEBUG);
     doThrow(new RuntimeException()).when(chain).doFilter(any(ServletRequest.class), any(ServletResponse.class));
     HttpServletResponse response = mockHttpResponse(true);
     underTest.doFilter(request("POST", "/context/service/call", "param=value"), response, chain);
 
-    List<String> debugLogs = logTester.logs(LoggerLevel.DEBUG);
+    List<String> debugLogs = logTester.logs(Level.DEBUG);
     assertThat(debugLogs.size()).isOne();
     assertThat(debugLogs.get(0)).contains("Processing of request", "failed");
   }
index 8f20eb2d1293ca37a825b29f7e10c774ecf6efb4..06332abf05059059534a000c8163a82401a2f9d7 100644 (file)
@@ -23,11 +23,12 @@ import org.junit.After;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
+import org.slf4j.event.Level;
 import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.measures.CoreMetrics;
 import org.sonar.api.measures.Metric;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.api.utils.System2;
-import org.sonar.api.utils.log.LogTester;
 import org.sonar.api.utils.log.LoggerLevel;
 import org.sonar.db.DbTester;
 import org.sonar.db.component.ComponentDto;
@@ -90,7 +91,7 @@ public class ProjectsInWarningDaemonTest {
     underTest.notifyStart();
 
     assertProjectsInWarningValue(2L);
-    assertThat(logger.logs(LoggerLevel.INFO)).contains("Counting number of projects in warning is enabled.");
+    assertThat(logger.logs(Level.INFO)).contains("Counting number of projects in warning is enabled.");
   }
 
   @Test
@@ -107,7 +108,7 @@ public class ProjectsInWarningDaemonTest {
     insertProjectInWarning(qualityGateStatus);
 
     assertProjectsInWarningValue(3L);
-    assertThat(logger.logs(LoggerLevel.INFO)).contains("Counting number of projects in warning is enabled.");
+    assertThat(logger.logs(Level.INFO)).contains("Counting number of projects in warning is enabled.");
   }
 
   @Test
@@ -125,7 +126,7 @@ public class ProjectsInWarningDaemonTest {
     projectMeasuresIndexer.indexOnAnalysis(project.uuid());
 
     assertProjectsInWarningValue(0L);
-    assertThat(logger.logs(LoggerLevel.INFO))
+    assertThat(logger.logs(Level.INFO))
       .contains(
         "Counting number of projects in warning is enabled.",
         "Counting number of projects in warning will be disabled as there are no more projects in warning.");
@@ -144,7 +145,7 @@ public class ProjectsInWarningDaemonTest {
     underTest.notifyStart();
 
     assertProjectsInWarningValue(2L);
-    assertThat(logger.logs(LoggerLevel.INFO)).contains("Counting number of projects in warning is enabled.");
+    assertThat(logger.logs(Level.INFO)).contains("Counting number of projects in warning is enabled.");
   }
 
   @Test
@@ -155,7 +156,7 @@ public class ProjectsInWarningDaemonTest {
     underTest.notifyStart();
 
     assertProjectsInWarningValue(0L);
-    assertThat(logger.logs(LoggerLevel.INFO)).contains("Counting number of projects in warning is enabled.");
+    assertThat(logger.logs(Level.INFO)).contains("Counting number of projects in warning is enabled.");
   }
 
   @Test
@@ -170,7 +171,7 @@ public class ProjectsInWarningDaemonTest {
     underTest.notifyStart();
 
     assertProjectsInWarningValue(0L);
-    assertThat(logger.logs(LoggerLevel.INFO)).contains("Counting number of projects in warning is not started as there are no projects in this situation.");
+    assertThat(logger.logs(Level.INFO)).contains("Counting number of projects in warning is not started as there are no projects in this situation.");
   }
 
   @Test
index b43a792f860ff85c69b7af026bac73b4a9b878fe..89a8a76de27b08bb98bc9275250a1ecd58113cfe 100644 (file)
@@ -48,7 +48,7 @@ import org.sonar.api.server.rule.Context;
 import org.sonar.api.server.rule.RuleDescriptionSection;
 import org.sonar.api.server.rule.RulesDefinition;
 import org.sonar.api.utils.DateUtils;
-import org.sonar.api.utils.log.LogTester;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.core.util.UuidFactory;
 import org.sonar.core.util.UuidFactoryFast;
 import org.sonar.db.DbClient;
index ef27c84ff7c3e009c9b6afd90844a2dab1641c6b..164536b5cac9cc188c59f4680954c3c222594403 100644 (file)
@@ -21,9 +21,9 @@ package org.sonar.server.startup;
 
 import org.junit.Rule;
 import org.junit.Test;
+import org.slf4j.event.Level;
 import org.sonar.api.platform.Server;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
+import org.sonar.api.testfixtures.log.LogTester;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.mockito.Mockito.mock;
@@ -42,7 +42,7 @@ public class LogServerIdTest {
     LogServerId underTest = new LogServerId(server);
 
     underTest.start();
-    assertThat(logTester.logs(LoggerLevel.INFO)).contains("Server ID: foo");
+    assertThat(logTester.logs(Level.INFO)).contains("Server ID: foo");
 
     // do not fail
     underTest.stop();
index 0cfd0ed30561018c7407169daa562a498d59a225..113fcaeb441656dc047e0d43ad41a82e5e802494 100644 (file)
@@ -24,10 +24,10 @@ import java.util.Objects;
 import java.util.Optional;
 import org.junit.Rule;
 import org.junit.Test;
+import org.slf4j.event.Level;
 import org.sonar.api.security.DefaultGroups;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.api.utils.System2;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
 import org.sonar.api.web.UserRole;
 import org.sonar.core.util.UuidFactoryFast;
 import org.sonar.db.DbTester;
@@ -69,7 +69,7 @@ public class RegisterPermissionTemplatesTest {
 
     verifyDefaultTemplateForProject(defaultTemplate.getUuid());
 
-    assertThat(logTester.logs(LoggerLevel.ERROR)).isEmpty();
+    assertThat(logTester.logs(Level.ERROR)).isEmpty();
   }
 
   @Test
@@ -90,7 +90,7 @@ public class RegisterPermissionTemplatesTest {
 
     verifyDefaultTemplateForProject(defaultTemplate.getUuid());
 
-    assertThat(logTester.logs(LoggerLevel.ERROR)).contains("Cannot setup default permission for group: sonar-administrators");
+    assertThat(logTester.logs(Level.ERROR)).contains("Cannot setup default permission for group: sonar-administrators");
   }
 
   @Test
index 4137486dbb241ee917af55bc403cab6fc800c7ec..f4e860abb19cb992083918fc190ee6b72669152f 100644 (file)
@@ -24,9 +24,10 @@ import java.util.Collections;
 import org.junit.After;
 import org.junit.Rule;
 import org.junit.Test;
+import org.slf4j.event.Level;
 import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.impl.utils.TestSystem2;
-import org.sonar.api.utils.log.LogTester;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.api.utils.log.LoggerLevel;
 import org.sonar.api.utils.text.JsonWriter;
 import org.sonar.server.property.InternalProperties;
@@ -176,7 +177,7 @@ public class TelemetryDaemonTest {
 
     verify(client, after(2_000).never()).upload(anyString());
     verify(client, timeout(2_000).times(1)).optOut(anyString());
-    assertThat(logger.logs(LoggerLevel.INFO)).contains("Sharing of SonarQube statistics is disabled.");
+    assertThat(logger.logs(Level.INFO)).contains("Sharing of SonarQube statistics is disabled.");
   }
 
   @Test
index 83b559a8b8e16b15036a640f42edf790fd2f9634..3ef617f813ece4be7349298bcedb24675cce2c6f 100644 (file)
@@ -21,6 +21,7 @@ dependencies {
   testImplementation 'com.google.code.findbugs:jsr305'
   testImplementation 'com.tngtech.java:junit-dataprovider'
   testImplementation 'org.mockito:mockito-core'
+  testImplementation 'org.sonarsource.api.plugin:sonar-plugin-api-test-fixtures'
   testImplementation testFixtures(project(':server:sonar-webserver-auth'))
   testImplementation project(':sonar-testing-harness')
     
index f179f2c3e64ea3833b991a2cbeed676fa4823c54..fd81a8d013c88e0458556a21531ae50b68a4cc14 100644 (file)
@@ -32,9 +32,9 @@ import org.elasticsearch.cluster.metadata.MappingMetadata;
 import org.elasticsearch.common.settings.Settings;
 import org.junit.Rule;
 import org.junit.Test;
+import org.slf4j.event.Level;
 import org.sonar.api.config.internal.MapSettings;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.server.es.IndexType.IndexMainType;
 import org.sonar.server.es.metadata.MetadataIndex;
 import org.sonar.server.es.metadata.MetadataIndexDefinition;
@@ -127,7 +127,7 @@ public class IndexCreatorTest {
 
     run(new FakeIndexDefinition());
 
-    assertThat(logTester.logs(LoggerLevel.INFO))
+    assertThat(logTester.logs(Level.INFO))
       .doesNotContain(LOG_DB_VENDOR_CHANGED)
       .doesNotContain(LOG_DB_SCHEMA_CHANGED)
       .contains("Create mapping fakes")
@@ -177,7 +177,7 @@ public class IndexCreatorTest {
 
   private void testDeleteOnDbChange(String expectedLog, Consumer<TestEsDbCompatibility> afterFirstStart) {
     run(new FakeIndexDefinition());
-    assertThat(logTester.logs(LoggerLevel.INFO))
+    assertThat(logTester.logs(Level.INFO))
       .doesNotContain(expectedLog)
       .contains("Create mapping fakes")
       .contains("Create mapping metadatas");
@@ -188,7 +188,7 @@ public class IndexCreatorTest {
     logTester.clear();
     run(new FakeIndexDefinition());
 
-    assertThat(logTester.logs(LoggerLevel.INFO))
+    assertThat(logTester.logs(Level.INFO))
       .contains(expectedLog)
       .contains("Create mapping fakes")
       // keep existing metadata
index 024f4613c2087b4b3392f58f64179126bde9b52e..a87e495aa10edb7baa13e178ac23bf5026496cce 100644 (file)
@@ -29,16 +29,18 @@ import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.stream.IntStream;
 import org.junit.After;
+import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.DisableOnDebug;
 import org.junit.rules.TestRule;
 import org.junit.rules.Timeout;
+import org.slf4j.event.Level;
 import org.sonar.api.config.Configuration;
 import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.impl.utils.TestSystem2;
 import org.sonar.api.utils.MessageException;
-import org.sonar.api.utils.log.LogTester;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.api.utils.log.LoggerLevel;
 import org.sonar.db.DbSession;
 import org.sonar.db.DbTester;
@@ -50,9 +52,9 @@ import static java.util.stream.IntStream.rangeClosed;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.mockito.Mockito.doAnswer;
 import static org.mockito.Mockito.spy;
-import static org.sonar.api.utils.log.LoggerLevel.ERROR;
-import static org.sonar.api.utils.log.LoggerLevel.INFO;
-import static org.sonar.api.utils.log.LoggerLevel.TRACE;
+import static org.slf4j.event.Level.ERROR;
+import static org.slf4j.event.Level.INFO;
+import static org.slf4j.event.Level.TRACE;
 
 public class RecoveryIndexerTest {
 
@@ -73,6 +75,11 @@ public class RecoveryIndexerTest {
 
   private RecoveryIndexer underTest;
 
+  @Before
+  public void before() {
+    logTester.setLevel(TRACE);
+  }
+
   @After
   public void tearDown() {
     if (underTest != null) {
@@ -87,7 +94,7 @@ public class RecoveryIndexerTest {
     underTest.start();
     underTest.stop();
 
-    assertThat(logTester.logs(LoggerLevel.DEBUG)).contains(
+    assertThat(logTester.logs(Level.DEBUG)).contains(
       "Elasticsearch recovery - sonar.search.recovery.delayInMs=300000",
       "Elasticsearch recovery - sonar.search.recovery.minAgeInMs=300000");
   }
@@ -379,15 +386,15 @@ public class RecoveryIndexerTest {
     system2.setNow(system2.now() + 100_000_000L);
   }
 
-  private void assertThatLogsContain(LoggerLevel loggerLevel, String message) {
+  private void assertThatLogsContain(Level loggerLevel, String message) {
     assertThat(logTester.logs(loggerLevel)).filteredOn(m -> m.contains(message)).isNotEmpty();
   }
 
-  private void assertThatLogsDoNotContain(LoggerLevel loggerLevel, String message) {
+  private void assertThatLogsDoNotContain(Level loggerLevel, String message) {
     assertThat(logTester.logs(loggerLevel)).filteredOn(m -> m.contains(message)).isEmpty();
   }
 
-  private void assertThatNoLogsFromRecovery(LoggerLevel loggerLevel) {
+  private void assertThatNoLogsFromRecovery(Level loggerLevel) {
     assertThat(logTester.logs(loggerLevel)).filteredOn(m -> m.contains("Elasticsearch recovery - ")).isEmpty();
   }
 
index ddbdef82183b1e5a00394fa76e78bc772a47ab88..9627bcbbbc055aaf42841636cc730fcbb49bc9b6 100644 (file)
@@ -30,7 +30,7 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.sonar.api.resources.Qualifiers;
 import org.sonar.api.rule.RuleKey;
-import org.sonar.api.utils.log.LogTester;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.db.DbTester;
 import org.sonar.db.component.ComponentDto;
 import org.sonar.db.component.SnapshotDto;
index 2d6de907f764806f9580616ff66353fee3806f4a..84fb86e4fb2d189d0f529819025471ed24bf6a21 100644 (file)
@@ -10,4 +10,5 @@ dependencies {
     testImplementation 'junit:junit'
     testImplementation 'org.assertj:assertj-core'
     testImplementation 'org.mockito:mockito-core'
+    testImplementation 'org.sonarsource.api.plugin:sonar-plugin-api-test-fixtures'
 }
index 6a991784c00e6db0ed3150ce8b74fa7eb7d6f972..3e6a7494f600097de1165f37bb0595df38112dcf 100644 (file)
@@ -32,12 +32,12 @@ import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.mockito.Mockito;
+import org.slf4j.event.Level;
 import org.sonar.api.config.Configuration;
 import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.internal.apachecommons.io.IOUtils;
 import org.sonar.api.internal.apachecommons.lang.StringUtils;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.server.es.EsClient;
 import org.sonar.server.es.response.NodeStatsResponse;
 
@@ -97,7 +97,7 @@ public class ElasticSearchMetricTaskTest {
 
     // elasticsearch health status is not mocked in this test, so this part raise an exception
     assertThat(logTester.logs()).hasSize(1);
-    assertThat(logTester.logs(LoggerLevel.ERROR)).containsOnly("Failed to query ES status");
+    assertThat(logTester.logs(Level.ERROR)).containsOnly("Failed to query ES status");
   }
 
   @Test
@@ -146,7 +146,7 @@ public class ElasticSearchMetricTaskTest {
     verifyNoMoreInteractions(serverMonitoringMetrics);
 
     assertThat(logTester.logs()).hasSize(2);
-    assertThat(logTester.logs(LoggerLevel.ERROR)).containsOnly("Failed to query ES status");
+    assertThat(logTester.logs(Level.ERROR)).containsOnly("Failed to query ES status");
   }
 
   @Test
index 2dcc84a9f29d15d21be458705eb597bb2a62b85e..944f087d7a4bb70674e0e6945b31efb5a91c4e99 100644 (file)
@@ -38,6 +38,7 @@ dependencies {
   testImplementation 'com.squareup.okhttp3:mockwebserver'
   testImplementation 'javax.servlet:javax.servlet-api'
   testImplementation 'org.mockito:mockito-core'
+  testImplementation 'org.sonarsource.api.plugin:sonar-plugin-api-test-fixtures'
   testImplementation 'org.springframework:spring-test:5.3.23'
   testImplementation testFixtures(project(':server:sonar-server-common'))
   testImplementation testFixtures(project(':server:sonar-webserver-auth'))
index 544a21daa8452558c9686a422fb8b57167bd8bdc..c852453117b328585a67bc6ed757f77c302abb51 100644 (file)
@@ -32,8 +32,8 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.sonar.api.server.ws.WebService;
 import org.sonar.api.server.ws.WebService.Param;
-import org.sonar.api.utils.log.LogAndArguments;
-import org.sonar.api.utils.log.LogTester;
+import org.sonar.api.testfixtures.log.LogAndArguments;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.api.utils.log.LoggerLevel;
 import org.sonar.api.web.UserRole;
 import org.sonar.core.config.CorePropertyDefinitions;
index 1687527a4f7cde7a306a24b60f139a9ae3e3780c..9f56986821b7ab038a53005901532317b7071449 100644 (file)
@@ -25,9 +25,9 @@ import java.util.List;
 import java.util.Random;
 import org.junit.Rule;
 import org.junit.Test;
+import org.slf4j.event.Level;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.api.utils.System2;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
 import org.sonar.core.util.UuidFactoryFast;
 import org.sonar.core.util.Uuids;
 import org.sonar.db.DbClient;
@@ -84,9 +84,9 @@ public class RegisterQualityGatesIT {
 
     verifyCorrectBuiltInQualityGate();
     assertThat(
-      logTester.logs(LoggerLevel.INFO).contains("Built-in quality gate [Sonar way] has been created")).isTrue();
+      logTester.logs(Level.INFO)).contains("Built-in quality gate [Sonar way] has been created");
     assertThat(
-      logTester.logs(LoggerLevel.INFO).contains("Built-in quality gate's conditions of [Sonar way] has been updated")).isTrue();
+      logTester.logs(Level.INFO)).contains("Built-in quality gate's conditions of [Sonar way] has been updated");
   }
 
   @Test
@@ -98,7 +98,7 @@ public class RegisterQualityGatesIT {
     assertThat(db.countRowsOfTable("quality_gates")).isOne();
     verifyCorrectBuiltInQualityGate();
     assertThat(
-      logTester.logs(LoggerLevel.INFO).contains("Built-in quality gate's conditions of [Sonar way] has been updated")).isTrue();
+      logTester.logs(Level.INFO)).contains("Built-in quality gate's conditions of [Sonar way] has been updated");
   }
 
   @Test
@@ -116,7 +116,7 @@ public class RegisterQualityGatesIT {
     assertThat(db.countRowsOfTable("quality_gates")).isOne();
     verifyCorrectBuiltInQualityGate();
     assertThat(
-      logTester.logs(LoggerLevel.INFO).contains("Built-in quality gate's conditions of [Sonar way] has been updated")).isTrue();
+      logTester.logs(Level.INFO)).contains("Built-in quality gate's conditions of [Sonar way] has been updated");
   }
 
   @Test
@@ -134,7 +134,7 @@ public class RegisterQualityGatesIT {
     assertThat(db.countRowsOfTable("quality_gates")).isOne();
     verifyCorrectBuiltInQualityGate();
     assertThat(
-      logTester.logs(LoggerLevel.INFO).contains("Built-in quality gate's conditions of [Sonar way] has been updated")).isTrue();
+      logTester.logs(Level.INFO)).contains("Built-in quality gate's conditions of [Sonar way] has been updated");
   }
 
   @Test
@@ -154,7 +154,7 @@ public class RegisterQualityGatesIT {
     assertThat(db.countRowsOfTable("quality_gates")).isOne();
     verifyCorrectBuiltInQualityGate();
     assertThat(
-      logTester.logs(LoggerLevel.INFO).contains("Quality gate [Sonar way] has been set as built-in")).isTrue();
+      logTester.logs(Level.INFO)).contains("Quality gate [Sonar way] has been set as built-in");
   }
 
   @Test
@@ -170,11 +170,11 @@ public class RegisterQualityGatesIT {
     verifyCorrectBuiltInQualityGate();
     // Log must not be present
     assertThat(
-      logTester.logs(LoggerLevel.INFO).contains("Quality gate [Sonar way] has been set as built-in")).isFalse();
+      logTester.logs(Level.INFO)).doesNotContain("Quality gate [Sonar way] has been set as built-in");
     assertThat(
-      logTester.logs(LoggerLevel.INFO).contains("Built-in quality gate [Sonar way] has been created")).isFalse();
+      logTester.logs(Level.INFO)).doesNotContain("Built-in quality gate [Sonar way] has been created");
     assertThat(
-      logTester.logs(LoggerLevel.INFO).contains("Built-in quality gate's conditions of [Sonar way] has been updated")).isFalse();
+      logTester.logs(Level.INFO)).doesNotContain("Built-in quality gate's conditions of [Sonar way] has been updated");
   }
 
   @Test
@@ -194,9 +194,9 @@ public class RegisterQualityGatesIT {
       .extracting(column -> column.get("name"))
       .containsExactly(BUILT_IN_NAME);
     assertThat(
-      logTester.logs(LoggerLevel.INFO).contains("Built-in quality gate [Sonar way] has been created")).isTrue();
+      logTester.logs(Level.INFO)).contains("Built-in quality gate [Sonar way] has been created");
     assertThat(
-      logTester.logs(LoggerLevel.INFO).contains("Built-in quality gate's conditions of [Sonar way] has been updated")).isTrue();
+      logTester.logs(Level.INFO)).contains("Built-in quality gate's conditions of [Sonar way] has been updated");
   }
 
   @Test
@@ -216,7 +216,7 @@ public class RegisterQualityGatesIT {
     // No exception thrown
     verifyCorrectBuiltInQualityGate();
     assertThat(
-      logTester.logs(LoggerLevel.INFO).contains("Built-in quality gate's conditions of [Sonar way] has been updated")).isTrue();
+      logTester.logs(Level.INFO)).contains("Built-in quality gate's conditions of [Sonar way] has been updated");
   }
 
   private void insertMetrics() {
index cd4d12d8e4f86604f43466891f9a2514c9cdd5d7..eac7cc3e7b543720576429a2fe57ac8a63c28c5e 100644 (file)
@@ -29,11 +29,11 @@ import java.util.Locale;
 import java.util.Optional;
 import org.junit.Rule;
 import org.junit.Test;
+import org.slf4j.event.Level;
 import org.sonar.api.impl.utils.TestSystem2;
 import org.sonar.api.resources.Language;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.api.utils.System2;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
 import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
 import org.sonar.db.DbTester;
@@ -91,7 +91,7 @@ public class RegisterQualityProfilesIT {
 
     assertThat(insert.callLogs).containsExactly(builtInQProfile);
     assertThat(update.callLogs).isEmpty();
-    assertThat(logTester.logs(LoggerLevel.INFO)).contains("Register profile foo/Sonar way");
+    assertThat(logTester.logs(Level.INFO)).contains("Register profile foo/Sonar way");
   }
 
   @Test
@@ -119,7 +119,7 @@ public class RegisterQualityProfilesIT {
     underTest.start();
 
     assertThat(selectPersistedName(outdatedProfile)).isEqualTo("Sonar way (outdated copy)");
-    assertThat(logTester.logs(LoggerLevel.INFO)).contains("Rename Quality profiles [foo/Sonar way] to [Sonar way (outdated copy)]");
+    assertThat(logTester.logs(Level.INFO)).contains("Rename Quality profiles [foo/Sonar way] to [Sonar way (outdated copy)]");
   }
 
   @Test
@@ -135,7 +135,7 @@ public class RegisterQualityProfilesIT {
 
     assertThat(insert.callLogs).isEmpty();
     assertThat(update.callLogs).containsExactly(builtIn);
-    assertThat(logTester.logs(LoggerLevel.INFO)).contains("Update profile foo/Sonar way");
+    assertThat(logTester.logs(Level.INFO)).contains("Update profile foo/Sonar way");
   }
 
   @Test
@@ -167,7 +167,7 @@ public class RegisterQualityProfilesIT {
 
     underTest.start();
 
-    assertThat(logTester.logs(LoggerLevel.INFO)).containsAnyOf(
+    assertThat(logTester.logs(Level.INFO)).containsAnyOf(
       format("Default built-in quality profile for language [foo] has been updated from [%s] to [%s] since previous default does not have active rules.",
         qProfileWithoutRule.getName(), qProfileWithOneRule.getName()));
 
@@ -228,7 +228,7 @@ public class RegisterQualityProfilesIT {
 
     var expectedSuffix = " (outdated copy since " + formatter.format(Instant.ofEpochMilli(system2.now())) + ")";
 
-    assertThat(logTester.logs(LoggerLevel.INFO)).contains(
+    assertThat(logTester.logs(Level.INFO)).contains(
       format("Quality profile [%s] for language [%s] is no longer built-in and has been renamed to [%s] "
         + "since it does not have any active rules.",
         qProfileWithoutRule.getName(), qProfileWithoutRule.getLanguage(), qProfileWithoutRule.getName() + expectedSuffix),
index 2c14247bc1b50e3ccaa2f8c953af1001cc651ad0..f252d34add8878d7d402a61418cedc597cfc9afc 100644 (file)
@@ -36,7 +36,7 @@ import org.sonar.api.server.profile.BuiltInQualityProfilesDefinition;
 import org.sonar.api.server.profile.BuiltInQualityProfilesDefinition.BuiltInActiveRule;
 import org.sonar.api.server.profile.BuiltInQualityProfilesDefinition.NewBuiltInQualityProfile;
 import org.sonar.api.utils.System2;
-import org.sonar.api.utils.log.LogTester;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.core.util.UuidFactoryFast;
 import org.sonar.core.util.stream.MoreCollectors;
 import org.sonar.db.DbClient;
index d49d5bc029be4286e54456182f4ce16efe4d086c..9902bc398cc39a7d0ff6c9e613137af8657c36e3 100644 (file)
@@ -23,8 +23,8 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.mockito.InOrder;
 import org.mockito.Mockito;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
+import org.slf4j.event.Level;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.server.app.ProcessCommandWrapper;
 import org.sonar.server.app.RestartFlagHolder;
 import org.sonar.server.exceptions.ForbiddenException;
@@ -96,7 +96,7 @@ public class RestartActionTest {
 
     actionTester.newRequest().execute();
 
-    assertThat(logTester.logs(LoggerLevel.INFO))
+    assertThat(logTester.logs(Level.INFO))
       .contains("SonarQube restart requested by " + login);
   }
 
index f611f82b6ce60f3a00ea4cb7ae6573938aef4639..38a3c47519f758eb51564680f8d04550e6cacd6e 100644 (file)
@@ -24,7 +24,7 @@ import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.sonar.api.resources.Qualifiers;
-import org.sonar.api.utils.log.LogTester;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.api.web.page.Page;
 import org.sonar.api.web.page.Page.Qualifier;
 import org.sonar.api.web.page.PageDefinition;
index 3889fcf5555fb7c352b3fc0389a026957f890bdc..3a2418226b18b4365e49a9ecf8efcd85efe4a15a 100644 (file)
@@ -26,6 +26,7 @@ dependencies {
   testImplementation 'javax.servlet:javax.servlet-api'
   testImplementation 'org.apache.tomcat.embed:tomcat-embed-core'
   testImplementation 'org.mockito:mockito-core'
+  testImplementation 'org.sonarsource.api.plugin:sonar-plugin-api-test-fixtures'
 
   testFixturesApi project(':sonar-testing-harness')
 
index 01586b39e43b3f468f1c2e021b133257c4b3140d..ed9b58f2b6a1fe89cab51e0300fe934379e1371f 100644 (file)
@@ -25,16 +25,17 @@ import com.tngtech.java.junit.dataprovider.UseDataProvider;
 import java.util.function.Consumer;
 import javax.servlet.http.HttpServletResponse;
 import org.apache.catalina.connector.ClientAbortException;
+import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mockito;
+import org.slf4j.event.Level;
 import org.sonar.api.server.ws.Request;
 import org.sonar.api.server.ws.RequestHandler;
 import org.sonar.api.server.ws.Response;
 import org.sonar.api.server.ws.WebService;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.server.exceptions.BadConfigurationException;
 import org.sonar.server.exceptions.BadRequestException;
 import org.sonarqube.ws.MediaTypes;
@@ -55,6 +56,11 @@ public class WebServiceEngineTest {
   @Rule
   public LogTester logTester = new LogTester();
 
+  @Before
+  public void setup() {
+    logTester.setLevel(Level.DEBUG);
+  }
+
   @Test
   public void load_ws_definitions_at_startup() {
     WebServiceEngine underTest = new WebServiceEngine(new WebService[]{
@@ -266,7 +272,7 @@ public class WebServiceEngineTest {
     assertThat(response.stream().outputAsString()).isEqualTo("{\"errors\":[{\"msg\":\"An error has occurred. Please contact your administrator\"}]}");
     assertThat(response.status()).isEqualTo(500);
     assertThat(response.mediaType()).isEqualTo(MediaTypes.JSON);
-    assertThat(logTester.logs(LoggerLevel.ERROR)).filteredOn(l -> l.contains("Fail to process request api/foo")).isNotEmpty();
+    assertThat(logTester.logs(Level.ERROR)).filteredOn(l -> l.contains("Fail to process request api/foo")).isNotEmpty();
   }
 
   @Test
@@ -281,7 +287,7 @@ public class WebServiceEngineTest {
       "{\"errors\":[{\"msg\":\"Bad request !\"}]}");
     assertThat(response.status()).isEqualTo(400);
     assertThat(response.mediaType()).isEqualTo(MediaTypes.JSON);
-    assertThat(logTester.logs(LoggerLevel.ERROR)).isEmpty();
+    assertThat(logTester.logs(Level.ERROR)).isEmpty();
   }
 
   @Test
@@ -299,7 +305,7 @@ public class WebServiceEngineTest {
       + "]}");
     assertThat(response.status()).isEqualTo(400);
     assertThat(response.mediaType()).isEqualTo(MediaTypes.JSON);
-    assertThat(logTester.logs(LoggerLevel.ERROR)).isEmpty();
+    assertThat(logTester.logs(Level.ERROR)).isEmpty();
   }
 
   @Test
@@ -314,7 +320,7 @@ public class WebServiceEngineTest {
       "{\"scope\":\"PROJECT\",\"errors\":[{\"msg\":\"Bad request !\"}]}");
     assertThat(response.status()).isEqualTo(400);
     assertThat(response.mediaType()).isEqualTo(MediaTypes.JSON);
-    assertThat(logTester.logs(LoggerLevel.ERROR)).isEmpty();
+    assertThat(logTester.logs(Level.ERROR)).isEmpty();
   }
 
   @Test
@@ -349,7 +355,7 @@ public class WebServiceEngineTest {
     // response is committed (status is already sent), so status can't be changed
     verify(response.stream(), never()).setStatus(anyInt());
 
-    assertThat(logTester.logs(LoggerLevel.DEBUG)).contains("Request api/foo has been aborted by client");
+    assertThat(logTester.logs(Level.DEBUG)).contains("Request api/foo has been aborted by client");
   }
 
   @Test
@@ -360,7 +366,7 @@ public class WebServiceEngineTest {
     run(request, response, newClientAbortWs());
 
     verify(response.stream()).setStatus(299);
-    assertThat(logTester.logs(LoggerLevel.DEBUG)).contains("Request api/foo has been aborted by client");
+    assertThat(logTester.logs(Level.DEBUG)).contains("Request api/foo has been aborted by client");
   }
 
   @Test
@@ -372,7 +378,7 @@ public class WebServiceEngineTest {
 
     // response is committed (status is already sent), so status can't be changed
     verify(response.stream(), never()).setStatus(anyInt());
-    assertThat(logTester.logs(LoggerLevel.ERROR)).contains("Fail to process request api/foo");
+    assertThat(logTester.logs(Level.ERROR)).contains("Fail to process request api/foo");
   }
 
   @Test
@@ -383,7 +389,7 @@ public class WebServiceEngineTest {
     run(request, response, newFailWs());
 
     verify(response.stream()).setStatus(500);
-    assertThat(logTester.logs(LoggerLevel.ERROR)).contains("Fail to process request api/foo");
+    assertThat(logTester.logs(Level.ERROR)).contains("Fail to process request api/foo");
   }
 
   @Test
@@ -395,7 +401,7 @@ public class WebServiceEngineTest {
 
     underTest.execute(request, response);
 
-    assertThat(logTester.logs(LoggerLevel.ERROR)).contains("Fail to process request /api/ping");
+    assertThat(logTester.logs(Level.ERROR)).contains("Fail to process request /api/ping");
   }
 
   private static WebService newWs(String path, Consumer<WebService.NewAction> consumer) {
index 00b58a58c7c0720d006938ef6943543efedfea95..ebc320c6259540caceaf26f9b1809df1a3a472de 100644 (file)
@@ -21,7 +21,7 @@ package org.sonar.server.ws;
 
 import org.junit.Rule;
 import org.junit.Test;
-import org.sonar.api.utils.log.LogTester;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.server.exceptions.BadRequestException;
 import org.sonarqube.ws.Issues;
 import org.sonarqube.ws.MediaTypes;
index f5cb9fe1c879a107c801f72a379553da7ccea3bf..3ae46ff40db14a72947452c2fb3ebc0699bdb422 100644 (file)
@@ -34,6 +34,7 @@ dependencies {
   testImplementation 'org.mockito:mockito-core'
   testImplementation 'org.eclipse.jetty:jetty-server'
   testImplementation 'org.eclipse.jetty:jetty-servlet'
+  testImplementation 'org.sonarsource.api.plugin:sonar-plugin-api-test-fixtures'
   testImplementation testFixtures(project(':server:sonar-server-common'))
   testImplementation testFixtures(project(':server:sonar-webserver-auth'))
   testImplementation testFixtures(project(':server:sonar-webserver-es'))
index a7bfb4d5d6df2f7ce1e7a46a3bab75c435307aba..49077005dbd70a63c87ce648c9057c5ddcf49468 100644 (file)
@@ -33,8 +33,8 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.mockito.InOrder;
 import org.mockito.Mockito;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
+import org.slf4j.event.Level;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.api.web.ServletFilter;
 import org.sonar.api.web.ServletFilter.UrlPattern;
 
@@ -153,7 +153,7 @@ public class MasterServletFilterTest {
 
     master.init(config, singletonList(filter));
 
-    assertThat(logTester.logs(LoggerLevel.INFO)).containsOnly("Initializing servlet filter PatternFilter [pattern=UrlPattern{inclusions=[/api/issues], exclusions=[/batch/projects]}]");
+    assertThat(logTester.logs(Level.INFO)).containsOnly("Initializing servlet filter PatternFilter [pattern=UrlPattern{inclusions=[/api/issues], exclusions=[/batch/projects]}]");
   }
 
   private static ServletFilter createMockFilter() {
index 90e5f3f13dd5797688aed28e22e2c99bbfea89b6..50c8aced38cb4169372b8ea242c240a22175a779 100644 (file)
@@ -36,11 +36,12 @@ import org.junit.After;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
+import org.slf4j.event.Level;
+import org.sonar.api.testfixtures.log.LogAndArguments;
+import org.sonar.api.testfixtures.log.LogTester;
+import org.sonar.core.extension.CoreExtensionRepository;
 import org.sonar.core.platform.PluginInfo;
 import org.sonar.core.platform.PluginRepository;
-import org.sonar.core.extension.CoreExtensionRepository;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.mockito.Mockito.mock;
@@ -58,6 +59,7 @@ public class StaticResourcesServletTest {
 
   @Before
   public void setUp() throws Exception {
+    logTester.setLevel(Level.TRACE);
     jetty = new Server(0);
     ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
     context.setContextPath("/");
@@ -74,12 +76,14 @@ public class StaticResourcesServletTest {
     }
   }
 
-  private Response call(String path) throws Exception {
+  private Response callAndStop(String path) throws Exception {
     OkHttpClient client = new OkHttpClient();
     Request request = new Request.Builder()
       .url(jetty.getURI().resolve(path).toString())
       .build();
-    return client.newCall(request).execute();
+    Response response = client.newCall(request).execute();
+    jetty.stop();
+    return response;
   }
 
   @Test
@@ -87,7 +91,7 @@ public class StaticResourcesServletTest {
     system.pluginStream = IOUtils.toInputStream("bar");
     when(pluginRepository.hasPlugin("myplugin")).thenReturn(true);
 
-    Response response = call("/static/myplugin/foo.txt");
+    Response response = callAndStop("/static/myplugin/foo.txt");
 
     assertThat(response.isSuccessful()).isTrue();
     assertThat(response.body().string()).isEqualTo("bar");
@@ -99,7 +103,7 @@ public class StaticResourcesServletTest {
     system.pluginStream = IOUtils.toInputStream("bar");
     when(pluginRepository.hasPlugin("myplugin")).thenReturn(true);
 
-    Response response = call("/static/myplugin/foo/bar.txt");
+    Response response = callAndStop("/static/myplugin/foo/bar.txt");
 
     assertThat(response.isSuccessful()).isTrue();
     assertThat(response.body().string()).isEqualTo("bar");
@@ -111,7 +115,7 @@ public class StaticResourcesServletTest {
     system.coreExtensionStream = IOUtils.toInputStream("bar");
     when(coreExtensionRepository.isInstalled("coreext")).thenReturn(true);
 
-    Response response = call("/static/coreext/foo/bar.txt");
+    Response response = callAndStop("/static/coreext/foo/bar.txt");
 
     assertThat(response.isSuccessful()).isTrue();
     assertThat(response.body().string()).isEqualTo("bar");
@@ -125,7 +129,7 @@ public class StaticResourcesServletTest {
     system.coreExtensionStream = IOUtils.toInputStream("bar of core extension");
     when(coreExtensionRepository.isInstalled("samekey")).thenReturn(true);
 
-    Response response = call("/static/samekey/foo/bar.txt");
+    Response response = callAndStop("/static/samekey/foo/bar.txt");
 
     assertThat(response.isSuccessful()).isTrue();
     assertThat(response.body().string()).isEqualTo("bar of core extension");
@@ -138,7 +142,7 @@ public class StaticResourcesServletTest {
     system.pluginStream = IOUtils.toInputStream("bar");
     when(pluginRepository.hasPlugin("myplugin")).thenReturn(true);
 
-    Response response = call("/static/myplugin/foo.css");
+    Response response = callAndStop("/static/myplugin/foo.css");
 
     assertThat(response.header("Content-Type")).isEqualTo("text/css");
     assertThat(response.body().string()).isEqualTo("bar");
@@ -149,11 +153,11 @@ public class StaticResourcesServletTest {
     system.pluginStream = null;
     when(pluginRepository.hasPlugin("myplugin")).thenReturn(true);
 
-    Response response = call("/static/myplugin/foo.css");
+    Response response = callAndStop("/static/myplugin/foo.css");
 
     assertThat(response.code()).isEqualTo(404);
-    assertThat(logTester.logs(LoggerLevel.ERROR)).isEmpty();
-    assertThat(logTester.logs(LoggerLevel.WARN)).isEmpty();
+    assertThat(logTester.logs(Level.ERROR)).isEmpty();
+    assertThat(logTester.logs(Level.WARN)).isEmpty();
   }
 
   @Test
@@ -161,11 +165,11 @@ public class StaticResourcesServletTest {
     system.pluginStream = null;
     when(pluginRepository.hasPlugin("myplugin")).thenReturn(false);
 
-    Response response = call("/static/myplugin/foo.css");
+    Response response = callAndStop("/static/myplugin/foo.css");
 
     assertThat(response.code()).isEqualTo(404);
-    assertThat(logTester.logs(LoggerLevel.ERROR)).isEmpty();
-    assertThat(logTester.logs(LoggerLevel.WARN)).isEmpty();
+    assertThat(logTester.logs(Level.ERROR)).isEmpty();
+    assertThat(logTester.logs(Level.WARN)).isEmpty();
   }
 
   @Test
@@ -174,12 +178,12 @@ public class StaticResourcesServletTest {
     when(pluginRepository.hasPlugin("myplugin")).thenReturn(true);
     when(pluginRepository.getPluginInfo("myplugin")).thenReturn(new PluginInfo("myplugin"));
 
-    Response response = call("/static/myplugin/foo.css");
+    Response response = callAndStop("/static/myplugin/foo.css");
 
     assertThat(response.isSuccessful()).isTrue();
     assertThat(response.body().string()).isEqualTo("bar");
-    assertThat(logTester.logs(LoggerLevel.ERROR)).isEmpty();
-    assertThat(logTester.logs(LoggerLevel.WARN)).isEmpty();
+    assertThat(logTester.logs(Level.ERROR)).isEmpty();
+    assertThat(logTester.logs(Level.WARN)).isEmpty();
   }
 
   @Test
@@ -188,11 +192,11 @@ public class StaticResourcesServletTest {
     system.isCommitted = true;
     when(pluginRepository.hasPlugin("myplugin")).thenReturn(false);
 
-    Response response = call("/static/myplugin/foo.css");
+    Response response = callAndStop("/static/myplugin/foo.css");
 
     assertThat(response.code()).isEqualTo(200);
-    assertThat(logTester.logs(LoggerLevel.ERROR)).isEmpty();
-    assertThat(logTester.logs(LoggerLevel.TRACE)).contains("Response is committed. Cannot send error response code 404");
+    assertThat(logTester.logs(Level.ERROR)).isEmpty();
+    assertThat(logTester.logs(Level.TRACE)).contains("Response is committed. Cannot send error response code 404");
   }
 
   @Test
@@ -200,11 +204,11 @@ public class StaticResourcesServletTest {
     system.sendErrorException = new IOException("Simulating sendError throwing IOException");
     when(pluginRepository.hasPlugin("myplugin")).thenReturn(false);
 
-    Response response = call("/static/myplugin/foo.css");
+    Response response = callAndStop("/static/myplugin/foo.css");
 
     assertThat(response.code()).isEqualTo(200);
-    assertThat(logTester.logs(LoggerLevel.ERROR)).isEmpty();
-    assertThat(logTester.logs(LoggerLevel.TRACE)).contains("Failed to send error code 404: java.io.IOException: Simulating sendError throwing IOException");
+    assertThat(logTester.logs(Level.ERROR)).isEmpty();
+    assertThat(logTester.logs(Level.TRACE)).contains("Failed to send error code 404: {}");
   }
 
   @Test
@@ -213,11 +217,11 @@ public class StaticResourcesServletTest {
     system.pluginStream = null;
     when(pluginRepository.hasPlugin("myplugin")).thenReturn(true);
 
-    Response response = call("/static/myplugin/foo.css");
+    Response response = callAndStop("/static/myplugin/foo.css");
 
     assertThat(response.code()).isEqualTo(200);
-    assertThat(logTester.logs(LoggerLevel.ERROR)).isEmpty();
-    assertThat(logTester.logs(LoggerLevel.TRACE)).contains("Response is committed. Cannot send error response code 404");
+    assertThat(logTester.logs(Level.ERROR)).isEmpty();
+    assertThat(logTester.logs(Level.TRACE)).contains("Response is committed. Cannot send error response code 404");
   }
 
   @Test
@@ -225,12 +229,12 @@ public class StaticResourcesServletTest {
     system.pluginStreamException = new ClientAbortException("Simulating ClientAbortException");
     when(pluginRepository.hasPlugin("myplugin")).thenReturn(true);
 
-    Response response = call("/static/myplugin/foo.css");
+    Response response = callAndStop("/static/myplugin/foo.css");
 
     assertThat(response.code()).isEqualTo(200);
-    assertThat(logTester.logs(LoggerLevel.ERROR)).isEmpty();
-    assertThat(logTester.logs(LoggerLevel.TRACE)).contains(
-      "Client canceled loading resource [static/foo.css] from plugin [myplugin]: org.apache.catalina.connector.ClientAbortException: Simulating ClientAbortException");
+    assertThat(logTester.logs(Level.ERROR)).isEmpty();
+    assertThat(logTester.getLogs(Level.TRACE)).extracting(LogAndArguments::getFormattedMsg).contains(
+      "Client canceled loading resource [static/foo.css] from plugin [myplugin]: {}");
   }
 
   @Test
@@ -239,10 +243,10 @@ public class StaticResourcesServletTest {
     system.pluginStreamException = new RuntimeException("Simulating a error");
     when(pluginRepository.hasPlugin("myplugin")).thenReturn(true);
 
-    Response response = call("/static/myplugin/foo.css");
+    Response response = callAndStop("/static/myplugin/foo.css");
 
     assertThat(response.code()).isEqualTo(200);
-    assertThat(logTester.logs(LoggerLevel.ERROR)).contains("Unable to load resource [static/foo.css] from plugin [myplugin]");
+    assertThat(logTester.logs(Level.ERROR)).contains("Unable to load resource [static/foo.css] from plugin [myplugin]");
   }
 
   private static class TestSystem extends StaticResourcesServlet.System {
index ded22c46c6f2aea054ae49593769da6f56da3eb0..7c85982378f88191fab9db7c26f0110f6bdba39d 100644 (file)
@@ -32,6 +32,7 @@ dependencies {
   testImplementation 'org.hamcrest:hamcrest-core'
   testImplementation 'org.mockito:mockito-core'
   testImplementation 'org.simpleframework:simple'
+  testImplementation 'org.sonarsource.api.plugin:sonar-plugin-api-test-fixtures'
   testImplementation project(':sonar-testing-harness')
 
   testCompileOnly 'com.google.code.findbugs:jsr305'
index a1c58f5ad8e368251b0c83e1c9049c533717542f..1f88942c6f7b54ea86fe34d590362f75779bbda5 100644 (file)
@@ -29,8 +29,8 @@ import org.assertj.core.data.MapEntry;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.TemporaryFolder;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
+import org.slf4j.event.Level;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.updatecenter.common.Version;
 
 import static org.assertj.core.api.Assertions.assertThat;
@@ -131,7 +131,7 @@ public class PluginClassLoaderTest {
       ImmutableMap.of("foo", createExplodedPlugin(info)));
     assertThat(defs).extracting(PluginClassLoaderDef::getBasePluginKey).containsExactly("foo");
 
-    List<String> warnings = logTester.logs(LoggerLevel.WARN);
+    List<String> warnings = logTester.logs(Level.WARN);
     assertThat(warnings).contains("Plugin foo [foo] uses a child first classloader which is deprecated");
   }
 
@@ -147,7 +147,7 @@ public class PluginClassLoaderTest {
       ImmutableMap.of("foo", createExplodedPlugin(info)));
     assertThat(defs).extracting(PluginClassLoaderDef::getBasePluginKey).containsExactly("foo");
 
-    List<String> warnings = logTester.logs(LoggerLevel.WARN);
+    List<String> warnings = logTester.logs(Level.WARN);
     assertThat(warnings).contains("API compatibility mode is no longer supported. In case of error, plugin foo [foo] should package its dependencies.");
   }
 
index 7f110fc3f9a311b2dd511824f77e3e6bc328c6cf..d4ca9389040aa137360eb02b5d9458848327b7b5 100644 (file)
@@ -24,8 +24,8 @@ import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicLong;
 import org.junit.Rule;
 import org.junit.Test;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
+import org.slf4j.event.Level;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.api.utils.log.Loggers;
 
 import static org.assertj.core.api.Assertions.assertThat;
@@ -41,7 +41,7 @@ public class ProgressLoggerTest {
     ProgressLogger progress = new ProgressLogger("ProgressLoggerTest", counter, Loggers.get(getClass()));
     progress.setPeriodMs(1L);
     progress.start();
-    while (logTester.logs(LoggerLevel.INFO).size()<2) {
+    while (logTester.logs(Level.INFO).size()<2) {
       Uninterruptibles.sleepUninterruptibly(1, TimeUnit.MILLISECONDS);
     }
     progress.stop();
@@ -69,6 +69,6 @@ public class ProgressLoggerTest {
   }
 
   private boolean hasInfoLog(String expectedLog) {
-    return logTester.logs(LoggerLevel.INFO).stream().anyMatch(s -> s.startsWith(expectedLog));
+    return logTester.logs(Level.INFO).stream().anyMatch(s -> s.startsWith(expectedLog));
   }
 }
index 745816f30684cb5793884e2b4153d6a2df54aa3e..f88bd0ee4f2eee1e45e8fb12dcabbd785af9bb0c 100644 (file)
@@ -26,7 +26,8 @@ import java.util.List;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.sonar.api.utils.log.LogTester;
+import org.slf4j.event.Level;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.api.utils.log.LoggerLevel;
 import org.sonar.api.utils.log.Loggers;
 
@@ -173,7 +174,7 @@ public class DefaultProfilerTest {
     addSomeContext(underTest);
     underTest.startInfo("Foo");
 
-    assertThat(tester.logs(LoggerLevel.INFO)).containsOnly("Foo | a_string=bar | an_int=42 | after_start=true");
+    assertThat(tester.logs(Level.INFO)).containsOnly("Foo | a_string=bar | an_int=42 | after_start=true");
   }
 
   @Test
@@ -182,7 +183,7 @@ public class DefaultProfilerTest {
     addSomeContext(underTest);
     underTest.startDebug("Foo");
 
-    assertThat(tester.logs(LoggerLevel.DEBUG)).containsOnly("Foo | a_string=bar | an_int=42 | after_start=true");
+    assertThat(tester.logs(Level.DEBUG)).containsOnly("Foo | a_string=bar | an_int=42 | after_start=true");
   }
 
   @Test
@@ -191,7 +192,7 @@ public class DefaultProfilerTest {
     addSomeContext(underTest);
     underTest.startTrace("Foo");
 
-    assertThat(tester.logs(LoggerLevel.TRACE)).containsOnly("Foo | a_string=bar | an_int=42 | after_start=true");
+    assertThat(tester.logs(Level.TRACE)).containsOnly("Foo | a_string=bar | an_int=42 | after_start=true");
   }
 
   @Test
@@ -200,7 +201,7 @@ public class DefaultProfilerTest {
     underTest.start().stopError("Rules registered");
 
     assertThat(tester.logs()).hasSize(1);
-    assertThat(tester.logs(LoggerLevel.ERROR).get(0))
+    assertThat(tester.logs(Level.ERROR).get(0))
       .startsWith("Rules registered | time=")
       .endsWith("ms | a_string=bar | an_int=42 | after_start=true");
   }
@@ -211,7 +212,7 @@ public class DefaultProfilerTest {
     underTest.start().stopInfo("Rules registered");
 
     assertThat(tester.logs()).hasSize(1);
-    assertThat(tester.logs(LoggerLevel.INFO).get(0))
+    assertThat(tester.logs(Level.INFO).get(0))
       .startsWith("Rules registered | time=")
       .endsWith("ms | a_string=bar | an_int=42 | after_start=true");
   }
@@ -223,7 +224,7 @@ public class DefaultProfilerTest {
     underTest.start().stopTrace("Rules registered");
 
     assertThat(tester.logs()).hasSize(1);
-    assertThat(tester.logs(LoggerLevel.TRACE).get(0))
+    assertThat(tester.logs(Level.TRACE).get(0))
       .startsWith("Rules registered | time=")
       .endsWith("ms | a_string=bar | an_int=42 | after_start=true");
   }
@@ -235,7 +236,7 @@ public class DefaultProfilerTest {
     underTest.start().stopError("Rules registered");
 
     assertThat(tester.logs()).hasSize(1);
-    assertThat(tester.logs(LoggerLevel.ERROR).get(0))
+    assertThat(tester.logs(Level.ERROR).get(0))
       .startsWith("Rules registered | a_string=bar | an_int=42 | after_start=true | time=")
       .endsWith("ms");
   }
@@ -247,7 +248,7 @@ public class DefaultProfilerTest {
     underTest.start().stopInfo("Rules registered");
 
     assertThat(tester.logs()).hasSize(1);
-    assertThat(tester.logs(LoggerLevel.INFO).get(0))
+    assertThat(tester.logs(Level.INFO).get(0))
       .startsWith("Rules registered | a_string=bar | an_int=42 | after_start=true | time=")
       .endsWith("ms");
   }
@@ -260,7 +261,7 @@ public class DefaultProfilerTest {
     underTest.start().stopTrace("Rules registered");
 
     assertThat(tester.logs()).hasSize(1);
-    assertThat(tester.logs(LoggerLevel.TRACE).get(0))
+    assertThat(tester.logs(Level.TRACE).get(0))
       .startsWith("Rules registered | a_string=bar | an_int=42 | after_start=true | time=")
       .endsWith("ms");
   }
@@ -273,7 +274,7 @@ public class DefaultProfilerTest {
     underTest.start().stopInfo("Bar");
 
     assertThat(tester.logs()).hasSize(2);
-    List<String> logs = tester.logs(LoggerLevel.INFO);
+    List<String> logs = tester.logs(Level.INFO);
     assertThat(logs.get(0))
         .startsWith("Foo | a_string=bar | an_int=42 | after_start=true | time=")
         .endsWith("ms");
@@ -291,7 +292,7 @@ public class DefaultProfilerTest {
     underTest.start().stopDebug("Bar");
 
     assertThat(tester.logs()).hasSize(2);
-    List<String> logs = tester.logs(LoggerLevel.DEBUG);
+    List<String> logs = tester.logs(Level.DEBUG);
     assertThat(logs.get(0))
         .startsWith("Foo | a_string=bar | an_int=42 | after_start=true | time=")
         .endsWith("ms");
@@ -309,7 +310,7 @@ public class DefaultProfilerTest {
     underTest.start().stopTrace("Bar");
 
     assertThat(tester.logs()).hasSize(2);
-    List<String> logs = tester.logs(LoggerLevel.TRACE);
+    List<String> logs = tester.logs(Level.TRACE);
     assertThat(logs.get(0))
         .startsWith("Foo | a_string=bar | an_int=42 | after_start=true | time=")
         .endsWith("ms");
index f00ee3db5412a9570026bc15818ace27e50f5bf9..c1a5e5999db4a233ab8e2735d9a418e05de636c4 100644 (file)
@@ -21,7 +21,7 @@ package org.sonar.core.util.logs;
 
 import org.junit.Rule;
 import org.junit.Test;
-import org.sonar.api.utils.log.LogTester;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.api.utils.log.LoggerLevel;
 import org.sonar.api.utils.log.Loggers;
 
index 51480338d9d88b09877e838757f26ba6acb65720..92bf8a3e6c9b8b363518af4c3512465c3064b84c 100644 (file)
@@ -23,6 +23,7 @@ dependencies {
   testImplementation 'junit:junit'
   testImplementation 'org.assertj:assertj-core'
   testImplementation 'org.mockito:mockito-core'
+  testImplementation 'org.sonarsource.api.plugin:sonar-plugin-api-test-fixtures'
 }
 
 import org.apache.tools.ant.filters.ReplaceTokens
index 204e7ae27f5e13df4a83cee94dce194926f52088..2af4bc494645c93fefd88889426f8a4b581dbb03 100644 (file)
@@ -256,7 +256,8 @@ public class DefaultInputFile extends DefaultInputComponent implements InputFile
   /**
    * Digest hash of the file.
    */
-  public String hash() {
+  @Override
+  public String md5Hash() {
     checkMetadata();
     return metadata.hash();
   }
index bd964a8f15dde36b1c4dfcbb249f8bfd144c3c78..179de739f5b8b37c31cfbbe513b6c7f002ade287 100644 (file)
@@ -29,13 +29,13 @@ import org.apache.commons.io.FileUtils;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.TemporaryFolder;
+import org.slf4j.event.Level;
 import org.sonar.api.batch.fs.internal.DefaultInputFile;
 import org.sonar.api.batch.fs.internal.FileMetadata;
 import org.sonar.api.batch.fs.internal.Metadata;
 import org.sonar.api.batch.fs.internal.TestInputFileBuilder;
 import org.sonar.api.notifications.AnalysisWarnings;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
+import org.sonar.api.testfixtures.log.LogTester;
 
 import static org.apache.commons.codec.digest.DigestUtils.md5Hex;
 import static org.assertj.core.api.Assertions.assertThat;
@@ -306,9 +306,9 @@ public class FileMetadataTest {
     assertThat(metadata.nonBlankLines()).isEqualTo(133);
     assertThat(metadata.hash()).isNotEmpty();
 
-    assertThat(logTester.logs(LoggerLevel.WARN).get(0)).contains("Invalid character encountered in file");
+    assertThat(logTester.logs(Level.WARN).get(0)).contains("Invalid character encountered in file");
     verify(analysisWarnings).addUnique("There are problems with file encoding in the source code. Please check the scanner logs for more details.");
-    assertThat(logTester.logs(LoggerLevel.WARN).get(0)).contains(
+    assertThat(logTester.logs(Level.WARN).get(0)).contains(
       "glyphicons-halflings-regular.woff at line 1 for encoding UTF-8. Please fix file content or configure the encoding to be used using property 'sonar.sourceEncoding'.");
   }
 
index 2851cf667980cbaf540a61cbb025f5fb3848d298..4f2babc1ba23ef2f4d25bff94800c22d5a8b727e 100644 (file)
@@ -25,8 +25,8 @@ import org.junit.BeforeClass;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.TemporaryFolder;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
+import org.slf4j.event.Level;
+import org.sonar.api.testfixtures.log.LogTester;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
@@ -115,6 +115,6 @@ public class DefaultTempFolderTest {
     // second call does not fail, nor log ERROR logs
     underTest.clean();
 
-    assertThat(logTester.logs(LoggerLevel.ERROR)).isEmpty();
+    assertThat(logTester.logs(Level.ERROR)).isEmpty();
   }
 }
index 269ec1996e527fc1bf37ce77a84d66796490e855..093f996a9c4c763e1b3cfb5160e5764d18f5366d 100644 (file)
@@ -57,6 +57,7 @@ dependencies {
   testImplementation 'com.fasterxml.staxmate:staxmate'
   testImplementation 'org.hamcrest:hamcrest-core'
   testImplementation 'org.mockito:mockito-core'
+  api 'org.sonarsource.api.plugin:sonar-plugin-api-test-fixtures'
   testImplementation project(':plugins:sonar-xoo-plugin')
 }
 
index a7a181a6f4322434aa128e1b4a01f793c1453806..ced4d750654baba295bdc254edde8840da12675f 100644 (file)
@@ -296,7 +296,7 @@ public class ScannerMediumTester extends ExternalResource {
       props.putAll(tester.globalProperties);
       props.putAll(taskProperties);
 
-      Batch.builder()
+      Batch.Builder builder = Batch.builder()
         .setGlobalProperties(props)
         .setEnableLoggingConfiguration(true)
         .addComponents(new EnvironmentInformation("mediumTest", "1.0"),
@@ -313,9 +313,13 @@ public class ScannerMediumTester extends ExternalResource {
           tester.analysisCacheLoader,
           tester.sonarRuntime,
           tester.reportMetadataHolder,
-          result)
-        .setLogOutput(tester.logOutput)
-        .build().execute();
+          result);
+      if (tester.logOutput != null) {
+        builder.setLogOutput(tester.logOutput);
+      } else {
+        builder.setEnableLoggingConfiguration(false);
+      }
+      builder.build().execute();
 
       return result;
     }
index 02f68d9e74bd2007f23cdc94987e083b91dcf78e..883b8be4548cb9340b340ff3fbfc770511227c37 100644 (file)
@@ -31,10 +31,11 @@ import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.TemporaryFolder;
+import org.slf4j.event.Level;
 import org.sonar.api.batch.fs.internal.DefaultInputFile;
 import org.sonar.api.batch.fs.internal.FileMetadata;
 import org.sonar.api.notifications.AnalysisWarnings;
-import org.sonar.api.utils.log.LogTester;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.scanner.mediumtest.AnalysisResult;
 import org.sonar.scanner.mediumtest.ScannerMediumTester;
 import org.sonar.scanner.protocol.output.ScannerReport;
@@ -70,6 +71,7 @@ public class BranchMediumIT {
 
   @Before
   public void prepare() throws IOException {
+    logTester.setLevel(Level.DEBUG);
     baseDir = temp.newFolder();
     Path filepath = baseDir.toPath().resolve(FILE_PATH);
     Files.write(filepath, FILE_CONTENT.getBytes());
index 08faf0f0f5eaee8da7f4c3d58a1849e499ee78bc..20b48b37ec91bc6925c340af7b2c55a7b18d6316 100644 (file)
@@ -24,12 +24,13 @@ import java.io.File;
 import java.io.IOException;
 import java.nio.charset.StandardCharsets;
 import org.apache.commons.io.FileUtils;
+import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.TemporaryFolder;
+import org.slf4j.event.Level;
 import org.sonar.api.batch.fs.InputFile;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.scanner.mediumtest.AnalysisResult;
 import org.sonar.scanner.mediumtest.ScannerMediumTester;
 import org.sonar.scanner.protocol.output.ScannerReport;
@@ -51,6 +52,11 @@ public class CoverageMediumIT {
     .registerPlugin("xoo", new XooPlugin())
     .addDefaultQProfile("xoo", "Sonar Way");
 
+  @Before
+  public void prepare() throws IOException {
+    logTester.setLevel(Level.DEBUG);
+  }
+
   @Test
   public void singleReport() throws IOException {
 
@@ -168,7 +174,7 @@ public class CoverageMediumIT {
     InputFile fileB = result.inputFile("moduleB/src/sampleB.xoo");
     assertThat(result.coverageFor(fileB, 2)).isNotNull();
 
-    assertThat(logTester.logs(LoggerLevel.WARN)).contains("Specifying module-relative paths at project level in the property 'sonar.coverage.exclusions' is deprecated. " +
+    assertThat(logTester.logs(Level.WARN)).contains("Specifying module-relative paths at project level in the property 'sonar.coverage.exclusions' is deprecated. " +
       "To continue matching files like 'moduleA/src/sampleA.xoo', update this property so that patterns refer to project-relative paths.");
   }
 
@@ -249,7 +255,7 @@ public class CoverageMediumIT {
     InputFile fileB = result.inputFile("moduleB/src/sample.xoo");
     assertThat(result.coverageFor(fileB, 2)).isNull();
 
-    assertThat(logTester.logs(LoggerLevel.WARN)).contains("Specifying module-relative paths at project level in the property 'sonar.coverage.exclusions' is deprecated. " +
+    assertThat(logTester.logs(Level.WARN)).contains("Specifying module-relative paths at project level in the property 'sonar.coverage.exclusions' is deprecated. " +
       "To continue matching files like 'moduleA/src/sample.xoo', update this property so that patterns refer to project-relative paths.");
   }
 
index 1f16e7241d760f5173e9d045df8a8da85edf0528..fe5676fd40f5cdb3691a68dac6b3749a51b9e565 100644 (file)
@@ -25,6 +25,7 @@ import java.util.List;
 import org.junit.Rule;
 import org.junit.Test;
 import org.sonar.api.batch.fs.InputFile;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.scanner.mediumtest.AnalysisResult;
 import org.sonar.scanner.mediumtest.ScannerMediumTester;
 import org.sonar.xoo.XooPlugin;
@@ -32,8 +33,9 @@ import org.sonar.xoo.XooPlugin;
 import static org.assertj.core.api.Assertions.assertThat;
 
 public class GenericCoverageMediumIT {
-  private final List<String> logs = new ArrayList<>();
-  
+  @Rule
+  public LogTester logTester = new LogTester();
+
   @Rule
   public ScannerMediumTester tester = new ScannerMediumTester()
     .registerPlugin("xoo", new XooPlugin())
@@ -45,7 +47,6 @@ public class GenericCoverageMediumIT {
     File projectDir = new File("test-resources/mediumtest/xoo/sample-generic-coverage");
 
     AnalysisResult result = tester
-      .setLogOutput((msg, level) -> logs.add(msg))
       .newAnalysis(new File(projectDir, "sonar-project.properties"))
       .property("sonar.coverageReportPaths", "coverage.xml")
       .execute();
@@ -62,7 +63,7 @@ public class GenericCoverageMediumIT {
     assertThat(result.coverageFor(withConditions, 3).getConditions()).isEqualTo(2);
     assertThat(result.coverageFor(withConditions, 3).getCoveredConditions()).isOne();
 
-    assertThat(logs).noneMatch(l -> l.contains("Please use 'sonar.coverageReportPaths'"));
+    assertThat(logTester.logs()).noneMatch(l -> l.contains("Please use 'sonar.coverageReportPaths'"));
 
   }
 
@@ -72,7 +73,6 @@ public class GenericCoverageMediumIT {
     File projectDir = new File("test-resources/mediumtest/xoo/sample-generic-coverage");
 
     AnalysisResult result = tester
-      .setLogOutput((msg, level) -> logs.add(msg))
       .newAnalysis(new File(projectDir, "sonar-project.properties"))
       .property("sonar.coverageReportPaths", "coverage.xml,coverage2.xml")
       .execute();
@@ -89,7 +89,7 @@ public class GenericCoverageMediumIT {
     assertThat(result.coverageFor(withConditions, 3).getConditions()).isEqualTo(2);
     assertThat(result.coverageFor(withConditions, 3).getCoveredConditions()).isEqualTo(2);
 
-    assertThat(logs).noneMatch(l -> l.contains("Please use 'sonar.coverageReportPaths'"));
+    assertThat(logTester.logs()).noneMatch(l -> l.contains("Please use 'sonar.coverageReportPaths'"));
   }
   
 }
index 0975bb74a74d1adec0ba3af3d6d0efa5e8bf5026..1455ab4512e7a89e05ca1dbf38db698909623a46 100644 (file)
@@ -29,9 +29,9 @@ import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.TemporaryFolder;
+import org.slf4j.event.Level;
 import org.sonar.api.batch.fs.InputFile;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.scanner.mediumtest.AnalysisResult;
 import org.sonar.scanner.mediumtest.ScannerMediumTester;
 import org.sonar.scanner.protocol.output.ScannerReport;
@@ -61,6 +61,7 @@ public class CpdMediumIT {
 
   @Before
   public void prepare() {
+    logTester.setLevel(Level.DEBUG);
     baseDir = temp.getRoot();
 
     builder = ImmutableMap.<String, String>builder()
@@ -345,7 +346,7 @@ public class CpdMediumIT {
     List<ScannerReport.Duplication> duplicationGroupsFile2 = result.duplicationsFor(inputFile2);
     assertThat(duplicationGroupsFile2).isEmpty();
 
-    assertThat(logTester.logs(LoggerLevel.WARN)).contains("Specifying module-relative paths at project level in the property 'sonar.cpd.exclusions' is deprecated. " +
+    assertThat(logTester.logs(Level.WARN)).contains("Specifying module-relative paths at project level in the property 'sonar.cpd.exclusions' is deprecated. " +
       "To continue matching files like 'moduleA/src/sampleA.xoo', update this property so that patterns refer to project-relative paths.");
   }
 
index 9c1c55338b3b2c1237f91e521c33f82550bfd8fc..bc7fac73a4376878b720a384866650f5d6382962 100644 (file)
@@ -38,6 +38,7 @@ import org.junit.Ignore;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.TemporaryFolder;
+import org.slf4j.event.Level;
 import org.sonar.api.CoreProperties;
 import org.sonar.api.SonarEdition;
 import org.sonar.api.batch.fs.InputFile;
@@ -45,7 +46,7 @@ import org.sonar.api.batch.fs.internal.DefaultInputFile;
 import org.sonar.api.utils.MessageException;
 import org.sonar.api.utils.PathUtils;
 import org.sonar.api.utils.System2;
-import org.sonar.api.utils.log.LogTester;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.api.utils.log.LoggerLevel;
 import org.sonar.scanner.mediumtest.AnalysisResult;
 import org.sonar.scanner.mediumtest.ScannerMediumTester;
@@ -82,6 +83,7 @@ public class FileSystemMediumIT {
 
   @Before
   public void prepare() throws IOException {
+    logTester.setLevel(Level.DEBUG);
     baseDir = temp.newFolder().getCanonicalFile();
 
     builder = ImmutableMap.<String, String>builder()
@@ -576,7 +578,7 @@ public class FileSystemMediumIT {
     InputFile fileB = result.inputFile("moduleB/src/sample.xoo");
     assertThat(fileB).isNull();
 
-    assertThat(logTester.logs(LoggerLevel.WARN))
+    assertThat(logTester.logs(Level.WARN))
       .contains("Specifying module-relative paths at project level in the property 'sonar.exclusions' is deprecated. " +
         "To continue matching files like 'moduleA/src/sample.xoo', update this property so that patterns refer to project-relative paths.");
   }
@@ -673,7 +675,7 @@ public class FileSystemMediumIT {
     InputFile fileB = result.inputFile("moduleB/src/sample.xoo");
     assertThat(fileB).isNull();
 
-    assertThat(logTester.logs(LoggerLevel.WARN))
+    assertThat(logTester.logs(Level.WARN))
       .contains("Specifying module-relative paths at project level in the property 'sonar.exclusions' is deprecated. " +
         "To continue matching files like 'moduleA/src/sample.xoo', update this property so that patterns refer to project-relative paths.");
   }
@@ -813,7 +815,7 @@ public class FileSystemMediumIT {
       .execute();
 
     assertThat(result.inputFiles()).hasSize(4);
-    assertThat(logTester.logs(LoggerLevel.INFO)).contains(
+    assertThat(logTester.logs(Level.INFO)).contains(
       "Deprecated Global Sensor: module_a/module_a1/src/main/xoo/com/sonar/it/samples/modules/a1/HelloA1.xoo",
       "Deprecated Global Sensor: module_a/module_a2/src/main/xoo/com/sonar/it/samples/modules/a2/HelloA2.xoo",
       "Deprecated Global Sensor: module_b/module_b1/src/main/xoo/com/sonar/it/samples/modules/b1/HelloB1.xoo",
@@ -829,7 +831,7 @@ public class FileSystemMediumIT {
       .execute();
 
     assertThat(result.inputFiles()).hasSize(4);
-    assertThat(logTester.logs(LoggerLevel.INFO)).contains(
+    assertThat(logTester.logs(Level.INFO)).contains(
       "Global Sensor: module_a/module_a1/src/main/xoo/com/sonar/it/samples/modules/a1/HelloA1.xoo",
       "Global Sensor: module_a/module_a2/src/main/xoo/com/sonar/it/samples/modules/a2/HelloA2.xoo",
       "Global Sensor: module_b/module_b1/src/main/xoo/com/sonar/it/samples/modules/b1/HelloB1.xoo",
@@ -945,7 +947,7 @@ public class FileSystemMediumIT {
         .build())
       .execute();
 
-    assertThat(logTester.logs(LoggerLevel.INFO))
+    assertThat(logTester.logs(Level.INFO))
       .containsSequence("Project configuration:",
         "  Included sources: **/global.inclusions",
         "  Excluded sources: **/global.exclusions, **/global.test.inclusions",
@@ -955,7 +957,6 @@ public class FileSystemMediumIT {
         "  Excluded sources for duplication: **/cpd.exclusions",
         "Indexing files of module 'moduleA'",
         "  Base dir: " + baseDirModuleA.toPath().toRealPath(LinkOption.NOFOLLOW_LINKS),
-        "  Source paths: src",
         "  Included sources: **/global.inclusions",
         "  Excluded sources: **/global.exclusions, **/global.test.inclusions",
         "  Included tests: **/global.test.inclusions",
@@ -964,7 +965,6 @@ public class FileSystemMediumIT {
         "  Excluded sources for duplication: **/cpd.exclusions",
         "Indexing files of module 'moduleB'",
         "  Base dir: " + baseDirModuleB.toPath().toRealPath(LinkOption.NOFOLLOW_LINKS),
-        "  Source paths: src",
         "  Included sources: **/global.inclusions",
         "  Excluded sources: **/global.exclusions, **/global.test.inclusions",
         "  Included tests: **/global.test.inclusions",
@@ -998,7 +998,7 @@ public class FileSystemMediumIT {
       .execute();
 
     assertThat(result.inputFiles()).hasSize(1);
-    assertThat(logTester.logs(LoggerLevel.WARN)).contains("File '" + xooFile2.getAbsolutePath() + "' is ignored. It is not located in project basedir '" + baseDir + "'.");
+    assertThat(logTester.logs(Level.WARN)).contains("File '" + xooFile2.getAbsolutePath() + "' is ignored. It is not located in project basedir '" + baseDir + "'.");
   }
 
   @Test
@@ -1020,7 +1020,7 @@ public class FileSystemMediumIT {
       .execute();
 
     assertThat(result.inputFiles()).hasSize(1);
-    assertThat(logTester.logs(LoggerLevel.WARN)).doesNotContain("File '" + xooFile2.getAbsolutePath() + "' is ignored. It is not located in project basedir '" + baseDir + "'.");
+    assertThat(logTester.logs(Level.WARN)).doesNotContain("File '" + xooFile2.getAbsolutePath() + "' is ignored. It is not located in project basedir '" + baseDir + "'.");
   }
 
   @Test
@@ -1039,7 +1039,7 @@ public class FileSystemMediumIT {
       .execute();
 
     assertThat(result.inputFiles()).hasSize(1);
-    assertThat(logTester.logs(LoggerLevel.WARN))
+    assertThat(logTester.logs(Level.WARN))
       .contains("File '" + xooFile2.getAbsolutePath() + "' is ignored. It is not located in module basedir '" + new File(baseDir, "moduleA") + "'.");
   }
 
index 2f9d939f7d87855a031667e6f2b94f823f45afaf..2ed34a2e85c0d1d7dc7c791674e68e0bfea58c06 100644 (file)
@@ -27,7 +27,8 @@ import org.apache.commons.io.FileUtils;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.TemporaryFolder;
-import org.sonar.api.utils.log.LogTester;
+import org.slf4j.event.Level;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.scanner.mediumtest.AnalysisResult;
 import org.sonar.scanner.mediumtest.ScannerMediumTester;
 import org.sonar.scanner.protocol.Constants.Severity;
@@ -105,6 +106,7 @@ public class ExternalIssuesMediumIT {
 
   @Test
   public void testLoadIssuesFromJsonReport() throws URISyntaxException, IOException {
+    logs.setLevel(Level.DEBUG);
     File projectDir = new File("test-resources/mediumtest/xoo/sample");
     File tmpDir = temp.newFolder();
     FileUtils.copyDirectory(projectDir, tmpDir);
index feaf921d141dd0be5a91e27626a3af0a1d0c423f..f303864355b8d967f73d88b32f15d4c25f5d32ab 100644 (file)
@@ -25,13 +25,14 @@ import java.io.IOException;
 import java.nio.charset.StandardCharsets;
 import java.util.List;
 import org.apache.commons.io.FileUtils;
+import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.TemporaryFolder;
+import org.slf4j.event.Level;
 import org.sonar.api.batch.rule.LoadedActiveRule;
 import org.sonar.api.rule.RuleKey;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.scanner.mediumtest.AnalysisResult;
 import org.sonar.scanner.mediumtest.ScannerMediumTester;
 import org.sonar.scanner.protocol.output.ScannerReport.ExternalIssue;
@@ -61,6 +62,11 @@ public class IssuesMediumIT {
     .addRules(new XooRulesDefinition())
     .addActiveRule("xoo", "OneIssuePerLine", null, "One issue per line", "MAJOR", "OneIssuePerLine.internal", "xoo");
 
+  @Before
+  public void setUp() throws Exception {
+    logTester.setLevel(Level.DEBUG);
+  }
+
   @Test
   public void testOneIssuePerLine() throws Exception {
     File projectDir = new File("test-resources/mediumtest/xoo/sample");
@@ -243,7 +249,7 @@ public class IssuesMediumIT {
         .build())
       .execute();
 
-    assertThat(logTester.logs(LoggerLevel.WARN)).contains(
+    assertThat(logTester.logs(Level.WARN)).contains(
       "Specifying module-relative paths at project level in property 'sonar.issue.ignore.multicriteria' is deprecated. To continue matching files like 'moduleA/src/sampleA.xoo', update this property so that patterns refer to project-relative paths.");
 
     List<Issue> issues = result.issuesFor(result.inputFile("moduleA/src/sampleA.xoo"));
@@ -281,7 +287,7 @@ public class IssuesMediumIT {
         .build())
       .execute();
 
-    assertThat(logTester.logs(LoggerLevel.WARN)).isEmpty();
+    assertThat(logTester.logs(Level.WARN)).isEmpty();
 
     result = tester.newAnalysis()
       .properties(ImmutableMap.<String, String>builder()
@@ -296,7 +302,7 @@ public class IssuesMediumIT {
         .build())
       .execute();
 
-    assertThat(logTester.logs(LoggerLevel.WARN)).containsOnly(
+    assertThat(logTester.logs(Level.WARN)).containsOnly(
       "Specifying issue exclusions at module level is not supported anymore. Configure the property 'sonar.issue.ignore.multicriteria' and any other issue exclusions at project level.");
 
     List<Issue> issues = result.issuesFor(result.inputFile("moduleA/src/sampleA.xoo"));
@@ -323,7 +329,7 @@ public class IssuesMediumIT {
         .build())
       .execute();
 
-    assertThat(logTester.logs(LoggerLevel.WARN)).isEmpty();
+    assertThat(logTester.logs(Level.WARN)).isEmpty();
   }
 
   @Test
@@ -388,7 +394,7 @@ public class IssuesMediumIT {
         .build())
       .execute();
 
-    assertThat(logTester.logs(LoggerLevel.WARN)).contains(
+    assertThat(logTester.logs(Level.WARN)).contains(
       "Specifying module-relative paths at project level in property 'sonar.issue.enforce.multicriteria' is deprecated. To continue matching files like 'moduleA/src/sampleA.xoo', update this property so that patterns refer to project-relative paths.");
 
     List<Issue> issues = result.issuesFor(result.inputFile("moduleA/src/sampleA.xoo"));
index 6cd81792a932cb323a5870c725ce74245d82f204..456e6305626574d9e48fd37d1dd28472b523a1de 100644 (file)
@@ -23,7 +23,7 @@ import com.google.common.collect.ImmutableMap;
 import org.junit.Rule;
 import org.junit.Test;
 import org.sonar.api.utils.MessageException;
-import org.sonar.api.utils.log.LogTester;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.scanner.mediumtest.ScannerMediumTester;
 
 import static org.assertj.core.api.Assertions.assertThat;
index c3f4fb1768e97c0e6780c5c20a4f8ce7e9a2a502..3797de5c15a6b74f464aecc2f1a4352ec0773d68 100644 (file)
@@ -25,13 +25,15 @@ import java.io.IOException;
 import java.nio.charset.StandardCharsets;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.CopyOnWriteArrayList;
 import org.apache.commons.io.FileUtils;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.TemporaryFolder;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
+import org.slf4j.event.Level;
+import org.sonar.api.testfixtures.log.LogTester;
+import org.sonar.batch.bootstrapper.LogOutput;
 import org.sonar.scanner.mediumtest.AnalysisResult;
 import org.sonar.scanner.mediumtest.ScannerMediumTester;
 import org.sonar.scanner.protocol.output.ScannerReport.Measure;
@@ -42,10 +44,8 @@ import static org.assertj.core.api.Assertions.tuple;
 import static org.junit.Assert.fail;
 
 public class MeasuresMediumIT {
-
   @Rule
   public LogTester logTester = new LogTester();
-
   @Rule
   public TemporaryFolder temp = new TemporaryFolder();
 
@@ -150,7 +150,7 @@ public class MeasuresMediumIT {
       .execute();
 
 
-    assertThat(logTester.logs(LoggerLevel.WARN)).contains("Storing measures on folders or modules is deprecated. Provided value of metric 'tests' is ignored.");
+    assertThat(logTester.logs(Level.WARN)).contains("Storing measures on folders or modules is deprecated. Provided value of metric 'tests' is ignored.");
   }
 
   @Test
@@ -176,7 +176,7 @@ public class MeasuresMediumIT {
       .execute();
 
 
-    assertThat(logTester.logs(LoggerLevel.WARN)).contains("Storing measures on folders or modules is deprecated. Provided value of metric 'tests' is ignored.");
+    assertThat(logTester.logs(Level.WARN)).contains("Storing measures on folders or modules is deprecated. Provided value of metric 'tests' is ignored.");
   }
 
 }
index 04451bf92f04f5bfa0a62ea705229f99658cba8a..776e587806934a393c5eb1d06e659363a6d952bd 100644 (file)
@@ -31,8 +31,9 @@ import org.assertj.core.util.Files;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.TemporaryFolder;
+import org.slf4j.event.Level;
 import org.sonar.api.SonarEdition;
-import org.sonar.api.utils.log.LogTester;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.scanner.mediumtest.ScannerMediumTester;
 import org.sonar.scanner.mediumtest.ScannerMediumTester.AnalysisBuilder;
 import org.sonar.scanner.protocol.output.FileStructure;
@@ -150,7 +151,7 @@ public class ScmMediumIT {
 
   @Test
   public void log_files_with_missing_blame() throws IOException, URISyntaxException {
-
+    logTester.setLevel(Level.DEBUG);
     File baseDir = prepareProject();
     File xooFileWithoutBlame = new File(baseDir, "src/sample_no_blame.xoo");
     FileUtils.write(xooFileWithoutBlame, "Sample xoo\ncontent\n3\n4\n5", StandardCharsets.UTF_8);
@@ -183,7 +184,7 @@ public class ScmMediumIT {
   // SONAR-6397
   @Test
   public void optimize_blame() throws IOException, URISyntaxException {
-
+    logTester.setLevel(Level.DEBUG);
     File baseDir = prepareProject();
     File changedContentScmOnServer = new File(baseDir, CHANGED_CONTENT_SCM_ON_SERVER_XOO);
     FileUtils.write(changedContentScmOnServer, SAMPLE_XOO_CONTENT + "\nchanged", StandardCharsets.UTF_8);
index 776a11575bf7335cc95f3c3cdacc3b121b9ec6da..35d86c2e63426ec87737cd80a68c31e7b635a91d 100644 (file)
@@ -24,7 +24,7 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.sonar.api.Plugin;
 import org.sonar.api.utils.MessageException;
-import org.sonar.api.utils.log.LogTester;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.scanner.mediumtest.ScannerMediumTester;
 
 import static org.assertj.core.api.Assertions.assertThat;
index 86962f74824d6b16028f027809bee6cd42349108..4b0d80044fc36a2f605a2aeb72c06c37c6600853 100644 (file)
@@ -26,6 +26,7 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.sonar.api.batch.fs.InputFile;
 import org.sonar.api.measures.CoreMetrics;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.scanner.mediumtest.AnalysisResult;
 import org.sonar.scanner.mediumtest.ScannerMediumTester;
 import org.sonar.xoo.XooPlugin;
@@ -34,8 +35,8 @@ import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.tuple;
 
 public class GenericTestExecutionMediumIT {
-  private final List<String> logs = new ArrayList<>();
-
+  @Rule
+  public LogTester logTester = new LogTester();
   @Rule
   public ScannerMediumTester tester = new ScannerMediumTester()
     .registerPlugin("xoo", new XooPlugin())
@@ -47,7 +48,6 @@ public class GenericTestExecutionMediumIT {
     File projectDir = new File("test-resources/mediumtest/xoo/sample-generic-test-exec");
 
     AnalysisResult result = tester
-      .setLogOutput((msg, level) -> logs.add(msg))
       .newAnalysis(new File(projectDir, "sonar-project.properties"))
       .property("sonar.testExecutionReportPaths", "unittest.xml")
       .execute();
@@ -61,7 +61,7 @@ public class GenericTestExecutionMediumIT {
         tuple(CoreMetrics.TEST_EXECUTION_TIME_KEY, 0, 1105L),
         tuple(CoreMetrics.TEST_FAILURES_KEY, 1, 0L));
 
-    assertThat(logs).noneMatch(l -> l.contains("Please use 'sonar.testExecutionReportPaths'"));
+    assertThat(logTester.logs()).noneMatch(l -> l.contains("Please use 'sonar.testExecutionReportPaths'"));
   }
 
   @Test
@@ -70,7 +70,6 @@ public class GenericTestExecutionMediumIT {
     File projectDir = new File("test-resources/mediumtest/xoo/sample-generic-test-exec");
 
     AnalysisResult result = tester
-      .setLogOutput((msg, level) -> logs.add(msg))
       .newAnalysis(new File(projectDir, "sonar-project.properties"))
       .property("sonar.testExecutionReportPaths", "unittest.xml,unittest2.xml")
       .execute();
@@ -84,7 +83,7 @@ public class GenericTestExecutionMediumIT {
         tuple(CoreMetrics.TEST_EXECUTION_TIME_KEY, 0, 1610L),
         tuple(CoreMetrics.TEST_FAILURES_KEY, 1, 0L));
 
-    assertThat(logs).noneMatch(l -> l.contains("Please use 'sonar.testExecutionReportPaths'"));
+    assertThat(logTester.logs()).noneMatch(l -> l.contains("Please use 'sonar.testExecutionReportPaths'"));
   }
 
 }
index dec6960b3cb470b031b5ba6d54344907045acc79..3c401e86b22c4980b21f22c1bef653f7110fa06e 100644 (file)
@@ -41,6 +41,7 @@ import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
 import org.junit.runners.Parameterized.Parameters;
 import org.mockito.ArgumentCaptor;
+import org.slf4j.event.Level;
 import org.sonar.api.batch.fs.FileSystem;
 import org.sonar.api.batch.fs.InputFile;
 import org.sonar.api.batch.fs.internal.DefaultInputFile;
@@ -48,8 +49,7 @@ import org.sonar.api.batch.fs.internal.TestInputFileBuilder;
 import org.sonar.api.batch.scm.BlameCommand.BlameInput;
 import org.sonar.api.batch.scm.BlameCommand.BlameOutput;
 import org.sonar.api.batch.scm.BlameLine;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.tmatesoft.svn.core.SVNAuthenticationException;
 import org.tmatesoft.svn.core.SVNDepth;
 import org.tmatesoft.svn.core.SVNURL;
@@ -321,7 +321,7 @@ public class SvnBlameCommandIT {
 
     assertThrows(IllegalStateException.class, () -> {
       svnBlameCommand.blame(clientManager, inputFile, output);
-      assertThat(logTester.logs(LoggerLevel.WARN)).contains("Authentication to SVN server is required but no " +
+      assertThat(logTester.logs(Level.WARN)).contains("Authentication to SVN server is required but no " +
         "authentication data was passed to the scanner");
     });
 
@@ -350,11 +350,8 @@ public class SvnBlameCommandIT {
       any(SVNRevision.class), any(SVNRevision.class), anyBoolean(), anyBoolean(), any(AnnotationHandler.class),
       eq(null));
 
-    assertThrows(IllegalStateException.class, () -> {
-      svnBlameCommand.blame(clientManager, inputFile, output);
-      assertThat(logTester.logs(LoggerLevel.WARN)).isEmpty();
-    });
-
+    assertThrows(IllegalStateException.class, () -> svnBlameCommand.blame(clientManager, inputFile, output));
+    assertThat(logTester.logs(Level.WARN)).contains("Authentication to SVN server is required but no authentication data was passed to the scanner");
   }
 
   private static void javaUnzip(File zip, File toDir) {
index cb2e3d0c96bc1c79b76df6b49313d814b4ae19a3..5eed107276d74bf615e71f9709cc5a2263761534 100644 (file)
@@ -77,7 +77,7 @@ public final class Batch {
   }
 
   private RuntimeException handleException(RuntimeException t) {
-    if (loggingConfig.isVerbose()) {
+    if (loggingConfig != null && loggingConfig.isVerbose()) {
       return t;
     }
 
index 1d5aed378127553c90396d1f7ec22813d45052e6..844940375054a9e8a0699c60e888813746880da8 100644 (file)
@@ -28,9 +28,10 @@ import org.apache.commons.lang.StringUtils;
 import org.junit.Rule;
 import org.junit.Test;
 import org.mockito.Mockito;
+import org.slf4j.event.Level;
 import org.sonar.api.notifications.AnalysisWarnings;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.api.utils.MessageException;
-import org.sonar.api.utils.log.LogTester;
 import org.sonar.api.utils.log.LoggerLevel;
 import org.sonarqube.ws.client.GetRequest;
 import org.sonarqube.ws.client.HttpException;
@@ -69,7 +70,7 @@ public class DefaultScannerWsClientTest {
     assertThat(result).isSameAs(response);
 
     // check logs
-    List<String> debugLogs = logTester.logs(LoggerLevel.DEBUG);
+    List<String> debugLogs = logTester.logs(Level.DEBUG);
     assertThat(debugLogs).hasSize(1);
     assertThat(debugLogs.get(0)).contains("GET 200 https://local/api/issues/search | time=");
   }
@@ -149,7 +150,7 @@ public class DefaultScannerWsClientTest {
     underTest.call(request);
 
     // check logs
-    List<String> warningLogs = logTester.logs(LoggerLevel.WARN);
+    List<String> warningLogs = logTester.logs(Level.WARN);
     assertThat(warningLogs).hasSize(2);
     assertThat(warningLogs.get(0)).contains("The token used for this analysis will expire on: " + fiveDaysLatter.format(DateTimeFormatter.ofPattern("MMMM dd, yyyy")));
     assertThat(warningLogs.get(1)).contains("Analysis executed with this token will fail after the expiration date.");
index 9936994fce306af5fd61f9d29392b0e6eaddf579..1e0d36b8bc05c79307408e6f3e209c57b4eddc5a 100644 (file)
@@ -26,7 +26,7 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.sonar.api.config.PropertyDefinitions;
 import org.sonar.api.utils.System2;
-import org.sonar.api.utils.log.LogTester;
+import org.sonar.api.testfixtures.log.LogTester;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.mockito.Mockito.mock;
index 52bc139c101f62257391a125467b8a7c35e77642..7b9c8506b81cfe1f1f4119640c29c119383de357 100644 (file)
@@ -33,7 +33,7 @@ import org.junit.Test;
 import org.mockito.ArgumentCaptor;
 import org.sonar.api.scanner.fs.InputProject;
 import org.sonar.api.utils.MessageException;
-import org.sonar.api.utils.log.LogTester;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.scanner.bootstrap.DefaultScannerWsClient;
 import org.sonar.scanner.protocol.internal.ScannerInternal.SensorCacheEntry;
 import org.sonar.scanner.protocol.internal.SensorCacheData;
index 27be416a12bae5ea25555fe820e5206647855afc..b40faeb0b9bd6b1e8925e904159d8af18aaf8129 100644 (file)
@@ -22,9 +22,9 @@ package org.sonar.scanner.ci.vendors;
 import javax.annotation.Nullable;
 import org.junit.Rule;
 import org.junit.Test;
+import org.slf4j.event.Level;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.api.utils.System2;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
 import org.sonar.scanner.ci.CiConfiguration;
 import org.sonar.scanner.ci.CiVendor;
 
@@ -77,7 +77,7 @@ public class CirrusCiTest {
     CiConfiguration configuration = underTest.loadConfiguration();
 
     assertThat(configuration.getScmRevision()).isEmpty();
-    assertThat(logs.logs(LoggerLevel.WARN)).contains("Missing environment variable CIRRUS_CHANGE_IN_REPO");
+    assertThat(logs.logs(Level.WARN)).contains("Missing environment variable CIRRUS_CHANGE_IN_REPO");
   }
 
   private void setEnvVariable(String key, @Nullable String value) {
index 95ee135bb9575b265637694a2d42814c71d90cba..8eef19bce63084ba447ff8b30c2cd00f707e750b 100644 (file)
@@ -23,9 +23,9 @@ import java.util.List;
 import javax.annotation.Nullable;
 import org.junit.Rule;
 import org.junit.Test;
+import org.slf4j.event.Level;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.api.utils.System2;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
 import org.sonar.scanner.ci.CiConfiguration;
 import org.sonar.scanner.ci.CiVendor;
 
@@ -71,7 +71,7 @@ public class CodeMagicTest {
     setEnvVariable("FCI_BUILD_ID", "1");
 
     CiConfiguration ciConfiguration = underTest.loadConfiguration();
-    List<String> logs = logTester.logs(LoggerLevel.WARN);
+    List<String> logs = logTester.logs(Level.WARN);
 
     assertThat(ciConfiguration.getScmRevision()).isEmpty();
     assertThat(logs).hasSize(1);
index 690bc23aee5ae3c79139278ac4b138e3478bf995..f37622fa2104abd58a62b4c4d7789df19f1bb7a0 100644 (file)
@@ -22,9 +22,9 @@ package org.sonar.scanner.ci.vendors;
 import javax.annotation.Nullable;
 import org.junit.Rule;
 import org.junit.Test;
+import org.slf4j.event.Level;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.api.utils.System2;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
 import org.sonar.scanner.ci.CiVendor;
 
 import static org.assertj.core.api.Assertions.assertThat;
@@ -66,7 +66,7 @@ public class GithubActionsTest {
     setEnvVariable("GITHUB_ACTION", "build");
 
     assertThat(underTest.loadConfiguration().getScmRevision()).isEmpty();
-    assertThat(logs.logs(LoggerLevel.WARN)).contains("Missing environment variable GITHUB_SHA");
+    assertThat(logs.logs(Level.WARN)).contains("Missing environment variable GITHUB_SHA");
   }
 
   private void setEnvVariable(String key, @Nullable String value) {
index dc74cad4abd166b58cb5368879d73782ef17529c..c1865c579a0642e5a4dd61bd891fc2ced539b542 100644 (file)
@@ -23,14 +23,14 @@ import com.google.common.collect.ImmutableMap;
 import java.util.Arrays;
 import org.junit.Rule;
 import org.junit.Test;
+import org.slf4j.event.Level;
 import org.sonar.api.config.Configuration;
 import org.sonar.api.config.PropertyDefinition;
 import org.sonar.api.config.PropertyDefinitions;
 import org.sonar.api.config.PropertyFieldDefinition;
 import org.sonar.api.config.internal.Encryption;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.api.utils.System2;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
 
 import static java.util.Collections.singletonList;
 import static org.assertj.core.api.Assertions.assertThat;
@@ -50,14 +50,14 @@ public class DefaultConfigurationTest {
     };
 
     assertThat(config.get("multiA")).hasValue("a,b");
-    assertThat(logTester.logs(LoggerLevel.WARN))
+    assertThat(logTester.logs(Level.WARN))
       .contains(
         "Access to the multi-values/property set property 'multiA' should be made using 'getStringArray' method. The SonarQube plugin using this property should be updated.");
 
     logTester.clear();
 
     assertThat(config.getStringArray("single")).containsExactly("foo");
-    assertThat(logTester.logs(LoggerLevel.WARN))
+    assertThat(logTester.logs(Level.WARN))
       .contains(
         "Property 'single' is not declared as multi-values/property set but was read using 'getStringArray' method. The SonarQube plugin declaring this property should be updated.");
 
@@ -65,7 +65,7 @@ public class DefaultConfigurationTest {
 
     assertThat(config.get("notDeclared")).hasValue("c,d");
     assertThat(config.getStringArray("notDeclared")).containsExactly("c", "d");
-    assertThat(logTester.logs(LoggerLevel.WARN)).isEmpty();
+    assertThat(logTester.logs(Level.WARN)).isEmpty();
   }
 
   @Test
@@ -77,14 +77,14 @@ public class DefaultConfigurationTest {
     };
 
     assertThat(config.get("props")).hasValue("1,2");
-    assertThat(logTester.logs(LoggerLevel.WARN))
+    assertThat(logTester.logs(Level.WARN))
       .contains(
         "Access to the multi-values/property set property 'props' should be made using 'getStringArray' method. The SonarQube plugin using this property should be updated.");
 
     logTester.clear();
 
     assertThat(config.getStringArray("props")).containsExactly("1", "2");
-    assertThat(logTester.logs(LoggerLevel.WARN)).isEmpty();
+    assertThat(logTester.logs(Level.WARN)).isEmpty();
   }
 
   @Test
index 97e6faf3d97b747458b47ec39ad9417f90d40eb8..13ec7ccec3309cc3a5abdd0af0b4921b50854214 100644 (file)
@@ -35,12 +35,12 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.TemporaryFolder;
 import org.mockito.ArgumentMatchers;
+import org.slf4j.event.Level;
 import org.sonar.api.SonarRuntime;
 import org.sonar.api.batch.fs.internal.DefaultInputFile;
 import org.sonar.api.batch.fs.internal.DefaultInputProject;
 import org.sonar.api.batch.fs.internal.TestInputFileBuilder;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.core.util.CloseableIterator;
 import org.sonar.duplications.block.Block;
 import org.sonar.duplications.block.ByteArray;
@@ -141,7 +141,7 @@ public class CpdExecutorTest {
     Duplication[] dups = readDuplications(1);
     assertThat(dups[0].getDuplicateList()).hasSize(CpdExecutor.MAX_CLONE_PART_PER_GROUP);
 
-    assertThat(logTester.logs(LoggerLevel.WARN))
+    assertThat(logTester.logs(Level.WARN))
       .contains("Too many duplication references on file " + batchComponent1 + " for block at line 0. Keep only the first "
         + CpdExecutor.MAX_CLONE_PART_PER_GROUP + " references.");
   }
@@ -159,7 +159,7 @@ public class CpdExecutorTest {
 
     assertThat(reader.readComponentDuplications(batchComponent1.scannerId())).toIterable().hasSize(CpdExecutor.MAX_CLONE_GROUP_PER_FILE);
 
-    assertThat(logTester.logs(LoggerLevel.WARN))
+    assertThat(logTester.logs(Level.WARN))
       .contains("Too many duplication groups on file " + batchComponent1 + ". Keep only the first " + CpdExecutor.MAX_CLONE_GROUP_PER_FILE + " groups.");
   }
 
@@ -203,7 +203,7 @@ public class CpdExecutorTest {
     verify(executorService).shutdown();
     verifyNoMoreInteractions(executorService);
     readDuplications(batchComponent1, 0);
-    assertThat(logTester.logs(LoggerLevel.ERROR)).contains("Resource not found in component store: unknown. Skipping CPD computation for it");
+    assertThat(logTester.logs(Level.ERROR)).contains("Resource not found in component store: unknown. Skipping CPD computation for it");
   }
 
   @Test
@@ -217,7 +217,7 @@ public class CpdExecutorTest {
     executor.execute(1);
 
     readDuplications(0);
-    assertThat(logTester.logs(LoggerLevel.WARN))
+    assertThat(logTester.logs(Level.WARN))
       .usingElementComparator((l, r) -> l.matches(r) ? 0 : 1)
       .containsOnly(
         "Timeout during detection of duplications for .*Foo.php");
index 75fe15385d2d70a88648e13d85110dc1e6a90058..315991b93fb99c1c885b8468b2c5430dbdcf1e1d 100644 (file)
@@ -26,14 +26,14 @@ import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.TemporaryFolder;
+import org.slf4j.event.Level;
 import org.sonar.api.batch.fs.TextRange;
-import org.sonar.api.batch.rule.Severity;
-import org.sonar.api.batch.sensor.issue.ExternalIssue;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
 import org.sonar.api.batch.fs.internal.DefaultInputFile;
 import org.sonar.api.batch.fs.internal.TestInputFileBuilder;
+import org.sonar.api.batch.rule.Severity;
 import org.sonar.api.batch.sensor.internal.SensorContextTester;
+import org.sonar.api.batch.sensor.issue.ExternalIssue;
+import org.sonar.api.testfixtures.log.LogTester;
 
 import static java.nio.charset.StandardCharsets.UTF_8;
 import static org.apache.commons.lang.ObjectUtils.defaultIfNull;
@@ -72,7 +72,7 @@ public class ExternalIssueImporterTest {
 
     assertThat(context.allExternalIssues()).isEmpty();
     assertThat(context.allIssues()).isEmpty();
-    assertThat(logs.logs(LoggerLevel.INFO)).contains("Imported 0 issues in 0 files");
+    assertThat(logs.logs(Level.INFO)).contains("Imported 0 issues in 0 files");
   }
 
   @Test
@@ -97,7 +97,7 @@ public class ExternalIssueImporterTest {
     assertThat(output.ruleId()).isEqualTo(input.ruleId);
     assertThat(output.severity()).isEqualTo(Severity.valueOf(input.severity));
     assertThat(output.remediationEffort()).isNull();
-    assertThat(logs.logs(LoggerLevel.INFO)).contains("Imported 1 issue in 1 file");
+    assertThat(logs.logs(Level.INFO)).contains("Imported 1 issue in 1 file");
   }
 
   @Test
index a3cc9ced05f3a497b23cef259d22fe1b05aa7541..e8cf14b5adbc14d18d376ca5e4349ccecfe6b298 100644 (file)
@@ -28,9 +28,9 @@ import org.junit.runner.RunWith;
 import org.mockito.InjectMocks;
 import org.mockito.Mock;
 import org.mockito.junit.MockitoJUnitRunner;
+import org.slf4j.event.Level;
 import org.sonar.api.batch.sensor.issue.NewExternalIssue;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.core.sarif.Run;
 import org.sonar.core.sarif.Sarif210;
 
@@ -95,7 +95,7 @@ public class DefaultSarif210ImporterTest extends TestCase {
     assertThat(sarifImportResults.getSuccessFullyImportedIssues()).isOne();
     assertThat(sarifImportResults.getSuccessFullyImportedRuns()).isOne();
     assertThat(sarifImportResults.getFailedRuns()).isOne();
-    assertThat(logTester.logs(LoggerLevel.WARN)).containsOnly("Failed to import a sarif run, error: " + testException.getMessage());
+    assertThat(logTester.logs(Level.WARN)).containsOnly("Failed to import a sarif run, error: " + testException.getMessage());
     verify(issue1run2).save();
   }
 
index 5a4f128f92c9b9fa888832a590142936e3bf7fdf..a06e2324ff5db322b6e92044fd059e8a861da5b6 100644 (file)
@@ -24,8 +24,9 @@ import java.util.Set;
 import org.assertj.core.api.Assertions;
 import org.assertj.core.groups.Tuple;
 import org.junit.Test;
+import org.slf4j.event.Level;
 import org.sonar.api.batch.rule.Severity;
-import org.sonar.api.utils.log.LogTester;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.api.utils.log.LoggerLevel;
 import org.sonar.core.sarif.DefaultConfiguration;
 import org.sonar.core.sarif.Driver;
@@ -153,7 +154,7 @@ public class RulesSeverityDetectorTest {
 
   private void assertWarningLog(String driverName, Severity defaultSeverity) {
     assertThat(logTester.logs()).hasSize(1);
-    assertThat(logTester.logs(LoggerLevel.WARN))
+    assertThat(logTester.logs(Level.WARN))
       .containsOnly(format(UNSUPPORTED_RULE_SEVERITIES_WARNING, driverName, defaultSeverity));
   }
 
index eb10e4d299584aca6f359d3135fddf651803ad43..6146886d1fe277ac9dfde61b4d4c736c40142166 100644 (file)
@@ -30,9 +30,9 @@ import org.mockito.InjectMocks;
 import org.mockito.Mock;
 import org.mockito.MockedStatic;
 import org.mockito.junit.MockitoJUnitRunner;
+import org.slf4j.event.Level;
 import org.sonar.api.batch.sensor.issue.NewExternalIssue;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.core.sarif.Result;
 import org.sonar.core.sarif.Run;
 
@@ -106,7 +106,7 @@ public class RunMapperTest {
 
       assertThat(newExternalIssues)
         .containsExactly(externalIssue2);
-      assertThat(logTester.logs(LoggerLevel.WARN)).containsOnly("Failed to import an issue raised by tool Test driver, error: test");
+      assertThat(logTester.logs(Level.WARN)).containsOnly("Failed to import an issue raised by tool Test driver, error: test");
     }
   }
 
index ccffa0e353a49726ca22ff1526348d39500be12e..533e05d97115127c27d5264607df69da814ed5a1 100644 (file)
@@ -22,19 +22,18 @@ package org.sonar.scanner.externalissue.sarif;
 import com.google.common.collect.MoreCollectors;
 import java.nio.file.Path;
 import java.util.Optional;
-import java.util.stream.Collectors;
 import org.apache.commons.lang.math.RandomUtils;
-import org.jetbrains.annotations.NotNull;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.junit.MockitoJUnitRunner;
+import org.slf4j.event.Level;
 import org.sonar.api.batch.sensor.internal.SensorContextTester;
 import org.sonar.api.config.internal.MapSettings;
-import org.sonar.api.utils.log.LogAndArguments;
-import org.sonar.api.utils.log.LogTester;
+import org.sonar.api.testfixtures.log.LogAndArguments;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.api.utils.log.LoggerLevel;
 import org.sonar.core.sarif.Sarif210;
 import org.sonar.core.sarif.SarifSerializer;
@@ -80,7 +79,7 @@ public class SarifIssuesImportSensorTest {
 
     verify(sarifImporter).importSarif(reportAndResults.getSarifReport());
 
-    assertThat(logTester.logs(LoggerLevel.INFO)).hasSize(1);
+    assertThat(logTester.logs(Level.INFO)).hasSize(1);
     assertSummaryIsCorrectlyDisplayed(FILE_1, reportAndResults.getSarifImportResults());
   }
 
@@ -115,7 +114,7 @@ public class SarifIssuesImportSensorTest {
     sensor.execute(sensorContext);
 
     verify(sarifImporter).importSarif(reportAndResults2.getSarifReport());
-    assertThat(logTester.logs(LoggerLevel.WARN)).contains("Failed to process SARIF report from file 'path/to/sarif/file.sarif', error: 'import failed'");
+    assertThat(logTester.logs(Level.WARN)).contains("Failed to process SARIF report from file 'path/to/sarif/file.sarif', error: 'import failed'");
     assertSummaryIsCorrectlyDisplayed(FILE_2, reportAndResults2.getSarifImportResults());
   }
 
@@ -130,7 +129,7 @@ public class SarifIssuesImportSensorTest {
     sensor.execute(sensorContext);
 
     verify(sarifImporter).importSarif(reportAndResults2.getSarifReport());
-    assertThat(logTester.logs(LoggerLevel.WARN)).contains("Failed to process SARIF report from file 'path/to/sarif/file.sarif', error: 'deserialization failed'");
+    assertThat(logTester.logs(Level.WARN)).contains("Failed to process SARIF report from file 'path/to/sarif/file.sarif', error: 'deserialization failed'");
     assertSummaryIsCorrectlyDisplayed(FILE_2, reportAndResults2.getSarifImportResults());
   }
 
index 043c1a7d5d24229b2d81f8ad6f05b4108574ff79..a37dd222edf9bb7755866fa28f7a72a1467dd81b 100644 (file)
@@ -26,12 +26,13 @@ import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.TemporaryFolder;
+import org.slf4j.event.Level;
 import org.sonar.api.batch.fs.InputFile;
 import org.sonar.api.batch.fs.internal.DefaultInputFile;
 import org.sonar.api.batch.fs.internal.TestInputFileBuilder;
 import org.sonar.api.batch.sensor.internal.SensorContextTester;
 import org.sonar.api.utils.MessageException;
-import org.sonar.api.utils.log.LogTester;
+import org.sonar.api.testfixtures.log.LogTester;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
@@ -48,6 +49,7 @@ public class GenericCoverageReportParserTest {
 
   @Before
   public void before() {
+    logs.setLevel(Level.DEBUG);
     context = SensorContextTester.create(new File(""));
     fileWithBranches = setupFile("src/main/java/com/example/ClassWithBranches.java");
     fileWithoutBranch = setupFile("src/main/java/com/example/ClassWithoutBranch.java");
index b2648a575a1058707a9caf7a40201fe7cb63570c..0e6329b4bfc02e4a2ac668b3d7d2bb2c15238bdd 100644 (file)
@@ -27,7 +27,7 @@ import org.junit.Test;
 import org.sonar.api.config.PropertyDefinitions;
 import org.sonar.api.config.internal.Encryption;
 import org.sonar.api.utils.System2;
-import org.sonar.api.utils.log.LogTester;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.scanner.config.DefaultConfiguration;
 import org.sonar.scanner.scan.ProjectConfiguration;
 
index 73688ea4884d871bb3865b9a28916092763b0a05..27974475c299bdcb2582926270bcad442bc74dd5 100644 (file)
@@ -26,12 +26,13 @@ import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.TemporaryFolder;
+import org.slf4j.event.Level;
 import org.sonar.api.batch.fs.InputFile;
 import org.sonar.api.batch.fs.internal.DefaultInputFile;
 import org.sonar.api.batch.fs.internal.TestInputFileBuilder;
 import org.sonar.api.batch.sensor.internal.SensorContextTester;
 import org.sonar.api.utils.MessageException;
-import org.sonar.api.utils.log.LogTester;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.scanner.deprecated.test.DefaultTestCase;
 import org.sonar.scanner.deprecated.test.DefaultTestPlan;
 import org.sonar.scanner.deprecated.test.TestPlanBuilder;
@@ -50,6 +51,7 @@ public class GenericTestExecutionReportParserTest {
   public TemporaryFolder temp = new TemporaryFolder();
   @Rule
   public LogTester logs = new LogTester();
+
   private TestPlanBuilder testPlanBuilder;
   private DefaultInputFile fileWithBranches;
   private DefaultInputFile emptyFile;
@@ -58,6 +60,7 @@ public class GenericTestExecutionReportParserTest {
 
   @Before
   public void before() {
+    logs.setLevel(Level.DEBUG);
     context = SensorContextTester.create(new File(""));
     fileWithBranches = setupFile("src/main/java/com/example/ClassWithBranches.java");
     emptyFile = setupFile("src/main/java/com/example/EmptyClass.java");
index fbd4f88228a9d1fa848df99e564ad7278bd1ca16..8712d9aff6807f10466e1eeadbb232cd4edc54bc 100644 (file)
@@ -28,12 +28,12 @@ import org.apache.commons.io.FileUtils;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.TemporaryFolder;
+import org.slf4j.event.Level;
 import org.sonar.api.batch.sensor.internal.SensorContextTester;
 import org.sonar.api.config.PropertyDefinitions;
 import org.sonar.api.config.internal.Encryption;
 import org.sonar.api.utils.System2;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.scanner.config.DefaultConfiguration;
 import org.sonar.scanner.deprecated.test.TestPlanBuilder;
 import org.sonar.scanner.scan.ProjectConfiguration;
@@ -62,11 +62,11 @@ public class GenericTestExecutionSensorTest {
     DefaultConfiguration config = new ProjectConfiguration(defs, new Encryption(null), settings);
 
     new GenericTestExecutionSensor(mock(TestPlanBuilder.class), config).execute(context);
-    assertThat(logTester.logs(LoggerLevel.WARN)).contains(
+    assertThat(logTester.logs(Level.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(
+    assertThat(logTester.logs(Level.INFO)).contains(
       "Imported test execution data for 0 files",
       "Test execution data ignored for 1 unknown files, including:\nA.java");
   }
index 4c232592e10487e5a9afe49abad34974bd815f91..6007ef1e617bf91d4fed10d8bfb95963af6188bc 100644 (file)
@@ -30,7 +30,7 @@ import org.sonar.api.notifications.AnalysisWarnings;
 import org.sonar.api.rule.RuleKey;
 import org.sonar.api.scan.issue.filter.IssueFilterChain;
 import org.sonar.api.utils.WildcardPattern;
-import org.sonar.api.utils.log.LogTester;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.scanner.issue.DefaultFilterableIssue;
 
 import static java.util.Collections.singleton;
index e77cb6dbe19c91e12001786c9e6f1f2eb660d040..53c3884aa603e918773ca5b3531faabfaee40944 100644 (file)
@@ -37,7 +37,7 @@ import org.sonar.api.batch.sensor.Sensor;
 import org.sonar.api.batch.sensor.SensorContext;
 import org.sonar.api.batch.sensor.SensorDescriptor;
 import org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor;
-import org.sonar.api.utils.log.LogTester;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.scanner.bootstrap.ScannerPluginRepository;
 import org.sonar.scanner.fs.InputModuleHierarchy;
 import org.sonar.scanner.scan.branch.BranchConfiguration;
index 8a73051b7cf6b6c82bf388fe4b250bb7aa3d4fcc..558b2b4f4b5f093076b26b8b1d49f7275c3aafdd 100644 (file)
@@ -28,8 +28,9 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.ArgumentMatcher;
 import org.mockito.Mockito;
+import org.slf4j.event.Level;
 import org.sonar.api.utils.MessageException;
-import org.sonar.api.utils.log.LogTester;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.scanner.bootstrap.DefaultScannerWsClient;
 import org.sonar.scanner.bootstrap.GlobalAnalysisMode;
 import org.sonar.scanner.report.CeTaskReportDataHolder;
@@ -64,6 +65,7 @@ public class QualityGateCheckTest {
 
   @Before
   public void before() {
+    logTester.setLevel(Level.DEBUG);
     when(reportMetadataHolder.getCeTaskId()).thenReturn("task-1234");
     when(reportMetadataHolder.getDashboardUrl()).thenReturn("http://dashboard-url.com");
   }
index 8ee25330d28a53b0968796e2dc0aec240deede39..605d8e7787e46f32aa67519d8e822a65cc5f03f6 100644 (file)
@@ -35,7 +35,7 @@ import org.junit.rules.TemporaryFolder;
 import org.sonar.api.batch.bootstrap.ProjectDefinition;
 import org.sonar.api.batch.fs.internal.DefaultInputModule;
 import org.sonar.api.utils.System2;
-import org.sonar.api.utils.log.LogTester;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.api.utils.log.LoggerLevel;
 import org.sonar.core.platform.PluginInfo;
 import org.sonar.scanner.bootstrap.GlobalServerSettings;
index d9de9f51e4b12ab6ed7275d6f83e05ca67a164cf..f18dfb97713b75015bf08f573c892c3f4192e8b8 100644 (file)
@@ -35,7 +35,7 @@ import org.sonar.api.batch.fs.internal.DefaultInputFile;
 import org.sonar.api.batch.fs.internal.DefaultInputProject;
 import org.sonar.api.batch.fs.internal.TestInputFileBuilder;
 import org.sonar.api.batch.scm.ScmProvider;
-import org.sonar.api.utils.log.LogTester;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.scanner.fs.InputModuleHierarchy;
 import org.sonar.scanner.protocol.output.FileStructure;
 import org.sonar.scanner.protocol.output.ScannerReportReader;
index ffbe3971c1a14dcfb47912c4aa4b9870da2bcfa9..0e45609e29470f2d6aad11c797e3d40f5b1c0659 100644 (file)
@@ -23,22 +23,21 @@ import java.io.IOException;
 import java.io.PipedInputStream;
 import java.io.PipedOutputStream;
 import java.nio.charset.StandardCharsets;
-import java.nio.file.Path;
 import java.util.List;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.mockito.ArgumentCaptor;
 import org.mockito.Mockito;
+import org.slf4j.event.Level;
 import org.sonar.api.batch.bootstrap.ProjectDefinition;
 import org.sonar.api.batch.fs.internal.DefaultInputModule;
 import org.sonar.api.impl.utils.JUnitTempFolder;
 import org.sonar.api.notifications.AnalysisWarnings;
 import org.sonar.api.platform.Server;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.api.utils.MessageException;
 import org.sonar.api.utils.TempFolder;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
 import org.sonar.scanner.bootstrap.DefaultScannerWsClient;
 import org.sonar.scanner.bootstrap.GlobalAnalysisMode;
 import org.sonar.scanner.fs.InputModuleHierarchy;
@@ -89,6 +88,7 @@ public class ReportPublisherTest {
 
   @Before
   public void setUp() {
+    logTester.setLevel(Level.DEBUG);
     root = new DefaultInputModule(
       ProjectDefinition.create().setKey("org.sonarsource.sonarqube:sonarqube").setBaseDir(reportTempFolder.newDir()).setWorkDir(reportTempFolder.getRoot()));
     when(moduleHierarchy.root()).thenReturn(root);
@@ -245,7 +245,7 @@ public class ReportPublisherTest {
     underTest.start();
     underTest.execute();
 
-    assertThat(logTester.logs(LoggerLevel.INFO))
+    assertThat(logTester.logs(Level.INFO))
       .contains("ANALYSIS SUCCESSFUL")
       .doesNotContain("dashboard/index");
 
@@ -264,9 +264,9 @@ public class ReportPublisherTest {
     underTest.execute();
 
     assertThat(properties.metadataFilePath()).exists();
-    assertThat(logTester.logs(LoggerLevel.DEBUG))
+    assertThat(logTester.logs(Level.DEBUG))
       .contains("Report metadata written to " + properties.metadataFilePath());
-    assertThat(logTester.logs(LoggerLevel.INFO))
+    assertThat(logTester.logs(Level.INFO))
       .contains("ANALYSIS SUCCESSFUL, you can find the results at: https://publicserver/sonarqube/dashboard?id=org.sonarsource.sonarqube%3Asonarqube")
       .contains("More about the report processing at https://publicserver/sonarqube/api/ce/task?id=TASK-123");
   }
@@ -276,7 +276,7 @@ public class ReportPublisherTest {
     underTest.prepareAndDumpMetadata("TASK-123");
 
     assertThat(properties.metadataFilePath()).exists();
-    assertThat(logTester.logs(LoggerLevel.DEBUG)).contains("Report metadata written to " + properties.metadataFilePath());
+    assertThat(logTester.logs(Level.DEBUG)).contains("Report metadata written to " + properties.metadataFilePath());
   }
 
   @Test
@@ -385,7 +385,7 @@ public class ReportPublisherTest {
     underTest.start();
     underTest.execute();
 
-    assertThat(logTester.logs(LoggerLevel.WARN)).isEmpty();
+    assertThat(logTester.logs(Level.WARN)).isEmpty();
 
     verifyNoInteractions(analysisWarnings);
   }
@@ -397,7 +397,7 @@ public class ReportPublisherTest {
     underTest.start();
     underTest.execute();
 
-    assertThat(logTester.logs(LoggerLevel.WARN)).containsOnly(SUPPORT_OF_32_BIT_JRE_IS_DEPRECATED_MESSAGE);
+    assertThat(logTester.logs(Level.WARN)).containsOnly(SUPPORT_OF_32_BIT_JRE_IS_DEPRECATED_MESSAGE);
     verify(analysisWarnings).addUnique(SUPPORT_OF_32_BIT_JRE_IS_DEPRECATED_MESSAGE);
   }
 
index 2e99bca7c727809692a426886cebb23266f22deb..651a1ba4fe686bb0bef4a644f0cbe0ea23854ce2 100644 (file)
@@ -26,7 +26,7 @@ import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.sonar.api.utils.DateUtils;
-import org.sonar.api.utils.log.LogTester;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.scanner.bootstrap.ScannerProperties;
 import org.sonar.scanner.rule.QualityProfiles;
 import org.sonarqube.ws.Qualityprofiles.SearchWsResponse.QualityProfile;
index f584add964d2a29fee3428982b34b9563658cc83..f41b334a2785aa07e7aad3d0e064320875a4ca03 100644 (file)
@@ -24,11 +24,11 @@ import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.mockito.Mockito;
+import org.slf4j.event.Level;
 import org.sonar.api.CoreProperties;
 import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.notifications.AnalysisWarnings;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.batch.bootstrapper.EnvironmentInformation;
 
 import static org.mockito.Mockito.times;
@@ -65,7 +65,7 @@ public class DeprecatedPropertiesWarningGeneratorTest {
     underTest.execute();
 
     verify(analysisWarnings, times(1)).addUnique(LOGIN_WARN_MESSAGE);
-    Assertions.assertThat(logger.logs(LoggerLevel.WARN)).contains(LOGIN_WARN_MESSAGE);
+    Assertions.assertThat(logger.logs(Level.WARN)).contains(LOGIN_WARN_MESSAGE);
   }
 
   @Test
@@ -76,7 +76,7 @@ public class DeprecatedPropertiesWarningGeneratorTest {
     underTest.execute();
 
     verify(analysisWarnings, times(1)).addUnique(PASSWORD_WARN_MESSAGE);
-    Assertions.assertThat(logger.logs(LoggerLevel.WARN)).contains(PASSWORD_WARN_MESSAGE);
+    Assertions.assertThat(logger.logs(Level.WARN)).contains(PASSWORD_WARN_MESSAGE);
   }
 
   @Test
@@ -87,7 +87,7 @@ public class DeprecatedPropertiesWarningGeneratorTest {
     underTest.execute();
 
     verify(analysisWarnings, times(1)).addUnique(LOGIN_WARN_MESSAGE + SCANNER_DOTNET_WARN_MESSAGE);
-    Assertions.assertThat(logger.logs(LoggerLevel.WARN)).contains(LOGIN_WARN_MESSAGE + SCANNER_DOTNET_WARN_MESSAGE);
+    Assertions.assertThat(logger.logs(Level.WARN)).contains(LOGIN_WARN_MESSAGE + SCANNER_DOTNET_WARN_MESSAGE);
   }
 
   @Test
@@ -99,7 +99,7 @@ public class DeprecatedPropertiesWarningGeneratorTest {
     underTest.execute();
 
     verify(analysisWarnings, times(1)).addUnique(PASSWORD_WARN_MESSAGE + SCANNER_DOTNET_WARN_MESSAGE);
-    Assertions.assertThat(logger.logs(LoggerLevel.WARN)).contains(PASSWORD_WARN_MESSAGE + SCANNER_DOTNET_WARN_MESSAGE);
+    Assertions.assertThat(logger.logs(Level.WARN)).contains(PASSWORD_WARN_MESSAGE + SCANNER_DOTNET_WARN_MESSAGE);
   }
 
   @Test
@@ -107,7 +107,7 @@ public class DeprecatedPropertiesWarningGeneratorTest {
     underTest.execute();
 
     verifyNoInteractions(analysisWarnings);
-    Assertions.assertThat(logger.logs(LoggerLevel.WARN)).isEmpty();
+    Assertions.assertThat(logger.logs(Level.WARN)).isEmpty();
   }
 
 }
index 01414c30e3ddac30f3d0232361cced2b400f7691..4617699e4c963cb997a925e357b7b2f2355833dd 100644 (file)
@@ -35,7 +35,7 @@ import org.sonar.api.batch.bootstrap.ProjectDefinition;
 import org.sonar.api.batch.bootstrap.ProjectReactor;
 import org.sonar.api.notifications.AnalysisWarnings;
 import org.sonar.api.utils.MessageException;
-import org.sonar.api.utils.log.LogTester;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.scanner.bootstrap.ScannerProperties;
 
 import static java.util.Collections.emptyMap;
index 58e6e4510eafd50f7c84bcbf5c21bd7edb130eff..9fe39d63f1b59c2252ef1ef876c8c9bee5751aa0 100644 (file)
@@ -33,7 +33,7 @@ import org.sonar.api.CoreProperties;
 import org.sonar.api.batch.bootstrap.ProjectDefinition;
 import org.sonar.api.batch.bootstrap.ProjectReactor;
 import org.sonar.api.utils.MessageException;
-import org.sonar.api.utils.log.LogTester;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.core.config.ScannerProperties;
 import org.sonar.scanner.ProjectInfo;
 import org.sonar.scanner.bootstrap.GlobalConfiguration;
index b36fadbb8482ae66a16f26d3fe92a88e335a6ba7..cfe8cd20d3290a8b716da312eeae9e27e1ce96ab 100644 (file)
@@ -26,13 +26,13 @@ import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.TemporaryFolder;
+import org.slf4j.event.Level;
 import org.sonar.api.batch.fs.IndexedFile;
 import org.sonar.api.batch.fs.InputFile;
 import org.sonar.api.batch.fs.internal.DefaultIndexedFile;
 import org.sonar.api.config.internal.MapSettings;
 import org.sonar.api.notifications.AnalysisWarnings;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
+import org.sonar.api.testfixtures.log.LogTester;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.mockito.Mockito.mock;
@@ -74,8 +74,8 @@ public class AbstractExclusionFiltersTest {
 
     String expectedWarn = "Use of sonar.tests.inclusions detected. " +
       "While being taken into account, the only supported property is sonar.test.inclusions. Consider updating your configuration.";
-    assertThat( logTester.logs(LoggerLevel.WARN) ).hasSize(1)
-     .contains(expectedWarn);
+    assertThat(logTester.logs(Level.WARN)).hasSize(1)
+      .contains(expectedWarn);
     verify(analysisWarnings).addUnique(expectedWarn);
   }
 
@@ -93,15 +93,15 @@ public class AbstractExclusionFiltersTest {
 
     String expectedWarn = "Use of sonar.tests.exclusions detected. " +
       "While being taken into account, the only supported property is sonar.test.exclusions. Consider updating your configuration.";
-    assertThat( logTester.logs(LoggerLevel.WARN) ).hasSize(1)
+    assertThat(logTester.logs(Level.WARN)).hasSize(1)
       .contains(expectedWarn);
     verify(analysisWarnings).addUnique(expectedWarn);
   }
 
   @Test
-  public void should_keepLegacyValue_when_legacyAndAliasPropertiesAreUsedForTestInclusions(){
+  public void should_keepLegacyValue_when_legacyAndAliasPropertiesAreUsedForTestInclusions() {
     settings.setProperty(PROJECT_TESTS_INCLUSIONS_PROPERTY, "**/*Dao.java");
-    settings.setProperty(PROJECT_TEST_INCLUSIONS_PROPERTY,"**/*Dto.java");
+    settings.setProperty(PROJECT_TEST_INCLUSIONS_PROPERTY, "**/*Dto.java");
     AbstractExclusionFilters filter = new AbstractExclusionFilters(analysisWarnings, settings.asConfig()::getStringArray) {
     };
 
@@ -112,15 +112,15 @@ public class AbstractExclusionFiltersTest {
     assertThat(filter.isIncluded(indexedFile.path(), Paths.get(indexedFile.relativePath()), InputFile.Type.TEST)).isTrue();
 
     String expectedWarn = "Use of sonar.test.inclusions and sonar.tests.inclusions at the same time. sonar.test.inclusions is taken into account. Consider updating your configuration";
-    assertThat( logTester.logs(LoggerLevel.WARN) ).hasSize(1)
+    assertThat(logTester.logs(Level.WARN)).hasSize(1)
       .contains(expectedWarn);
     verify(analysisWarnings).addUnique(expectedWarn);
   }
 
   @Test
-  public void should_keepLegacyValue_when_legacyAndAliasPropertiesAreUsedForTestExclusions(){
+  public void should_keepLegacyValue_when_legacyAndAliasPropertiesAreUsedForTestExclusions() {
     settings.setProperty(PROJECT_TESTS_EXCLUSIONS_PROPERTY, "**/*Dao.java");
-    settings.setProperty(PROJECT_TEST_EXCLUSIONS_PROPERTY,"**/*Dto.java");
+    settings.setProperty(PROJECT_TEST_EXCLUSIONS_PROPERTY, "**/*Dto.java");
     AbstractExclusionFilters filter = new AbstractExclusionFilters(analysisWarnings, settings.asConfig()::getStringArray) {
     };
 
@@ -131,7 +131,7 @@ public class AbstractExclusionFiltersTest {
     assertThat(filter.isExcluded(indexedFile.path(), Paths.get(indexedFile.relativePath()), InputFile.Type.TEST)).isTrue();
 
     String expectedWarn = "Use of sonar.test.exclusions and sonar.tests.exclusions at the same time. sonar.test.exclusions is taken into account. Consider updating your configuration";
-    assertThat( logTester.logs(LoggerLevel.WARN) ).hasSize(1)
+    assertThat(logTester.logs(Level.WARN)).hasSize(1)
       .contains(expectedWarn);
     verify(analysisWarnings).addUnique(expectedWarn);
   }
index df139587912e3c6f7916c0c7ca3ade28a04a4be8..5fffbc1202f251ca05fd13354dbccb30f136ef39 100644 (file)
@@ -99,7 +99,7 @@ public class MetadataGeneratorTest {
     DefaultInputFile inputFile = createInputFileWithMetadata(tempFile);
     assertThat(inputFile.lines()).isEqualTo(3);
     assertThat(inputFile.nonBlankLines()).isEqualTo(3);
-    assertThat(inputFile.hash()).isEqualTo(md5Hex("foo\nbar\nbaz"));
+    assertThat(inputFile.md5Hash()).isEqualTo(md5Hex("foo\nbar\nbaz"));
     assertThat(inputFile.originalLineStartOffsets()).containsOnly(0, 4, 9);
     assertThat(inputFile.originalLineEndOffsets()).containsOnly(3, 7, 12);
   }
index 8bf50b199c7dc58759db0db2a8a05f25c63d2b0b..80017adbbbc5e77bd6e4f598ab9dc2d747783340 100644 (file)
@@ -27,12 +27,13 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Answers;
+import org.slf4j.event.Level;
 import org.sonar.api.CoreProperties;
 import org.sonar.api.batch.scm.ScmProvider;
 import org.sonar.api.config.Configuration;
 import org.sonar.api.notifications.AnalysisWarnings;
 import org.sonar.api.utils.MessageException;
-import org.sonar.api.utils.log.LogTester;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.core.config.ScannerProperties;
 import org.sonar.scanner.fs.InputModuleHierarchy;
 
@@ -96,6 +97,7 @@ public class ScmConfigurationTest {
 
   @Test
   public void log_when_disabled() {
+    logTester.setLevel(Level.DEBUG);
     when(settings.getBoolean(CoreProperties.SCM_DISABLED_KEY)).thenReturn(Optional.of(true));
 
     underTest.start();
index a9fff0e97c38917d2e7d151faf2b9d0015828f2b..ff789c27e61993459dba009dbaecca6152523ad9 100644 (file)
@@ -22,11 +22,12 @@ package org.sonar.scanner.sensor;
 import javax.annotation.Nullable;
 import org.junit.Rule;
 import org.junit.Test;
+import org.slf4j.event.Level;
 import org.sonar.api.batch.fs.InputFile;
 import org.sonar.api.batch.fs.internal.DefaultInputFile;
 import org.sonar.api.config.Configuration;
 import org.sonar.api.config.internal.MapSettings;
-import org.sonar.api.utils.log.LogTester;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.scanner.scan.branch.BranchConfiguration;
 import org.sonar.scanner.scan.branch.DefaultBranchConfiguration;
 
@@ -54,6 +55,7 @@ public class UnchangedFilesHandlerTest {
 
   @Test
   public void not_active_if_its_pr() {
+    logTester.setLevel(Level.DEBUG);
     BranchConfiguration prConfig = branchConfiguration(null, null, true);
     UnchangedFilesHandler handler = new UnchangedFilesHandler(enabledConfig, prConfig, executingSensorContext);
     assertThat(logTester.logs()).contains("Optimization for unchanged files not enabled because it's not an analysis of a branch with a previous analysis");
@@ -64,6 +66,7 @@ public class UnchangedFilesHandlerTest {
 
   @Test
   public void not_active_if_using_different_reference() {
+    logTester.setLevel(Level.DEBUG);
     BranchConfiguration differentRefConfig = branchConfiguration("a", "b", false);
     UnchangedFilesHandler handler = new UnchangedFilesHandler(enabledConfig, differentRefConfig, executingSensorContext);
     assertThat(logTester.logs()).contains("Optimization for unchanged files not enabled because it's not an analysis of a branch with a previous analysis");
index cf3758c35ffa7418ef1523158e557aaf0743baf8..d7cbf83287e2b6e676937ef052478fae63f936a0 100644 (file)
@@ -26,7 +26,8 @@ import org.junit.Test;
 import org.junit.rules.DisableOnDebug;
 import org.junit.rules.TestRule;
 import org.junit.rules.Timeout;
-import org.sonar.api.utils.log.LogTester;
+import org.slf4j.event.Level;
+import org.sonar.api.testfixtures.log.LogTester;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
@@ -56,10 +57,12 @@ public class ProgressReportTest {
   }
 
   @Test
-  public void do_log() {
+  public void do_log() throws InterruptedException {
+    logTester.setLevel(Level.DEBUG);
     underTest.start("start");
     underTest.message("Some message");
     boolean logged = false;
+    Thread.sleep(1000);
     while (!logged) {
       logged = logTester.logs().contains("Some message");
     }
index 088ee40d541c0de9a40fd62b5b45c07934f6d803..1bdb7713045b8daa78a861b2f30e7804ff22fb2f 100644 (file)
@@ -41,6 +41,7 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.TemporaryFolder;
 import org.junit.runner.RunWith;
+import org.slf4j.event.Level;
 import org.sonar.api.batch.fs.InputFile;
 import org.sonar.api.batch.fs.internal.DefaultFileSystem;
 import org.sonar.api.batch.fs.internal.DefaultInputFile;
@@ -49,11 +50,10 @@ import org.sonar.api.batch.scm.BlameCommand;
 import org.sonar.api.batch.scm.BlameLine;
 import org.sonar.api.notifications.AnalysisWarnings;
 import org.sonar.api.scan.filesystem.PathResolver;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.api.utils.DateUtils;
 import org.sonar.api.utils.MessageException;
 import org.sonar.api.utils.System2;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
 import org.sonar.scm.git.strategy.BlameStrategy;
 import org.sonar.scm.git.strategy.DefaultBlameStrategy.BlameAlgorithmEnum;
 
@@ -95,6 +95,7 @@ public class CompositeBlameCommandTest {
 
   @Test
   public void use_jgit_if_native_git_disabled() throws IOException {
+    logTester.setLevel(Level.DEBUG);
     NativeGitBlameCommand gitCmd = new NativeGitBlameCommand("invalidcommandnotfound", System2.INSTANCE, processWrapperFactory);
     BlameCommand blameCmd = new CompositeBlameCommand(analysisWarnings, pathResolver, jGitBlameCommand, gitCmd, (p, f) -> GIT_NATIVE_BLAME);
     File projectDir = createNewTempFolder();
@@ -105,7 +106,7 @@ public class CompositeBlameCommandTest {
     TestBlameOutput output = new TestBlameOutput();
     blameCmd.blame(input, output);
 
-    assertThat(logTester.logs(LoggerLevel.DEBUG)).contains("Using GIT_NATIVE_BLAME strategy to blame files");
+    assertThat(logTester.logs(Level.DEBUG)).contains("Using GIT_NATIVE_BLAME strategy to blame files");
     assertThat(output.blame).hasSize(1);
     assertThat(output.blame.get(input.filesToBlame().iterator().next())).hasSize(29);
   }
@@ -129,6 +130,7 @@ public class CompositeBlameCommandTest {
 
   @Test
   public void fallback_to_jgit_if_native_git_fails() throws Exception {
+    logTester.setLevel(Level.DEBUG);
     NativeGitBlameCommand gitCmd = mock(NativeGitBlameCommand.class);
     BlameCommand blameCmd = new CompositeBlameCommand(analysisWarnings, pathResolver, jGitBlameCommand, gitCmd, (p, f) -> GIT_NATIVE_BLAME);
     File projectDir = createNewTempFolder();
@@ -141,7 +143,7 @@ public class CompositeBlameCommandTest {
     TestBlameOutput output = new TestBlameOutput();
     blameCmd.blame(input, output);
 
-    assertThat(logTester.logs(LoggerLevel.DEBUG)).contains("Using GIT_NATIVE_BLAME strategy to blame files");
+    assertThat(logTester.logs(Level.DEBUG)).contains("Using GIT_NATIVE_BLAME strategy to blame files");
     assertThat(output.blame).hasSize(1);
     assertThat(output.blame.get(input.filesToBlame().iterator().next())).hasSize(29);
 
@@ -190,7 +192,7 @@ public class CompositeBlameCommandTest {
     assertThat(output.blame).isEmpty();
     verifyNoInteractions(jgit);
 
-    assertThat(logTester.logs(LoggerLevel.WARN))
+    assertThat(logTester.logs(Level.WARN))
       .contains("Could not find HEAD commit");
   }
 
@@ -282,7 +284,7 @@ public class CompositeBlameCommandTest {
     blameCommand.blame(input, output);
 
     assertThat(logTester.logs())
-      .haveAtLeastOne(new Condition<>(s-> s.startsWith("This git repository references another local repository which is not well supported"),
+      .haveAtLeastOne(new Condition<>(s -> s.startsWith("This git repository references another local repository which is not well supported"),
         "log for reference detected"));
 
     // contains commits referenced from the old clone and commits in the new clone
index ee1730b191b7d8d4f5f4a88cff16d577b341cad6..65d63fbc19dcbfca569ff0c9d23ff76c57fe49ce 100644 (file)
@@ -32,7 +32,8 @@ import org.eclipse.jgit.lib.Repository;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.TemporaryFolder;
-import org.sonar.api.utils.log.LogTester;
+import org.slf4j.event.Level;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.api.utils.log.LoggerLevel;
 
 import static java.nio.charset.StandardCharsets.UTF_8;
@@ -88,7 +89,7 @@ public class GitIgnoreCommandTest {
       .isFalse();
 
     int expectedIncludedFiles = (int) Math.pow(child_folders_per_folder, folder_depth) + 1; // The .gitignore file is indexed
-    assertThat(logTester.logs(LoggerLevel.DEBUG)).contains(expectedIncludedFiles + " non excluded files in this Git repository");
+    assertThat(logTester.logs(Level.DEBUG)).contains(expectedIncludedFiles + " non excluded files in this Git repository");
   }
 
   @Test
@@ -114,7 +115,7 @@ public class GitIgnoreCommandTest {
     assertThat(underTest.isIgnored(projectDir.resolve("module1/folder_0_0/Foo.php"))).isFalse();
 
     int expectedIncludedFiles = 6;
-    assertThat(logTester.logs(LoggerLevel.DEBUG)).contains(expectedIncludedFiles + " non excluded files in this Git repository");
+    assertThat(logTester.logs(Level.DEBUG)).contains(expectedIncludedFiles + " non excluded files in this Git repository");
   }
 
   @Test
@@ -139,10 +140,10 @@ public class GitIgnoreCommandTest {
     assertThat(underTest.isIgnored(projectDir.resolve("folder_0_0/Foo.php"))).isFalse();
 
     // ignoring not cloned submodules
-    assertThat(logTester.logs(LoggerLevel.DEBUG)).contains("Git submodule [module1] found, but has not been cloned, skipping.");
+    assertThat(logTester.logs(Level.DEBUG)).contains("Git submodule [module1] found, but has not been cloned, skipping.");
 
     int expectedIncludedFiles = 3;
-    assertThat(logTester.logs(LoggerLevel.DEBUG)).contains(expectedIncludedFiles + " non excluded files in this Git repository");
+    assertThat(logTester.logs(Level.DEBUG)).contains(expectedIncludedFiles + " non excluded files in this Git repository");
   }
 
   @Test
@@ -168,7 +169,7 @@ public class GitIgnoreCommandTest {
       .isTrue();
 
     int expectedIncludedFiles = (int) Math.pow(child_folders_per_folder, folder_depth - 1);
-    assertThat(logTester.logs(LoggerLevel.DEBUG)).contains(expectedIncludedFiles + " non excluded files in this Git repository");
+    assertThat(logTester.logs(Level.DEBUG)).contains(expectedIncludedFiles + " non excluded files in this Git repository");
   }
 
   private Path createGitRepoWithIgnore() throws IOException, GitAPIException {
index cb7d1f68aecdaf33a6ddf4c2694b6f5c5884351c..7bddf0123ee3191db9672f2f37a26d72bb042523 100644 (file)
@@ -59,8 +59,8 @@ import org.sonar.api.notifications.AnalysisWarnings;
 import org.sonar.api.scan.filesystem.PathResolver;
 import org.sonar.api.utils.MessageException;
 import org.sonar.api.utils.System2;
-import org.sonar.api.utils.log.LogAndArguments;
-import org.sonar.api.utils.log.LogTester;
+import org.sonar.api.testfixtures.log.LogAndArguments;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.core.documentation.DocumentationLinkGenerator;
 import org.sonar.scm.git.strategy.DefaultBlameStrategy;
 
index af8a102f367839397bed1c461b616a2251021d4c..2f22be669ee8ddadfb610caa71c06b5c98ddb617 100644 (file)
@@ -37,7 +37,7 @@ import org.junit.rules.TemporaryFolder;
 import org.sonar.api.batch.scm.BlameLine;
 import org.sonar.api.utils.DateUtils;
 import org.sonar.api.utils.System2;
-import org.sonar.api.utils.log.LogTester;
+import org.sonar.api.testfixtures.log.LogTester;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.junit.Assume.assumeTrue;
index 8bebca19a87c653a95b57db7f722fb769a3705c3..9f1624c7c0ad59565dad09b0c4ee224fdc212f8d 100644 (file)
@@ -37,10 +37,11 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.TemporaryFolder;
 import org.junit.runner.RunWith;
+import org.slf4j.event.Level;
 import org.sonar.api.batch.scm.BlameLine;
 import org.sonar.api.utils.DateUtils;
 import org.sonar.api.utils.System2;
-import org.sonar.api.utils.log.LogTester;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.scm.git.ProcessWrapperFactory.ProcessWrapper;
 
 import static org.assertj.core.api.Assertions.assertThat;
@@ -319,6 +320,7 @@ public class NativeGitBlameCommandTest {
 
   @Test
   public void execution_on_windows_should_fallback_to_full_path() {
+    logTester.setLevel(Level.DEBUG);
     System2 system2 = mock(System2.class);
     when(system2.isOsWindows()).thenReturn(true);
 
index 1295293380615ecce3858589d907b889572eeac0..53f9dd4c7c21c0c9513f527d31bc7b646bedf6e0 100644 (file)
@@ -24,7 +24,8 @@ import java.io.IOException;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.TemporaryFolder;
-import org.sonar.api.utils.log.LogTester;
+import org.slf4j.event.Level;
+import org.sonar.api.testfixtures.log.LogTester;
 import org.sonar.api.utils.log.LoggerLevel;
 
 import static org.assertj.core.api.Assertions.assertThat;
@@ -40,12 +41,13 @@ public class ProcessWrapperFactoryTest {
 
   @Test
   public void should_log_error_output_in_debug_mode() throws IOException {
+    logTester.setLevel(Level.DEBUG);
     var root = temp.newFolder().toPath();
     var processWrapper = underTest.create(root, v -> {}, "git", "blame");
     assertThatThrownBy(() -> processWrapper.execute())
       .isInstanceOf(IllegalStateException.class);
 
-    assertThat(logTester.logs(LoggerLevel.DEBUG).get(0)).contains("fatal: not a git repository");
+    assertThat(logTester.logs(Level.DEBUG).get(0)).contains("fatal: not a git repository");
   }
 
 }
index 2cf351e5e336ab18cfc3e4f8d7eab5a11abf1f2d..2754f3f04ee5a2f599c825a48c0dac0c4dfd6381 100644 (file)
@@ -22,9 +22,9 @@ package org.sonar.scm.git.strategy;
 import java.util.Optional;
 import org.junit.Rule;
 import org.junit.Test;
+import org.slf4j.event.Level;
 import org.sonar.api.config.Configuration;
-import org.sonar.api.utils.log.LogTester;
-import org.sonar.api.utils.log.LoggerLevel;
+import org.sonar.api.testfixtures.log.LogTester;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
@@ -75,8 +75,7 @@ public class DefaultBlameStrategyTest {
     assertThat(underTest.getBlameAlgorithm(1, 10)).isEqualTo(GIT_NATIVE_BLAME);
     assertThat(underTest.getBlameAlgorithm(1, 11)).isEqualTo(GIT_FILES_BLAME);
 
-
     assertThat(underTest.getBlameAlgorithm(0, 10)).isEqualTo(GIT_NATIVE_BLAME);
-    assertThat(logTester.logs(LoggerLevel.WARN)).contains("Available processors are 0. Falling back to native git blame");
+    assertThat(logTester.logs(Level.WARN)).contains("Available processors are 0. Falling back to native git blame");
   }
 }