Package com.github.kevinsawicki.http

Examples of com.github.kevinsawicki.http.HttpRequest.body()


        HttpRequest httpRequest = server.client().GET(
                "/api/contextParams/baseUri")
                .header("X-Forwarded-Proto", "https")
                .header("X-Forwarded-Host", "www.example.com");
        assertThat(httpRequest.code()).isEqualTo(200);
        assertThat(httpRequest.body().trim()).isEqualTo("https://www.example.com/api");
    }

    @Test
    public void should_access_client_address() throws Exception {
        HttpRequest httpRequest = server.client().GET(
View Full Code Here


    @Test
    public void should_access_client_address() throws Exception {
        HttpRequest httpRequest = server.client().GET(
                "/api/contextParams/clientAddress");
        assertThat(httpRequest.code()).isEqualTo(200);
        assertThat(httpRequest.body().trim()).contains("127.0.0.1");
    }

    @Test
    public void should_use_x_forwarded_for_client_address() throws Exception {
        HttpRequest httpRequest = server.client().GET(
View Full Code Here

    @Test
    public void should_use_x_forwarded_for_client_address() throws Exception {
        HttpRequest httpRequest = server.client().GET(
                "/api/contextParams/clientAddress").header("X-Forwarded-For", "10.0.10.1");
        assertThat(httpRequest.code()).isEqualTo(200);
        assertThat(httpRequest.body().trim()).contains("10.0.10.1");
    }

    @Test
    public void should_access_request() throws Exception {
        HttpRequest httpRequest = server.client().GET(
View Full Code Here

    @Test
    public void should_access_request() throws Exception {
        HttpRequest httpRequest = server.client().GET(
                "/api/contextParams/request");
        assertThat(httpRequest.code()).isEqualTo(200);
        assertThat(httpRequest.body().trim()).isEqualTo("[RESTX REQUEST] GET /contextParams/request");
    }

    @Test
    public void should_access_locale() throws Exception {
        HttpRequest httpRequest = server.client().GET(
View Full Code Here

    @Test
    public void should_access_locale() throws Exception {
        HttpRequest httpRequest = server.client().GET(
                "/api/contextParams/locale").header("Accept-Language", "fr-FR");
        assertThat(httpRequest.code()).isEqualTo(200);
        assertThat(httpRequest.body().trim()).isEqualTo("fr-FR");
    }

    @Test
    public void should_access_locales() throws Exception {
        HttpRequest httpRequest = server.client().GET(
View Full Code Here

    @Test
    public void should_access_locales() throws Exception {
        HttpRequest httpRequest = server.client().GET(
                "/api/contextParams/locales").header("Accept-Language", "fr-FR, en-US");
        assertThat(httpRequest.code()).isEqualTo(200);
        assertThat(httpRequest.body().trim()).isEqualTo("[fr_FR, en_US]");
    }
}
View Full Code Here

    @Test
    public void should_access_resource_relying_on_module_declaring_exceptions() throws Exception {
        HttpRequest httpRequest = server.client().authenticatedAs("admin")
                .GET("/api/providesWithExceptions");
        assertThat(httpRequest.code()).isEqualTo(200);
        assertThat(httpRequest.body().trim()).isEqualTo("noproblem");
    }
}
View Full Code Here

    @Test
    public void should_return_path_params() throws Exception {
        HttpRequest httpRequest = server.client().authenticatedAs("admin").GET(
                "/api/params/path/v1/v2/35v4");
        assertThat(httpRequest.code()).isEqualTo(200);
        assertThat(httpRequest.body().trim()).isEqualTo("a=v1 b=v2 c=35 d=v4");
    }

    @Test
    public void should_return_query_params() throws Exception {
        HttpRequest httpRequest = server.client().authenticatedAs("admin").GET(
View Full Code Here

    @Test
    public void should_return_query_params() throws Exception {
        HttpRequest httpRequest = server.client().authenticatedAs("admin").GET(
                "/api/params/query/1?a=v1&b=v2");
        assertThat(httpRequest.code()).isEqualTo(200);
        assertThat(httpRequest.body().trim()).isEqualTo("a=v1 b=v2");
    }

    @Test
    public void should_return_query_params_without_optional() throws Exception {
        HttpRequest httpRequest = server.client().authenticatedAs("admin").GET(
View Full Code Here

    @Test
    public void should_return_query_params_without_optional() throws Exception {
        HttpRequest httpRequest = server.client().authenticatedAs("admin").GET(
                "/api/params/query/1?a=v1");
        assertThat(httpRequest.code()).isEqualTo(200);
        assertThat(httpRequest.body().trim()).isEqualTo("a=v1 b=default");
    }

    @Test
    public void should_return_query_params_datetime() throws Exception {
        HttpRequest httpRequest = server.client().authenticatedAs("admin").GET(
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.