Package com.github.kevinsawicki.http

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


        Factory.LocalMachines.overrideComponents().set("LifecycleListenerFilter", filter);
        HttpRequest httpRequest = server.client().authenticatedAs("admin").GET(
                "/api/core/hello?who=restx");

        assertThat(httpRequest.code()).isEqualTo(200);
        assertThat(httpRequest.body().trim()).isEqualTo("hello restx");

        assertLifecycleMethods(filter, "[Optional.absent()]", "[Optional.of(hello restx)]");
    }

    @Test
View Full Code Here


        Factory.LocalMachines.overrideComponents().set("LifecycleListenerFilter", filter);
        HttpRequest httpRequest = server.client().authenticatedAs("admin").GET(
                "/api/core/hellomsg?who=restx");

        assertThat(httpRequest.code()).isEqualTo(200);
        assertThat(httpRequest.body().trim()).isEqualTo("{\n  \"msg\" : \"hello restx\"\n}");

        assertLifecycleMethods(filter, "[Optional.absent()]", "[Optional.of(Message{msg='hello restx'})]");
    }

    @Test
View Full Code Here

        int code = httpRequest.code();
        System.out.println("<< RESPONSE");
        System.out.println(code);
        System.out.println();
        String body = httpRequest.body(Charsets.UTF_8.name());
        System.out.println(body);
        System.out.println();

        assertThat(code).isEqualTo(when.getThen().getExpectedCode());
        if (isJSON(when.getThen().getExpected())) {
View Full Code Here

        Factory.LocalMachines.overrideComponents().set("LifecycleListenerFilter", filter);
        HttpRequest httpRequest = server.client().authenticatedAs("admin").POST(
                "/api/core/hellomsg").send("{\"msg\": \"restx\"}");

        assertThat(httpRequest.code()).isEqualTo(200);
        assertThat(httpRequest.body().trim()).isEqualTo("{\n  \"msg\" : \"hello restx\"\n}");

        assertLifecycleMethods(filter, "[Optional.of(Message{msg='restx'})]", "[Optional.of(Message{msg='hello restx'})]");
    }

View Full Code Here

    @Test
    public void should_get_labels_json() throws Exception {
        HttpRequest request = server.client().GET("/api/i18n/labels.json");

        assertThat(request.code()).isEqualTo(200);
        assertThat(request.body()).isEqualTo("{\n" +
                "  \"key1\" : \"value1\",\n" +
                "  \"key2\" : \"hello {{test}}\"\n" +
                "}\n");
    }
View Full Code Here

    @Test
    public void should_get_labels_js() throws Exception {
        HttpRequest request = server.client().GET("/api/i18n/labels.js");

        assertThat(request.code()).isEqualTo(200);
        assertThat(request.body()).isEqualTo(
                "// RESTX Labels - customize this with restx.i18n.labelsJsTemplate named String\n" +
                "window.labels = {\n" +
                "  \"key1\" : \"value1\",\n" +
                "  \"key2\" : \"hello {{test}}\"\n" +
                "};\n");
View Full Code Here

                .setRouterPath("/api").setPort(WebServers.findAvailablePort()).build();
        server.start();
        try {
            HttpRequest httpRequest = HttpRequest.get(server.baseUrl() + "/api/route1/xavier");
            assertThat(httpRequest.code()).isEqualTo(200);
            assertThat(httpRequest.body().trim()).isEqualTo("{\"id\":\"xavier\"}");

            httpRequest = HttpRequest.put(server.baseUrl() + "/api/route4").send("{\"test\":\"val1\"}");
            assertThat(httpRequest.code()).isEqualTo(200);
            assertThat(httpRequest.body().trim()).isEqualTo("{\"test\":\"val1\",\"size\":1}");
        } finally {
View Full Code Here

            assertThat(httpRequest.code()).isEqualTo(200);
            assertThat(httpRequest.body().trim()).isEqualTo("{\"id\":\"xavier\"}");

            httpRequest = HttpRequest.put(server.baseUrl() + "/api/route4").send("{\"test\":\"val1\"}");
            assertThat(httpRequest.code()).isEqualTo(200);
            assertThat(httpRequest.body().trim()).isEqualTo("{\"test\":\"val1\",\"size\":1}");
        } finally {
            server.stop();
        }
    }
View Full Code Here

        server.start();
        try {
            HttpRequest httpRequest = HttpRequest.get(server.baseUrl() + "/api/test/test.txt");
            assertThat(httpRequest.code()).isEqualTo(200);
            assertThat(httpRequest.contentType()).isEqualTo("text/plain; charset=UTF-8");
            assertThat(httpRequest.body().trim()).isEqualTo("hello");

            httpRequest = HttpRequest.put(server.baseUrl() + "/api/test/test.txt").send("bonjour");
            assertThat(httpRequest.code()).isEqualTo(HttpStatus.NOT_FOUND.getCode());
        } finally {
            server.stop();
View Full Code Here

                .setRouterPath("/api").setPort(WebServers.findAvailablePort()).build();
        server.start();
        try {
            HttpRequest httpRequest = HttpRequest.get(server.baseUrl() + "/api/test/");
            assertThat(httpRequest.code()).isEqualTo(200);
            assertThat(httpRequest.body().trim()).isEqualTo("[\n" +
                    "\"test.txt\"\n" +
                    "]");
        } 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.