aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-ce-task/src
diff options
context:
space:
mode:
authorMatteo Mara <matteo.mara@sonarsource.com>2024-10-07 18:13:33 +0200
committersonartech <sonartech@sonarsource.com>2024-10-14 20:03:03 +0000
commit1ad3667d30dd82213ae47bea2c267188f003b2c7 (patch)
tree422f1f66b48114de0e79de9f7bd53aceff3f7c91 /server/sonar-ce-task/src
parentce2e686a3e269f937ffb51635928cd1a597b2d07 (diff)
downloadsonarqube-1ad3667d30dd82213ae47bea2c267188f003b2c7.tar.gz
sonarqube-1ad3667d30dd82213ae47bea2c267188f003b2c7.zip
NO-JIRA Stop using deprecated methods from RandomStringUtils
Diffstat (limited to 'server/sonar-ce-task/src')
-rw-r--r--server/sonar-ce-task/src/it/java/org/sonar/ce/task/log/CeTaskMessagesImplIT.java15
-rw-r--r--server/sonar-ce-task/src/test/java/org/sonar/ce/task/CeTaskCanceledExceptionTest.java4
-rw-r--r--server/sonar-ce-task/src/test/java/org/sonar/ce/task/CeTaskComponentTest.java18
-rw-r--r--server/sonar-ce-task/src/test/java/org/sonar/ce/task/CeTaskInterruptedExceptionTest.java6
-rw-r--r--server/sonar-ce-task/src/test/java/org/sonar/ce/task/CeTaskTimeoutExceptionTest.java2
-rw-r--r--server/sonar-ce-task/src/test/java/org/sonar/ce/task/log/CeTaskMessagesMessageTest.java6
6 files changed, 25 insertions, 26 deletions
diff --git a/server/sonar-ce-task/src/it/java/org/sonar/ce/task/log/CeTaskMessagesImplIT.java b/server/sonar-ce-task/src/it/java/org/sonar/ce/task/log/CeTaskMessagesImplIT.java
index 966c7f84ce8..0a42950d338 100644
--- a/server/sonar-ce-task/src/it/java/org/sonar/ce/task/log/CeTaskMessagesImplIT.java
+++ b/server/sonar-ce-task/src/it/java/org/sonar/ce/task/log/CeTaskMessagesImplIT.java
@@ -36,8 +36,7 @@ import org.sonar.db.DbClient;
import org.sonar.db.DbTester;
import static java.util.stream.Collectors.toList;
-import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic;
-import static org.apache.commons.lang3.RandomStringUtils.randomAlphanumeric;
+import static org.apache.commons.lang3.RandomStringUtils.secure;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.assertj.core.api.Assertions.tuple;
@@ -51,11 +50,11 @@ public class CeTaskMessagesImplIT {
private DbClient dbClient = dbTester.getDbClient();
private UuidFactory uuidFactory = mock(UuidFactory.class);
- private String taskUuid = randomAlphabetic(12);
+ private String taskUuid = secure().nextAlphabetic(12);
private CeTask ceTask = new CeTask.Builder()
.setUuid(taskUuid)
- .setType(randomAlphabetic(5))
+ .setType(secure().nextAlphabetic(5))
.build();
private CeTaskMessagesImpl underTest = new CeTaskMessagesImpl(dbClient, uuidFactory, ceTask);
@@ -69,8 +68,8 @@ public class CeTaskMessagesImplIT {
@Test
public void add_persist_message_to_DB() {
- CeTaskMessages.Message message = new CeTaskMessages.Message(randomAlphabetic(20), 2_999L);
- String uuid = randomAlphanumeric(40);
+ CeTaskMessages.Message message = new CeTaskMessages.Message(secure().nextAlphabetic(20), 2_999L);
+ String uuid = secure().nextAlphanumeric(40);
when(uuidFactory.create()).thenReturn(uuid);
underTest.add(message);
@@ -91,10 +90,10 @@ public class CeTaskMessagesImplIT {
Random random = new Random();
List<CeTaskMessages.Message> messages = Stream.of(
// some (or none) non null Message before null one
- IntStream.range(0, random.nextInt(5)).mapToObj(i -> new CeTaskMessages.Message(randomAlphabetic(3) + "_i", 1_999L + i)),
+ IntStream.range(0, random.nextInt(5)).mapToObj(i -> new CeTaskMessages.Message(secure().nextAlphabetic(3) + "_i", 1_999L + i)),
Stream.of((CeTaskMessages.Message) null),
// some (or none) non null Message after null one
- IntStream.range(0, random.nextInt(5)).mapToObj(i -> new CeTaskMessages.Message(randomAlphabetic(3) + "_i", 1_999L + i)))
+ IntStream.range(0, random.nextInt(5)).mapToObj(i -> new CeTaskMessages.Message(secure().nextAlphabetic(3) + "_i", 1_999L + i)))
.flatMap(t -> t)
.collect(toList());
diff --git a/server/sonar-ce-task/src/test/java/org/sonar/ce/task/CeTaskCanceledExceptionTest.java b/server/sonar-ce-task/src/test/java/org/sonar/ce/task/CeTaskCanceledExceptionTest.java
index 6f3825f1dd1..36b50d3f9e5 100644
--- a/server/sonar-ce-task/src/test/java/org/sonar/ce/task/CeTaskCanceledExceptionTest.java
+++ b/server/sonar-ce-task/src/test/java/org/sonar/ce/task/CeTaskCanceledExceptionTest.java
@@ -22,14 +22,14 @@ package org.sonar.ce.task;
import org.junit.Test;
import org.sonar.db.ce.CeActivityDto;
-import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic;
+import static org.apache.commons.lang3.RandomStringUtils.secure;
import static org.assertj.core.api.Assertions.assertThat;
public class CeTaskCanceledExceptionTest {
@Test
public void message_is_based_on_specified_thread_name() {
Thread t = new Thread();
- t.setName(randomAlphabetic(29));
+ t.setName(secure().nextAlphabetic(29));
CeTaskCanceledException underTest = new CeTaskCanceledException(t);
diff --git a/server/sonar-ce-task/src/test/java/org/sonar/ce/task/CeTaskComponentTest.java b/server/sonar-ce-task/src/test/java/org/sonar/ce/task/CeTaskComponentTest.java
index 091c4fd6fb3..c9448120b98 100644
--- a/server/sonar-ce-task/src/test/java/org/sonar/ce/task/CeTaskComponentTest.java
+++ b/server/sonar-ce-task/src/test/java/org/sonar/ce/task/CeTaskComponentTest.java
@@ -25,7 +25,7 @@ import com.tngtech.java.junit.dataprovider.UseDataProvider;
import org.junit.Test;
import org.junit.runner.RunWith;
-import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic;
+import static org.apache.commons.lang3.RandomStringUtils.secure;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
@@ -58,10 +58,10 @@ public class CeTaskComponentTest {
@Test
public void equals_is_based_on_all_fields() {
- String uuid = randomAlphabetic(2);
- String key = randomAlphabetic(3);
- String name = randomAlphabetic(4);
- String somethingElse = randomAlphabetic(5);
+ String uuid = secure().nextAlphabetic(2);
+ String key = secure().nextAlphabetic(3);
+ String name = secure().nextAlphabetic(4);
+ String somethingElse = secure().nextAlphabetic(5);
CeTask.Component underTest = new CeTask.Component(uuid, key, name);
assertThat(underTest)
@@ -77,10 +77,10 @@ public class CeTaskComponentTest {
@Test
public void hashcode_is_based_on_all_fields() {
- String uuid = randomAlphabetic(2);
- String key = randomAlphabetic(3);
- String name = randomAlphabetic(4);
- String somethingElse = randomAlphabetic(5);
+ String uuid = secure().nextAlphabetic(2);
+ String key = secure().nextAlphabetic(3);
+ String name = secure().nextAlphabetic(4);
+ String somethingElse = secure().nextAlphabetic(5);
CeTask.Component underTest = new CeTask.Component(uuid, key, name);
assertThat(underTest)
diff --git a/server/sonar-ce-task/src/test/java/org/sonar/ce/task/CeTaskInterruptedExceptionTest.java b/server/sonar-ce-task/src/test/java/org/sonar/ce/task/CeTaskInterruptedExceptionTest.java
index c0c69cc7aca..aaa4b37d01d 100644
--- a/server/sonar-ce-task/src/test/java/org/sonar/ce/task/CeTaskInterruptedExceptionTest.java
+++ b/server/sonar-ce-task/src/test/java/org/sonar/ce/task/CeTaskInterruptedExceptionTest.java
@@ -23,7 +23,7 @@ import java.util.Random;
import org.junit.Test;
import org.sonar.db.ce.CeActivityDto;
-import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic;
+import static org.apache.commons.lang3.RandomStringUtils.secure;
import static org.assertj.core.api.Assertions.assertThat;
import static org.sonar.ce.task.CeTaskInterruptedException.isTaskInterruptedException;
@@ -31,7 +31,7 @@ public class CeTaskInterruptedExceptionTest {
@Test
public void isCauseInterruptedException_returns_CeTaskInterruptedException_or_subclass() {
- String message = randomAlphabetic(50);
+ String message = secure().nextAlphabetic(50);
CeActivityDto.Status status = randomStatus();
CeTaskInterruptedException e1 = new CeTaskInterruptedException(message, status) {
@@ -46,7 +46,7 @@ public class CeTaskInterruptedExceptionTest {
@Test
public void isCauseInterruptedException_returns_CeTaskInterruptedException_or_subclass_in_cause_chain() {
- String message = randomAlphabetic(50);
+ String message = secure().nextAlphabetic(50);
CeActivityDto.Status status = randomStatus();
CeTaskInterruptedException e1 = new CeTaskInterruptedException(message, status) {
diff --git a/server/sonar-ce-task/src/test/java/org/sonar/ce/task/CeTaskTimeoutExceptionTest.java b/server/sonar-ce-task/src/test/java/org/sonar/ce/task/CeTaskTimeoutExceptionTest.java
index d624ed25023..7f5d3aba3ee 100644
--- a/server/sonar-ce-task/src/test/java/org/sonar/ce/task/CeTaskTimeoutExceptionTest.java
+++ b/server/sonar-ce-task/src/test/java/org/sonar/ce/task/CeTaskTimeoutExceptionTest.java
@@ -28,7 +28,7 @@ import org.sonar.db.ce.CeActivityDto;
import static org.assertj.core.api.Assertions.assertThat;
public class CeTaskTimeoutExceptionTest {
- private String message = RandomStringUtils.randomAlphabetic(50);
+ private String message = RandomStringUtils.secure().nextAlphabetic(50);
private CeTaskTimeoutException underTest = new CeTaskTimeoutException(message);
@Test
diff --git a/server/sonar-ce-task/src/test/java/org/sonar/ce/task/log/CeTaskMessagesMessageTest.java b/server/sonar-ce-task/src/test/java/org/sonar/ce/task/log/CeTaskMessagesMessageTest.java
index 74663de4144..458f4111672 100644
--- a/server/sonar-ce-task/src/test/java/org/sonar/ce/task/log/CeTaskMessagesMessageTest.java
+++ b/server/sonar-ce-task/src/test/java/org/sonar/ce/task/log/CeTaskMessagesMessageTest.java
@@ -22,7 +22,7 @@ package org.sonar.ce.task.log;
import org.junit.Test;
import org.sonar.ce.task.log.CeTaskMessages.Message;
-import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic;
+import static org.apache.commons.lang3.RandomStringUtils.secure;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
@@ -52,7 +52,7 @@ public class CeTaskMessagesMessageTest {
@Test
public void equals_is_based_on_text_and_timestamp() {
long timestamp = 10_000_000_000L;
- String text = randomAlphabetic(23);
+ String text = secure().nextAlphabetic(23);
Message underTest = new Message(text, timestamp);
assertThat(underTest)
@@ -67,7 +67,7 @@ public class CeTaskMessagesMessageTest {
@Test
public void hashsode_is_based_on_text_and_timestamp() {
long timestamp = 10_000_000_000L;
- String text = randomAlphabetic(23);
+ String text = secure().nextAlphabetic(23);
Message underTest = new Message(text, timestamp);
assertThat(underTest.hashCode())