juneau-rest-mock
| Maven | |
|---|---|
| Jar | juneau-rest-mock-10.0.0.jar |
| OSGi | org.apache.juneau.rest.mock_10.0.0.jar |
| Links | Maven Central · Javadocs · Source |
Contents/Features
The juneau-rest-mock module contains convenience APIs for performing serverless unit testing of your REST APIs.
Each of the APIs provides the ability to fully test your server and client REST interfaces without the need for a
running servlet container.
See the guide: Test an endpoint with MockRestClient
Tests run entirely in-process. The mock client performs full serialization and parsing of the HTTP request and response, then dispatches the request directly to the resource's RestOpInvoker rather than sending it over the wire. This makes tests fast and self-contained while still exercising nearly all of the client- and server-side code paths — the actual over-the-wire transmission is the only aspect being bypassed.
The module ships two flavors of mock client:
- The classic MockRestClient — built on the Apache HttpClient 4.5–based classic RestClient, exposing its full fluent surface. This is the client documented in Mock REST Client Overview.
- The next-generation MockRestClient — paired with the transport-agnostic RestClient, for tests that target the new stack. See Next-Generation REST Client for examples.
Both clients live in the same Maven module and can be mixed in a single project.
In This Section
📄️ 3.7.1. Mock REST Client Overview
The MockRestClient class is used for performing
📄️ 3.7.2. NG Mock REST Client
The juneau-rest-mock module provides two ways to test code that uses the NG