Class JmeterFunctions
- java.lang.Object
-
- org.anasoid.jmc.core.wrapper.jmc.functions.JmeterFunctions
-
public final class JmeterFunctions extends java.lang.ObjectImplementation of Native Jmeter functions.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringALPHAAlpha characters.static java.lang.StringALPHA_NUMERICAlpha Numeric characters.static java.lang.StringALPHA_UPPERUpper alpha characters.static java.lang.StringNUMERICNumeric characters.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.Stringcounter(@NonNull java.lang.Boolean perThread)The counter generates a new number each time it is called, starting with 1 and incrementing by +1 each time.static java.lang.Stringcounter(@NonNull java.lang.Boolean perThread, Variable variableName)The counter generates a new number each time it is called, starting with 1 and incrementing by +1 each time.static java.lang.Stringeval(@NonNull java.lang.String val)The eval function returns the result of evaluating a string expression.static java.lang.StringevalVar(@NonNull Variable variable)The evalVar function returns the result of evaluating an expression stored in a variable.static java.lang.Stringgroovy(@NonNull java.lang.String expression)The groovy function evaluates Apache Groovy scripts passed to it, and returns the result.static java.lang.Stringgroovy(@NonNull java.lang.String expression, Variable variableName)The groovy function evaluates Apache Groovy scripts passed to it, and returns the result.static java.lang.StringisPropDefined(@NonNull java.lang.String propertyName)The __isPropDefined function returns true if property exists or false if not.static java.lang.StringisVarDefined(@NonNull Variable variable)The isVarDefined function returns true if variable exists or false if not.static java.lang.StringjavaScript(@NonNull java.lang.String expression)The javaScript function executes a piece of JavaScript (not Java!) code and returns its value.static java.lang.StringjavaScript(@NonNull java.lang.String expression, Variable variableName)The javaScript function executes a piece of JavaScript (not Java!) code and returns its value.static java.lang.Stringjexl3(@NonNull java.lang.String expression)The jexl function returns the result of evaluating a Commons JEXL expression.static java.lang.Stringjexl3(@NonNull java.lang.String expression, Variable variableName)The jexl function returns the result of evaluating a Commons JEXL expression.static java.lang.Stringlog(java.lang.String input)The log function logs a message, and returns its input string.static java.lang.Stringlog(java.lang.String input, java.lang.String logLevel)The log function logs a message, and returns its input string.static java.lang.Stringlog(java.lang.String input, java.lang.String logLevel, java.lang.String comment)The log function logs a message, and returns its input string.static java.lang.Stringlog(java.lang.String input, java.lang.String logLevel, java.lang.String throwable, java.lang.String comment)The log function logs a message, and returns its input string.static java.lang.Stringlogn(java.lang.String input)The logn function logs a message, and returns the empty string.static java.lang.Stringlogn(java.lang.String input, java.lang.String logLevel)The logn function logs a message, and returns the empty string.static java.lang.Stringlogn(java.lang.String input, java.lang.String logLevel, java.lang.String throwable)The logn function logs a message, and returns the empty string.static java.lang.StringmachineIP()The machineIP function returns the local IP address.static java.lang.StringmachineName()The machineName function returns the local host name.static java.lang.Stringproperty(@NonNull java.lang.String propertyName, java.lang.String defaultValue)The property function returns the value of a JMeter property.static java.lang.Stringproperty(@NonNull java.lang.String propertyName, Variable variableName, java.lang.String defaultValue)The property function returns the value of a JMeter property.static java.lang.Stringrandom(int min, int max)The random function returns a random number that lies between the given min and max values.static java.lang.Stringrandom(int min, int max, Variable variableName)The random function returns a random number that lies between the given min and max values.static java.lang.Stringrandom(java.lang.String min, java.lang.String max)The random function returns a random number that lies between the given min and max values.static java.lang.Stringrandom(java.lang.String min, java.lang.String max, Variable variableName)The random function returns a random number that lies between the given min and max values.static java.lang.StringrandomAlpha(int length)The randomAlpha function returns a random alpha String of length using characters in chars to use.static java.lang.StringrandomAlpha(int length, Variable variableName)The randomAlpha function returns a random alpha String of length using characters in chars to use.static java.lang.StringrandomAlpha(java.lang.String length, Variable variableName)The randomAlpha function returns a random alpha String of length using characters in chars to use.static java.lang.StringrandomAlphaNumeric(int length)The randomAlpha function returns a random alpha numeric String of length using characters in * chars to use.static java.lang.StringrandomAlphaNumeric(int length, Variable variableName)The randomAlpha function returns a random alpha numeric String of length using characters in * chars to use.static java.lang.StringrandomAlphaNumeric(java.lang.String length, Variable variableName)The randomAlpha function returns a random alpha numeric String of length using characters in chars to use.static java.lang.StringrandomDate(java.lang.String format, java.lang.String startDate, @NonNull java.lang.String endDate)The RandomDate function returns a random date that lies between the given start date and end date values.static java.lang.StringrandomDate(java.lang.String format, java.lang.String startDate, @NonNull java.lang.String endDate, java.lang.String locale)The RandomDate function returns a random date that lies between the given start date and end date values.static java.lang.StringrandomDate(java.lang.String format, java.lang.String startDate, @NonNull java.lang.String endDate, java.lang.String locale, Variable variableName)The RandomDate function returns a random date that lies between the given start date and end date values.static java.lang.StringrandomString(int length, java.lang.String chars)The RandomString function returns a random String of length using characters in chars to use.static java.lang.StringrandomString(int length, java.lang.String chars, Variable variableName)The RandomString function returns a random String of length using characters in chars to use.static java.lang.StringrandomString(java.lang.String length, java.lang.String chars)The RandomString function returns a random String of length using characters in chars to use.static java.lang.StringrandomString(java.lang.String length, java.lang.String chars, Variable variableName)The RandomString function returns a random String of length using characters in chars to use.static java.lang.StringsamplerName()The samplerName function returns the name (i.e.static java.lang.StringsetProperty(@NonNull java.lang.String propertyName, java.lang.String propertyValue)The setProperty function sets the value of a JMeter property.static java.lang.StringsetProperty(@NonNull java.lang.String propertyName, java.lang.String propertyValue, java.lang.Boolean returnOrigin)The setProperty function sets the value of a JMeter property.static java.lang.StringtestPlanName()The TestPlanName function returns the name of the current test plan (can be used in Including Plans to know the name of the calling test plan).static java.lang.StringthreadGroupName()The thread group name function simply returns the name of the thread group being executed.static java.lang.StringthreadNum()get thread number.static java.lang.Stringtime()The time function returns the current time in various formats.static java.lang.Stringtime(java.lang.String format)The time function returns the current time in various formats.static java.lang.Stringtime(java.lang.String format, Variable variableName)The time function returns the current time in various formats.static java.lang.StringtimeShift(java.lang.String format, java.lang.String dateToShift, java.lang.String valueToShift, java.lang.String locale)The timeShift function returns a date in the given format with the specified amount of seconds, minutes, hours, days or months added.static java.lang.StringtimeShift(java.lang.String format, java.lang.String dateToShift, java.lang.String valueToShift, java.lang.String locale, Variable variableName)The timeShift function returns a date in the given format with the specified amount of seconds, minutes, hours, days or months added.static java.lang.Stringuuid()The UUID function returns a pseudo random type 4 Universally Unique IDentifier (UUID)..
-
-
-
Field Detail
-
ALPHA
public static final java.lang.String ALPHA
Alpha characters.- See Also:
- Constant Field Values
-
ALPHA_UPPER
public static final java.lang.String ALPHA_UPPER
Upper alpha characters.
-
NUMERIC
public static final java.lang.String NUMERIC
Numeric characters.- See Also:
- Constant Field Values
-
ALPHA_NUMERIC
public static final java.lang.String ALPHA_NUMERIC
Alpha Numeric characters.- See Also:
- Constant Field Values
-
-
Method Detail
-
counter
public static java.lang.String counter(@NonNull @NonNull java.lang.Boolean perThread, Variable variableName)The counter generates a new number each time it is called, starting with 1 and incrementing by +1 each time. The counter can be configured to keep each simulated user's values separate, or to use the same counter for all users. If each user's values is incremented separately, that is like counting the number of iterations through the test plan. A global counter is like counting how many times that request was run.- Parameters:
perThread- TRUE if you wish each simulated user's counter to be kept independent and separate from the other users. FALSE for a global counter.variableName- A reference name for reusing the value computed by this function.
-
counter
public static java.lang.String counter(@NonNull @NonNull java.lang.Boolean perThread)The counter generates a new number each time it is called, starting with 1 and incrementing by +1 each time. The counter can be configured to keep each simulated user's values separate, or to use the same counter for all users. If each user's values is incremented separately, that is like counting the number of iterations through the test plan. A global counter is like counting how many times that request was run.- Parameters:
perThread- TRUE if you wish each simulated user's counter to be kept independent and separate from the other users. FALSE for a global counter.
-
eval
public static java.lang.String eval(@NonNull @NonNull java.lang.String val)The eval function returns the result of evaluating a string expression.- Parameters:
val- expression to be evaluated.
-
evalVar
public static java.lang.String evalVar(@NonNull @NonNull Variable variable)The evalVar function returns the result of evaluating an expression stored in a variable.- Parameters:
variable- expression to be evaluated.
-
groovy
public static java.lang.String groovy(@NonNull @NonNull java.lang.String expression, Variable variableName)The groovy function evaluates Apache Groovy scripts passed to it, and returns the result. Don't escape commas.- Parameters:
expression- An Apache Groovy script.variableName- A reference name for reusing the value computed by this function.
-
groovy
public static java.lang.String groovy(@NonNull @NonNull java.lang.String expression)The groovy function evaluates Apache Groovy scripts passed to it, and returns the result. Don't escape commas.- Parameters:
expression- An Apache Groovy script.
-
isPropDefined
public static java.lang.String isPropDefined(@NonNull @NonNull java.lang.String propertyName)The __isPropDefined function returns true if property exists or false if not.- Parameters:
propertyName- The Property Name to be used to check if defined.
-
isVarDefined
public static java.lang.String isVarDefined(@NonNull @NonNull Variable variable)The isVarDefined function returns true if variable exists or false if not.- Parameters:
variable- The Variable to be used to check if defined
-
javaScript
public static java.lang.String javaScript(@NonNull @NonNull java.lang.String expression, Variable variableName)The javaScript function executes a piece of JavaScript (not Java!) code and returns its value.- Parameters:
expression- The expression to be evaluated.variableName- A reference name for reusing the value computed by this function.
-
javaScript
public static java.lang.String javaScript(@NonNull @NonNull java.lang.String expression)The javaScript function executes a piece of JavaScript (not Java!) code and returns its value.- Parameters:
expression- The expression to be evaluated.
-
jexl3
public static java.lang.String jexl3(@NonNull @NonNull java.lang.String expression, Variable variableName)The jexl function returns the result of evaluating a Commons JEXL expression. See links below for more information on JEXL expressions.- Parameters:
expression- The expression to be evaluated.variableName- A reference name for reusing the value computed by this function.
-
jexl3
public static java.lang.String jexl3(@NonNull @NonNull java.lang.String expression)The jexl function returns the result of evaluating a Commons JEXL expression. See links below * for more information on JEXL expressions.- Parameters:
expression- The expression to be evaluated.
-
log
public static java.lang.String log(java.lang.String input, java.lang.String logLevel, java.lang.String throwable, java.lang.String comment)The log function logs a message, and returns its input string.- Parameters:
input- String to be logged.logLevel- String to be logged.throwable- If non-empty, creates a Throwable to pass to the logger.comment- If present, it is displayed in the string. Useful for identifying what is being logged.- Returns:
- logged text.
-
log
public static java.lang.String log(java.lang.String input, java.lang.String logLevel, java.lang.String comment)The log function logs a message, and returns its input string.- Parameters:
input- String to be logged.logLevel- String to be logged.comment- If present, it is displayed in the string. Useful for identifying what is being logged.- Returns:
- logged text.
-
log
public static java.lang.String log(java.lang.String input, java.lang.String logLevel)The log function logs a message, and returns its input string.- Parameters:
input- String to be logged.logLevel- String to be logged. logged.- Returns:
- logged text.
-
log
public static java.lang.String log(java.lang.String input)
The log function logs a message, and returns its input string.- Parameters:
input- String to be logged.- Returns:
- logged text.
-
logn
public static java.lang.String logn(java.lang.String input, java.lang.String logLevel, java.lang.String throwable)The logn function logs a message, and returns the empty string.- Parameters:
input- String to be logged.logLevel- String to be logged.throwable- If non-empty, creates a Throwable to pass to the logger.- Returns:
- logged text.
-
logn
public static java.lang.String logn(java.lang.String input, java.lang.String logLevel)The logn function logs a message, and returns the empty string.- Parameters:
input- String to be logged.logLevel- String to be logged.- Returns:
- logged text.
-
logn
public static java.lang.String logn(java.lang.String input)
The logn function logs a message, and returns the empty string.- Parameters:
input- String to be logged.- Returns:
- logged text.
-
machineIP
public static java.lang.String machineIP()
The machineIP function returns the local IP address. This uses the Java method InetAddress.getLocalHost() and passes it to getHostAddress().
-
machineName
public static java.lang.String machineName()
The machineName function returns the local host name. This uses the Java method InetAddress.getLocalHost() and passes it to getHostName().
-
property
public static java.lang.String property(@NonNull @NonNull java.lang.String propertyName, Variable variableName, java.lang.String defaultValue)The property function returns the value of a JMeter property. If the property value cannot be found, and no default has been supplied, it returns the property name.- Parameters:
propertyName- he property name to be retrieved.variableName- A reference name for reusing the value computed by this function.defaultValue- The default value for the property.
-
property
public static java.lang.String property(@NonNull @NonNull java.lang.String propertyName, java.lang.String defaultValue)The property function returns the value of a JMeter property. If the property value cannot be found, and no default has been supplied, it returns the property name.- Parameters:
propertyName- he property name to be retrieved.defaultValue- The default value for the property.
-
random
public static java.lang.String random(java.lang.String min, java.lang.String max, Variable variableName)The random function returns a random number that lies between the given min and max values.- Parameters:
min- Minimum value.max- Maximum value.variableName- variableName A reference name for reusing the value computed by this function.
-
random
public static java.lang.String random(java.lang.String min, java.lang.String max)The random function returns a random number that lies between the given min and max values.- Parameters:
min- Minimum value.max- Maximum value.
-
random
public static java.lang.String random(int min, int max, Variable variableName)The random function returns a random number that lies between the given min and max values.- Parameters:
min- Minimum value.max- Maximum value.variableName- variableName A reference name for reusing the value computed by this function.
-
random
public static java.lang.String random(int min, int max)The random function returns a random number that lies between the given min and max values.- Parameters:
min- Minimum value.max- Maximum value.
-
randomAlpha
public static java.lang.String randomAlpha(java.lang.String length, Variable variableName)The randomAlpha function returns a random alpha String of length using characters in chars to use.- Parameters:
length- A number length of generated String.variableName- A reference name for reusing the value computed by this function.
-
randomAlpha
public static java.lang.String randomAlpha(int length, Variable variableName)The randomAlpha function returns a random alpha String of length using characters in chars to use.- Parameters:
length- A number length of generated String.variableName- A reference name for reusing the value computed by this function.
-
randomAlpha
public static java.lang.String randomAlpha(int length)
The randomAlpha function returns a random alpha String of length using characters in chars to use.- Parameters:
length- A number length of generated String.
-
randomAlphaNumeric
public static java.lang.String randomAlphaNumeric(java.lang.String length, Variable variableName)The randomAlpha function returns a random alpha numeric String of length using characters in chars to use.- Parameters:
length- A number length of generated String.variableName- A reference name for reusing the value computed by this function.
-
randomAlphaNumeric
public static java.lang.String randomAlphaNumeric(int length, Variable variableName)The randomAlpha function returns a random alpha numeric String of length using characters in * chars to use.- Parameters:
length- A number length of generated String.variableName- A reference name for reusing the value computed by this function.
-
randomAlphaNumeric
public static java.lang.String randomAlphaNumeric(int length)
The randomAlpha function returns a random alpha numeric String of length using characters in * chars to use.- Parameters:
length- A number length of generated String.
-
randomDate
public static java.lang.String randomDate(java.lang.String format, java.lang.String startDate, @NonNull @NonNull java.lang.String endDate, java.lang.String locale, Variable variableName)The RandomDate function returns a random date that lies between the given start date and end date values.- Parameters:
format- Format string for DateTimeFormatter (default yyyy-MM-dd).startDate- The start date, the default is now.endDate- The end date.locale- The string format of a locale. The language code must be lowercase. The country code must be uppercase. The separator must be an underscore, e.g. en_EN. See http://www.oracle.com/technetwork/java/javase/javase7locales-334809.html. If omitted, by default the function uses the Apache JMeter locale one.variableName- The variable to set.
-
randomDate
public static java.lang.String randomDate(java.lang.String format, java.lang.String startDate, @NonNull @NonNull java.lang.String endDate, java.lang.String locale)The RandomDate function returns a random date that lies between the given start date and end date values.- Parameters:
format- Format string for DateTimeFormatter (default yyyy-MM-dd).startDate- The start date, the default is now.endDate- The end date.locale- The string format of a locale. The language code must be lowercase. The country code must be uppercase. The separator must be an underscore, e.g. en_EN. See http://www.oracle.com/technetwork/java/javase/javase7locales-334809.html. If omitted, by default the function uses the Apache JMeter locale one.
-
randomDate
public static java.lang.String randomDate(java.lang.String format, java.lang.String startDate, @NonNull @NonNull java.lang.String endDate)The RandomDate function returns a random date that lies between the given start date and end date values.- Parameters:
format- Format string for DateTimeFormatter (default yyyy-MM-dd).startDate- The start date, the default is now.endDate- The end date.
-
randomString
public static java.lang.String randomString(java.lang.String length, java.lang.String chars, Variable variableName)The RandomString function returns a random String of length using characters in chars to use.- Parameters:
length- A number length of generated String.chars- Chars used to generate String.variableName- A reference name for reusing the value computed by this function.
-
randomString
public static java.lang.String randomString(java.lang.String length, java.lang.String chars)The RandomString function returns a random String of length using characters in chars to use.- Parameters:
length- A number length of generated String.chars- Chars used to generate String.
-
randomString
public static java.lang.String randomString(int length, java.lang.String chars, Variable variableName)The RandomString function returns a random String of length using characters in chars to use.- Parameters:
length- A number length of generated String.chars- Chars used to generate String.variableName- A reference name for reusing the value computed by this function.
-
randomString
public static java.lang.String randomString(int length, java.lang.String chars)The RandomString function returns a random String of length using characters in chars to use.- Parameters:
length- A number length of generated String.chars- Chars used to generate String.
-
samplerName
public static java.lang.String samplerName()
The samplerName function returns the name (i.e. label) of the current sampler.
-
setProperty
public static java.lang.String setProperty(@NonNull @NonNull java.lang.String propertyName, java.lang.String propertyValue, java.lang.Boolean returnOrigin)The setProperty function sets the value of a JMeter property. The default return value from the function is the empty string, so the function call can be used anywhere functions are valid.- Parameters:
propertyName- The property name to be set.propertyValue- The value for the property.returnOrigin- Should the original value be returned?
-
setProperty
public static java.lang.String setProperty(@NonNull @NonNull java.lang.String propertyName, java.lang.String propertyValue)The setProperty function sets the value of a JMeter property. The default return value from the function is the empty string, so the function call can be used anywhere functions are valid.- Parameters:
propertyName- The property name to be set.propertyValue- The value for the property.
-
testPlanName
public static java.lang.String testPlanName()
The TestPlanName function returns the name of the current test plan (can be used in Including Plans to know the name of the calling test plan).
-
threadGroupName
public static java.lang.String threadGroupName()
The thread group name function simply returns the name of the thread group being executed.
-
threadNum
public static java.lang.String threadNum()
get thread number.- Returns:
- returns a number between zero and (max number of running threads minus one) .
-
time
public static java.lang.String time(java.lang.String format, Variable variableName)The time function returns the current time in various formats.- Parameters:
format- The format to be passed to SimpleDateFormat. The function supports various shorthand aliases, see below. If omitted, the function returns the current time in milliseconds since the epoch.variableName- The name of the variable to set.
-
time
public static java.lang.String time(java.lang.String format)
The time function returns the current time in various formats.- Parameters:
format- The format to be passed to SimpleDateFormat. The function supports various shorthand aliases, see below. If omitted, the function returns the current time in milliseconds since the epoch.
-
time
public static java.lang.String time()
The time function returns the current time in various formats.- Returns:
- returns the current time in milliseconds since the epoch.
-
timeShift
public static java.lang.String timeShift(java.lang.String format, java.lang.String dateToShift, java.lang.String valueToShift, java.lang.String locale, Variable variableName)The timeShift function returns a date in the given format with the specified amount of seconds, minutes, hours, days or months added.- Parameters:
format- The format to be passed to DateTimeFormatter. See DateTimeFormatter If omitted, the function uses milliseconds since epoch format.dateToShift- Indicate the date in the format set by the parameter 'Format' to shift If omitted, the date is set to now.valueToShift- Indicate the specified amount of seconds, minutes, hours or days to shift according to a textual representation of a duration such as PnDTnHnMn.nS. See https://docs.oracle.com/javase/8/docs/api/java/time/Duration.html#parse-java.lang.CharSequence- <p>PT20.345S parses as 20.345 seconds PT15M parses as 15 minutes PT10H parses as 10 hours P2D parses as 2 days -P6H3M parses as -6 hours and -3 minuteslocale- The string format of a locale. The language code must be lowercase. The country code must be uppercase. The separator must be an underscore. ex: en_EN See http://www.oracle.com/technetwork/java/javase/javase7locales-334809.html If omitted, by default the function use the ApacheJMeter locale one.variableName- The name of the variable to set.
-
timeShift
public static java.lang.String timeShift(java.lang.String format, java.lang.String dateToShift, java.lang.String valueToShift, java.lang.String locale)The timeShift function returns a date in the given format with the specified amount of seconds, minutes, hours, days or months added.- Parameters:
format- The format to be passed to DateTimeFormatter. See DateTimeFormatter If omitted, the function uses milliseconds since epoch format.dateToShift- Indicate the date in the format set by the parameter 'Format' to shift If omitted, the date is set to now.valueToShift- Indicate the specified amount of seconds, minutes, hours or days to shift according to a textual representation of a duration such as PnDTnHnMn.nS. See https://docs.oracle.com/javase/8/docs/api/java/time/Duration.html#parse-java.lang.CharSequence- <p>PT20.345S parses as 20.345 seconds PT15M parses as 15 minutes PT10H parses as 10 hours P2D parses as 2 days -P6H3M parses as -6 hours and -3 minuteslocale- The string format of a locale. The language code must be lowercase. The country code must be uppercase. The separator must be an underscore. ex: en_EN See http://www.oracle.com/technetwork/java/javase/javase7locales-334809.html If omitted, by default the function use the ApacheJMeter locale one.
-
uuid
public static java.lang.String uuid()
The UUID function returns a pseudo random type 4 Universally Unique IDentifier (UUID)..
-
-