use of com.github.mjeanroy.junit.servers.client.HttpHeader in project junit-servers by mjeanroy.
the class AbstractHttpResponseImplTest method it_should_get_x_content_security_policy_header.
@Test
void it_should_get_x_content_security_policy_header() {
final String name = "X-Content-Security-Policy";
final String value = "default-src 'self'";
final V response = createHttpResponseWithHeader(name, value);
final HttpHeader header = response.getXContentSecurityPolicy();
assertHeader(header, name, value);
}
use of com.github.mjeanroy.junit.servers.client.HttpHeader in project junit-servers by mjeanroy.
the class AbstractHttpResponseImplTest method it_should_get_content_type_header.
@Test
void it_should_get_content_type_header() {
final String name = "Content-Type";
final String value = "text/html; charset=utf-8";
final V response = createHttpResponseWithHeader(name, value);
final HttpHeader header = response.getContentType();
assertHeader(header, name, value);
}
use of com.github.mjeanroy.junit.servers.client.HttpHeader in project junit-servers by mjeanroy.
the class AbstractHttpResponseImplTest method it_should_get_all_headers.
@Test
void it_should_get_all_headers() {
final HttpHeader h1 = HttpHeader.header("Content-Type", "text/html; charset=utf-8");
final HttpHeader h2 = HttpHeader.header("Status", "200");
final V response = createHttpResponseWithHeaders(h1, h2);
final Collection<HttpHeader> headers = response.getHeaders();
assertThat(headers).hasSize(2).extracting("name", "values").contains(tuple(h1.getName(), h1.getValues()), tuple(h2.getName(), h2.getValues()));
}
use of com.github.mjeanroy.junit.servers.client.HttpHeader in project junit-servers by mjeanroy.
the class AbstractHttpResponseImplTest method createHttpResponseWithHeaders.
/**
* Create HTTP response with given headers.
*
* @param headers The headers.
* @return The HTTP Response.
*/
private V createHttpResponseWithHeaders(HttpHeader... headers) {
final long duration = 1000L;
final T builder = getBuilder();
for (HttpHeader h : headers) {
for (String value : h.getValues()) {
builder.withHeader(h.getName(), value);
}
}
final U delegate = builder.build();
return createHttpResponse(delegate, duration);
}
use of com.github.mjeanroy.junit.servers.client.HttpHeader in project junit-servers by mjeanroy.
the class AbstractHttpResponseImplTest method it_should_get_content_encoding_header.
@Test
void it_should_get_content_encoding_header() {
final String name = "Content-Encoding";
final String value = "gzip";
final V response = createHttpResponseWithHeader(name, value);
HttpHeader header = response.getContentEncoding();
assertHeader(header, name, value);
}
Aggregations