Package rife.bld.extension.testing
Class TestingUtils
java.lang.Object
rife.bld.extension.testing.TestingUtils
Utility class that provides methods for generating random values and predefined character sets..
- Since:
- 1.0
- Author:
- Erik C. Thauvin
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
A string constant containing all uppercase letters, lowercase letters, and numeric digits.static final String
A string constant containing all hexadecimal digits and letters.static final String
A string constant containing all lowercase letters.static final String
A string constant containing all numeric digits.static final String
A string constant containing all uppercase letters.static final String
A string constant representing a set of characters that are safe for use in URLs. -
Method Summary
Modifier and TypeMethodDescriptionstatic int
generateRandomInt
(int min, int max) Generates a random integer within the specified range.static String
Generates a random string with default parameters.static String
generateRandomString
(int length) Generates a random string with a specified length.static String
generateRandomString
(int length, String characters) Generates a random string with specified parameters.
-
Field Details
-
ALPHANUMERIC_CHARACTERS
A string constant containing all uppercase letters, lowercase letters, and numeric digits.- See Also:
-
HEXADECIMAL_CHARACTERS
A string constant containing all hexadecimal digits and letters.- See Also:
-
LOWERCASE_CHARACTERS
A string constant containing all lowercase letters.- See Also:
-
NUMERIC_CHARACTERS
A string constant containing all numeric digits.- See Also:
-
UPPERCASE_CHARACTERS
A string constant containing all uppercase letters.- See Also:
-
URL_SAFE_CHARACTERS
A string constant representing a set of characters that are safe for use in URLs.It includes uppercase and lowercase letters, digits, and the symbols
-
and_
.- See Also:
-
-
Method Details
-
generateRandomInt
public static int generateRandomInt(int min, int max) Generates a random integer within the specified range.- Parameters:
min
- the minimum value (inclusive) of the random numbermax
- the maximum value (inclusive) of the random number- Returns:
- a random integer between
min
andmax
, inclusive - Throws:
IllegalArgumentException
- ifmin
is greater thanmax
-
generateRandomString
Generates a random string with specified parameters.- Parameters:
length
- the desired length of the generated stringcharacters
- the character set to use- Returns:
- a randomly generated string of the specified length
- Throws:
IllegalArgumentException
- if the length is non-positive or the character set is null/empty
-
generateRandomString
Generates a random string with default parameters.- Returns:
- a 10-character random alphanumeric string
-
generateRandomString
Generates a random string with a specified length.- Parameters:
length
- the desired length of the generated string- Returns:
- a random alphanumeric string of the specified length
- Throws:
IllegalArgumentException
- if length is non-positive
-