Package com.github.kevinsawicki.http

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


    @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 {
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 {
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 {
View Full Code Here

    public void should_return_query_params_datetime() 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") +
                        "&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 {
View Full Code Here

    @Test
    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_send_redirect() throws Exception {
        HttpRequest httpRequest = server.client().authenticatedAs("admin").GET(
                "/api/core/webexception/redirect").followRedirects(false);
        assertThat(httpRequest.code()).isEqualTo(302);
        assertThat(httpRequest.header("Location")).isEqualTo("/api/core/hello?who=restx");
    }

    @Test
    public void should_follow_redirect() throws Exception {
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

                .GET("/api/uuids/random")
                .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

        WebServer server = SpecsServer.getServer(WebServers.findAvailablePort(), "/api", ".");
        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

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.