use of com.github.mjeanroy.junit.servers.client.HttpRequest in project junit-servers by mjeanroy.
the class BaseHttpClientTest method it_should_create_request_with_root_path.
@Test
void it_should_create_request_with_root_path() {
final String serverUrl = url(scheme, host, 8080, "");
final String path = "/";
when(server.getUrl()).thenReturn(serverUrl);
when(server.getPath()).thenReturn(path);
final HttpClient client = createDefaultClient(server);
final HttpMethod httpMethod = HttpMethod.GET;
final HttpRequest httpRequest = client.prepareRequest(httpMethod, path);
assertThat(httpRequest.getEndpoint()).isNotNull();
assertThat(httpRequest.getEndpoint().getScheme()).isEqualTo(scheme);
assertThat(httpRequest.getEndpoint().getHost()).isEqualTo(host);
assertThat(httpRequest.getEndpoint().getPort()).isEqualTo(port);
assertThat(httpRequest.getEndpoint().getPath()).isEqualTo(path);
assertThat(httpRequest.getEndpoint().toString()).isEqualTo(localUrl(port));
}
use of com.github.mjeanroy.junit.servers.client.HttpRequest in project junit-servers by mjeanroy.
the class BaseHttpClientTest method it_should_create_post_request.
@Test
void it_should_create_post_request() {
final HttpClient client = createDefaultClient(server);
final HttpRequest httpRequest = client.preparePost("/foo");
assertThat(httpRequest.getMethod()).isEqualTo(HttpMethod.POST);
}
use of com.github.mjeanroy.junit.servers.client.HttpRequest in project junit-servers by mjeanroy.
the class BaseHttpClientTest method it_should_create_request_and_set_path_separator.
@Test
void it_should_create_request_and_set_path_separator() {
final String serverUrl = url(scheme, host, port, "");
when(server.getUrl()).thenReturn(serverUrl);
when(server.getPath()).thenReturn("/");
final HttpClient client = createDefaultClient(server);
final String path = "/foo";
final HttpMethod httpMethod = HttpMethod.GET;
final HttpRequest httpRequest = client.prepareRequest(httpMethod, path);
assertThat(httpRequest.getEndpoint()).isNotNull();
assertThat(httpRequest.getEndpoint().getScheme()).isEqualTo(scheme);
assertThat(httpRequest.getEndpoint().getHost()).isEqualTo(host);
assertThat(httpRequest.getEndpoint().getPort()).isEqualTo(port);
assertThat(httpRequest.getEndpoint().getPath()).isEqualTo(path);
assertThat(httpRequest.getEndpoint().toString()).isEqualTo(url(scheme, host, port, path));
}
use of com.github.mjeanroy.junit.servers.client.HttpRequest in project junit-servers by mjeanroy.
the class BaseHttpClientTest method it_should_create_request_and_do_not_prepend_server_path.
@Test
void it_should_create_request_and_do_not_prepend_server_path() {
final HttpClient client = createDefaultClient(server);
final String endpoint = "/foo";
final String fullPath = server.getPath() + endpoint;
final HttpMethod httpMethod = HttpMethod.POST;
final HttpRequest httpRequest = client.prepareRequest(httpMethod, fullPath);
assertThat(httpRequest.getMethod()).isEqualTo(httpMethod);
assertThat(httpRequest.getEndpoint()).isNotNull();
assertThat(httpRequest.getEndpoint().getScheme()).isEqualTo(scheme);
assertThat(httpRequest.getEndpoint().getHost()).isEqualTo(host);
assertThat(httpRequest.getEndpoint().getPort()).isEqualTo(port);
assertThat(httpRequest.getEndpoint().getPath()).isEqualTo(fullPath);
assertThat(httpRequest.getEndpoint().toString()).isEqualTo(url(scheme, host, port, fullPath));
}
use of com.github.mjeanroy.junit.servers.client.HttpRequest in project junit-servers by mjeanroy.
the class BaseHttpClientTest method it_should_create_get_request.
@Test
void it_should_create_get_request() {
final HttpClient client = createDefaultClient(server);
final HttpRequest httpRequest = client.prepareGet("/foo");
assertThat(httpRequest.getMethod()).isEqualTo(HttpMethod.GET);
}
Aggregations