Package com.github.kevinsawicki.http

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


                        .allowDirectoryListing().readonly().on("/test"))
                .build())
                .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


                        .allowDirectoryListing().on("/test"))
                .build())
                .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]");

            httpRequest = HttpRequest.put(server.baseUrl() + "/api/test/test.txt").send("bonjour");
            assertThat(httpRequest.code()).isEqualTo(HttpStatus.CREATED.getCode());

            httpRequest = HttpRequest.get(server.baseUrl() + "/api/test/test.txt");
            assertThat(httpRequest.code()).isEqualTo(200);
            assertThat(httpRequest.body().trim()).isEqualTo("bonjour");

            httpRequest = HttpRequest.get(server.baseUrl() + "/api/test/");
            assertThat(httpRequest.code()).isEqualTo(200);
            assertThat(httpRequest.body().trim()).isEqualTo("[\n" +
                    "\"test.txt\"\n" +
                    "]");

            httpRequest = HttpRequest.put(server.baseUrl() + "/api/test/test.txt").send("hello");
            assertThat(httpRequest.code()).isEqualTo(HttpStatus.ACCEPTED.getCode());

            httpRequest = HttpRequest.get(server.baseUrl() + "/api/test/test.txt");
            assertThat(httpRequest.code()).isEqualTo(200);
            assertThat(httpRequest.body().trim()).isEqualTo("hello");

            httpRequest = HttpRequest.put(server.baseUrl() + "/api/test/test2.txt").send("bonjour");
            assertThat(httpRequest.code()).isEqualTo(HttpStatus.CREATED.getCode());

            httpRequest = HttpRequest.get(server.baseUrl() + "/api/test/");
            assertThat(httpRequest.code()).isEqualTo(200);
            assertThat(httpRequest.body().trim()).isIn("[\n" +
                    "\"test.txt\",\n" +
                    "\"test2.txt\"\n" +
                    "]", "[\n" +
                    "\"test2.txt\",\n" +
                    "\"test.txt\"\n" +
                    "]");

            httpRequest = HttpRequest.delete(server.baseUrl() + "/api/test/test.txt");
            assertThat(httpRequest.code()).isEqualTo(HttpStatus.NO_CONTENT.getCode());
            httpRequest = HttpRequest.delete(server.baseUrl() + "/api/test/test2.txt");
            assertThat(httpRequest.code()).isEqualTo(HttpStatus.NO_CONTENT.getCode());

            httpRequest = HttpRequest.get(server.baseUrl() + "/api/test/");
            assertThat(httpRequest.code()).isEqualTo(200);
            assertThat(httpRequest.body().trim()).isEqualTo("[\n]");

            httpRequest = HttpRequest.put(server.baseUrl() + "/api/test/dir/").send("[]");
            assertThat(httpRequest.code()).isEqualTo(HttpStatus.CREATED.getCode());

            httpRequest = HttpRequest.get(server.baseUrl() + "/api/test/");
            assertThat(httpRequest.code()).isEqualTo(200);
            assertThat(httpRequest.body().trim()).isEqualTo("[\n" +
                    "\"dir/\"\n" +
                    "]");

            httpRequest = HttpRequest.get(server.baseUrl() + "/api/test/dir/");
            assertThat(httpRequest.code()).isEqualTo(200);
            assertThat(httpRequest.body().trim()).isEqualTo("[\n]");

            httpRequest = HttpRequest.delete(server.baseUrl() + "/api/test/dir/");
            assertThat(httpRequest.code()).isEqualTo(HttpStatus.NO_CONTENT.getCode());

            httpRequest = HttpRequest.get(server.baseUrl() + "/api/test/");
            assertThat(httpRequest.code()).isEqualTo(200);
            assertThat(httpRequest.body().trim()).isEqualTo("[\n]");

            httpRequest = HttpRequest.put(server.baseUrl() + "/api/test/dir/test.txt").send("bonjour");
            assertThat(httpRequest.code()).isEqualTo(HttpStatus.CREATED.getCode());

            httpRequest = HttpRequest.get(server.baseUrl() + "/api/test/dir/test.txt");
            assertThat(httpRequest.code()).isEqualTo(200);
            assertThat(httpRequest.body().trim()).isEqualTo("bonjour");
        } finally {
            server.stop();
        }
    }
View Full Code Here

TOP

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

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.