skip to content

Catch-All Mappings

The any-URL mapping added to stop a test failing, what it silently shadows once precedence is in play, and the switch that turns the request journal off so verification can no longer object.

on this pageshow

explore

questions

4

In WireMock, what does the --no-request-journal flag switch off, and what then happens to verify()?

level: juniorimportance: must knowfreq 46%

answer

  1. the server stops remembering
  2. no journal, no verification
  3. a start-up flag, not a log level
  4. an exception, not a zero count

basics

~20 s

WireMock's --no-request-journal flag stops the server recording the requests it receives. Because nothing is recorded, verification is not weakened but abolished: the disabled journal raises RequestJournalDisabledException. A verify() call after that flag can never pass, whatever the client sent.

solid answer

~40 s

WireMock's request journal is the in-memory record of every request the server has served, and `verify(...)`, `findAll(...)` and `getAllServeEvents()` all read from it. Starting the server with `--no-request-journal` — or building the configuration with `wireMockConfig().disableRequestJournal()` — turns that record off entirely, so there is nothing left to read. The disabled journal raises `RequestJournalDisabledException` from the count, the matching-request lookup, the serve-event list and the journal removals, and WireMock reports the journal as disabled instead of returning an answer. A ferry-timetable suite in that state can no longer prove the client ever called `GET /v1/routes/DOV-CAL/departures`, nor with what `date` query parameter. Teams usually reach for the flag to cut memory on a long run and then forget it is set, at which point the suite quietly stops being able to check anything about a request.

code

bash · 10 lines
bash
# Shared ferry-timetable stubs, started with the journal switched off
java -jar wiremock-standalone.jar \
  --port 8080 \
  --root-dir ./ferry-stubs \
  --no-request-journal

# Asking what was received now reports the journal as disabled
curl -s -X POST http://localhost:8080/__admin/requests/count \
  -H 'Content-Type: application/json' \
  -d '{"method": "GET", "url": "/v1/routes/DOV-CAL/departures"}'

go deeper

for a junior

Be ready to say plainly what the flag turns off — the record of requests the server received — and that WireMock's verify() then cannot run at all. Do not describe it as merely slower or less detailed.

for a middle

Explain the mechanism: the disabled journal raises RequestJournalDisabledException from the count, the matching-request lookup and the serve-event list, so WireMock reports the journal as disabled instead of returning a number.

for a senior

Show that you would look for this flag first when a suite verifies nothing yet passes, and that turning the journal back on changes no response, which makes it the safe half of undoing a permissive fixture.

for a principal

Own the rule for shared instances: decide whether memory pressure ever justifies switching the journal off, where that decision is recorded and who reviews it, because every suite on that instance loses verification at once.

