Package org.mockserver.mock
Enum Class MockMode
- All Implemented Interfaces:
Serializable,Comparable<MockMode>,Constable
High-level operating mode for MockServer, packaging the common
record / replay / pass-through workflows into a single switch (set via
PUT /mockserver/mode). Each mode is a convenience over the existing
attemptToProxyIfNoMatchingExpectation configuration plus the event-log
recording that MockServer already performs:
SIMULATE— match expectations and return mocks; unmatched requests get a 404. This is the default behaviour (proxy-on-no-match disabled).SPY— match expectations and return mocks, but forward unmatched requests to the real upstream (proxy-on-no-match enabled) so they are served live and recorded.CAPTURE— forward and record; with no expectations defined this captures all traffic. Backed by the same proxy-on-no-match behaviour asSPY.
Recorded interactions are available through the existing recording/retrieve endpoints (e.g. retrieving recorded requests as expectations).
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum Constants -
Method Summary
Modifier and TypeMethodDescriptionstatic MockModefromProxyFlag(boolean attemptToProxyIfNoMatchingExpectation) Derives the reported mode from the liveattemptToProxyIfNoMatchingExpectationflag.static MockModeParses a mode name case-insensitively.booleanWhether, in this mode, a request that matches no expectation should be proxied to its upstream (and thereby recorded) rather than answered with a 404.static MockModeReturns the enum constant of this class with the specified name.static MockMode[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
SIMULATE
-
SPY
-
CAPTURE
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
proxyUnmatchedRequests
public boolean proxyUnmatchedRequests()Whether, in this mode, a request that matches no expectation should be proxied to its upstream (and thereby recorded) rather than answered with a 404. -
fromProxyFlag
Derives the reported mode from the liveattemptToProxyIfNoMatchingExpectationflag. SPY and CAPTURE share the same underlying flag, so an enabled flag reports asSPY. -
parse
Parses a mode name case-insensitively.- Throws:
IllegalArgumentException- if the value is null/blank or not a known mode
-