Package com.vtence.molecule

Examples of com.vtence.molecule.Application


        response.assertBody("An acceptable encoding could not be found");
    }

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


        assertThat("body", response.text(), equalTo("uncompressed body"));
    }

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

    MockResponse response = new MockResponse();

    @Test public void
    logsRequestsServedInApacheCommonLogFormat() throws Exception {
        request.remoteIp("192.168.0.1").method(GET).uri("/products?keyword=dogs");
        apacheCommonLogger.connectTo(new Application() {
            public void handle(Request request, Response response) throws Exception {
                response.body("a response with a size of 28");
                response.status(HttpStatus.OK);
            }
        });
View Full Code Here

    }

    @Test public void
    hyphenReplacesContentSizeForEmptyResponses() throws Exception {
        request.remoteIp("192.168.0.1").method(DELETE).uri("/logout");
        apacheCommonLogger.connectTo(new Application() {
            public void handle(Request request, Response response) throws Exception {
                response.body("");
                response.status(HttpStatus.NO_CONTENT);
            }
        });
View Full Code Here

        request.assertAttribute(Connection.class, nullValue());
    }

    private Application crashWith(final HttpException error) {
        return new Application() {
            public void handle(Request request, Response response) throws Exception {
                throw error;
            }
        };
    }
View Full Code Here

            }
        };
    }

    private Application reportPresenceOfAttribute(final Object key, final Object value) {
        return new Application() {
            public void handle(Request request, Response response) throws Exception {
                response.body(request.attribute(key) == value ? "on" : "off");
            }
        };
    }
View Full Code Here

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

    @Before public void
    stubApplication() {
        filters.connectTo(new Application() {
            public void handle(Request request, Response response) throws Exception {
                response.set("content", "content");
            }
        });
    }
View Full Code Here

        serverHeader.handle(request, response);
        assertServer(serverName);
    }

    private Application write(final String text) {
        return new Application() {
            public void handle(Request request, Response response) throws Exception {
                response.body(text);
            }
        };
    }
View Full Code Here

            }
        };
    }

    private Application echoSessionId() {
        return new Application() {
            public void handle(Request request, Response response) throws Exception {
                Session session = Session.get(request);
                response.body("Session: " + session.id());
            }
        };
View Full Code Here

            }
        };
    }

    private Application incrementCounter() {
        return new Application() {
            public void handle(Request request, Response response) throws Exception {
                Session session = Session.get(request);
                Integer counter = session.contains("counter") ? session.<Integer>get("counter") : 0;
                session.put("counter", counter++);
                response.body("Counter: " + counter);
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.