Package org.mockserver.mock
Class CassetteRegistry
java.lang.Object
org.mockserver.mock.CassetteRegistry
Process-wide registry of known cassettes — fixture files of MockServer expectations
recorded with
record_llm_fixtures or loaded with load_expectations_from_file.
The dashboard's Cassettes tab keeps a per-browser list in localStorage; this registry
is the server-side counterpart so cassettes are also discoverable across page reloads, across
browsers, and from automation (e.g. the demo data loader). It holds only lightweight metadata —
the cassette's file path, name, expectation count and how it was created — never the file
contents themselves. State is held in a ConcurrentHashMap keyed by file path and is
cleared on server reset (see HttpState.reset()).
Exposed over the control plane as GET/PUT/DELETE /mockserver/cassettes.
Registration policy (settled — do not re-open). A cassette enters this registry from exactly three places, and loading and recording register automatically:
- the
record_llm_fixturesMCP tool, when it writes a fixture file (origin"recorded"); - the
load_expectations_from_fileMCP tool, when it loads a fixture file (origin"loaded"); - an explicit
PUT /mockserver/cassettes, to track a cassette produced some other way.
register(java.lang.String, java.lang.String, int, java.lang.String) directly rather than routing through a shared load/record method — there is
no such method: recording writes bytes and loading reads them, and they converge only on this registry.
A manual PUT is therefore not required after a load or a record. Every path upserts by
file path (see register(java.lang.String, java.lang.String, int, java.lang.String)), so re-loading or re-recording the same file updates the existing entry
in place rather than duplicating it.-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic CassetteRegistrylist()Snapshot of all registered cassettes, most-recently-used first.Register (or update) a cassette, stamping itslastUsedwith the current time.booleanRemove a cassette by path.voidreset()Clear all cassettes.
-
Constructor Details
-
CassetteRegistry
-
-
Method Details
-
getInstance
-
register
public CassetteRegistry.Entry register(String path, String filename, int expectationCount, String origin) Register (or update) a cassette, stamping itslastUsedwith the current time. When a cassette with the samepathalready exists it is updated in place rather than duplicated. No-op ifpathis blank.- Parameters:
origin- how the cassette was created —"recorded"or"loaded"- Returns:
- the stored entry, or
nullifpathwas blank
-
remove
Remove a cassette by path. Returns true if one was removed. -
list
Snapshot of all registered cassettes, most-recently-used first. -
reset
public void reset()Clear all cassettes. Called on server reset and for test isolation.
-