public void runTest(RestTest restTest, String baseApiUrl) throws Error {
        String requestPath = TestUtil.doPropertyReplacement(restTest.getRequestPath());
        URI uri = null;
        try {
            uri = getUri(baseApiUrl, requestPath);
        } catch (URISyntaxException e) {
            throw new RuntimeException("Invalid URI", e);
        }

        log("Sending HTTP request to: " + uri);

        // Retries attempt to connect up to 4 times if there's an IOException
        // e.g. occasional CI issue connecting to localhost on first attempt)
        Request request = new ApacheRequest(uri.toString())
            .through(RetryIfUnableToConnect.class)
            .method(restTest.getRequestMethod());

        try {
            Map<String, String> requestHeaders = restTest.getRequestHeaders();
            for (Entry<String, String> entry : requestHeaders.entrySet()) {
                String value = TestUtil.doPropertyReplacement(entry.getValue());
                // Handle system properties that may be configured in the rest-test itself
                if (entry.getKey().startsWith("X-RestTest-System-Property")) {
                    String[] split = value.split("=");
                    System.setProperty(split[0], split[1]);
                    continue;
                }

                if (entry.getKey().equals("Content-Type")) {
                    String contentType = entry.getKey() != null ? StringUtils.appendIfMissing(value, "; charset=UTF-8") : "text/plain; charset=UTF-8";
                    request = request.header(entry.getKey(), contentType);
                } else {
                    request = request.header(entry.getKey(), value);
                }
            }

            // Set up basic auth
            String authorization = createBasicAuthorization(restTest.getUsername(), restTest.getPassword());
            if (authorization != null) {
                request = request.header("Authorization", authorization);
            }

            if (restTest.getRequestPayload() != null && !restTest.getRequestPayload().isEmpty()) {
                request = request.body().set(restTest.getRequestPayload()).back();
            }

            assertResponse(restTest, request.fetch());
        } catch (Error e) {
            logPlain("[ERROR] " + e.getMessage());
            e.printStackTrace();
            throw e;
        } catch (ProtocolException e) {
            logPlain("[HTTP PROTOCOL EXCEPTION] " + e.getMessage());
            throw new Error(e);
        } catch (IOException e) {
            logPlain("[IO EXCEPTION] " + e.getMessage());
            throw new Error(e);
        } catch (Exception e) {
            logPlain("[EXCEPTION] " + e.getMessage());
            throw new Error(e);
        }
    }
Runs a single REST test.

@param restTest
@param baseApiUrl
@throws Error
test/common/src/main/java/io/apiman/test/common/util/TestPlanRunner.java