The Java version of the mock-lab proxymock demo. It serves an HTTP API on
:8080 and fulfills each request by calling the CNCF projects API downstream
(DOWNSTREAM_URL, default https://demo-api.trafficreplay.com; set PORT to change the port).
Single file, run directly with JDK 11+ source-file mode — no build tool.
java App.javaFirst time only: install proxymock and run
proxymock init --api-key <key>once (free key at app.speedscale.com/signup). In a Codespace the CLI is preinstalled.
proxymock record -- java App.java # 1. record the downstream calls
../lab/tests/run_tests.sh --recording # 2. second terminal: drive every endpoint
proxymock web # 3. browse the recorded traffic (:7788)
proxymock mock -- java App.java # 4. serve the downstream from the recording
proxymock replay --test-against http://localhost:8080 # 5. replay (or use Replay in proxymock web)No extra config needed: when proxymock record wraps the JVM it injects JAVA_TOOL_OPTIONS
with the -D proxy flags and a CA truststore, so java.net.http.HttpClient routes through
proxymock automatically.
This app also serves POST /oauth/token, POST /api/orders (Bearer-protected, validates the project against the downstream), and GET /api/orders/{order_id} (Bearer-protected). The access_token and order_id are generated fresh on every call. The quickstart's ../lab/tests/run_tests.sh drives this flow too. On replay those two IDs are stale, so a committed smart replace blueprint re-chains them — see the root README and ../lab/proxymock/ for the ready-to-run recording + blueprint.
Endpoints and the API contract: see the root README and openapi.yaml.