Package org.mockserver.load
Class LoadCapture
java.lang.Object
org.mockserver.model.ObjectWithReflectiveEqualsHashCodeToString
org.mockserver.model.ObjectWithJsonToString
org.mockserver.load.LoadCapture
Declarative cross-step capture / correlation rule for a
LoadStep. After the step's
response returns, each capture extracts a value from that response and binds it to name
in the iteration's mutable captured-variable map, so a SUBSEQUENT step in the SAME iteration can
reference it from its templated request fields (path, body and headers) via
$iteration.captured.<name> (Velocity) / {{iteration.captured.<name>}} (Mustache).
Scope is per-iteration — one virtual user's single pass through the steps (the natural "one user session" correlation scope). The map is created fresh at the start of each iteration and is never shared across virtual users or across a VU's successive iterations, so it is race-free and captures never leak between users or runs.
The primary use case is a login step capturing a token that later steps replay, e.g.
Authorization: Bearer {{iteration.captured.token}}.
getName()— the variable name later steps referencegetSource()— where to extract from (response body JSONPath, header, or body regex)getExpression()— the JSONPath, header name, or regex (group 1 for regex)getDefaultValue()— used when extraction yields nothing (otherwise the var is left unset)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumWhere in the step's response aLoadCaptureextracts its value from. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionThe fallback value bound tonamewhen extraction yields nothing (may be null, in which case the variable is left unset on no match).The JSONPath, header name, or regex driving extraction (may be null, in which case the capture is skipped).getName()The variable name later steps reference (may be null/blank, in which case the capture is skipped).The extraction source (may be null, in which case the capture is skipped).static LoadCapturestatic LoadCaptureloadCapture(String name, LoadCapture.Source source, String expression) withDefaultValue(String defaultValue) withExpression(String expression) withSource(LoadCapture.Source source) Methods inherited from class org.mockserver.model.ObjectWithJsonToString
toStringMethods inherited from class org.mockserver.model.ObjectWithReflectiveEqualsHashCodeToString
equals, fieldsExcludedFromEqualsAndHashCode, hashCode
-
Constructor Details
-
LoadCapture
public LoadCapture()
-
-
Method Details
-
loadCapture
-
loadCapture
-
getName
The variable name later steps reference (may be null/blank, in which case the capture is skipped). -
withName
-
getSource
The extraction source (may be null, in which case the capture is skipped). -
withSource
-
getExpression
The JSONPath, header name, or regex driving extraction (may be null, in which case the capture is skipped). -
withExpression
-
getDefaultValue
The fallback value bound tonamewhen extraction yields nothing (may be null, in which case the variable is left unset on no match). -
withDefaultValue
-