Package org.webbitserver

Examples of org.webbitserver.HttpHandler


        final CountDownLatch latch = new CountDownLatch(1);
        final CountDownLatch latch2 = new CountDownLatch(1);
        final CountDownLatch latch3 = new CountDownLatch(1);

        webServer.add(new HttpHandler() {
            @Override
            public void handleHttpRequest(HttpRequest request, HttpResponse response, HttpControl control) throws Exception {
                response.content("length:" + request.bodyAsBytes().length);
                latch2.countDown();
                latch.await();
View Full Code Here


        webServer.stop().get();
    }

    @Test
    public void compressedPostIsUncompressedProperly() throws IOException, ExecutionException, InterruptedException {
        webServer.add(new HttpHandler() {
            @Override
            public void handleHttpRequest(HttpRequest request, HttpResponse response, HttpControl control)
                    throws Exception {
                response.content(request.body()).end();
            }
View Full Code Here

        assertEquals(content, result);
    }

    @Test
    public void compressedResponseIsSentProperly() throws IOException, ExecutionException, InterruptedException {
        webServer.add(new HttpHandler() {
            @Override
            public void handleHttpRequest(HttpRequest request, HttpResponse response, HttpControl control)
                    throws Exception {
                response.content(content).end();
            }
View Full Code Here

    @Test
    public void closesConnectionAfterTimeoutIfClientKeepsConnectioOpen() throws IOException, InterruptedException, ExecutionException {
        webServer
                .staleConnectionTimeout(100)
                .add(new HttpHandler() {
                    @Override
                    public void handleHttpRequest(HttpRequest request, HttpResponse response, HttpControl control)
                            throws Exception {
                        response.content("Body = {" + request.body() + "}");
                        response.header("Content-Length",
View Full Code Here

import static org.mockito.Mockito.verifyZeroInteractions;

public class PathMatchHandlerTest {
    @Test
    public void matchesRequestWithFullUri() throws Exception {
        HttpHandler handler = mock(HttpHandler.class);
        PathMatchHandler pmh = new PathMatchHandler("/hello", handler);

        HttpRequest req = new StubHttpRequest("http://host.com:8080/hello");
        HttpResponse res = new StubHttpResponse();
        HttpControl ctl = new StubHttpControl();
View Full Code Here

        verify(handler).handleHttpRequest(req, res, ctl);
    }

    @Test
    public void matchesRequestWithPathOnly() throws Exception {
        HttpHandler handler = mock(HttpHandler.class);
        PathMatchHandler pmh = new PathMatchHandler("/hello", handler);

        HttpRequest req = new StubHttpRequest("/hello");
        HttpResponse res = new StubHttpResponse();
        HttpControl ctl = new StubHttpControl();
View Full Code Here

        verify(handler).handleHttpRequest(req, res, ctl);
    }

    @Test
    public void matchesRequestWithRegexpPath() throws Exception {
        HttpHandler handler = mock(HttpHandler.class);
        PathMatchHandler pmh = new PathMatchHandler("/hello/.*", handler);

        HttpRequest req = new StubHttpRequest("/hello/world");
        HttpResponse res = new StubHttpResponse();
        HttpControl ctl = new StubHttpControl();
View Full Code Here

        verify(handler).handleHttpRequest(req, res, ctl);
    }

    @Test
    public void handsOffWhenIllegalURIPath() throws Exception {
        HttpHandler handler = mock(HttpHandler.class);
        PathMatchHandler pmh = new PathMatchHandler("/hello", handler);

        HttpRequest req = new StubHttpRequest("//");
        HttpResponse res = new StubHttpResponse();
        HttpControl ctl = mock(HttpControl.class);
View Full Code Here

        verify(ctl).nextHandler();
    }

    @Test
    public void handsOffWhenNoMatch() throws Exception {
        HttpHandler handler = mock(HttpHandler.class);
        PathMatchHandler pmh = new PathMatchHandler("/hello", handler);

        HttpRequest req = new StubHttpRequest("http://hello.com:8080/wtf");
        HttpResponse res = new StubHttpResponse();
        HttpControl ctl = mock(HttpControl.class);
View Full Code Here

        webServer.stop().get();
    }

    @Test
    public void setsOneOutboundCookie() throws IOException, InterruptedException, ExecutionException {
        webServer.add(new HttpHandler() {
            @Override
            public void handleHttpRequest(HttpRequest request, HttpResponse response, HttpControl control) throws Exception {
                response.cookie(new HttpCookie("a", "b")).end();
            }
        }).start().get();
View Full Code Here

TOP

Related Classes of org.webbitserver.HttpHandler

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.