Package rife.bld.extension.testing
Class TestingUtils
java.lang.Object
rife.bld.extension.testing.TestingUtils
Provides static methods for generating random values and predefined character sets.
- Since:
- 1.0
- Author:
- Erik C. Thauvin
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringA string constant containing all uppercase letters, lowercase letters, and numeric digits.static final StringA string constant containing all hexadecimal digits and letters.static final StringA string constant containing all lowercase letters.static final StringA string constant containing all numeric digits.static final StringA string constant containing all uppercase letters.static final StringA string constant representing a set of characters that are safe for use in URLs. -
Method Summary
Modifier and TypeMethodDescriptionstatic intgenerateRandomInt(int min, int max) Generates a random integer within the specified range.static StringGenerates a random string with default parameters.static StringgenerateRandomString(int length) Generates a random string with a specified length.static StringgenerateRandomString(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, 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
minandmax, inclusive - Throws:
IllegalArgumentException- ifminis 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 isnullor 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
-