private void assertResponse(RestTest restTest, Response response) {
        int actualStatusCode = response.status();
        try {
            Assert.assertEquals("Unexpected REST response status code.  Status message: " + response.reason(), restTest.getExpectedStatusCode(),
                    actualStatusCode);
        } catch (Error e) {
            if (actualStatusCode >= 400) {
                InputStream content = null;
                try {
                    String payload = response.body();
                    System.out.println("------ START ERROR PAYLOAD ------");
                    if (payload.startsWith("{")) {
                        payload = payload.replace("\\r\\n", "\r\n").replace("\\t", "\t");
                    }
                    System.out.println(payload);
                    System.out.println("------ END   ERROR PAYLOAD ------");
                } catch (Exception e1) {
                } finally {
                    IOUtils.closeQuietly(content);
                }
            }
            throw e;
        }
        for (Entry<String, String> entry : restTest.getExpectedResponseHeaders().entrySet()) {
            String expectedHeaderName = entry.getKey();
            if (expectedHeaderName.startsWith("X-RestTest-")) {
                testMetaHeaders.put(entry.getKey(), entry.getValue());
                continue;
            }
            String expectedHeaderValue = entry.getValue();
            List<String> headers = response.headers().get(expectedHeaderName);

            Assert.assertNotNull("Expected header to exist but was not found: " + expectedHeaderName, headers);
            Assert.assertEquals("For response header " + expectedHeaderName, expectedHeaderValue, headers.get(0));
        }
        List<String> ctValueList = response.headers().get("Content-Type");
        if (ctValueList == null) {
            assertNoPayload(restTest, response);
        } else {
            String ctValueFirst = ctValueList.get(0);
            if (ctValueFirst.startsWith("application/json")) {
                assertJsonPayload(restTest, response);
            } else if (ctValueFirst.startsWith("text/plain") || ctValueFirst.startsWith("text/html")) {
                assertTextPayload(restTest, response);
            } else if (ctValueFirst.startsWith("application/xml") || ctValueFirst.startsWith("application/wsdl+xml") || ctValueFirst.startsWith("text/xml")) {
                assertXmlPayload(restTest, response);
            } else if (ctValueFirst.startsWith("image/")) {
                assertBinaryEquals(restTest, response);
            }
        }
    }
Assert that the response matched the expected.

@param restTest
@param response
test/common/src/main/java/io/apiman/test/common/util/TestPlanRunner.java