$ show mock-server/mockserver-monorepo
MockServer is a highly sophisticated, multi-protocol HTTP(S) mock server and proxy for testing, written in Java with Netty. It supports HTTP/1.1, HTTP/2, HTTP/3 (QUIC), gRPC, WebSockets, DNS, TCP, and binary protocols on a single port. The core engine provides expectation-based request matching, response generation, forwarding, proxying, recording, verification, and chaos engineering (latency, connection drops, error injection). It also includes built-in LLM mocking (OpenAI, Anthropic, Gemini, etc.), OIDC/OAuth2/SAML identity providers, SCIM provisioning, WASM custom rules, and drift detection. The repository is a monorepo containing the Java server, multi-language client libraries (Java, Node, Python, Ruby, Go, .NET, Rust, PHP), a React dashboard UI, IDE plugins (JetBrains, VS Code), Helm charts, Docker images, and extensive CI/CD pipelines via Buildkite. The architecture is modular with clear separation of concerns: core model/matcher/serialization in `mockserver-core`, Netty transport in `mockserver-netty`, language-specific clients in `mockserver-client-*`, and a React UI in `mockserver-ui`. The codebase demonstrates strong engineering practices including DTO patterns with Jackson serializers, a matcher hierarchy with compiled-once validators, bounded caches, constant-time equality checks, and extensive test coverage with integration tests across multiple environments.
The LLM identified 3 files worth highlighting for reuse:
Base class used by all model DTOs providing consistent toString output as JSON, along with reflective equals/hashCode via ObjectWithReflectiveEqualsHashCodeToString. This pattern eliminates boilerplate across hundreds of model classes and ensures that debug/log output is always meaningful JSON. Reusable in any Java project needing consistent object representation.
A bounded LRU cache with a listener interface for eviction callbacks, supporting runtime size adjustment and full concurrency. Used internally for caching compiled JSON schemas and matchers. The implementation is self-contained, thread-safe, and can be extracted as a standalone utility for any application requiring an evictable, size-limited cache with observable eviction.
A thread-safe wrapper that compiles an expensive object (e.g., JSON Schema validator) once and caches it, with semantics to release the compiled object when the owning server stops (e.g., after a JUnit test lifecycle). Prevents memory leaks and unnecessary recompilation. The pattern is generic and can be reused for any one-time initialization that must be tied to a lifecycle.