Package com.github.kevinsawicki.http

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


        HttpRequest httpRequest = server.client().authenticatedAs("admin").GET(
                "/api/params/query/2" +
                        "?a=" + URLEncoder.encode("2013-11-20T14:00:00.000+01:00", "UTF-8") +
                        "&b=" + URLEncoder.encode("2013-12-20T14:00:00.000+01:00", "UTF-8"));
        assertThat(httpRequest.code()).isEqualTo(200);
        assertThat(httpRequest.body().trim()).isEqualTo("a=2013-11-20T13:00:00.000Z b=2013-12-20T13:00:00.000Z");
    }

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


    public void should_return_query_params_datetime_without_optional() throws Exception {
        HttpRequest httpRequest = server.client().authenticatedAs("admin").GET(
                "/api/params/query/2" +
                        "?a=" + URLEncoder.encode("2013-11-20T14:00:00.000+01:00", "UTF-8"));
        assertThat(httpRequest.code()).isEqualTo(200);
        assertThat(httpRequest.body().trim()).isEqualTo("a=2013-11-20T13:00:00.000Z b=1970-01-01T00:00:00.000Z");
    }

}
View Full Code Here

    @Test
    public void should_follow_redirect() throws Exception {
        HttpRequest httpRequest = server.client().authenticatedAs("admin").GET(
                "/api/core/webexception/redirect");
        assertThat(httpRequest.code()).isEqualTo(200);
        assertThat(httpRequest.body().trim()).isEqualTo("hello restx");
    }
}
View Full Code Here

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

                .header("RestxMode", RestxContext.Modes.RECORDING)
                .header("RestxRecordPath", dir.getAbsolutePath())
                ;

        assertThat(httpRequest.code()).isEqualTo(200);
        assertThat(httpRequest.body()).isNotEmpty();

        File record = new File(dir, "001_GET_uuids_random.spec.yaml");
        waitForFileExists(record);

View Full Code Here

        server.start();
        try {
            HttpRequest httpRequest = HttpRequest.get(server.baseUrl() + "/api/message?who=xavier");

            assertThat(httpRequest.code()).isEqualTo(200);
            assertThat(httpRequest.body().trim()).isEqualTo("{\"message\":\"hello xavier, it's 14:33:18\"}");
        } finally {
            server.stop();
        }

    }
View Full Code Here

    @Test
    public void should_return_A() throws Exception {
        HttpRequest httpRequest = server.client().authenticatedAs("admin").GET(
                "/api/polymorphic/single/A");
        assertThat(httpRequest.code()).isEqualTo(200);
        assertThat(httpRequest.body().trim()).isEqualTo("{\n" +
                "  \"@class\" : \".PolymorphicResource$A\",\n" +
                "  \"a\" : \"a\"\n" +
                "}");
    }
View Full Code Here

    @Test
    public void should_return_B() throws Exception {
        HttpRequest httpRequest = server.client().authenticatedAs("admin").GET(
                "/api/polymorphic/single/B");
        assertThat(httpRequest.code()).isEqualTo(200);
        assertThat(httpRequest.body().trim()).isEqualTo("{\n" +
                "  \"@class\" : \".PolymorphicResource$B\",\n" +
                "  \"a\" : \"a\",\n" +
                "  \"b\" : \"b\"\n" +
                "}");
    }
View Full Code Here

    @Test
    public void should_return_B_list() throws Exception {
        HttpRequest httpRequest = server.client().authenticatedAs("admin").GET(
                "/api/polymorphic/list/B");
        assertThat(httpRequest.code()).isEqualTo(200);
        assertThat(httpRequest.body().trim()).isEqualTo("[ {\n" +
                "  \"@class\" : \".PolymorphicResource$A\",\n" +
                "  \"a\" : \"a1\"\n" +
                "}, {\n" +
                "  \"@class\" : \".PolymorphicResource$B\",\n" +
                "  \"a\" : \"a2\",\n" +
View Full Code Here

    @Test
    public void should_post_A() throws Exception {
        HttpRequest httpRequest = server.client().authenticatedAs("admin").POST(
                "/api/polymorphic").send("{\"@class\":\".PolymorphicResource$A\",\"a\":\"a3\"}");
        assertThat(httpRequest.code()).isEqualTo(200);
        assertThat(httpRequest.body().trim()).isEqualTo("{\n" +
                "  \"@class\" : \".PolymorphicResource$A\",\n" +
                "  \"a\" : \"a3\"\n" +
                "}");
    }
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.