Package org.mockserver.load
Class LoadFeeder
java.lang.Object
org.mockserver.model.ObjectWithReflectiveEqualsHashCodeToString
org.mockserver.model.ObjectWithJsonToString
org.mockserver.load.LoadFeeder
Parameterized test data ("data feeder") for a
LoadScenario. Per iteration, the orchestrator
selects one row from the feeder's dataset and exposes it to that iteration's templated request
fields (path, body and headers) via IterationContext.getData() — referenced as
$iteration.data.<column> (Velocity) / {{iteration.data.<column>}} (Mustache),
exactly the way cross-step captures are referenced through
$iteration.captured.<name>.
Dataset, two equivalent forms (source of truth):
rows— an inline list of column-to-value maps (the PRIMARY mechanism; JSON-native, round-trips byte-for-byte, no parsing, no I/O surface).data+format— an OPTIONAL raw inline dataset (CSVorJSON) parsed into rows on demand. The raw text is the stored source of truth: it is serialized back verbatim (the derived rows are NOT re-serialized), so adata/formatfeeder round-trips without double-parsing. CSV parsing reusesCsvTemplateHelper(RFC 4180-ish: handles embedded commas, doubled quotes and newlines; first line = headers). JSON parsing expects an array of objects.
rows wins (the inline rows are
authoritative and data is ignored).
External sources are intentionally out of scope for this version: a feeder cannot fetch from a URL or read an arbitrary file path (that would add an SSRF / arbitrary-file-read surface to a self-load feature). The dataset is always inline in the scenario body. Loading from an external source is a possible future enhancement.
Selection strategy (LoadFeeder.Strategy):
CIRCULAR(default) —rows[globalIteration % size]; never exhausts, so sustained load cycles the dataset.RANDOM— a uniformly random row each iteration.SEQUENTIAL—rows[globalIteration]used exactly once each, in order; the run COMPLETES once the dataset is exhausted (data-driven "replay this dataset once").
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe raw-dataset format ofgetData().static enumHow a row is chosen for each iteration from the resolved dataset. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetData()The raw inline dataset parsed pergetFormat()(may be null whengetRows()is used).getRows()The inline dataset (may be null whengetData()/getFormat()is used instead).The selection strategy (defaults toLoadFeeder.Strategy.CIRCULAR).static LoadFeederstatic LoadFeederloadFeeder(List<Map<String, String>> rows) Convenience: an inline-rows feeder with the default CIRCULAR strategy.withFormat(LoadFeeder.Format format) withStrategy(LoadFeeder.Strategy strategy) Methods inherited from class org.mockserver.model.ObjectWithJsonToString
toStringMethods inherited from class org.mockserver.model.ObjectWithReflectiveEqualsHashCodeToString
equals, fieldsExcludedFromEqualsAndHashCode, hashCode
-
Constructor Details
-
LoadFeeder
public LoadFeeder()
-
-
Method Details
-
loadFeeder
-
loadFeeder
Convenience: an inline-rows feeder with the default CIRCULAR strategy. -
getRows
The inline dataset (may be null whengetData()/getFormat()is used instead). The PRIMARY mechanism: each entry is one row of column-name to value. -
withRows
-
withRow
-
getData
The raw inline dataset parsed pergetFormat()(may be null whengetRows()is used). The stored source of truth — serialized back verbatim, never re-derived from rows. -
withData
-
getFormat
-
withFormat
-
getStrategy
The selection strategy (defaults toLoadFeeder.Strategy.CIRCULAR). -
withStrategy
-
resolvedRows
The effective dataset: the inlinerowswhen present, otherwise the rows parsed fromdata/format(parsed once and cached). Never null — returns an empty list when neither form yields any row. Each returned map is unmodifiable.- Throws:
IllegalArgumentException- ifdatais set but malformed for itsformat, ordatais set without aformat
-