Package com.vtence.molecule

Examples of com.vtence.molecule.Application


    MockRequest request = new MockRequest();
    MockResponse response = new MockResponse();

    @Test public void
    deflatesResponseWhenClientAcceptsDeflate() throws Exception {
        compressor.connectTo(new Application() {
            public void handle(Request request, Response response) throws Exception {
                response.body("uncompressed body");
            }
        });
View Full Code Here


        assertThat("body", inflate(response), equalTo("uncompressed body"));
    }

    @Test public void
    gzipsResponseWhenClientAcceptsGZip() throws Exception {
        compressor.connectTo(new Application() {
            public void handle(Request request, Response response) throws Exception {
                response.body("uncompressed body");
            }
        });
View Full Code Here

        assertThat("body", unzip(response), equalTo("uncompressed body"));
    }

    @Test public void
    usesFirstAcceptedContentCoding() throws Exception {
        compressor.connectTo(new Application() {
            public void handle(Request request, Response response) throws Exception {
                response.body("uncompressed body");
            }
        });
View Full Code Here

        assertThat("body", unzip(response), equalTo("uncompressed body"));
    }

    @Test public void
    skipsCompressionOfEmptyContent() throws Exception {
        compressor.connectTo(new Application() {
            public void handle(Request request, Response response) throws Exception {
            }
        });

        request.header("Accept-Encoding", "deflate");
View Full Code Here

        response.assertNoHeader("Content-Encoding");
    }

    @Test public void
    removesContentLengthHeaderWhenCompressing() throws Exception {
        compressor.connectTo(new Application() {
            public void handle(Request request, Response response) throws Exception {
                response.contentLength(128);
                response.body("uncompressed body...");
            }
        });
View Full Code Here

        response.assertNoHeader("Content-Length");
    }

    @Test public void
    fallsBackToNoCompressionWhenClientDoesNotAcceptOurEncodings() throws Exception {
        compressor.connectTo(new Application() {
            public void handle(Request request, Response response) throws Exception {
                response.body("uncompressed body");
            }
        });
View Full Code Here

        response.assertBody("uncompressed body");
    }

    @Test public void
    preservesContentLengthOfIdentityResponses() throws Exception {
        compressor.connectTo(new Application() {
            public void handle(Request request, Response response) throws Exception {
                response.contentLength(128);
                response.body("uncompressed body...");
            }
        });
View Full Code Here

        response.assertHeader("Content-Length", "128");
    }

    @Test public void
    skipsCompressionIfResponseAlreadyEncoded() throws Exception {
        compressor.connectTo(new Application() {
            public void handle(Request request, Response response) throws Exception {
                response.set("Content-Encoding", "deflate");
                response.body("<compressed body>");
            }
        });
View Full Code Here

        response.assertBody("<compressed body>");
    }

    @Test public void
    compressesAnywayWhenContentEncodingIsIdentity() throws Exception {
        compressor.connectTo(new Application() {
            public void handle(Request request, Response response) throws Exception {
                response.set("Content-Encoding", "identity");
                response.body("uncompressed body");
            }
        });
View Full Code Here

        assertThat("body", unzip(response), equalTo("uncompressed body"));
    }

    @Test public void
    reportsLackOfAnAcceptableEncoding() throws Exception {
        compressor.connectTo(new Application() {
            public void handle(Request request, Response response) throws Exception {
                response.body("uncompressed body");
            }
        });
        request.header("Accept-Encoding", "identity;q=0");
View Full Code Here

TOP

Related Classes of com.vtence.molecule.Application

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.