Class IterationContext

java.lang.Object
org.mockserver.load.IterationContext

public class IterationContext extends Object
Per-iteration template variable exposed to a LoadScenario step under the key "iteration", sibling of request / response. It lets a step's templated request fields vary per iteration without any cross-step state (e.g. $iteration.index for a unique path segment).

Plain JavaBean getters so all three engine syntaxes resolve identically: $iteration.index (Velocity), {{iteration.index}} (Mustache) and iteration.getIndex() (JavaScript).

getCaptured() exposes the iteration's mutable captured-variable map so a step's templated request fields can reference values extracted from an earlier step's response, e.g. $iteration.captured.token (Velocity) / {{iteration.captured.token}} (Mustache). Both engines resolve a member of a Map<String,String> getter by key. Scope is per-iteration (one virtual user's single pass through the steps); the map is never shared across users/iterations.

getData() exposes the single data-feeder row selected for this iteration the same way, referenced as $iteration.data.<column> / {{iteration.data.<column>}}. Empty when the scenario has no feeder.

  • Constructor Details

    • IterationContext

      public IterationContext(long index, int vuId, long vuIteration, long elapsedMillis, long count)
    • IterationContext

      public IterationContext(long index, int vuId, long vuIteration, long elapsedMillis, long count, Map<String,String> captured)
    • IterationContext

      public IterationContext(long index, int vuId, long vuIteration, long elapsedMillis, long count, Map<String,String> captured, Map<String,String> data)
  • Method Details

    • getIndex

      public long getIndex()
    • getVuId

      public int getVuId()
    • getVuIteration

      public long getVuIteration()
    • getElapsedMillis

      public long getElapsedMillis()
    • getCount

      public long getCount()
    • getCaptured

      public Map<String,String> getCaptured()
      The iteration's cross-step captured variables (name to extracted value), referenced from a step's templated fields as $iteration.captured.<name> / {{iteration.captured.<name>}}. Never null (empty when nothing has been captured yet).
    • getData

      public Map<String,String> getData()
      The data-feeder row selected for this iteration (column to value), referenced from a step's templated fields as $iteration.data.<column> / {{iteration.data.<column>}}. Never null (empty when the scenario has no feeder). The map is unmodifiable.