diff --git a/src/pom.xml b/src/pom.xml index 8125d20..5b33957 100644 --- a/src/pom.xml +++ b/src/pom.xml @@ -58,6 +58,13 @@ ${log4j.version} + + + org.apache.commons + commons-lang3 + 3.4 + + junit junit diff --git a/src/src/main/java/com/pkrete/xrd4j/tools/test_service/util/ApplicationHelper.java b/src/src/main/java/com/pkrete/xrd4j/tools/test_service/util/ApplicationHelper.java index c8a9f54..0424364 100644 --- a/src/src/main/java/com/pkrete/xrd4j/tools/test_service/util/ApplicationHelper.java +++ b/src/src/main/java/com/pkrete/xrd4j/tools/test_service/util/ApplicationHelper.java @@ -3,6 +3,7 @@ import java.util.Random; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.apache.commons.lang3.RandomStringUtils; /** * This class offers helper methods for the application. @@ -12,7 +13,6 @@ public class ApplicationHelper { private static final Logger logger = LoggerFactory.getLogger(ApplicationHelper.class); - private static final String CHARACTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 "; /** * Returns a random string of given length. @@ -22,13 +22,9 @@ public class ApplicationHelper { */ public static String getRandomString(int length) { logger.debug("Generate random string of {} charaters.", length); - Random random = new Random(); - StringBuilder sb = new StringBuilder(); - while (sb.toString().getBytes().length < length) { - sb.append(CHARACTERS.charAt(random.nextInt(CHARACTERS.length()))); - } - logger.debug("String generated."); - return sb.toString(); + String s = RandomStringUtils.randomAlphanumeric(length); + logger.debug("String generated"); + return s; } /**