Package org.apache.juneau.rest.mock
Class MockHttpTransport.Builder
java.lang.Object
org.apache.juneau.rest.mock.MockHttpTransport.Builder
- Enclosing class:
- MockHttpTransport
Fluent builder for
MockHttpTransport.- Since:
- 9.2.1
-
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds and returns theMockHttpTransport.Sets a fallback handler used when no route matches.on(String method, String path, MockHttpTransport.RequestHandler handler) Registers a handler for the given HTTP method and path.Enables recording of all received requests so they can be retrieved viaMockHttpTransport.getRecordedRequests().
-
Method Details
-
on
public MockHttpTransport.Builder on(String method, String path, MockHttpTransport.RequestHandler handler) Registers a handler for the given HTTP method and path.- Parameters:
method- The HTTP method (e.g."GET").nullmatches any method.path- The exact request path (e.g."/api/users").nullmatches any path.handler- The handler. Must not benull .- Returns:
- This object.
-
fallback
Sets a fallback handler used when no route matches.Without a fallback, unmatched requests receive a
404response.- Parameters:
value- The fallback handler.
Can benull — anull fallback is the intentional default (unmatched requests get a404).- Returns:
- This object.
-
recordRequests
Enables recording of all received requests so they can be retrieved viaMockHttpTransport.getRecordedRequests().- Returns:
- This object.
-
build
Builds and returns theMockHttpTransport.- Returns:
- A new instance. Never
null .
-