/** * Invokes a handler in a controlled way, allowing it to be tested. * * @param handler The handler to invoke * @return A result object indicating what happened * @throws InvocationTimeoutException if the handler takes more than {@link #timeout(int)} seconds * to send a response or call {@code next()} on the context */ public Invocation invoke(Handler handler) throws InvocationTimeoutException { Request request = new DefaultRequest(requestHeaders, method, uri, requestBody); Registry registry = registryBuilder.build(); return new DefaultInvocation( request, status, responseHeaders, responseBody.copy(), registry, timeout, handler); }