Package org.mockserver.load
Class LoadResponseExtractor
java.lang.Object
org.mockserver.load.LoadResponseExtractor
Shared response-extraction primitives used by both
LoadCapture (cross-step correlation) and
LoadCheck (per-step response assertions). Factored out so the two features share ONE
extraction implementation (JSONPath / header / body-regex / status) rather than each carrying its
own copy.
Every method is null-safe and returns null on "nothing to extract" (null response, blank
expression, empty body, no match). Callers decide what a null means (a capture falls back to
its default; a check treats it as the observed value for its comparator). A malformed JSONPath or
regex may still throw — the caller is expected to run these best-effort inside a try/catch so
a bad expression never breaks the load dispatch path.
-
Method Summary
Modifier and TypeMethodDescriptionstatic Stringheader(HttpResponse response, String name) Return the first value of the named response header, ornullwhen the response, name or header value is blank.static StringjsonPath(HttpResponse response, String expression) Evaluateexpressionas a Jayway JSONPath over the response body and render the result as a plain string (seestringifyJsonPath(Object)).static StringregexGroup1(HttpResponse response, String pattern) Matchpatternas a regex over the response body string and return capture group 1, ornullwhen there is no match (or no group 1).static Stringstatus(HttpResponse response) Return the response status code as a string, ornullwhen absent.static StringstringifyJsonPath(Object result) Render a JSONPath result as a plain string: a scalar becomes itsString.valueOf; a single-element collection (the common definite-path-returning-a-list case) is unwrapped to its element; an empty collection is treated as no match.
-
Method Details
-
jsonPath
Evaluateexpressionas a Jayway JSONPath over the response body and render the result as a plain string (seestringifyJsonPath(Object)). Returnsnullwhen the response, expression or body is blank. -
header
Return the first value of the named response header, ornullwhen the response, name or header value is blank. -
regexGroup1
Matchpatternas a regex over the response body string and return capture group 1, ornullwhen there is no match (or no group 1). -
status
Return the response status code as a string, ornullwhen absent. -
stringifyJsonPath
Render a JSONPath result as a plain string: a scalar becomes itsString.valueOf; a single-element collection (the common definite-path-returning-a-list case) is unwrapped to its element; an empty collection is treated as no match. MirrorsCaptureProcessor.
-