use of com.github.mjeanroy.junit.servers.client.HttpResponse in project junit-servers by mjeanroy.
the class OkHttpRequest method doExecute.
@Override
protected HttpResponse doExecute() throws Exception {
final HttpUrl endpoint = getEndpoint();
final okhttp3.HttpUrl.Builder httpUrlBuilder = new okhttp3.HttpUrl.Builder().scheme(endpoint.getScheme()).host(endpoint.getHost()).port(endpoint.getPort()).addPathSegments(endpoint.getPath().substring(1));
// Append all query parameters.
for (HttpParameter queryParam : queryParams.values()) {
httpUrlBuilder.addEncodedQueryParameter(queryParam.getEncodedName(), queryParam.getEncodedValue());
}
final Request.Builder builder = new Request.Builder().url(httpUrlBuilder.build());
handleBody(builder);
handleCookies(builder);
handleHeaders(builder);
final Call call = client.newCall(builder.build());
final long start = System.nanoTime();
try (Response response = call.execute()) {
final long duration = System.nanoTime() - start;
return OkHttpResponseFactory.of(response, duration);
}
}
use of com.github.mjeanroy.junit.servers.client.HttpResponse in project springmvc-mustache by mjeanroy.
the class IndexControllerTest method it_should_render_handlebars_template_using_model_and_mustache_view.
@Test
void it_should_render_handlebars_template_using_model_and_mustache_view(HttpClient client) {
HttpResponse response = client.prepareGet("/jane").execute();
assertThat(response.status()).isEqualTo(200);
assertThat(response.body()).contains("Hello, my name is Jane Doe");
}
use of com.github.mjeanroy.junit.servers.client.HttpResponse in project springmvc-mustache by mjeanroy.
the class IndexControllerTest method it_should_render_mustache_template.
@Test
void it_should_render_mustache_template(HttpClient client) {
HttpResponse response = client.prepareGet("/").execute();
assertThat(response.status()).isEqualTo(200);
assertThat(response.body()).contains("Hello, my name is John Doe");
}
use of com.github.mjeanroy.junit.servers.client.HttpResponse in project springmvc-mustache by mjeanroy.
the class IndexControllerTest method it_should_render_handlebars_template.
@Test
void it_should_render_handlebars_template(HttpClient client) {
HttpResponse response = client.prepareGet("/").execute();
assertThat(response.status()).isEqualTo(200);
assertThat(response.body()).contains("Hello, my name is John Doe");
}
use of com.github.mjeanroy.junit.servers.client.HttpResponse in project springmvc-mustache by mjeanroy.
the class IndexControllerTest method it_should_render_handlebars_template.
@Test
void it_should_render_handlebars_template(HttpClient client) {
HttpResponse response = client.prepareGet("/").execute();
assertThat(response.status()).isEqualTo(200);
assertThat(response.body()).contains("Hello, my name is John Doe");
}
Aggregations