Package net.sf.jruby.rails.asyncweb.mock

Examples of net.sf.jruby.rails.asyncweb.mock.MockHttpResponse


    }

    public void testRun() throws Exception {
        try {
            MockHttpRequest request = new MockHttpRequest();
            MockHttpResponse response = new MockHttpResponse();

            request.setHttpResponse(response);

            request.setParameterString("");
            request.setRequestURI("/functional_test/get");

            request.setHeader("Host", "localhost");
            request.setHeader("Accept", "text/html, text/plain, text/sgml, */*;q=0.01");
            request.setHeader("Accept-Encoding", "gzip, compress");
            request.setHeader("Accept-Language", "ja, en");

            service.handleRequest(request);

            assertEquals(200, response.getStatus().getCode());
            assertEquals("OK", response.getReason());
            assertEquals("text/html", response.getContentType());
            assertEquals("Hello, World.", response.getOutputAsText());

        } catch (RaiseException e) {
            printJRubyBacktrace(e);
        }
    }
View Full Code Here


    public void testHandleRequest() throws Exception {
        MockHttpRequest request = new MockHttpRequest();
        request.setRequestURI("/robots.txt");

        MockHttpResponse response = new MockHttpResponse();
        response.setOutputStream(new ByteArrayOutputStream());

        request.setHttpResponse(response);
        service.handleRequest(request);

        assertEquals("text/plain", response.getContentType());
        assertEquals(ResponseStatus.OK, response.getStatus());
        assertEquals("# robots.txt", response.getOutputAsText());
    }
View Full Code Here

    public void testHandleRequestNot() throws Exception {
        MockHttpRequest request = new MockHttpRequest();
        request.setRequestURI("/robots.txt");
        request.setHeader("If-Modified-Since", "Wed, 01 Jan 3000 00:00:00 GMT");

        MockHttpResponse response = new MockHttpResponse();
        response.setOutputStream(new ByteArrayOutputStream());

        request.setHttpResponse(response);
        service.handleRequest(request);

        assertEquals(ResponseStatus.NOT_MODIFIED, response.getStatus());
        assertEquals("", response.getOutputAsText());
    }
View Full Code Here

TOP

Related Classes of net.sf.jruby.rails.asyncweb.mock.MockHttpResponse

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.