Package com.vtence.molecule

Examples of com.vtence.molecule.Application


        response.assertNotChunked();
    }

    @Test public void
    encodesResponsesAccordingToContentType() throws IOException {
        server.run(new Application() {
            public void handle(Request request, Response response) throws Exception {
                response.contentType("text/plain; charset=utf-16");
                response.body("This content requires encoding &âçüè!");
                response.status(HttpStatus.OK);
            }
View Full Code Here


        response.assertContentIsEncodedAs("UTF-16");
    }

    @Test public void
    supportsArrayParameters() throws IOException {
        server.run(new Application() {
            public void handle(Request request, Response response) throws Exception {
                response.body(request.parameters("names").toString());
            }
        });
View Full Code Here

    @SuppressWarnings("unchecked")
    @Test public void
    providesGeneralRequestInformation() throws IOException {
        final Map<String, String> info = new HashMap<String, String>();
        server.run(new Application() {
            public void handle(Request request, Response response) throws Exception {
                info.put("uri", request.uri());
                info.put("path", request.path());
                info.put("ip", request.remoteIp());
                info.put("hostname", request.remoteHost());
View Full Code Here

    @SuppressWarnings("unchecked")
    @Test public void
    supportsRequestHeaders() throws IOException {
        final Map<String, Iterable<String>> headers = new HashMap<String, Iterable<String>>();
        server.run(new Application() {
            public void handle(Request request, Response response) throws Exception {
                headers.put("names", request.headerNames());
                headers.put("accept", Arrays.asList(request.header("Accept")));
                headers.put("encoding", request.headers("Accept-Encoding"));
            }
View Full Code Here

    @SuppressWarnings("unchecked")
    @Test public void
    detailsRequestContent() throws IOException {
        final Map<String, String> content = new HashMap<String, String>();
        server.run(new Application() {
            public void handle(Request request, Response response) throws Exception {
                content.put("contentType", String.valueOf(request.contentType()));
                content.put("contentLength", String.valueOf(request.contentLength()));
                content.put("body", request.body());
            }
View Full Code Here

    }

    @Test public void
    readsRequestCookies() throws IOException {
        final Map<String, String> cookies = new HashMap<String, String>();
        server.run(new Application() {
            public void handle(Request request, Response response) throws Exception {
                for (Cookie cookie : request.cookies()) {
                    cookies.put(cookie.name(), cookie.value());
                }
            }
View Full Code Here

                hasEntry("cookie2", "value2")));
    }

    @Test public void
    setsResponseCookies() throws IOException {
        server.run(new Application() {
            public void handle(Request request, Response response) throws Exception {
                Cookie cookie = new Cookie("cookie", "value");
                cookie.httpOnly(true);
                cookie.maxAge(1800);
                response.add(cookie);
View Full Code Here

    }

    @Test public void
    supportsRequestAttributes() throws IOException {
        final Map<Object, Object> attributes = new HashMap<Object, Object>();
        server.run(new Application() {
            public void handle(Request request, Response response) throws Exception {
                request.attribute("name", "Velociraptor");
                request.attribute("family", "Dromaeosauridae");
                request.attribute("clade", "Dinosauria");
                request.removeAttribute("family");
View Full Code Here

            assertThat("error", e, sameInstance(error));
        }
    }

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

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

    @Test public void
    sendsNotModifiedWithoutMessageBodyWhenETagIndicatesEntityIsCurrent() throws Exception {
        conditional.connectTo(new Application() {
            public void handle(Request request, Response response) throws Exception {
                response.set("ETag", "12345678")
                        .contentType("text/plain").contentLength(32).body("response content");
            }
        });
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.