diff options
author | Matteo Mara <matteo.mara@sonarsource.com> | 2024-03-08 18:08:49 +0100 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2024-03-16 20:02:46 +0000 |
commit | 4592d635902de23b402a28787a8468ba1ac3a3a4 (patch) | |
tree | 2561ce21fbcd2fb14f77daa1e28f32b815291f1e /sonar-scanner-engine/src/test | |
parent | 4f2cb04c5da8b5b07c459afdb6d777b29db779b5 (diff) | |
download | sonarqube-4592d635902de23b402a28787a8468ba1ac3a3a4.tar.gz sonarqube-4592d635902de23b402a28787a8468ba1ac3a3a4.zip |
SONAR-21452 move from commons-lang:commons-lang to org.apache.commons:commons-lang3
Diffstat (limited to 'sonar-scanner-engine/src/test')
15 files changed, 29 insertions, 28 deletions
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/ProjectInfoTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/ProjectInfoTest.java index db839190139..943a40144c0 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/ProjectInfoTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/ProjectInfoTest.java @@ -26,17 +26,15 @@ import java.time.ZoneId; import java.time.ZoneOffset; import java.util.Date; import javax.annotation.Nullable; -import org.apache.commons.lang.RandomStringUtils; +import org.apache.commons.lang3.RandomStringUtils; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.EmptySource; import org.junit.jupiter.params.provider.NullAndEmptySource; -import org.junit.jupiter.params.provider.NullSource; import org.sonar.api.CoreProperties; import org.sonar.api.config.internal.MapSettings; import org.sonar.api.utils.MessageException; -import static org.apache.commons.lang.RandomStringUtils.randomAlphabetic; +import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.mockito.Mockito.mock; diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/WsTestUtil.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/WsTestUtil.java index 39e87f20270..cac8b437689 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/WsTestUtil.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/WsTestUtil.java @@ -22,7 +22,7 @@ package org.sonar.scanner; import java.io.InputStream; import java.io.Reader; import javax.annotation.Nullable; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.mockito.ArgumentMatcher; import org.sonar.scanner.bootstrap.DefaultScannerWsClient; import org.sonarqube.ws.client.WsRequest; 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 a3401061a57..07bcae141a7 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 @@ -24,7 +24,7 @@ import java.time.ZoneOffset; import java.time.format.DateTimeFormatter; import java.util.Collections; import java.util.List; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.junit.Rule; import org.junit.Test; import org.mockito.Mockito; diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/ExtensionInstallerTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/ExtensionInstallerTest.java index 351913c9a1f..e8159ed92ba 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/ExtensionInstallerTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/ExtensionInstallerTest.java @@ -20,8 +20,7 @@ package org.sonar.scanner.bootstrap; import java.util.Arrays; - -import org.apache.commons.lang.ClassUtils; +import org.apache.commons.lang3.ClassUtils; import org.junit.Test; import org.sonar.api.Plugin; import org.sonar.api.SonarRuntime; diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/PluginFilesTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/PluginFilesTest.java index c39887b17c4..a252bbbe3a0 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/PluginFilesTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/PluginFilesTest.java @@ -33,7 +33,7 @@ import okhttp3.mockwebserver.MockWebServer; import okio.Buffer; import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.io.FileUtils; -import org.apache.commons.lang.RandomStringUtils; +import org.apache.commons.lang3.RandomStringUtils; import org.junit.Before; import org.junit.Rule; import org.junit.Test; 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 549a8517a16..bdbd28fcdaa 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 @@ -20,9 +20,10 @@ package org.sonar.scanner.externalissue; import java.io.File; +import java.security.SecureRandom; import java.util.Map; +import java.util.Random; import javax.annotation.Nullable; -import org.apache.commons.lang.math.RandomUtils; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -41,8 +42,8 @@ import org.sonar.api.rules.RuleType; import org.sonar.api.testfixtures.log.LogTester; import static java.nio.charset.StandardCharsets.UTF_8; -import static org.apache.commons.lang.ObjectUtils.defaultIfNull; -import static org.apache.commons.lang.RandomStringUtils.randomAlphabetic; +import static org.apache.commons.lang3.ObjectUtils.defaultIfNull; +import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.sonar.api.issue.impact.Severity.HIGH; @@ -57,6 +58,8 @@ public class ExternalIssueImporterTest { public static final String RULE_NAME = "some_rule_name"; public static final CleanCodeAttribute RULE_ATTRIBUTE = CleanCodeAttribute.FORMATTED; + private final Random random = new SecureRandom(); + @Rule public TemporaryFolder temp = new TemporaryFolder(); @Rule @@ -381,7 +384,7 @@ public class ExternalIssueImporterTest { input.ruleId = randomAlphabetic(5); input.severity = "CRITICAL"; input.type = "BUG"; - input.effortMinutes = RandomUtils.nextInt(); + input.effortMinutes = random.nextInt(Integer.MAX_VALUE); input.primaryLocation = new ExternalIssueReport.Location(); input.primaryLocation.filePath = sourceFile.getProjectRelativePath(); input.primaryLocation.message = randomAlphabetic(5); 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 4133dddf0ad..ab647c6a29d 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 @@ -27,15 +27,15 @@ import java.util.Arrays; import java.util.List; import java.util.Properties; import org.apache.commons.io.FileUtils; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.junit.Before; import org.junit.Rule; import org.junit.Test; 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.testfixtures.log.LogTester; +import org.sonar.api.utils.System2; 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/MetadataPublisherTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/MetadataPublisherTest.java index cda7b52c377..91607834d0d 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/MetadataPublisherTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/MetadataPublisherTest.java @@ -60,7 +60,7 @@ import org.sonar.scanner.scm.ScmConfiguration; import org.sonar.scanner.scm.ScmRevision; import static java.util.Collections.emptyMap; -import static org.apache.commons.lang.RandomStringUtils.randomAlphabetic; +import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.entry; import static org.mockito.ArgumentMatchers.any; 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 25d5800a45f..7ed5fc9e084 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 @@ -28,14 +28,14 @@ import java.util.List; import java.util.Map; import java.util.Properties; import org.apache.commons.io.FileUtils; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.junit.Rule; import org.junit.Test; 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.testfixtures.log.LogTester; +import org.sonar.api.utils.MessageException; 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 e24235de671..3be0fda2132 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 @@ -38,7 +38,7 @@ import org.sonar.scanner.ProjectInfo; import org.sonar.scanner.bootstrap.GlobalConfiguration; import static java.lang.String.format; -import static org.apache.commons.lang.RandomStringUtils.randomAscii; +import static org.apache.commons.lang3.RandomStringUtils.randomAscii; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.mock; diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/CharsetDetectorTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/CharsetDetectorTest.java index 65c98bae530..64d7a67e1f3 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/CharsetDetectorTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/CharsetDetectorTest.java @@ -29,7 +29,7 @@ import java.nio.file.Paths; import java.util.List; import java.util.Random; import org.apache.commons.io.IOUtils; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/CharsetValidationTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/CharsetValidationTest.java index 4f76294bf5f..382eae972e8 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/CharsetValidationTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/CharsetValidationTest.java @@ -32,7 +32,7 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.util.Arrays; import java.util.List; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.junit.Before; import org.junit.Test; import org.sonar.scanner.scan.filesystem.CharsetValidation.Validation; diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/DirectoryFileVisitorTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/DirectoryFileVisitorTest.java index b7794c959a8..59bc00a3654 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/DirectoryFileVisitorTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/DirectoryFileVisitorTest.java @@ -27,7 +27,7 @@ import java.nio.file.Files; import java.nio.file.LinkOption; import java.nio.file.Path; import java.nio.file.attribute.BasicFileAttributes; -import org.apache.commons.lang.SystemUtils; +import org.apache.commons.lang3.SystemUtils; import org.junit.ClassRule; import org.junit.Test; import org.junit.rules.TemporaryFolder; diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scm/git/ChangedFileTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scm/git/ChangedFileTest.java index 1f05e6cc9eb..1bb25a29438 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scm/git/ChangedFileTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scm/git/ChangedFileTest.java @@ -26,8 +26,8 @@ import org.sonar.api.batch.fs.internal.DefaultIndexedFile; import org.sonar.api.batch.fs.internal.DefaultInputFile; import org.sonar.api.batch.fs.internal.SensorStrategy; -import static org.apache.commons.lang.RandomStringUtils.random; -import static org.apache.commons.lang.RandomStringUtils.randomNumeric; +import static org.apache.commons.lang3.RandomStringUtils.random; +import static org.apache.commons.lang3.RandomStringUtils.randomNumeric; import static org.assertj.core.api.Assertions.assertThat; public class ChangedFileTest { 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 ae3e1cb1aa6..81580d12787 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 @@ -27,6 +27,7 @@ import java.nio.file.LinkOption; import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.StandardOpenOption; +import java.security.SecureRandom; import java.time.Instant; import java.util.Arrays; import java.util.Collections; @@ -57,10 +58,10 @@ import org.junit.rules.TemporaryFolder; import org.sonar.api.config.Configuration; 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.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.core.documentation.DocumentationLinkGenerator; import org.sonar.scm.git.strategy.DefaultBlameStrategy; @@ -122,7 +123,7 @@ public class GitScmProviderTest { public LogTester logs = new LogTester(); private final GitIgnoreCommand gitIgnoreCommand = mock(GitIgnoreCommand.class); - private static final Random random = new Random(); + private static final Random RANDOM = new SecureRandom(); private static final System2 system2 = mock(System2.class); private Path worktree; @@ -812,7 +813,7 @@ public class GitScmProviderTest { for (int i = 0; i < 4; i++) { sb.append(' '); for (int j = 0; j < prefix.length(); j++) { - sb.append((char) ('a' + random.nextInt(26))); + sb.append((char) ('a' + RANDOM.nextInt(26))); } } return sb.toString(); |