aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api-impl
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 /sonar-plugin-api-impl
parentce2e686a3e269f937ffb51635928cd1a597b2d07 (diff)
downloadsonarqube-1ad3667d30dd82213ae47bea2c267188f003b2c7.tar.gz
sonarqube-1ad3667d30dd82213ae47bea2c267188f003b2c7.zip
NO-JIRA Stop using deprecated methods from RandomStringUtils
Diffstat (limited to 'sonar-plugin-api-impl')
-rw-r--r--sonar-plugin-api-impl/src/test/java/org/sonar/api/config/internal/MapSettingsTest.java18
-rw-r--r--sonar-plugin-api-impl/src/test/java/org/sonar/api/config/internal/MultivaluePropertyTest.java20
2 files changed, 19 insertions, 19 deletions
diff --git a/sonar-plugin-api-impl/src/test/java/org/sonar/api/config/internal/MapSettingsTest.java b/sonar-plugin-api-impl/src/test/java/org/sonar/api/config/internal/MapSettingsTest.java
index 590788fd9af..6af058de1c2 100644
--- a/sonar-plugin-api-impl/src/test/java/org/sonar/api/config/internal/MapSettingsTest.java
+++ b/sonar-plugin-api-impl/src/test/java/org/sonar/api/config/internal/MapSettingsTest.java
@@ -42,7 +42,7 @@ import org.sonar.api.utils.DateUtils;
import org.sonar.api.utils.System2;
import static java.util.Collections.singletonList;
-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.ThrowableAssert.ThrowingCallable;
@@ -79,14 +79,14 @@ public class MapSettingsTest {
public void set_throws_NPE_if_key_is_null() {
MapSettings underTest = new MapSettings();
- expectKeyNullNPE(() -> underTest.set(null, randomAlphanumeric(3)));
+ expectKeyNullNPE(() -> underTest.set(null, secure().nextAlphanumeric(3)));
}
@Test
public void set_throws_NPE_if_value_is_null() {
MapSettings underTest = new MapSettings();
- assertThatThrownBy(() -> underTest.set(randomAlphanumeric(3), null))
+ assertThatThrownBy(() -> underTest.set(secure().nextAlphanumeric(3), null))
.isInstanceOf(NullPointerException.class)
.hasMessage("value can't be null");
}
@@ -95,7 +95,7 @@ public class MapSettingsTest {
public void set_accepts_empty_value_and_trims_it() {
MapSettings underTest = new MapSettings();
Random random = new Random();
- String key = randomAlphanumeric(3);
+ String key = secure().nextAlphanumeric(3);
underTest.set(key, blank(random));
@@ -118,7 +118,7 @@ public class MapSettingsTest {
@Test
public void set_property_string_throws_NPE_if_key_is_null() {
- String key = randomAlphanumeric(3);
+ String key = secure().nextAlphanumeric(3);
Settings underTest = new MapSettings(new PropertyDefinitions(System2.INSTANCE, singletonList(PropertyDefinition.builder(key).multiValues(true).build())));
@@ -139,7 +139,7 @@ public class MapSettingsTest {
Random random = new Random();
String blankBefore = blank(random);
String blankAfter = blank(random);
- String key = randomAlphanumeric(3);
+ String key = secure().nextAlphanumeric(3);
setPropertyCaller.accept(underTest, blankBefore + key + blankAfter);
@@ -148,7 +148,7 @@ public class MapSettingsTest {
@Test
public void set_property_string_array_trims_key() {
- String key = randomAlphanumeric(3);
+ String key = secure().nextAlphanumeric(3);
Settings underTest = new MapSettings(new PropertyDefinitions(System2.INSTANCE, singletonList(PropertyDefinition.builder(key).multiValues(true).build())));
@@ -188,8 +188,8 @@ public class MapSettingsTest {
Random random = new Random();
String blankBefore = blank(random);
String blankAfter = blank(random);
- String key = randomAlphanumeric(3);
- String value = randomAlphanumeric(3);
+ String key = secure().nextAlphanumeric(3);
+ String value = secure().nextAlphanumeric(3);
underTest.setProperty(key, blankBefore + value + blankAfter);
diff --git a/sonar-plugin-api-impl/src/test/java/org/sonar/api/config/internal/MultivaluePropertyTest.java b/sonar-plugin-api-impl/src/test/java/org/sonar/api/config/internal/MultivaluePropertyTest.java
index 9e09ecd2031..1452e78d673 100644
--- a/sonar-plugin-api-impl/src/test/java/org/sonar/api/config/internal/MultivaluePropertyTest.java
+++ b/sonar-plugin-api-impl/src/test/java/org/sonar/api/config/internal/MultivaluePropertyTest.java
@@ -27,7 +27,7 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import static java.util.function.UnaryOperator.identity;
-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.sonar.api.config.internal.MultivalueProperty.parseAsCsv;
@@ -114,9 +114,9 @@ public class MultivaluePropertyTest {
@DataProvider
public static Object[][] plains() {
return new Object[][] {
- {randomAlphanumeric(1)},
- {randomAlphanumeric(2)},
- {randomAlphanumeric(3 + new Random().nextInt(5))}
+ {secure().nextAlphanumeric(1)},
+ {secure().nextAlphanumeric(2)},
+ {secure().nextAlphanumeric(3 + new Random().nextInt(5))}
};
}
@@ -147,7 +147,7 @@ public class MultivaluePropertyTest {
@Test
public void trimAccordingToStringTrim() {
- String str = randomAlphanumeric(4);
+ String str = secure().nextAlphanumeric(4);
for (int i = 0; i <= ' '; i++) {
String prefixed = (char) i + str;
String suffixed = (char) i + str;
@@ -166,11 +166,11 @@ public class MultivaluePropertyTest {
String threePlusEmpty = randomTrimmedChars(3 + random.nextInt(5), random);
String onePlusEmpty = randomTrimmedChars(1 + random.nextInt(5), random);
- String plain = randomAlphanumeric(1);
- String plainWithtrimmable = randomAlphanumeric(2) + onePlusEmpty + randomAlphanumeric(3);
- String quotedWithSeparator = '"' + randomAlphanumeric(3) + ',' + randomAlphanumeric(2) + '"';
- String quotedWithDoubleSeparator = '"' + randomAlphanumeric(3) + ",," + randomAlphanumeric(2) + '"';
- String quotedWithtrimmable = '"' + randomAlphanumeric(3) + onePlusEmpty + randomAlphanumeric(2) + '"';
+ String plain = secure().nextAlphanumeric(1);
+ String plainWithtrimmable = secure().nextAlphanumeric(2) + onePlusEmpty + secure().nextAlphanumeric(3);
+ String quotedWithSeparator = '"' + secure().nextAlphanumeric(3) + ',' + secure().nextAlphanumeric(2) + '"';
+ String quotedWithDoubleSeparator = '"' + secure().nextAlphanumeric(3) + ",," + secure().nextAlphanumeric(2) + '"';
+ String quotedWithtrimmable = '"' + secure().nextAlphanumeric(3) + onePlusEmpty + secure().nextAlphanumeric(2) + '"';
String[] empties = {oneEmpty, twoEmpty, threePlusEmpty};
String[] strings = {plain, plainWithtrimmable,