diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2017-06-08 19:01:09 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2017-06-08 19:01:09 +0200 |
commit | 6dae946633458b9e69e841b57c16570eb1311943 (patch) | |
tree | 70f43c8b32b4e21e5c644bff6c344e45e10c64cc /server/sonar-db-dao | |
parent | 6aac427873da6027ffb175322672b11ef13db999 (diff) | |
download | sonarqube-6dae946633458b9e69e841b57c16570eb1311943.tar.gz sonarqube-6dae946633458b9e69e841b57c16570eb1311943.zip |
Fix false-positives with randomly generated strings for DB
Only characters with supported encoding should be used by DB tests.
Diffstat (limited to 'server/sonar-db-dao')
-rw-r--r-- | server/sonar-db-dao/src/test/java/org/sonar/db/rule/RuleDbTester.java | 4 | ||||
-rw-r--r-- | server/sonar-db-dao/src/test/java/org/sonar/db/rule/RuleTesting.java | 3 |
2 files changed, 3 insertions, 4 deletions
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/rule/RuleDbTester.java b/server/sonar-db-dao/src/test/java/org/sonar/db/rule/RuleDbTester.java index 0b6c234cdd7..7ba24919da6 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/rule/RuleDbTester.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/rule/RuleDbTester.java @@ -21,12 +21,12 @@ package org.sonar.db.rule; import java.util.Arrays; import java.util.function.Consumer; -import org.apache.commons.lang.RandomStringUtils; import org.sonar.api.rule.RuleKey; import org.sonar.api.server.rule.RuleParamType; import org.sonar.db.DbTester; import org.sonar.db.organization.OrganizationDto; +import static org.apache.commons.lang.RandomStringUtils.randomAlphabetic; import static org.sonar.db.rule.RuleTesting.newRule; import static org.sonar.db.rule.RuleTesting.newRuleDto; @@ -125,7 +125,7 @@ public class RuleDbTester { public RuleParamDto insertRuleParam(RuleDto rule) { RuleParamDto param = new RuleParamDto(); param.setRuleId(rule.getId()); - param.setName(RandomStringUtils.random(10)); + param.setName(randomAlphabetic(10)); param.setType(RuleParamType.STRING.type()); db.getDbClient().ruleDao().insertRuleParam(db.getSession(), rule.getDefinition(), param); db.commit(); diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/rule/RuleTesting.java b/server/sonar-db-dao/src/test/java/org/sonar/db/rule/RuleTesting.java index 86c659636b8..696644b8705 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/rule/RuleTesting.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/rule/RuleTesting.java @@ -35,7 +35,6 @@ import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.collect.ImmutableSet.copyOf; import static com.google.common.collect.Sets.newHashSet; import static java.util.Objects.requireNonNull; -import static org.apache.commons.lang.RandomStringUtils.random; import static org.apache.commons.lang.RandomStringUtils.randomAlphabetic; import static org.apache.commons.lang.RandomStringUtils.randomAlphanumeric; import static org.apache.commons.lang.math.RandomUtils.nextInt; @@ -252,7 +251,7 @@ public class RuleTesting { } public static RuleKey randomRuleKeyOfMaximumLength() { - return RuleKey.of(random(255), random(200)); + return RuleKey.of(randomAlphabetic(255), randomAlphabetic(200)); } public static Consumer<RuleDefinitionDto> setRepositoryKey(String repositoryKey) { |