Package com.github.kevinsawicki.http

Examples of com.github.kevinsawicki.http.HttpRequest$RequestOutputStream


        assertThat(httpRequest.header("Access-Control-Allow-Origin")).isEqualTo(randomOrigin);
    }

    @Test
    public void should_handle_any_origin_on_head() throws Exception {
        HttpRequest httpRequest = client().HEAD("/api/cors/2").header("Origin", randomOrigin);
        assertHttpResponse(httpRequest, 204, "");
        assertThat(httpRequest.header("Access-Control-Allow-Origin")).isEqualTo(randomOrigin);
    }
View Full Code Here


        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(
                "/api/params/query/1?a=v1");
        assertThat(httpRequest.code()).isEqualTo(200);
        assertThat(httpRequest.body().trim()).isEqualTo("a=v1 b=default");
    }
View Full Code Here

        assertThat(httpRequest.header("Access-Control-Allow-Origin")).isEqualTo(randomOrigin);
    }

    @Test
    public void should_reject_preflight_request_for_put_when_not_configured() throws Exception {
        HttpRequest httpRequest = client().OPTIONS("/api/cors/2")
                .header("Origin", randomOrigin)
                .header("Access-Control-Request-Method", "PUT")
                ;
        assertHttpResponse(httpRequest, 403, "");
    }
View Full Code Here

        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(
                "/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");
    }
View Full Code Here

        assertHttpResponse(httpRequest, 403, "");
    }

    @Test
    public void should_handle_preflight_request_for_put() throws Exception {
        HttpRequest httpRequest = client().OPTIONS("/api/cors/3")
                .header("Origin", randomOrigin)
                .header("Access-Control-Request-Method", "PUT")
                ;
        assertHttpResponse(httpRequest, 200, "");
        assertThat(httpRequest.header("Access-Control-Allow-Origin")).isEqualTo(randomOrigin);
    }
View Full Code Here

        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(
                "/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

        assertThat(httpRequest.header("Access-Control-Allow-Origin")).isEqualTo(randomOrigin);
    }

    @Test
    public void should_reject_preflight_request_for_delete_when_not_configured() throws Exception {
        HttpRequest httpRequest = client().OPTIONS("/api/cors/3")
                .header("Origin", randomOrigin)
                .header("Access-Control-Request-Method", "DELETE")
                ;
        assertHttpResponse(httpRequest, 403, "");
    }
View Full Code Here

        Factory.LocalMachines.threadLocal().clear();
    }

    @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");
    }
View Full Code Here

        assertThat(httpRequest.header("Location")).isEqualTo("/api/core/hello?who=restx");
    }

    @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

        Factory.LocalMachines.threadLocal().clear();
    }

    @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

TOP

Related Classes of com.github.kevinsawicki.http.HttpRequest$RequestOutputStream

Copyright © 2018 www.massapicom. 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.