Class CassetteRegistry

java.lang.Object
org.mockserver.mock.CassetteRegistry

public class CassetteRegistry extends Object
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.

  • Constructor Details

    • CassetteRegistry

      public CassetteRegistry(LongSupplier clock)
  • Method Details

    • getInstance

      public static CassetteRegistry getInstance()
    • register

      public CassetteRegistry.Entry register(String path, String filename, int expectationCount, String origin)
      Register (or update) a cassette, stamping its lastUsed with the current time. When a cassette with the same path already exists it is updated in place rather than duplicated. No-op if path is blank.
      Parameters:
      origin - how the cassette was created — "recorded" or "loaded"
      Returns:
      the stored entry, or null if path was blank
    • remove

      public boolean remove(String path)
      Remove a cassette by path. Returns true if one was removed.
    • list

      public List<CassetteRegistry.Entry> 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.