aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Davis <jeremy.davis@sonarsource.com>2023-04-04 10:20:33 +0200
committersonartech <sonartech@sonarsource.com>2023-04-11 20:03:15 +0000
commitba00face3dc7fbab07c4526b8035a6f42ce2dc2d (patch)
tree7540208b6b81f7f58501712d760298a05a6b931a
parent5e6f30d7c4989a683ba0e45fa39ed7dfa3b0252f (diff)
downloadsonarqube-ba00face3dc7fbab07c4526b8035a6f42ce2dc2d.tar.gz
sonarqube-ba00face3dc7fbab07c4526b8035a6f42ce2dc2d.zip
SONAR-19015 Use new log test fixtures in the sonar-plugin-api
-rw-r--r--build.gradle1
-rw-r--r--gradle.properties2
-rw-r--r--plugins/sonar-xoo-plugin/build.gradle1
-rw-r--r--plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/extensions/XooPostJobTest.java2
-rw-r--r--server/sonar-alm-client/build.gradle1
-rw-r--r--server/sonar-alm-client/src/test/java/org/sonar/alm/client/azure/AzureDevOpsHttpClientTest.java35
-rw-r--r--server/sonar-alm-client/src/test/java/org/sonar/alm/client/bitbucket/bitbucketcloud/BitbucketCloudRestClientTest.java26
-rw-r--r--server/sonar-alm-client/src/test/java/org/sonar/alm/client/bitbucketserver/BitbucketServerRestClientTest.java2
-rw-r--r--server/sonar-alm-client/src/test/java/org/sonar/alm/client/github/GithubApplicationClientImplTest.java2
-rw-r--r--server/sonar-alm-client/src/test/java/org/sonar/alm/client/github/GithubApplicationHttpClientImplTest.java5
-rw-r--r--server/sonar-alm-client/src/test/java/org/sonar/alm/client/gitlab/GitlabHttpClientTest.java16
-rw-r--r--server/sonar-auth-saml/build.gradle1
-rw-r--r--server/sonar-auth-saml/src/it/java/org/sonar/auth/saml/SamlIdentityProviderIT.java4
-rw-r--r--server/sonar-ce-task-projectanalysis/build.gradle1
-rw-r--r--server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectanalysis/filemove/FileMoveDetectionStepIT.java10
-rw-r--r--server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectanalysis/filemove/PullRequestFileMoveDetectionStepIT.java2
-rw-r--r--server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectanalysis/issue/ScmAccountToUserLoaderIT.java6
-rw-r--r--server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectanalysis/scm/ScmInfoDbLoaderIT.java17
-rw-r--r--server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectanalysis/step/ExtractReportStepIT.java5
-rw-r--r--server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectanalysis/step/LoadPeriodsStepIT.java12
-rw-r--r--server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/analysis/ExportAnalysesStepIT.java9
-rw-r--r--server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/branches/ExportBranchesStepIT.java7
-rw-r--r--server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/component/ExportComponentsStepIT.java12
-rw-r--r--server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/file/ExportLineHashesStepIT.java12
-rw-r--r--server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/issue/ExportIssuesChangelogStepIT.java8
-rw-r--r--server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/issue/ExportIssuesStepIT.java7
-rw-r--r--server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/rule/ExportAdHocRulesStepIT.java13
-rw-r--r--server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/ExportEventsStepIT.java9
-rw-r--r--server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/ExportLinksStepIT.java9
-rw-r--r--server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/ExportLiveMeasuresStepIT.java18
-rw-r--r--server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/ExportMeasuresStepIT.java9
-rw-r--r--server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/ExportMetricsStepIT.java9
-rw-r--r--server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/ExportNewCodePeriodsStepIT.java9
-rw-r--r--server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/ExportSettingsStepIT.java11
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/api/posttask/PostProjectAnalysisTasksExecutorTest.java10
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/duplication/CrossProjectDuplicationStatusHolderImplTest.java18
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/duplication/IntegrateCrossProjectDuplicationsTest.java8
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/IssueAssignerTest.java12
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/metric/ReportMetricValidatorImplTest.java9
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/scm/ScmInfoRepositoryImplTest.java5
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/source/linereader/HighlightingLineReaderTest.java11
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/source/linereader/SymbolsLineReaderTest.java4
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ExecuteVisitorsStepTest.java6
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectexport/rule/ExportRuleStepTest.java7
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectexport/steps/DumpWriterImplTest.java6
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectexport/steps/ExportPluginsStepTest.java14
-rw-r--r--server/sonar-ce-task/build.gradle1
-rw-r--r--server/sonar-ce-task/src/test/java/org/sonar/ce/task/step/ComputationStepExecutorTest.java7
-rw-r--r--server/sonar-ce/build.gradle1
-rw-r--r--server/sonar-ce/src/it/java/org/sonar/ce/queue/NextPendingTaskPickerIT.java2
-rw-r--r--server/sonar-ce/src/it/java/org/sonar/ce/taskprocessor/CeWorkerImplIT.java68
-rw-r--r--server/sonar-ce/src/test/java/org/sonar/ce/configuration/CeWorkerCountSettingWarningTest.java6
-rw-r--r--server/sonar-ce/src/test/java/org/sonar/ce/taskprocessor/CeWorkerControllerImplTest.java6
-rw-r--r--server/sonar-ce/src/test/java/org/sonar/ce/taskprocessor/TimeoutCeTaskInterrupterTest.java6
-rw-r--r--server/sonar-db-core/build.gradle1
-rw-r--r--server/sonar-db-core/src/it/java/org/sonar/db/DatabaseUtilsIT.java8
-rw-r--r--server/sonar-db-core/src/test/java/org/sonar/db/DefaultDatabaseTest.java2
-rw-r--r--server/sonar-db-core/src/test/java/org/sonar/db/dialect/H2Test.java6
-rw-r--r--server/sonar-db-core/src/test/java/org/sonar/db/dialect/PostgreSqlTest.java8
-rw-r--r--server/sonar-db-core/src/test/java/org/sonar/db/profiling/ProfiledDataSourceTest.java15
-rw-r--r--server/sonar-db-dao/build.gradle1
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/DBSessionsImplTest.java6
-rw-r--r--server/sonar-db-migration/build.gradle1
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/step/MigrationStepsExecutorImplTest.java18
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v100/LogMessageIfSonarScimEnabledPresentPropertyTest.java10
-rw-r--r--server/sonar-server-common/build.gradle2
-rw-r--r--server/sonar-server-common/src/it/java/org/sonar/server/es/BulkIndexerIT.java5
-rw-r--r--server/sonar-server-common/src/it/java/org/sonar/server/issue/index/IssueIndexerIT.java6
-rw-r--r--server/sonar-server-common/src/it/java/org/sonar/server/rule/index/RuleIndexerIT.java10
-rw-r--r--server/sonar-server-common/src/it/java/org/sonar/server/webhook/SynchronousWebHooksImplIT.java21
-rw-r--r--server/sonar-server-common/src/test/java/org/sonar/server/async/AsyncExecutionImplTest.java6
-rw-r--r--server/sonar-server-common/src/test/java/org/sonar/server/es/EsClientProviderTest.java10
-rw-r--r--server/sonar-server-common/src/test/java/org/sonar/server/log/ServerLoggingTest.java2
-rw-r--r--server/sonar-server-common/src/test/java/org/sonar/server/platform/ServerFileSystemImplTest.java2
-rw-r--r--server/sonar-server-common/src/test/java/org/sonar/server/plugins/PluginRequirementsValidatorTest.java10
-rw-r--r--server/sonar-webserver-api/build.gradle1
-rw-r--r--server/sonar-webserver-api/src/test/java/org/sonar/server/plugins/PluginConsentVerifierTest.java6
-rw-r--r--server/sonar-webserver-api/src/test/java/org/sonar/server/plugins/PluginJarLoaderTest.java2
-rw-r--r--server/sonar-webserver-api/src/test/java/org/sonar/server/plugins/PluginUninstallerTest.java2
-rw-r--r--server/sonar-webserver-api/src/test/java/org/sonar/server/plugins/ServerPluginManagerTest.java3
-rw-r--r--server/sonar-webserver-api/src/test/java/org/sonar/server/qualitygate/changeevent/QGChangeEventListenersImplTest.java16
-rw-r--r--server/sonar-webserver-auth/build.gradle1
-rw-r--r--server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/DefaultAdminCredentialsVerifierImplTest.java6
-rw-r--r--server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/GithubWebhookAuthenticationTest.java4
-rw-r--r--server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/InitFilterTest.java12
-rw-r--r--server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/LogOAuthWarningTest.java10
-rw-r--r--server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/OAuth2CallbackFilterTest.java10
-rw-r--r--server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/UserRegistrarImplTest.java2
-rw-r--r--server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/event/AuthenticationEventImplTest.java5
-rw-r--r--server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/purge/ExpiredSessionsCleanerTest.java4
-rw-r--r--server/sonar-webserver-auth/src/test/java/org/sonar/server/user/SystemPasscodeImplTest.java10
-rw-r--r--server/sonar-webserver-auth/src/test/java/org/sonar/server/usertoken/notification/TokenExpirationNotificationSchedulerImplTest.java4
-rw-r--r--server/sonar-webserver-auth/src/test/java/org/sonar/server/usertoken/notification/TokenExpirationNotificationSenderTest.java8
-rw-r--r--server/sonar-webserver-core/build.gradle1
-rw-r--r--server/sonar-webserver-core/src/test/java/org/sonar/server/issue/index/AsyncIssueIndexingImplTest.java18
-rw-r--r--server/sonar-webserver-core/src/test/java/org/sonar/server/platform/DatabaseServerCompatibilityTest.java7
-rw-r--r--server/sonar-webserver-core/src/test/java/org/sonar/server/platform/db/CheckAnyonePermissionsAtStartupTest.java11
-rw-r--r--server/sonar-webserver-core/src/test/java/org/sonar/server/platform/db/CheckLanguageSpecificParamsAtStartupTest.java7
-rw-r--r--server/sonar-webserver-core/src/test/java/org/sonar/server/platform/db/EmbeddedDatabaseTest.java2
-rw-r--r--server/sonar-webserver-core/src/test/java/org/sonar/server/platform/db/migration/AutoDbMigrationTest.java12
-rw-r--r--server/sonar-webserver-core/src/test/java/org/sonar/server/platform/web/RootFilterTest.java7
-rw-r--r--server/sonar-webserver-core/src/test/java/org/sonar/server/qualitygate/ProjectsInWarningDaemonTest.java15
-rw-r--r--server/sonar-webserver-core/src/test/java/org/sonar/server/rule/RegisterRulesTest.java2
-rw-r--r--server/sonar-webserver-core/src/test/java/org/sonar/server/startup/LogServerIdTest.java6
-rw-r--r--server/sonar-webserver-core/src/test/java/org/sonar/server/startup/RegisterPermissionTemplatesTest.java8
-rw-r--r--server/sonar-webserver-core/src/test/java/org/sonar/server/telemetry/TelemetryDaemonTest.java5
-rw-r--r--server/sonar-webserver-es/build.gradle1
-rw-r--r--server/sonar-webserver-es/src/test/java/org/sonar/server/es/IndexCreatorTest.java10
-rw-r--r--server/sonar-webserver-es/src/test/java/org/sonar/server/es/RecoveryIndexerTest.java23
-rw-r--r--server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueQueryFactoryTest.java2
-rw-r--r--server/sonar-webserver-monitoring/build.gradle1
-rw-r--r--server/sonar-webserver-monitoring/src/test/java/org/sonar/server/monitoring/ElasticSearchMetricTaskTest.java8
-rw-r--r--server/sonar-webserver-webapi/build.gradle1
-rw-r--r--server/sonar-webserver-webapi/src/it/java/org/sonar/server/projectanalysis/ws/SearchActionIT.java4
-rw-r--r--server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualitygate/RegisterQualityGatesIT.java28
-rw-r--r--server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/RegisterQualityProfilesIT.java14
-rw-r--r--server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/RegisterQualityProfilesNotificationIT.java2
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/RestartActionTest.java6
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/ui/PageRepositoryTest.java2
-rw-r--r--server/sonar-webserver-ws/build.gradle1
-rw-r--r--server/sonar-webserver-ws/src/test/java/org/sonar/server/ws/WebServiceEngineTest.java28
-rw-r--r--server/sonar-webserver-ws/src/test/java/org/sonar/server/ws/WsUtilsTest.java2
-rw-r--r--server/sonar-webserver/build.gradle1
-rw-r--r--server/sonar-webserver/src/test/java/org/sonar/server/platform/web/MasterServletFilterTest.java6
-rw-r--r--server/sonar-webserver/src/test/java/org/sonar/server/platform/web/StaticResourcesServletTest.java72
-rw-r--r--sonar-core/build.gradle1
-rw-r--r--sonar-core/src/test/java/org/sonar/core/platform/PluginClassLoaderTest.java8
-rw-r--r--sonar-core/src/test/java/org/sonar/core/util/ProgressLoggerTest.java8
-rw-r--r--sonar-core/src/test/java/org/sonar/core/util/logs/DefaultProfilerTest.java27
-rw-r--r--sonar-core/src/test/java/org/sonar/core/util/logs/ProfilerTest.java2
-rw-r--r--sonar-plugin-api-impl/build.gradle1
-rw-r--r--sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/fs/internal/DefaultInputFile.java3
-rw-r--r--sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/fs/internal/fs/FileMetadataTest.java8
-rw-r--r--sonar-plugin-api-impl/src/test/java/org/sonar/api/impl/utils/DefaultTempFolderTest.java6
-rw-r--r--sonar-scanner-engine/build.gradle1
-rw-r--r--sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/ScannerMediumTester.java12
-rw-r--r--sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/branch/BranchMediumIT.java4
-rw-r--r--sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/coverage/CoverageMediumIT.java14
-rw-r--r--sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/coverage/GenericCoverageMediumIT.java12
-rw-r--r--sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/cpd/CpdMediumIT.java7
-rw-r--r--sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/fs/FileSystemMediumIT.java22
-rw-r--r--sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/issues/ExternalIssuesMediumIT.java4
-rw-r--r--sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/issues/IssuesMediumIT.java20
-rw-r--r--sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/issues/PreviewMediumIT.java2
-rw-r--r--sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/measures/MeasuresMediumIT.java12
-rw-r--r--sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/scm/ScmMediumIT.java7
-rw-r--r--sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/tasks/TasksMediumIT.java2
-rw-r--r--sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/tests/GenericTestExecutionMediumIT.java11
-rw-r--r--sonar-scanner-engine/src/it/java/org/sonar/scm/svn/SvnBlameCommandIT.java13
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/batch/bootstrapper/Batch.java2
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/DefaultScannerWsClientTest.java7
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/GlobalConfigurationProviderTest.java2
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/cache/DefaultAnalysisCacheLoaderTest.java2
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/ci/vendors/CirrusCiTest.java6
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/ci/vendors/CodeMagicTest.java6
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/ci/vendors/GithubActionsTest.java6
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/config/DefaultConfigurationTest.java14
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/cpd/CpdExecutorTest.java12
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/externalissue/ExternalIssueImporterTest.java12
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/externalissue/sarif/DefaultSarif210ImporterTest.java6
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/externalissue/sarif/RulesSeverityDetectorTest.java5
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/externalissue/sarif/RunMapperTest.java6
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/externalissue/sarif/SarifIssuesImportSensorTest.java13
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/genericcoverage/GenericCoverageReportParserTest.java4
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/genericcoverage/GenericCoverageSensorTest.java2
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/genericcoverage/GenericTestExecutionReportParserTest.java5
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/genericcoverage/GenericTestExecutionSensorTest.java8
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/issue/ignore/IgnoreIssuesFilterTest.java2
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/phases/ModuleSensorsExecutorTest.java2
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/qualitygate/QualityGateCheckTest.java4
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/report/AnalysisContextReportPublisherTest.java2
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/report/ChangedLinesPublisherTest.java2
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/report/ReportPublisherTest.java18
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/repository/QualityProfileProviderTest.java2
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/DeprecatedPropertiesWarningGeneratorTest.java14
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ProjectReactorBuilderTest.java2
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ProjectReactorValidatorTest.java2
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/AbstractExclusionFiltersTest.java22
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/MetadataGeneratorTest.java2
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/scm/ScmConfigurationTest.java4
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/sensor/UnchangedFilesHandlerTest.java5
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/util/ProgressReportTest.java7
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scm/git/CompositeBlameCommandTest.java14
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scm/git/GitIgnoreCommandTest.java13
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scm/git/GitScmProviderTest.java4
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scm/git/JGitBlameCommandTest.java2
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scm/git/NativeGitBlameCommandTest.java4
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scm/git/ProcessWrapperFactoryTest.java6
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scm/git/strategy/DefaultBlameStrategyTest.java7
189 files changed, 854 insertions, 680 deletions
diff --git a/build.gradle b/build.gradle
index ab480a924a5..c54ad59cc36 100644
--- a/build.gradle
+++ b/build.gradle
@@ -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'
diff --git a/gradle.properties b/gradle.properties
index 2412f69fe95..30b06f4a376 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -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
diff --git a/plugins/sonar-xoo-plugin/build.gradle b/plugins/sonar-xoo-plugin/build.gradle
index 07d6ff5f45f..a152bff4d29 100644
--- a/plugins/sonar-xoo-plugin/build.gradle
+++ b/plugins/sonar-xoo-plugin/build.gradle
@@ -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')
}
diff --git a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/extensions/XooPostJobTest.java b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/extensions/XooPostJobTest.java
index f113ed7b5f9..39b8f051c48 100644
--- a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/extensions/XooPostJobTest.java
+++ b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/extensions/XooPostJobTest.java
@@ -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;
diff --git a/server/sonar-alm-client/build.gradle b/server/sonar-alm-client/build.gradle
index 7d35c2e4533..a15661a6cba 100644
--- a/server/sonar-alm-client/build.gradle
+++ b/server/sonar-alm-client/build.gradle
@@ -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'
}
diff --git a/server/sonar-alm-client/src/test/java/org/sonar/alm/client/azure/AzureDevOpsHttpClientTest.java b/server/sonar-alm-client/src/test/java/org/sonar/alm/client/azure/AzureDevOpsHttpClientTest.java
index 059fc103ade..fdf44a85971 100644
--- a/server/sonar-alm-client/src/test/java/org/sonar/alm/client/azure/AzureDevOpsHttpClientTest.java
+++ b/server/sonar-alm-client/src/test/java/org/sonar/alm/client/azure/AzureDevOpsHttpClientTest.java
@@ -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");
diff --git a/server/sonar-alm-client/src/test/java/org/sonar/alm/client/bitbucket/bitbucketcloud/BitbucketCloudRestClientTest.java b/server/sonar-alm-client/src/test/java/org/sonar/alm/client/bitbucket/bitbucketcloud/BitbucketCloudRestClientTest.java
index ecd6d763105..b164a94d957 100644
--- a/server/sonar-alm-client/src/test/java/org/sonar/alm/client/bitbucket/bitbucketcloud/BitbucketCloudRestClientTest.java
+++ b/server/sonar-alm-client/src/test/java/org/sonar/alm/client/bitbucket/bitbucketcloud/BitbucketCloudRestClientTest.java
@@ -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"));
}
}
diff --git a/server/sonar-alm-client/src/test/java/org/sonar/alm/client/bitbucketserver/BitbucketServerRestClientTest.java b/server/sonar-alm-client/src/test/java/org/sonar/alm/client/bitbucketserver/BitbucketServerRestClientTest.java
index c1e7cee87ce..5de1f69d9f7 100644
--- a/server/sonar-alm-client/src/test/java/org/sonar/alm/client/bitbucketserver/BitbucketServerRestClientTest.java
+++ b/server/sonar-alm-client/src/test/java/org/sonar/alm/client/bitbucketserver/BitbucketServerRestClientTest.java
@@ -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;
diff --git a/server/sonar-alm-client/src/test/java/org/sonar/alm/client/github/GithubApplicationClientImplTest.java b/server/sonar-alm-client/src/test/java/org/sonar/alm/client/github/GithubApplicationClientImplTest.java
index ed823e73d4b..fbe8aa95ca0 100644
--- a/server/sonar-alm-client/src/test/java/org/sonar/alm/client/github/GithubApplicationClientImplTest.java
+++ b/server/sonar-alm-client/src/test/java/org/sonar/alm/client/github/GithubApplicationClientImplTest.java
@@ -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;
diff --git a/server/sonar-alm-client/src/test/java/org/sonar/alm/client/github/GithubApplicationHttpClientImplTest.java b/server/sonar-alm-client/src/test/java/org/sonar/alm/client/github/GithubApplicationHttpClientImplTest.java
index 8487382837d..1e90d5b127b 100644
--- a/server/sonar-alm-client/src/test/java/org/sonar/alm/client/github/GithubApplicationHttpClientImplTest.java
+++ b/server/sonar-alm-client/src/test/java/org/sonar/alm/client/github/GithubApplicationHttpClientImplTest.java
@@ -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();
}
diff --git a/server/sonar-alm-client/src/test/java/org/sonar/alm/client/gitlab/GitlabHttpClientTest.java b/server/sonar-alm-client/src/test/java/org/sonar/alm/client/gitlab/GitlabHttpClientTest.java
index 6fb184e6e52..48c0b2d0067 100644
--- a/server/sonar-alm-client/src/test/java/org/sonar/alm/client/gitlab/GitlabHttpClientTest.java
+++ b/server/sonar-alm-client/src/test/java/org/sonar/alm/client/gitlab/GitlabHttpClientTest.java
@@ -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")
+ "] " +
diff --git a/server/sonar-auth-saml/build.gradle b/server/sonar-auth-saml/build.gradle
index cf41ccabb0c..db3de357a60 100644
--- a/server/sonar-auth-saml/build.gradle
+++ b/server/sonar-auth-saml/build.gradle
@@ -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'))
}
diff --git a/server/sonar-auth-saml/src/it/java/org/sonar/auth/saml/SamlIdentityProviderIT.java b/server/sonar-auth-saml/src/it/java/org/sonar/auth/saml/SamlIdentityProviderIT.java
index f598d9c9969..f67636785e3 100644
--- a/server/sonar-auth-saml/src/it/java/org/sonar/auth/saml/SamlIdentityProviderIT.java
+++ b/server/sonar-auth-saml/src/it/java/org/sonar/auth/saml/SamlIdentityProviderIT.java
@@ -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;
diff --git a/server/sonar-ce-task-projectanalysis/build.gradle b/server/sonar-ce-task-projectanalysis/build.gradle
index 166e007fae0..47a59374b60 100644
--- a/server/sonar-ce-task-projectanalysis/build.gradle
+++ b/server/sonar-ce-task-projectanalysis/build.gradle
@@ -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'))
diff --git a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectanalysis/filemove/FileMoveDetectionStepIT.java b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectanalysis/filemove/FileMoveDetectionStepIT.java
index a8e9be91e89..57e9b7397bc 100644
--- a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectanalysis/filemove/FileMoveDetectionStepIT.java
+++ b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectanalysis/filemove/FileMoveDetectionStepIT.java
@@ -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
diff --git a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectanalysis/filemove/PullRequestFileMoveDetectionStepIT.java b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectanalysis/filemove/PullRequestFileMoveDetectionStepIT.java
index 044c69fe388..4c86e49cadc 100644
--- a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectanalysis/filemove/PullRequestFileMoveDetectionStepIT.java
+++ b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectanalysis/filemove/PullRequestFileMoveDetectionStepIT.java
@@ -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;
diff --git a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectanalysis/issue/ScmAccountToUserLoaderIT.java b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectanalysis/issue/ScmAccountToUserLoaderIT.java
index 128f9927f50..9e91e0b66a9 100644
--- a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectanalysis/issue/ScmAccountToUserLoaderIT.java
+++ b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectanalysis/issue/ScmAccountToUserLoaderIT.java
@@ -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
diff --git a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectanalysis/scm/ScmInfoDbLoaderIT.java b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectanalysis/scm/ScmInfoDbLoaderIT.java
index 1591410151c..c647e7f5bac 100644
--- a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectanalysis/scm/ScmInfoDbLoaderIT.java
+++ b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectanalysis/scm/ScmInfoDbLoaderIT.java
@@ -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();
}
diff --git a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectanalysis/step/ExtractReportStepIT.java b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectanalysis/step/ExtractReportStepIT.java
index edea98f75be..ed2499f48ae 100644
--- a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectanalysis/step/ExtractReportStepIT.java
+++ b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectanalysis/step/ExtractReportStepIT.java
@@ -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
diff --git a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectanalysis/step/LoadPeriodsStepIT.java b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectanalysis/step/LoadPeriodsStepIT.java
index 51b03356334..0c8e8031f8d 100644
--- a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectanalysis/step/LoadPeriodsStepIT.java
+++ b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectanalysis/step/LoadPeriodsStepIT.java
@@ -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) {
diff --git a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/analysis/ExportAnalysesStepIT.java b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/analysis/ExportAnalysesStepIT.java
index 95a7f770898..c90a2a2a619 100644
--- a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/analysis/ExportAnalysesStepIT.java
+++ b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/analysis/ExportAnalysesStepIT.java
@@ -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
diff --git a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/branches/ExportBranchesStepIT.java b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/branches/ExportBranchesStepIT.java
index c09be119ba2..950175a3c30 100644
--- a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/branches/ExportBranchesStepIT.java
+++ b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/branches/ExportBranchesStepIT.java
@@ -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()));
diff --git a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/component/ExportComponentsStepIT.java b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/component/ExportComponentsStepIT.java
index e39789dfffc..7c33c052ae1 100644
--- a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/component/ExportComponentsStepIT.java
+++ b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/component/ExportComponentsStepIT.java
@@ -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(
diff --git a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/file/ExportLineHashesStepIT.java b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/file/ExportLineHashesStepIT.java
index ac6a7cfee6f..6ca08fc528b 100644
--- a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/file/ExportLineHashesStepIT.java
+++ b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/file/ExportLineHashesStepIT.java
@@ -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) {
diff --git a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/issue/ExportIssuesChangelogStepIT.java b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/issue/ExportIssuesChangelogStepIT.java
index 0d8e79be2a1..d316d5aadc6 100644
--- a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/issue/ExportIssuesChangelogStepIT.java
+++ b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/issue/ExportIssuesChangelogStepIT.java
@@ -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
diff --git a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/issue/ExportIssuesStepIT.java b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/issue/ExportIssuesStepIT.java
index 3dfb5e68d3b..ae29778c205 100644
--- a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/issue/ExportIssuesStepIT.java
+++ b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/issue/ExportIssuesStepIT.java
@@ -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
diff --git a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/rule/ExportAdHocRulesStepIT.java b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/rule/ExportAdHocRulesStepIT.java
index 902c5d32577..afc77a8336c 100644
--- a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/rule/ExportAdHocRulesStepIT.java
+++ b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/rule/ExportAdHocRulesStepIT.java
@@ -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
diff --git a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/ExportEventsStepIT.java b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/ExportEventsStepIT.java
index e2aea5fc0b5..aa5e7a8debb 100644
--- a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/ExportEventsStepIT.java
+++ b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/ExportEventsStepIT.java
@@ -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");
diff --git a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/ExportLinksStepIT.java b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/ExportLinksStepIT.java
index d1b8475bdec..1fab9897443 100644
--- a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/ExportLinksStepIT.java
+++ b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/ExportLinksStepIT.java
@@ -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(
diff --git a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/ExportLiveMeasuresStepIT.java b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/ExportLiveMeasuresStepIT.java
index c4aad6eb747..644e8eff578 100644
--- a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/ExportLiveMeasuresStepIT.java
+++ b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/ExportLiveMeasuresStepIT.java
@@ -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());
}
diff --git a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/ExportMeasuresStepIT.java b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/ExportMeasuresStepIT.java
index 8d16133ac45..c9eca291c93 100644
--- a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/ExportMeasuresStepIT.java
+++ b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/ExportMeasuresStepIT.java
@@ -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());
}
diff --git a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/ExportMetricsStepIT.java b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/ExportMetricsStepIT.java
index 16f7a3202df..4304b5fc353 100644
--- a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/ExportMetricsStepIT.java
+++ b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/ExportMetricsStepIT.java
@@ -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();
diff --git a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/ExportNewCodePeriodsStepIT.java b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/ExportNewCodePeriodsStepIT.java
index 49abb861511..8ef1e54a009 100644
--- a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/ExportNewCodePeriodsStepIT.java
+++ b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/ExportNewCodePeriodsStepIT.java
@@ -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
diff --git a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/ExportSettingsStepIT.java b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/ExportSettingsStepIT.java
index e8ca859a22a..4cd506d9ac2 100644
--- a/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/ExportSettingsStepIT.java
+++ b/server/sonar-ce-task-projectanalysis/src/it/java/org/sonar/ce/task/projectexport/steps/ExportSettingsStepIT.java
@@ -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
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/api/posttask/PostProjectAnalysisTasksExecutorTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/api/posttask/PostProjectAnalysisTasksExecutorTest.java
index ee67a8ff77a..c95b925ccee 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/api/posttask/PostProjectAnalysisTasksExecutorTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/api/posttask/PostProjectAnalysisTasksExecutorTest.java
@@ -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$");
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/duplication/CrossProjectDuplicationStatusHolderImplTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/duplication/CrossProjectDuplicationStatusHolderImplTest.java
index a3b687b8c67..183bb82cc7e 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/duplication/CrossProjectDuplicationStatusHolderImplTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/duplication/CrossProjectDuplicationStatusHolderImplTest.java
@@ -19,10 +19,11 @@
*/
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
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/duplication/IntegrateCrossProjectDuplicationsTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/duplication/IntegrateCrossProjectDuplicationsTest.java
index 0238df2cd20..9e0c7ed63e6 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/duplication/IntegrateCrossProjectDuplicationsTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/duplication/IntegrateCrossProjectDuplicationsTest.java
@@ -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
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/IssueAssignerTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/IssueAssignerTest.java
index f3c69f54a1d..286f9ce04b6 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/IssueAssignerTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/IssueAssignerTest.java
@@ -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
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/metric/ReportMetricValidatorImplTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/metric/ReportMetricValidatorImplTest.java
index ccc3f0d0ce7..8ce7b773f66 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/metric/ReportMetricValidatorImplTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/metric/ReportMetricValidatorImplTest.java
@@ -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()));
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/scm/ScmInfoRepositoryImplTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/scm/ScmInfoRepositoryImplTest.java
index 869ac7b70df..b997411125f 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/scm/ScmInfoRepositoryImplTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/scm/ScmInfoRepositoryImplTest.java
@@ -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);
}
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/source/linereader/HighlightingLineReaderTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/source/linereader/HighlightingLineReaderTest.java
index 46af56a8377..e848618c617 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/source/linereader/HighlightingLineReaderTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/source/linereader/HighlightingLineReaderTest.java
@@ -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());
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/source/linereader/SymbolsLineReaderTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/source/linereader/SymbolsLineReaderTest.java
index e5080fbf33b..ff88d25ad46 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/source/linereader/SymbolsLineReaderTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/source/linereader/SymbolsLineReaderTest.java
@@ -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;
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ExecuteVisitorsStepTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ExecuteVisitorsStepTest.java
index 37aa4594433..69e330b328e 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ExecuteVisitorsStepTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ExecuteVisitorsStepTest.java
@@ -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=");
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectexport/rule/ExportRuleStepTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectexport/rule/ExportRuleStepTest.java
index 52f1db477f1..1fc8f316d0c 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectexport/rule/ExportRuleStepTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectexport/rule/ExportRuleStepTest.java
@@ -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
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectexport/steps/DumpWriterImplTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectexport/steps/DumpWriterImplTest.java
index 4be0c7d6aa5..54990a5c94e 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectexport/steps/DumpWriterImplTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectexport/steps/DumpWriterImplTest.java
@@ -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());
}
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectexport/steps/ExportPluginsStepTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectexport/steps/ExportPluginsStepTest.java
index 9e26038fce2..5ddb0d39843 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectexport/steps/ExportPluginsStepTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectexport/steps/ExportPluginsStepTest.java
@@ -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
diff --git a/server/sonar-ce-task/build.gradle b/server/sonar-ce-task/build.gradle
index c8d51225ef2..c7d1127bc1d 100644
--- a/server/sonar-ce-task/build.gradle
+++ b/server/sonar-ce-task/build.gradle
@@ -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'
diff --git a/server/sonar-ce-task/src/test/java/org/sonar/ce/task/step/ComputationStepExecutorTest.java b/server/sonar-ce-task/src/test/java/org/sonar/ce/task/step/ComputationStepExecutorTest.java
index 0b8cde76160..1af78cdac9f 100644
--- a/server/sonar-ce-task/src/test/java/org/sonar/ce/task/step/ComputationStepExecutorTest.java
+++ b/server/sonar-ce-task/src/test/java/org/sonar/ce/task/step/ComputationStepExecutorTest.java
@@ -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=");
diff --git a/server/sonar-ce/build.gradle b/server/sonar-ce/build.gradle
index acdf2dafb00..6e36ace52a9 100644
--- a/server/sonar-ce/build.gradle
+++ b/server/sonar-ce/build.gradle
@@ -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'))
diff --git a/server/sonar-ce/src/it/java/org/sonar/ce/queue/NextPendingTaskPickerIT.java b/server/sonar-ce/src/it/java/org/sonar/ce/queue/NextPendingTaskPickerIT.java
index 282ade6bb62..86057fc7889 100644
--- a/server/sonar-ce/src/it/java/org/sonar/ce/queue/NextPendingTaskPickerIT.java
+++ b/server/sonar-ce/src/it/java/org/sonar/ce/queue/NextPendingTaskPickerIT.java
@@ -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;
diff --git a/server/sonar-ce/src/it/java/org/sonar/ce/taskprocessor/CeWorkerImplIT.java b/server/sonar-ce/src/it/java/org/sonar/ce/taskprocessor/CeWorkerImplIT.java
index f0acbec6aa2..9e98bd98d81 100644
--- a/server/sonar-ce/src/it/java/org/sonar/ce/taskprocessor/CeWorkerImplIT.java
+++ b/server/sonar-ce/src/it/java/org/sonar/ce/taskprocessor/CeWorkerImplIT.java
@@ -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
diff --git a/server/sonar-ce/src/test/java/org/sonar/ce/configuration/CeWorkerCountSettingWarningTest.java b/server/sonar-ce/src/test/java/org/sonar/ce/configuration/CeWorkerCountSettingWarningTest.java
index 70ffcfcd940..5a95ae061ed 100644
--- a/server/sonar-ce/src/test/java/org/sonar/ce/configuration/CeWorkerCountSettingWarningTest.java
+++ b/server/sonar-ce/src/test/java/org/sonar/ce/configuration/CeWorkerCountSettingWarningTest.java
@@ -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.");
}
}
diff --git a/server/sonar-ce/src/test/java/org/sonar/ce/taskprocessor/CeWorkerControllerImplTest.java b/server/sonar-ce/src/test/java/org/sonar/ce/taskprocessor/CeWorkerControllerImplTest.java
index ec9a4db651e..8f627de253e 100644
--- a/server/sonar-ce/src/test/java/org/sonar/ce/taskprocessor/CeWorkerControllerImplTest.java
+++ b/server/sonar-ce/src/test/java/org/sonar/ce/taskprocessor/CeWorkerControllerImplTest.java
@@ -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");
}
}
diff --git a/server/sonar-ce/src/test/java/org/sonar/ce/taskprocessor/TimeoutCeTaskInterrupterTest.java b/server/sonar-ce/src/test/java/org/sonar/ce/taskprocessor/TimeoutCeTaskInterrupterTest.java
index 1e675d6e58e..730094c9864 100644
--- a/server/sonar-ce/src/test/java/org/sonar/ce/taskprocessor/TimeoutCeTaskInterrupterTest.java
+++ b/server/sonar-ce/src/test/java/org/sonar/ce/taskprocessor/TimeoutCeTaskInterrupterTest.java
@@ -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");
}
diff --git a/server/sonar-db-core/build.gradle b/server/sonar-db-core/build.gradle
index 5413fef01b0..cc70946e9fd 100644
--- a/server/sonar-db-core/build.gradle
+++ b/server/sonar-db-core/build.gradle
@@ -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')
diff --git a/server/sonar-db-core/src/it/java/org/sonar/db/DatabaseUtilsIT.java b/server/sonar-db-core/src/it/java/org/sonar/db/DatabaseUtilsIT.java
index 5fd95eb47e1..91763ab314e 100644
--- a/server/sonar-db-core/src/it/java/org/sonar/db/DatabaseUtilsIT.java
+++ b/server/sonar-db-core/src/it/java/org/sonar/db/DatabaseUtilsIT.java
@@ -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
diff --git a/server/sonar-db-core/src/test/java/org/sonar/db/DefaultDatabaseTest.java b/server/sonar-db-core/src/test/java/org/sonar/db/DefaultDatabaseTest.java
index 7093513823c..068bc3ee00c 100644
--- a/server/sonar-db-core/src/test/java/org/sonar/db/DefaultDatabaseTest.java
+++ b/server/sonar-db-core/src/test/java/org/sonar/db/DefaultDatabaseTest.java
@@ -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;
diff --git a/server/sonar-db-core/src/test/java/org/sonar/db/dialect/H2Test.java b/server/sonar-db-core/src/test/java/org/sonar/db/dialect/H2Test.java
index 75de6af28dc..71ed8ac7693 100644
--- a/server/sonar-db-core/src/test/java/org/sonar/db/dialect/H2Test.java
+++ b/server/sonar-db-core/src/test/java/org/sonar/db/dialect/H2Test.java
@@ -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
diff --git a/server/sonar-db-core/src/test/java/org/sonar/db/dialect/PostgreSqlTest.java b/server/sonar-db-core/src/test/java/org/sonar/db/dialect/PostgreSqlTest.java
index e8450a657ff..ac6553a4173 100644
--- a/server/sonar-db-core/src/test/java/org/sonar/db/dialect/PostgreSqlTest.java
+++ b/server/sonar-db-core/src/test/java/org/sonar/db/dialect/PostgreSqlTest.java
@@ -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
diff --git a/server/sonar-db-core/src/test/java/org/sonar/db/profiling/ProfiledDataSourceTest.java b/server/sonar-db-core/src/test/java/org/sonar/db/profiling/ProfiledDataSourceTest.java
index d7bac5f94ca..6ac3a99ca8e 100644
--- a/server/sonar-db-core/src/test/java/org/sonar/db/profiling/ProfiledDataSourceTest.java
+++ b/server/sonar-db-core/src/test/java/org/sonar/db/profiling/ProfiledDataSourceTest.java
@@ -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=");
}
diff --git a/server/sonar-db-dao/build.gradle b/server/sonar-db-dao/build.gradle
index 9a2885a35dc..c312242405b 100644
--- a/server/sonar-db-dao/build.gradle
+++ b/server/sonar-db-dao/build.gradle
@@ -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')
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/DBSessionsImplTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/DBSessionsImplTest.java
index 1f422b341c1..9fe5a6afc2b 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/DBSessionsImplTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/DBSessionsImplTest.java
@@ -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());
diff --git a/server/sonar-db-migration/build.gradle b/server/sonar-db-migration/build.gradle
index e2dc94173dc..510acdbed34 100644
--- a/server/sonar-db-migration/build.gradle
+++ b/server/sonar-db-migration/build.gradle
@@ -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'))
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/step/MigrationStepsExecutorImplTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/step/MigrationStepsExecutorImplTest.java
index 4616dcfe377..015a853b659 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/step/MigrationStepsExecutorImplTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/step/MigrationStepsExecutorImplTest.java
@@ -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=");
}
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v100/LogMessageIfSonarScimEnabledPresentPropertyTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v100/LogMessageIfSonarScimEnabledPresentPropertyTest.java
index 7bd3a481880..f0c196d068a 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v100/LogMessageIfSonarScimEnabledPresentPropertyTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v100/LogMessageIfSonarScimEnabledPresentPropertyTest.java
@@ -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);
}
}
diff --git a/server/sonar-server-common/build.gradle b/server/sonar-server-common/build.gradle
index 4f6caafbbb4..3b872c8cd3f 100644
--- a/server/sonar-server-common/build.gradle
+++ b/server/sonar-server-common/build.gradle
@@ -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'
diff --git a/server/sonar-server-common/src/it/java/org/sonar/server/es/BulkIndexerIT.java b/server/sonar-server-common/src/it/java/org/sonar/server/es/BulkIndexerIT.java
index 774e3bdc0a3..7a9bac079fb 100644
--- a/server/sonar-server-common/src/it/java/org/sonar/server/es/BulkIndexerIT.java
+++ b/server/sonar-server-common/src/it/java/org/sonar/server/es/BulkIndexerIT.java
@@ -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();
diff --git a/server/sonar-server-common/src/it/java/org/sonar/server/issue/index/IssueIndexerIT.java b/server/sonar-server-common/src/it/java/org/sonar/server/issue/index/IssueIndexerIT.java
index b5fadad5fee..ed038aef32c 100644
--- a/server/sonar-server-common/src/it/java/org/sonar/server/issue/index/IssueIndexerIT.java
+++ b/server/sonar-server-common/src/it/java/org/sonar/server/issue/index/IssueIndexerIT.java
@@ -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);
diff --git a/server/sonar-server-common/src/it/java/org/sonar/server/rule/index/RuleIndexerIT.java b/server/sonar-server-common/src/it/java/org/sonar/server/rule/index/RuleIndexerIT.java
index e096598bfcc..d03ba3698f8 100644
--- a/server/sonar-server-common/src/it/java/org/sonar/server/rule/index/RuleIndexerIT.java
+++ b/server/sonar-server-common/src/it/java/org/sonar/server/rule/index/RuleIndexerIT.java
@@ -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()),
diff --git a/server/sonar-server-common/src/it/java/org/sonar/server/webhook/SynchronousWebHooksImplIT.java b/server/sonar-server-common/src/it/java/org/sonar/server/webhook/SynchronousWebHooksImplIT.java
index f671da1fb65..cc932b1b8b6 100644
--- a/server/sonar-server-common/src/it/java/org/sonar/server/webhook/SynchronousWebHooksImplIT.java
+++ b/server/sonar-server-common/src/it/java/org/sonar/server/webhook/SynchronousWebHooksImplIT.java
@@ -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();
diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/async/AsyncExecutionImplTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/async/AsyncExecutionImplTest.java
index e19e8bcdbdd..ff568d0c59c 100644
--- a/server/sonar-server-common/src/test/java/org/sonar/server/async/AsyncExecutionImplTest.java
+++ b/server/sonar-server-common/src/test/java/org/sonar/server/async/AsyncExecutionImplTest.java
@@ -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
diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/es/EsClientProviderTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/es/EsClientProviderTest.java
index 1affd024067..329a3062ea1 100644
--- a/server/sonar-server-common/src/test/java/org/sonar/server/es/EsClientProviderTest.java
+++ b/server/sonar-server-common/src/test/java/org/sonar/server/es/EsClientProviderTest.java
@@ -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]"), ""));
}
}
diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/log/ServerLoggingTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/log/ServerLoggingTest.java
index c2f651e64c5..dec7aa5c539 100644
--- a/server/sonar-server-common/src/test/java/org/sonar/server/log/ServerLoggingTest.java
+++ b/server/sonar-server-common/src/test/java/org/sonar/server/log/ServerLoggingTest.java
@@ -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;
diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/platform/ServerFileSystemImplTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/platform/ServerFileSystemImplTest.java
index 3fde464ab52..87354828934 100644
--- a/server/sonar-server-common/src/test/java/org/sonar/server/platform/ServerFileSystemImplTest.java
+++ b/server/sonar-server-common/src/test/java/org/sonar/server/platform/ServerFileSystemImplTest.java
@@ -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;
diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/plugins/PluginRequirementsValidatorTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/plugins/PluginRequirementsValidatorTest.java
index 98bbd20b0f7..454db86e6a5 100644
--- a/server/sonar-server-common/src/test/java/org/sonar/server/plugins/PluginRequirementsValidatorTest.java
+++ b/server/sonar-server-common/src/test/java/org/sonar/server/plugins/PluginRequirementsValidatorTest.java
@@ -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");
}
diff --git a/server/sonar-webserver-api/build.gradle b/server/sonar-webserver-api/build.gradle
index 18082686d54..8bec2704447 100644
--- a/server/sonar-webserver-api/build.gradle
+++ b/server/sonar-webserver-api/build.gradle
@@ -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')
diff --git a/server/sonar-webserver-api/src/test/java/org/sonar/server/plugins/PluginConsentVerifierTest.java b/server/sonar-webserver-api/src/test/java/org/sonar/server/plugins/PluginConsentVerifierTest.java
index 9ed421dcad5..813bac5d10d 100644
--- a/server/sonar-webserver-api/src/test/java/org/sonar/server/plugins/PluginConsentVerifierTest.java
+++ b/server/sonar-webserver-api/src/test/java/org/sonar/server/plugins/PluginConsentVerifierTest.java
@@ -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)
diff --git a/server/sonar-webserver-api/src/test/java/org/sonar/server/plugins/PluginJarLoaderTest.java b/server/sonar-webserver-api/src/test/java/org/sonar/server/plugins/PluginJarLoaderTest.java
index 50e6bf313b5..f8d54673e6c 100644
--- a/server/sonar-webserver-api/src/test/java/org/sonar/server/plugins/PluginJarLoaderTest.java
+++ b/server/sonar-webserver-api/src/test/java/org/sonar/server/plugins/PluginJarLoaderTest.java
@@ -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;
diff --git a/server/sonar-webserver-api/src/test/java/org/sonar/server/plugins/PluginUninstallerTest.java b/server/sonar-webserver-api/src/test/java/org/sonar/server/plugins/PluginUninstallerTest.java
index e6dee992bfd..b18e73df9b7 100644
--- a/server/sonar-webserver-api/src/test/java/org/sonar/server/plugins/PluginUninstallerTest.java
+++ b/server/sonar-webserver-api/src/test/java/org/sonar/server/plugins/PluginUninstallerTest.java
@@ -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;
diff --git a/server/sonar-webserver-api/src/test/java/org/sonar/server/plugins/ServerPluginManagerTest.java b/server/sonar-webserver-api/src/test/java/org/sonar/server/plugins/ServerPluginManagerTest.java
index e7f145590e2..6d72afd4c72 100644
--- a/server/sonar-webserver-api/src/test/java/org/sonar/server/plugins/ServerPluginManagerTest.java
+++ b/server/sonar-webserver-api/src/test/java/org/sonar/server/plugins/ServerPluginManagerTest.java
@@ -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;
diff --git a/server/sonar-webserver-api/src/test/java/org/sonar/server/qualitygate/changeevent/QGChangeEventListenersImplTest.java b/server/sonar-webserver-api/src/test/java/org/sonar/server/qualitygate/changeevent/QGChangeEventListenersImplTest.java
index d7d465fcde0..2beafbfe310 100644
--- a/server/sonar-webserver-api/src/test/java/org/sonar/server/qualitygate/changeevent/QGChangeEventListenersImplTest.java
+++ b/server/sonar-webserver-api/src/test/java/org/sonar/server/qualitygate/changeevent/QGChangeEventListenersImplTest.java
@@ -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 + "...",
diff --git a/server/sonar-webserver-auth/build.gradle b/server/sonar-webserver-auth/build.gradle
index bda05a4689e..a5362a835cb 100644
--- a/server/sonar-webserver-auth/build.gradle
+++ b/server/sonar-webserver-auth/build.gradle
@@ -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')
diff --git a/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/DefaultAdminCredentialsVerifierImplTest.java b/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/DefaultAdminCredentialsVerifierImplTest.java
index d1bd8d25396..5382b5c88d2 100644
--- a/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/DefaultAdminCredentialsVerifierImplTest.java
+++ b/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/DefaultAdminCredentialsVerifierImplTest.java
@@ -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));
}
diff --git a/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/GithubWebhookAuthenticationTest.java b/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/GithubWebhookAuthenticationTest.java
index a8433bd9d55..b3cde7ceae6 100644
--- a/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/GithubWebhookAuthenticationTest.java
+++ b/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/GithubWebhookAuthenticationTest.java
@@ -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;
diff --git a/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/InitFilterTest.java b/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/InitFilterTest.java
index a4c1d65f689..cc84c22a853 100644
--- a/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/InitFilterTest.java
+++ b/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/InitFilterTest.java
@@ -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();
}
diff --git a/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/LogOAuthWarningTest.java b/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/LogOAuthWarningTest.java
index 344c65c0207..7918cc6dc59 100644
--- a/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/LogOAuthWarningTest.java
+++ b/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/LogOAuthWarningTest.java
@@ -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();
}
diff --git a/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/OAuth2CallbackFilterTest.java b/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/OAuth2CallbackFilterTest.java
index 6ac07d7bff3..5b4699d557e 100644
--- a/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/OAuth2CallbackFilterTest.java
+++ b/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/OAuth2CallbackFilterTest.java
@@ -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();
}
diff --git a/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/UserRegistrarImplTest.java b/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/UserRegistrarImplTest.java
index ef0bc0b076c..61d8f615bb7 100644
--- a/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/UserRegistrarImplTest.java
+++ b/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/UserRegistrarImplTest.java
@@ -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;
diff --git a/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/event/AuthenticationEventImplTest.java b/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/event/AuthenticationEventImplTest.java
index 83f78ad2559..ca1ea2a3cde 100644
--- a/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/event/AuthenticationEventImplTest.java
+++ b/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/event/AuthenticationEventImplTest.java
@@ -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);
}
diff --git a/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/purge/ExpiredSessionsCleanerTest.java b/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/purge/ExpiredSessionsCleanerTest.java
index 3a9b0c2fe85..e6b233ad3d3 100644
--- a/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/purge/ExpiredSessionsCleanerTest.java
+++ b/server/sonar-webserver-auth/src/test/java/org/sonar/server/authentication/purge/ExpiredSessionsCleanerTest.java
@@ -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;
diff --git a/server/sonar-webserver-auth/src/test/java/org/sonar/server/user/SystemPasscodeImplTest.java b/server/sonar-webserver-auth/src/test/java/org/sonar/server/user/SystemPasscodeImplTest.java
index ee874c6692b..1db4f46db06 100644
--- a/server/sonar-webserver-auth/src/test/java/org/sonar/server/user/SystemPasscodeImplTest.java
+++ b/server/sonar-webserver-auth/src/test/java/org/sonar/server/user/SystemPasscodeImplTest.java
@@ -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
diff --git a/server/sonar-webserver-auth/src/test/java/org/sonar/server/usertoken/notification/TokenExpirationNotificationSchedulerImplTest.java b/server/sonar-webserver-auth/src/test/java/org/sonar/server/usertoken/notification/TokenExpirationNotificationSchedulerImplTest.java
index f8933b61bb7..92f01c6bc3e 100644
--- a/server/sonar-webserver-auth/src/test/java/org/sonar/server/usertoken/notification/TokenExpirationNotificationSchedulerImplTest.java
+++ b/server/sonar-webserver-auth/src/test/java/org/sonar/server/usertoken/notification/TokenExpirationNotificationSchedulerImplTest.java
@@ -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;
diff --git a/server/sonar-webserver-auth/src/test/java/org/sonar/server/usertoken/notification/TokenExpirationNotificationSenderTest.java b/server/sonar-webserver-auth/src/test/java/org/sonar/server/usertoken/notification/TokenExpirationNotificationSenderTest.java
index 472b0ee4e97..a5b4e82189b 100644
--- a/server/sonar-webserver-auth/src/test/java/org/sonar/server/usertoken/notification/TokenExpirationNotificationSenderTest.java
+++ b/server/sonar-webserver-auth/src/test/java/org/sonar/server/usertoken/notification/TokenExpirationNotificationSenderTest.java
@@ -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.");
}
diff --git a/server/sonar-webserver-core/build.gradle b/server/sonar-webserver-core/build.gradle
index 1abb12d00a5..562fda20b89 100644
--- a/server/sonar-webserver-core/build.gradle
+++ b/server/sonar-webserver-core/build.gradle
@@ -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'))
diff --git a/server/sonar-webserver-core/src/test/java/org/sonar/server/issue/index/AsyncIssueIndexingImplTest.java b/server/sonar-webserver-core/src/test/java/org/sonar/server/issue/index/AsyncIssueIndexingImplTest.java
index aab8cb22a0a..7c8c3382157 100644
--- a/server/sonar-webserver-core/src/test/java/org/sonar/server/issue/index/AsyncIssueIndexingImplTest.java
+++ b/server/sonar-webserver-core/src/test/java/org/sonar/server/issue/index/AsyncIssueIndexingImplTest.java
@@ -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.");
}
diff --git a/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/DatabaseServerCompatibilityTest.java b/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/DatabaseServerCompatibilityTest.java
index 46201b8a611..2e76e9934d0 100644
--- a/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/DatabaseServerCompatibilityTest.java
+++ b/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/DatabaseServerCompatibilityTest.java
@@ -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",
"################################################################################",
diff --git a/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/db/CheckAnyonePermissionsAtStartupTest.java b/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/db/CheckAnyonePermissionsAtStartupTest.java
index 56436667bf3..43b5ffc2982 100644
--- a/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/db/CheckAnyonePermissionsAtStartupTest.java
+++ b/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/db/CheckAnyonePermissionsAtStartupTest.java
@@ -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);
}
}
diff --git a/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/db/CheckLanguageSpecificParamsAtStartupTest.java b/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/db/CheckLanguageSpecificParamsAtStartupTest.java
index 24fc0b08b38..5c2c8fa06fd 100644
--- a/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/db/CheckLanguageSpecificParamsAtStartupTest.java
+++ b/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/db/CheckLanguageSpecificParamsAtStartupTest.java
@@ -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();
}
diff --git a/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/db/EmbeddedDatabaseTest.java b/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/db/EmbeddedDatabaseTest.java
index 36049917e09..500ed03b887 100644
--- a/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/db/EmbeddedDatabaseTest.java
+++ b/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/db/EmbeddedDatabaseTest.java
@@ -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;
diff --git a/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/db/migration/AutoDbMigrationTest.java b/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/db/migration/AutoDbMigrationTest.java
index ae3718b8da3..188f09a7eb5 100644
--- a/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/db/migration/AutoDbMigrationTest.java
+++ b/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/db/migration/AutoDbMigrationTest.java
@@ -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");
}
}
diff --git a/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/web/RootFilterTest.java b/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/web/RootFilterTest.java
index 6259bb0339f..acacaf9e1e8 100644
--- a/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/web/RootFilterTest.java
+++ b/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/web/RootFilterTest.java
@@ -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");
}
diff --git a/server/sonar-webserver-core/src/test/java/org/sonar/server/qualitygate/ProjectsInWarningDaemonTest.java b/server/sonar-webserver-core/src/test/java/org/sonar/server/qualitygate/ProjectsInWarningDaemonTest.java
index 8f20eb2d129..06332abf050 100644
--- a/server/sonar-webserver-core/src/test/java/org/sonar/server/qualitygate/ProjectsInWarningDaemonTest.java
+++ b/server/sonar-webserver-core/src/test/java/org/sonar/server/qualitygate/ProjectsInWarningDaemonTest.java
@@ -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
diff --git a/server/sonar-webserver-core/src/test/java/org/sonar/server/rule/RegisterRulesTest.java b/server/sonar-webserver-core/src/test/java/org/sonar/server/rule/RegisterRulesTest.java
index b43a792f860..89a8a76de27 100644
--- a/server/sonar-webserver-core/src/test/java/org/sonar/server/rule/RegisterRulesTest.java
+++ b/server/sonar-webserver-core/src/test/java/org/sonar/server/rule/RegisterRulesTest.java
@@ -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;
diff --git a/server/sonar-webserver-core/src/test/java/org/sonar/server/startup/LogServerIdTest.java b/server/sonar-webserver-core/src/test/java/org/sonar/server/startup/LogServerIdTest.java
index ef27c84ff7c..164536b5cac 100644
--- a/server/sonar-webserver-core/src/test/java/org/sonar/server/startup/LogServerIdTest.java
+++ b/server/sonar-webserver-core/src/test/java/org/sonar/server/startup/LogServerIdTest.java
@@ -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();
diff --git a/server/sonar-webserver-core/src/test/java/org/sonar/server/startup/RegisterPermissionTemplatesTest.java b/server/sonar-webserver-core/src/test/java/org/sonar/server/startup/RegisterPermissionTemplatesTest.java
index 0cfd0ed3056..113fcaeb441 100644
--- a/server/sonar-webserver-core/src/test/java/org/sonar/server/startup/RegisterPermissionTemplatesTest.java
+++ b/server/sonar-webserver-core/src/test/java/org/sonar/server/startup/RegisterPermissionTemplatesTest.java
@@ -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
diff --git a/server/sonar-webserver-core/src/test/java/org/sonar/server/telemetry/TelemetryDaemonTest.java b/server/sonar-webserver-core/src/test/java/org/sonar/server/telemetry/TelemetryDaemonTest.java
index 4137486dbb2..f4e860abb19 100644
--- a/server/sonar-webserver-core/src/test/java/org/sonar/server/telemetry/TelemetryDaemonTest.java
+++ b/server/sonar-webserver-core/src/test/java/org/sonar/server/telemetry/TelemetryDaemonTest.java
@@ -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
diff --git a/server/sonar-webserver-es/build.gradle b/server/sonar-webserver-es/build.gradle
index 83b559a8b8e..3ef617f813e 100644
--- a/server/sonar-webserver-es/build.gradle
+++ b/server/sonar-webserver-es/build.gradle
@@ -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')
diff --git a/server/sonar-webserver-es/src/test/java/org/sonar/server/es/IndexCreatorTest.java b/server/sonar-webserver-es/src/test/java/org/sonar/server/es/IndexCreatorTest.java
index f179f2c3e64..fd81a8d013c 100644
--- a/server/sonar-webserver-es/src/test/java/org/sonar/server/es/IndexCreatorTest.java
+++ b/server/sonar-webserver-es/src/test/java/org/sonar/server/es/IndexCreatorTest.java
@@ -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
diff --git a/server/sonar-webserver-es/src/test/java/org/sonar/server/es/RecoveryIndexerTest.java b/server/sonar-webserver-es/src/test/java/org/sonar/server/es/RecoveryIndexerTest.java
index 024f4613c20..a87e495aa10 100644
--- a/server/sonar-webserver-es/src/test/java/org/sonar/server/es/RecoveryIndexerTest.java
+++ b/server/sonar-webserver-es/src/test/java/org/sonar/server/es/RecoveryIndexerTest.java
@@ -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();
}
diff --git a/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueQueryFactoryTest.java b/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueQueryFactoryTest.java
index ddbdef82183..9627bcbbbc0 100644
--- a/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueQueryFactoryTest.java
+++ b/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueQueryFactoryTest.java
@@ -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;
diff --git a/server/sonar-webserver-monitoring/build.gradle b/server/sonar-webserver-monitoring/build.gradle
index 2d6de907f76..84fb86e4fb2 100644
--- a/server/sonar-webserver-monitoring/build.gradle
+++ b/server/sonar-webserver-monitoring/build.gradle
@@ -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'
}
diff --git a/server/sonar-webserver-monitoring/src/test/java/org/sonar/server/monitoring/ElasticSearchMetricTaskTest.java b/server/sonar-webserver-monitoring/src/test/java/org/sonar/server/monitoring/ElasticSearchMetricTaskTest.java
index 6a991784c00..3e6a7494f60 100644
--- a/server/sonar-webserver-monitoring/src/test/java/org/sonar/server/monitoring/ElasticSearchMetricTaskTest.java
+++ b/server/sonar-webserver-monitoring/src/test/java/org/sonar/server/monitoring/ElasticSearchMetricTaskTest.java
@@ -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
diff --git a/server/sonar-webserver-webapi/build.gradle b/server/sonar-webserver-webapi/build.gradle
index 2dcc84a9f29..944f087d7a4 100644
--- a/server/sonar-webserver-webapi/build.gradle
+++ b/server/sonar-webserver-webapi/build.gradle
@@ -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'))
diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/projectanalysis/ws/SearchActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/projectanalysis/ws/SearchActionIT.java
index 544a21daa84..c852453117b 100644
--- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/projectanalysis/ws/SearchActionIT.java
+++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/projectanalysis/ws/SearchActionIT.java
@@ -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;
diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualitygate/RegisterQualityGatesIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualitygate/RegisterQualityGatesIT.java
index 1687527a4f7..9f56986821b 100644
--- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualitygate/RegisterQualityGatesIT.java
+++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualitygate/RegisterQualityGatesIT.java
@@ -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() {
diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/RegisterQualityProfilesIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/RegisterQualityProfilesIT.java
index cd4d12d8e4f..eac7cc3e7b5 100644
--- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/RegisterQualityProfilesIT.java
+++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/RegisterQualityProfilesIT.java
@@ -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),
diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/RegisterQualityProfilesNotificationIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/RegisterQualityProfilesNotificationIT.java
index 2c14247bc1b..f252d34add8 100644
--- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/RegisterQualityProfilesNotificationIT.java
+++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/RegisterQualityProfilesNotificationIT.java
@@ -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;
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/RestartActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/RestartActionTest.java
index d49d5bc029b..9902bc398cc 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/RestartActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/RestartActionTest.java
@@ -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);
}
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ui/PageRepositoryTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ui/PageRepositoryTest.java
index f611f82b6ce..38a3c47519f 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ui/PageRepositoryTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ui/PageRepositoryTest.java
@@ -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;
diff --git a/server/sonar-webserver-ws/build.gradle b/server/sonar-webserver-ws/build.gradle
index 3889fcf5555..3a2418226b1 100644
--- a/server/sonar-webserver-ws/build.gradle
+++ b/server/sonar-webserver-ws/build.gradle
@@ -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')
diff --git a/server/sonar-webserver-ws/src/test/java/org/sonar/server/ws/WebServiceEngineTest.java b/server/sonar-webserver-ws/src/test/java/org/sonar/server/ws/WebServiceEngineTest.java
index 01586b39e43..ed9b58f2b6a 100644
--- a/server/sonar-webserver-ws/src/test/java/org/sonar/server/ws/WebServiceEngineTest.java
+++ b/server/sonar-webserver-ws/src/test/java/org/sonar/server/ws/WebServiceEngineTest.java
@@ -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) {
diff --git a/server/sonar-webserver-ws/src/test/java/org/sonar/server/ws/WsUtilsTest.java b/server/sonar-webserver-ws/src/test/java/org/sonar/server/ws/WsUtilsTest.java
index 00b58a58c7c..ebc320c6259 100644
--- a/server/sonar-webserver-ws/src/test/java/org/sonar/server/ws/WsUtilsTest.java
+++ b/server/sonar-webserver-ws/src/test/java/org/sonar/server/ws/WsUtilsTest.java
@@ -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;
diff --git a/server/sonar-webserver/build.gradle b/server/sonar-webserver/build.gradle
index f5cb9fe1c87..3ae46ff40db 100644
--- a/server/sonar-webserver/build.gradle
+++ b/server/sonar-webserver/build.gradle
@@ -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'))
diff --git a/server/sonar-webserver/src/test/java/org/sonar/server/platform/web/MasterServletFilterTest.java b/server/sonar-webserver/src/test/java/org/sonar/server/platform/web/MasterServletFilterTest.java
index a7bfb4d5d6d..49077005dbd 100644
--- a/server/sonar-webserver/src/test/java/org/sonar/server/platform/web/MasterServletFilterTest.java
+++ b/server/sonar-webserver/src/test/java/org/sonar/server/platform/web/MasterServletFilterTest.java
@@ -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() {
diff --git a/server/sonar-webserver/src/test/java/org/sonar/server/platform/web/StaticResourcesServletTest.java b/server/sonar-webserver/src/test/java/org/sonar/server/platform/web/StaticResourcesServletTest.java
index 90e5f3f13dd..50c8aced38c 100644
--- a/server/sonar-webserver/src/test/java/org/sonar/server/platform/web/StaticResourcesServletTest.java
+++ b/server/sonar-webserver/src/test/java/org/sonar/server/platform/web/StaticResourcesServletTest.java
@@ -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 {
diff --git a/sonar-core/build.gradle b/sonar-core/build.gradle
index ded22c46c6f..7c85982378f 100644
--- a/sonar-core/build.gradle
+++ b/sonar-core/build.gradle
@@ -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'
diff --git a/sonar-core/src/test/java/org/sonar/core/platform/PluginClassLoaderTest.java b/sonar-core/src/test/java/org/sonar/core/platform/PluginClassLoaderTest.java
index a1c58f5ad8e..1f88942c6f7 100644
--- a/sonar-core/src/test/java/org/sonar/core/platform/PluginClassLoaderTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/platform/PluginClassLoaderTest.java
@@ -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.");
}
diff --git a/sonar-core/src/test/java/org/sonar/core/util/ProgressLoggerTest.java b/sonar-core/src/test/java/org/sonar/core/util/ProgressLoggerTest.java
index 7f110fc3f9a..d4ca9389040 100644
--- a/sonar-core/src/test/java/org/sonar/core/util/ProgressLoggerTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/util/ProgressLoggerTest.java
@@ -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));
}
}
diff --git a/sonar-core/src/test/java/org/sonar/core/util/logs/DefaultProfilerTest.java b/sonar-core/src/test/java/org/sonar/core/util/logs/DefaultProfilerTest.java
index 745816f3068..f88bd0ee4f2 100644
--- a/sonar-core/src/test/java/org/sonar/core/util/logs/DefaultProfilerTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/util/logs/DefaultProfilerTest.java
@@ -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");
diff --git a/sonar-core/src/test/java/org/sonar/core/util/logs/ProfilerTest.java b/sonar-core/src/test/java/org/sonar/core/util/logs/ProfilerTest.java
index f00ee3db541..c1a5e5999db 100644
--- a/sonar-core/src/test/java/org/sonar/core/util/logs/ProfilerTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/util/logs/ProfilerTest.java
@@ -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;
diff --git a/sonar-plugin-api-impl/build.gradle b/sonar-plugin-api-impl/build.gradle
index 51480338d9d..92bf8a3e6c9 100644
--- a/sonar-plugin-api-impl/build.gradle
+++ b/sonar-plugin-api-impl/build.gradle
@@ -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
diff --git a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/fs/internal/DefaultInputFile.java b/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/fs/internal/DefaultInputFile.java
index 204e7ae27f5..2af4bc49464 100644
--- a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/fs/internal/DefaultInputFile.java
+++ b/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/fs/internal/DefaultInputFile.java
@@ -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();
}
diff --git a/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/fs/internal/fs/FileMetadataTest.java b/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/fs/internal/fs/FileMetadataTest.java
index bd964a8f15d..179de739f5b 100644
--- a/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/fs/internal/fs/FileMetadataTest.java
+++ b/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/fs/internal/fs/FileMetadataTest.java
@@ -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'.");
}
diff --git a/sonar-plugin-api-impl/src/test/java/org/sonar/api/impl/utils/DefaultTempFolderTest.java b/sonar-plugin-api-impl/src/test/java/org/sonar/api/impl/utils/DefaultTempFolderTest.java
index 2851cf66798..4f2babc1ba2 100644
--- a/sonar-plugin-api-impl/src/test/java/org/sonar/api/impl/utils/DefaultTempFolderTest.java
+++ b/sonar-plugin-api-impl/src/test/java/org/sonar/api/impl/utils/DefaultTempFolderTest.java
@@ -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();
}
}
diff --git a/sonar-scanner-engine/build.gradle b/sonar-scanner-engine/build.gradle
index 269ec1996e5..093f996a9c4 100644
--- a/sonar-scanner-engine/build.gradle
+++ b/sonar-scanner-engine/build.gradle
@@ -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')
}
diff --git a/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/ScannerMediumTester.java b/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/ScannerMediumTester.java
index a7a181a6f43..ced4d750654 100644
--- a/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/ScannerMediumTester.java
+++ b/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/ScannerMediumTester.java
@@ -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;
}
diff --git a/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/branch/BranchMediumIT.java b/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/branch/BranchMediumIT.java
index 02f68d9e74b..883b8be4548 100644
--- a/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/branch/BranchMediumIT.java
+++ b/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/branch/BranchMediumIT.java
@@ -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());
diff --git a/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/coverage/CoverageMediumIT.java b/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/coverage/CoverageMediumIT.java
index 08faf0f0f5e..20b48b37ec9 100644
--- a/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/coverage/CoverageMediumIT.java
+++ b/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/coverage/CoverageMediumIT.java
@@ -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.");
}
diff --git a/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/coverage/GenericCoverageMediumIT.java b/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/coverage/GenericCoverageMediumIT.java
index 1f16e7241d7..fe5676fd40f 100644
--- a/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/coverage/GenericCoverageMediumIT.java
+++ b/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/coverage/GenericCoverageMediumIT.java
@@ -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'"));
}
}
diff --git a/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/cpd/CpdMediumIT.java b/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/cpd/CpdMediumIT.java
index 0975bb74a74..1455ab4512e 100644
--- a/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/cpd/CpdMediumIT.java
+++ b/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/cpd/CpdMediumIT.java
@@ -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.");
}
diff --git a/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/fs/FileSystemMediumIT.java b/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/fs/FileSystemMediumIT.java
index 9c1c55338b3..bc7fac73a43 100644
--- a/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/fs/FileSystemMediumIT.java
+++ b/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/fs/FileSystemMediumIT.java
@@ -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") + "'.");
}
diff --git a/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/issues/ExternalIssuesMediumIT.java b/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/issues/ExternalIssuesMediumIT.java
index 2f9d939f7d8..2ed34a2e85c 100644
--- a/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/issues/ExternalIssuesMediumIT.java
+++ b/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/issues/ExternalIssuesMediumIT.java
@@ -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);
diff --git a/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/issues/IssuesMediumIT.java b/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/issues/IssuesMediumIT.java
index feaf921d141..f303864355b 100644
--- a/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/issues/IssuesMediumIT.java
+++ b/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/issues/IssuesMediumIT.java
@@ -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"));
diff --git a/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/issues/PreviewMediumIT.java b/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/issues/PreviewMediumIT.java
index 6cd81792a93..456e6305626 100644
--- a/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/issues/PreviewMediumIT.java
+++ b/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/issues/PreviewMediumIT.java
@@ -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;
diff --git a/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/measures/MeasuresMediumIT.java b/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/measures/MeasuresMediumIT.java
index c3f4fb1768e..3797de5c15a 100644
--- a/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/measures/MeasuresMediumIT.java
+++ b/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/measures/MeasuresMediumIT.java
@@ -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.");
}
}
diff --git a/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/scm/ScmMediumIT.java b/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/scm/ScmMediumIT.java
index 04451bf92f0..776e5878069 100644
--- a/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/scm/ScmMediumIT.java
+++ b/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/scm/ScmMediumIT.java
@@ -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);
diff --git a/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/tasks/TasksMediumIT.java b/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/tasks/TasksMediumIT.java
index 776a11575bf..35d86c2e634 100644
--- a/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/tasks/TasksMediumIT.java
+++ b/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/tasks/TasksMediumIT.java
@@ -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;
diff --git a/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/tests/GenericTestExecutionMediumIT.java b/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/tests/GenericTestExecutionMediumIT.java
index 86962f74824..4b0d80044fc 100644
--- a/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/tests/GenericTestExecutionMediumIT.java
+++ b/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/tests/GenericTestExecutionMediumIT.java
@@ -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'"));
}
}
diff --git a/sonar-scanner-engine/src/it/java/org/sonar/scm/svn/SvnBlameCommandIT.java b/sonar-scanner-engine/src/it/java/org/sonar/scm/svn/SvnBlameCommandIT.java
index dec6960b3cb..3c401e86b22 100644
--- a/sonar-scanner-engine/src/it/java/org/sonar/scm/svn/SvnBlameCommandIT.java
+++ b/sonar-scanner-engine/src/it/java/org/sonar/scm/svn/SvnBlameCommandIT.java
@@ -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) {
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/batch/bootstrapper/Batch.java b/sonar-scanner-engine/src/main/java/org/sonar/batch/bootstrapper/Batch.java
index cb2e3d0c96b..5eed107276d 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/batch/bootstrapper/Batch.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/batch/bootstrapper/Batch.java
@@ -77,7 +77,7 @@ public final class Batch {
}
private RuntimeException handleException(RuntimeException t) {
- if (loggingConfig.isVerbose()) {
+ if (loggingConfig != null && loggingConfig.isVerbose()) {
return t;
}
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/DefaultScannerWsClientTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/DefaultScannerWsClientTest.java
index 1d5aed37812..84494037505 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/DefaultScannerWsClientTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/DefaultScannerWsClientTest.java
@@ -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.");
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/GlobalConfigurationProviderTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/GlobalConfigurationProviderTest.java
index 9936994fce3..1e0d36b8bc0 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/GlobalConfigurationProviderTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/GlobalConfigurationProviderTest.java
@@ -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;
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/cache/DefaultAnalysisCacheLoaderTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/cache/DefaultAnalysisCacheLoaderTest.java
index 52bc139c101..7b9c8506b81 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/cache/DefaultAnalysisCacheLoaderTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/cache/DefaultAnalysisCacheLoaderTest.java
@@ -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;
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/ci/vendors/CirrusCiTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/ci/vendors/CirrusCiTest.java
index 27be416a12b..b40faeb0b9b 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/ci/vendors/CirrusCiTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/ci/vendors/CirrusCiTest.java
@@ -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) {
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/ci/vendors/CodeMagicTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/ci/vendors/CodeMagicTest.java
index 95ee135bb95..8eef19bce63 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/ci/vendors/CodeMagicTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/ci/vendors/CodeMagicTest.java
@@ -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);
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/ci/vendors/GithubActionsTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/ci/vendors/GithubActionsTest.java
index 690bc23aee5..f37622fa210 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/ci/vendors/GithubActionsTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/ci/vendors/GithubActionsTest.java
@@ -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) {
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/config/DefaultConfigurationTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/config/DefaultConfigurationTest.java
index dc74cad4abd..c1865c579a0 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/config/DefaultConfigurationTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/config/DefaultConfigurationTest.java
@@ -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
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/cpd/CpdExecutorTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/cpd/CpdExecutorTest.java
index 97e6faf3d97..13ec7ccec33 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/cpd/CpdExecutorTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/cpd/CpdExecutorTest.java
@@ -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");
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/externalissue/ExternalIssueImporterTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/externalissue/ExternalIssueImporterTest.java
index 75fe15385d2..315991b93fb 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/externalissue/ExternalIssueImporterTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/externalissue/ExternalIssueImporterTest.java
@@ -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
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/externalissue/sarif/DefaultSarif210ImporterTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/externalissue/sarif/DefaultSarif210ImporterTest.java
index a3cc9ced05f..e8cf14b5adb 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/externalissue/sarif/DefaultSarif210ImporterTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/externalissue/sarif/DefaultSarif210ImporterTest.java
@@ -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();
}
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/externalissue/sarif/RulesSeverityDetectorTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/externalissue/sarif/RulesSeverityDetectorTest.java
index 5a4f128f92c..a06e2324ff5 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/externalissue/sarif/RulesSeverityDetectorTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/externalissue/sarif/RulesSeverityDetectorTest.java
@@ -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));
}
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/externalissue/sarif/RunMapperTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/externalissue/sarif/RunMapperTest.java
index eb10e4d2995..6146886d1fe 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/externalissue/sarif/RunMapperTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/externalissue/sarif/RunMapperTest.java
@@ -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");
}
}
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/externalissue/sarif/SarifIssuesImportSensorTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/externalissue/sarif/SarifIssuesImportSensorTest.java
index ccffa0e353a..533e05d9711 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/externalissue/sarif/SarifIssuesImportSensorTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/externalissue/sarif/SarifIssuesImportSensorTest.java
@@ -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());
}
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/genericcoverage/GenericCoverageReportParserTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/genericcoverage/GenericCoverageReportParserTest.java
index 043c1a7d5d2..a37dd222edf 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/genericcoverage/GenericCoverageReportParserTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/genericcoverage/GenericCoverageReportParserTest.java
@@ -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");
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/genericcoverage/GenericCoverageSensorTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/genericcoverage/GenericCoverageSensorTest.java
index b2648a575a1..0e6329b4bfc 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/genericcoverage/GenericCoverageSensorTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/genericcoverage/GenericCoverageSensorTest.java
@@ -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;
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/genericcoverage/GenericTestExecutionReportParserTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/genericcoverage/GenericTestExecutionReportParserTest.java
index 73688ea4884..27974475c29 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/genericcoverage/GenericTestExecutionReportParserTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/genericcoverage/GenericTestExecutionReportParserTest.java
@@ -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");
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/genericcoverage/GenericTestExecutionSensorTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/genericcoverage/GenericTestExecutionSensorTest.java
index fbd4f88228a..8712d9aff68 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/genericcoverage/GenericTestExecutionSensorTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/genericcoverage/GenericTestExecutionSensorTest.java
@@ -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");
}
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/issue/ignore/IgnoreIssuesFilterTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/issue/ignore/IgnoreIssuesFilterTest.java
index 4c232592e10..6007ef1e617 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/issue/ignore/IgnoreIssuesFilterTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/issue/ignore/IgnoreIssuesFilterTest.java
@@ -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;
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/phases/ModuleSensorsExecutorTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/phases/ModuleSensorsExecutorTest.java
index e77cb6dbe19..53c3884aa60 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/phases/ModuleSensorsExecutorTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/phases/ModuleSensorsExecutorTest.java
@@ -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;
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/qualitygate/QualityGateCheckTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/qualitygate/QualityGateCheckTest.java
index 8a73051b7cf..558b2b4f4b5 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/qualitygate/QualityGateCheckTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/qualitygate/QualityGateCheckTest.java
@@ -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");
}
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/AnalysisContextReportPublisherTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/AnalysisContextReportPublisherTest.java
index 8ee25330d28..605d8e7787e 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/AnalysisContextReportPublisherTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/AnalysisContextReportPublisherTest.java
@@ -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;
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/ChangedLinesPublisherTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/ChangedLinesPublisherTest.java
index d9de9f51e4b..f18dfb97713 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/ChangedLinesPublisherTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/ChangedLinesPublisherTest.java
@@ -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;
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/ReportPublisherTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/ReportPublisherTest.java
index ffbe3971c1a..0e45609e294 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/ReportPublisherTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/ReportPublisherTest.java
@@ -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);
}
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/repository/QualityProfileProviderTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/repository/QualityProfileProviderTest.java
index 2e99bca7c72..651a1ba4fe6 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/repository/QualityProfileProviderTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/repository/QualityProfileProviderTest.java
@@ -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;
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/DeprecatedPropertiesWarningGeneratorTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/DeprecatedPropertiesWarningGeneratorTest.java
index f584add964d..f41b334a278 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/DeprecatedPropertiesWarningGeneratorTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/DeprecatedPropertiesWarningGeneratorTest.java
@@ -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();
}
}
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ProjectReactorBuilderTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ProjectReactorBuilderTest.java
index 01414c30e3d..4617699e4c9 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ProjectReactorBuilderTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ProjectReactorBuilderTest.java
@@ -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;
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ProjectReactorValidatorTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ProjectReactorValidatorTest.java
index 58e6e4510ea..9fe39d63f1b 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ProjectReactorValidatorTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/ProjectReactorValidatorTest.java
@@ -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;
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/AbstractExclusionFiltersTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/AbstractExclusionFiltersTest.java
index b36fadbb848..cfe8cd20d32 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/AbstractExclusionFiltersTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/AbstractExclusionFiltersTest.java
@@ -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);
}
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/MetadataGeneratorTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/MetadataGeneratorTest.java
index df139587912..5fffbc1202f 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/MetadataGeneratorTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/MetadataGeneratorTest.java
@@ -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);
}
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scm/ScmConfigurationTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scm/ScmConfigurationTest.java
index 8bf50b199c7..80017adbbbc 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scm/ScmConfigurationTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scm/ScmConfigurationTest.java
@@ -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();
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/sensor/UnchangedFilesHandlerTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/sensor/UnchangedFilesHandlerTest.java
index a9fff0e97c3..ff789c27e61 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/sensor/UnchangedFilesHandlerTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/sensor/UnchangedFilesHandlerTest.java
@@ -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");
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/util/ProgressReportTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/util/ProgressReportTest.java
index cf3758c35ff..d7cbf83287e 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/util/ProgressReportTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/util/ProgressReportTest.java
@@ -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");
}
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scm/git/CompositeBlameCommandTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scm/git/CompositeBlameCommandTest.java
index 088ee40d541..1bdb7713045 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scm/git/CompositeBlameCommandTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scm/git/CompositeBlameCommandTest.java
@@ -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
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scm/git/GitIgnoreCommandTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scm/git/GitIgnoreCommandTest.java
index ee1730b191b..65d63fbc19d 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scm/git/GitIgnoreCommandTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scm/git/GitIgnoreCommandTest.java
@@ -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 {
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scm/git/GitScmProviderTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scm/git/GitScmProviderTest.java
index cb7d1f68aec..7bddf0123ee 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scm/git/GitScmProviderTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scm/git/GitScmProviderTest.java
@@ -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;
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scm/git/JGitBlameCommandTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scm/git/JGitBlameCommandTest.java
index af8a102f367..2f22be669ee 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scm/git/JGitBlameCommandTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scm/git/JGitBlameCommandTest.java
@@ -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;
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scm/git/NativeGitBlameCommandTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scm/git/NativeGitBlameCommandTest.java
index 8bebca19a87..9f1624c7c0a 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scm/git/NativeGitBlameCommandTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scm/git/NativeGitBlameCommandTest.java
@@ -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);
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scm/git/ProcessWrapperFactoryTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scm/git/ProcessWrapperFactoryTest.java
index 12952933806..53f9dd4c7c2 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scm/git/ProcessWrapperFactoryTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scm/git/ProcessWrapperFactoryTest.java
@@ -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");
}
}
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scm/git/strategy/DefaultBlameStrategyTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scm/git/strategy/DefaultBlameStrategyTest.java
index 2cf351e5e33..2754f3f04ee 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scm/git/strategy/DefaultBlameStrategyTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scm/git/strategy/DefaultBlameStrategyTest.java
@@ -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");
}
}