## The request journal, and what reads from it WireMock keeps an in-memory **request journal**: an ordered record of every request the server has received, each entry pairing the request as it arrived with the stub that matched it and the response that went back. Serving traffic does not depend on it. Matching an incoming request against the registered mappings, choosing a reply and writing it to the socket all happen whether or not an entry is stored. The journal exists for one purpose — so that a test can ask, afterwards, *what did my code actually send?* Every part of WireMock's verification surface reads from that store: - `verify(...)`, with count matchers such as `exactly(`, `moreThanOrExactly(` and `lessThan(`, asks the journal how many recorded requests match a pattern. - `findAll(...)` returns the matching entries as `LoggedRequest` objects, so a test can inspect the path, query string, headers and body that arrived. - `getAllServeEvents()` returns the whole record, one `ServeEvent` per request served. - The admin API exposes the same store over HTTP: `GET /__admin/requests`, `POST /__admin/requests/count` and `POST /__admin/requests/find`. Take the journal away and all four lose their input at the same moment. ## What the flag actually does `--no-request-journal` is a WireMock start-up option, given on the standalone command line or expressed as `wireMockConfig().disableRequestJournal()` when the server runs embedded. It does not shrink the journal, sample it, or keep a summary of it. It replaces the store with a disabled one, and the disabled journal **raises `RequestJournalDisabledException`** from the count, the matching-request lookup, the serve-event list and the journal removals. WireMock's admin layer turns that into a result reporting the journal as disabled rather than a number, so the caller gets a failure instead of an answer. The important word is *abolished*, not *degraded*. There is no partial history to fall back on, no window of recent requests, not even a zero count a test could interpret. The correct mental model is that the server has stopped remembering, so no question about the past has an answer at all. ## Why anyone turns it off - **Memory.** The journal grows with every request, so an instance that lives for hours behind a soak run or a shared CI service accumulates entries steadily. Switching it off removes that growth outright. - **A copied command line.** One team sets it for one long run; the flag then travels into a Compose file or a CI job that other suites reuse without reading. - **Confusion with output.** Someone conflates the recorded journal with console noise and reaches for this flag when they meant `--verbose` or a logging setting. Only the first is a real reason, and it is a memory decision rather than a testing one. On any instance a suite verifies against, it is the wrong trade. ## What it costs a ferry-timetable suite | Question the test wants to ask | Journal on | Started with `--no-request-journal` | |---|---|---| | Did the client call `GET /v1/routes/DOV-CAL/departures`? | `verify(getRequestedFor(urlPathEqualTo("/v1/routes/DOV-CAL/departures")))` answers it | the call reports the journal disabled | | Which `date` parameter did it send? | `findAll(...)` returns the `LoggedRequest` | no record exists to inspect | | Did it fire the departure lookup twice? | a count matcher answers | unanswerable | A suite in that state can still assert on what the client did with the response — the parsed departures, the rendered timetable — but it cannot assert anything about the request. If the client silently stopped sending `date`, or began calling a stale path, nothing objects: a broad enough mapping still replies, and the record that would have shown the difference was never written. ## Why it belongs beside a catch-all mapping A mapping broad enough to answer everything means no request can fail to match. A disabled journal means no request can be checked after the fact. Either alone is recoverable; together they remove both halves of the evidence and the suite becomes a machine for producing green. The combination is nearly always accidental — one flag added for memory, one mapping added to unblock a build — but it is worth naming as a single failure mode, because the repair has two parts and they are undone in a particular order. Two neighbouring facts are worth carrying: 1. In MockServer, `mockserver.disableLogging` is the comparable switch: it disables the log and the processing of log events that verification reads from. 2. In Mountebank the same choice is made per imposter rather than per process, through `recordRequests`, which governs whether an imposter retains the requests it received for later inspection. ## Finding it, and undoing it The cheapest check is to ask the instance itself. In WireMock, `POST /__admin/requests/count` with a request pattern returns a count while the journal is live and reports the journal as disabled when it is not, which is a one-line probe for a CI job to run before any suite that verifies anything. Undoing it is equally cheap: removing the flag changes no response and cannot turn a passing test red, because recording is a side effect of serving rather than part of it.

  • Why would a team turn the WireMock request journal off in the first place?
    The journal holds every request the instance has served in memory, so a long-lived or high-volume WireMock instance grows steadily; `--no-request-journal` removes that growth outright. It is a memory decision rather than a testing one, and it is the wrong trade on any instance a suite verifies against, because `verify(...)` and `getAllServeEvents()` stop being usable for every test sharing that server, not just the one that set the flag.
  • How would you notice from a run alone that the journal is disabled?
    You do not get a clean assertion failure — you get an error naming the disabled journal instead of a count. Ask the instance directly: in WireMock, `POST /__admin/requests/count` with a request pattern reports the journal as disabled rather than returning a number, which makes a reliable one-line CI probe. Without that probe a suite that never verifies anything stays green and says nothing.

saying these in an interview costs you the question

  • Thinks verification still works, just with fewer entries
  • Says verify() simply returns a count of zero once the journal is off
  • Confuses the request journal with console logging or the --verbose flag
  • Assumes stub matching stops working when the journal is disabled
  • Treats it as a per-test toggle rather than a server start-up option
open as a page

In WireMock, what does a catch-all stub that answers every request hide in a ferry-timetable suite?

level: middleimportance: should knowfreq 52%

basics

~20 s

A WireMock catch-all stub answers every request, even ones nobody stubbed. A wrong path or an unstubbed ferry endpoint gets the same canned 200, so the client's error branches never run. The specific mappings beneath it stop being served.

open as a page

How would you set and enforce a policy on WireMock catch-all mappings and --no-request-journal across teams?

level: principalimportance: should knowfreq 31%

basics

~20 s

Make both failure modes reviewable rather than cultural. Require every mapping in a shared WireMock set to name a method and a URL constraint, and keep the request journal on in CI. A mapping answering anything becomes a time-boxed, owned exception.

open as a page

In what order would you undo a WireMock ferry fixture's catch-all stub and its --no-request-journal flag?

level: seniorimportance: nice to knowfreq 38%

basics

~20 s

Turn WireMock's request journal back on first. Recording changes no response, so nothing can break, and verify() plus the serve-event list immediately show what the suite really sends. Only then narrow or delete the catch-all mapping, which does change behaviour.

open as a page