/** * Asserts response status code * * @param status * expected HTTP response code * @param response * server response */ public static void assertStatus(int status, Response response) { assertEquals("Response status ", (Object) status, response.status); }
/** * Verify response charset encoding, as returned by the server in the Content-Type header. Be aware that if no * charset is returned, assertion will fail. * * @param charset * expected charset encoding such as "utf-8" or "iso8859-1". * @param response * server response */ public static void assertCharset(String charset, Response response) { int pos = response.contentType.indexOf("charset=") + 8; String responseCharset = (pos > 7) ? response.contentType.substring(pos).toLowerCase() : ""; assertEquals("Response charset", charset.toLowerCase(), responseCharset); }
/** * Exact equality assertion on response body * * @param content * expected body content * @param response * server response */ public static void assertContentEquals(String content, Response response) { assertEquals(content, getContent(response)); }
/** * Exact equality assertion on a response header value * * @param headerName * header to verify. case-insensitive * @param value * expected header value * @param response * server response */ public static void assertHeaderEquals(String headerName, String value, Response response) { assertNotNull("Response header " + headerName + " missing", response.headers.get(headerName)); assertEquals("Response header " + headerName + " mismatch", value, response.headers.get(headerName).value()); }