Package com.github.kevinsawicki.http

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


    @Test
    public void should_find_bar() throws Exception {
        HttpRequest httpRequest = server.client().authenticatedAs("admin").GET("/api/optional/dependency/bar");
        assertThat(httpRequest.code()).isEqualTo(200);
        assertThat(httpRequest.body()).isEqualTo("true");
    }

}
View Full Code Here


    @Test
    public void should_retrieve_details_view() throws Exception {
        HttpRequest httpRequest = server.client().GET("/api/jacksonviews/carsDetails");
        assertThat(httpRequest.code()).isEqualTo(200);
        assertThat(httpRequest.body().trim()).isEqualTo(
                "[ {\n" +
                        "  \"brand\" : \"Brand1\",\n" +
                        "  \"model\" : \"samplest-Model1\",\n" +
                        "  \"status\" : {\n" +
                        "    \"status\" : \"ko\",\n" +
View Full Code Here

    }
    @Test
    public void should_retrieve_default_view() throws Exception {
        HttpRequest httpRequest = server.client().GET("/api/jacksonviews/cars");
        assertThat(httpRequest.code()).isEqualTo(200);
        assertThat(httpRequest.body().trim()).isEqualTo(
                "[ {\n" +
                        "  \"brand\" : \"Brand1\",\n" +
                        "  \"model\" : \"samplest-Model1\",\n" +
                        "  \"status\" : {\n" +
                        "    \"status\" : \"ko\"\n" +
View Full Code Here

    @Test
    public void should_access_keys() throws Exception {
        HttpRequest httpRequest = server.client().GET(
                "/api/settings/key1");
        assertThat(httpRequest.code()).isEqualTo(200);
        assertThat(httpRequest.body().trim()).isEqualTo("value1");

        httpRequest = server.client().GET(
                "/api/settings/key2");
        assertThat(httpRequest.code()).isEqualTo(200);
        assertThat(httpRequest.body().trim()).isEqualTo("value2");
View Full Code Here

        assertThat(httpRequest.body().trim()).isEqualTo("value1");

        httpRequest = server.client().GET(
                "/api/settings/key2");
        assertThat(httpRequest.code()).isEqualTo(200);
        assertThat(httpRequest.body().trim()).isEqualTo("value2");

        httpRequest = server.client().GET(
                "/api/settings/key3");
        assertThat(httpRequest.code()).isEqualTo(200);
        assertThat(httpRequest.body().trim()).isEqualTo("MyValue3");
View Full Code Here

        assertThat(httpRequest.body().trim()).isEqualTo("value2");

        httpRequest = server.client().GET(
                "/api/settings/key3");
        assertThat(httpRequest.code()).isEqualTo(200);
        assertThat(httpRequest.body().trim()).isEqualTo("MyValue3");
    }

}
View Full Code Here

    @Test
    public void should_access_base_uri() throws Exception {
        HttpRequest httpRequest = server.client().GET(
                "/api/contextParams/baseUri");
        assertThat(httpRequest.code()).isEqualTo(200);
        assertThat(httpRequest.body().trim()).isEqualTo(server.getServer().baseUrl() + "/api");
    }

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

            server.start();
            try {
                HttpTestClient client = HttpTestClient.withBaseUrl(server.baseUrl());
                HttpRequest httpRequest = client.GET("/api/autostartable/test");
                assertThat(httpRequest.code()).isEqualTo(200);
                assertThat(httpRequest.body().trim()).isEqualTo(
                        "called: 1 - autostartable: called: 1 started: 1 closed: 0 instanciated: 1" +
                                " serverId: "+server.getServerId()+" baseUrl: "+server.baseUrl()+" routerPresent: true");

                httpRequest = client.GET("/api/autostartable/test");
                assertThat(httpRequest.code()).isEqualTo(200);
View Full Code Here

        HttpRequest httpRequest = server.client().GET(
                "/api/contextParams/baseUri")
                .header("Via", "HTTPS/1.1 proxy")
                .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_use_proxy_headers_proto_for_base_uri() throws Exception {
        HttpRequest httpRequest = server.client().GET(
View Full Code Here

                httpRequest = client.GET("/api/autostartable/test");
                assertThat(httpRequest.code()).isEqualTo(200);
                // called should be only one in test mode, components are dropped at each request
                // but autostartable should be reused
                assertThat(httpRequest.body().trim()).isEqualTo(
                        "called: 1 - autostartable: called: 2 started: 1 closed: 0 instanciated: 1" +
                                " serverId: "+server.getServerId()+" baseUrl: "+server.baseUrl()+" routerPresent: true");
            } finally {
                server.stop();
            }
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.