Random values
Following functions help you generate random values.
File🔗
String file()
Generate a file with a default size of 1kB, in the default OS temp directory. File name is prefixed with chutney
Returns :
- The canonical path of the file
Examples :
SpEL : ${#generate.file()}
String file(int fileSize)
Generate a file with a size of n bytes, in the default OS temp directory. File name is prefix with chutney and maximum file size is 100MB (104857600 bytes).
Returns :
- The canonical path of the file
Examples :
SpEL : ${#generate.file(42)}
String file(String destination, int fileSize)
Generate a file with a size of n bytes, with a specific path and filename. Maximum file size is 100MB (104857600 bytes).
Returns :
- The canonical path of the file
Examples :
SpEL : ${#generate.file("/path/to/dest/file", 42)}
Identifier🔗
String id(String prefix, int length)
Generate a String with a given prefix and n random characters.
Returns :
- The generated String
Examples :
SpEL : ${#generate.id("prefix-", 6)}
-> ex. output prefix-r4nd0m
String id(int length, String suffix)
Generate a String with n random characters and a given suffix.
Returns :
- The generated String
Examples :
SpEL : ${#generate.id(6, "-suffix")}
-> ex. output r4nd0m-suffix
String id(String prefix, int length, String suffix)
Generate a String with a given prefix, n random characters and a given suffix.
Returns :
- The generated String
Examples :
SpEL : ${#generate.id("pre-", 6, "-suf")}
-> ex. output pre-r4nd0m-suf
Int🔗
String randomInt(int bound)
Generate a random int value between 0 (included) and a given bound value (excluded) (i.e [0, bound[
).
See Random.nextInt(int) for further details
Returns :
- The random int value as a String
Examples :
SpEL : ${#generate.randomInt(42)}
Long🔗
String randomLong()
Generate a random long value.
See Random.nextLong() for further details
Returns :
- The generated long value as a String
Examples :
SpEL : ${#generate.randomLong()}
UUID🔗
String uuid()
Generates a unique identifier (UUID).
See UUID.uuid() for further details
Returns :
- The UUID as a String
Examples :
SpEL without : ${T(java.util.UUID).randomUUID().toString()}
SpEL with : ${#generate.uuid()}