Package com.mockrunner.mock.web

Examples of com.mockrunner.mock.web.MockHttpServletRequest


        super.setUp();
       
        HelloWorld helloWorld = new HelloWorld();
        Service service = new Service("hello", helloWorld, new Version("1.0.0"),Collections.singletonList("hello"));

        request = new MockHttpServletRequest() {
                public int getServerPort() {
                    return 8080;
                }
            };
View Full Code Here


     * </p>
     * @param path The path for the request and optional the query string.
     * @return
     */
    protected MockHttpServletRequest createRequest(String path) {
        MockHttpServletRequest request = new GeoServerMockHttpServletRequest();

        request.setScheme("http");
        request.setServerName("localhost");
        request.setContextPath("/geoserver");
        request.setRequestURI(ResponseUtils.stripQueryString(ResponseUtils.appendPath(
                    "/geoserver/", path)));
        request.setRequestURL(ResponseUtils.appendPath("http://localhost/geoserver", path ) );
        request.setQueryString(ResponseUtils.getQueryString(path));
        request.setRemoteAddr("127.0.0.1");
        request.setServletPath(ResponseUtils.makePathAbsolute( ResponseUtils.stripRemainingPath(path)) );
        request.setPathInfo(ResponseUtils.makePathAbsolute( ResponseUtils.stripBeginningPath( path)));
       
        kvp(request, path);

        MockHttpSession session = new MockHttpSession();
        session.setupServletContext(new MockServletContext());
        request.setSession(session);

        request.setUserPrincipal(null);

        return request;
    }
View Full Code Here

     * @return the mock servlet response
     *
     * @throws Exception
     */
    protected MockHttpServletResponse getAsServletResponse( String path ) throws Exception {
        MockHttpServletRequest request = createRequest( path );
        request.setMethod( "GET" );
        request.setBodyContent(new byte[]{});
       
        return dispatch( request );
    }
View Full Code Here

     * @return An input stream which is the result of the request.
     *
     * @throws Exception
     */
    protected InputStream post( String path ) throws Exception {
        MockHttpServletRequest request = createRequest( path );
        request.setMethod( "POST" );
        request.setContentType( "application/x-www-form-urlencoded" );
        request.setBodyContent(new byte[]{});
       
        MockHttpServletResponse response = dispatch( request );
        return new ByteArrayInputStream( response.getOutputStreamContent().getBytes() );
    }
View Full Code Here

    }
   
    protected MockHttpServletResponse putAsServletResponse(String path, byte[] body, String contentType )
        throws Exception {
       
        MockHttpServletRequest request = createRequest(path);
        request.setMethod("PUT");
        request.setContentType(contentType);
        request.setBodyContent(body);
        request.setHeader( "Content-type", contentType );

        return dispatch(request);
    }
View Full Code Here

        MockHttpServletResponse response = postAsServletResponse(path, body, contentType);
        return new ByteArrayInputStream(response.getOutputStreamContent().getBytes());
    }
   
    protected MockHttpServletResponse postAsServletResponse(String path, String body, String contentType) throws Exception {
        MockHttpServletRequest request = createRequest(path);
        request.setMethod("POST");
        request.setContentType(contentType);
        request.setBodyContent(body);
        request.setHeader("Content-type",  contentType );

        return dispatch(request);
    }
View Full Code Here

     * @param path The path of the request.
     *
     * @return The http status code.
     */
    protected MockHttpServletResponse deleteAsServletResponse(String path) throws Exception {
        MockHttpServletRequest request = createRequest(path);
        request.setMethod("DELETE");
       
        return dispatch(request);
    }
View Full Code Here

     * For example, to make a request to "http://localhost:8080/geoserver/ows" the path would be "ows"
     * @param body the body for the request.  May be empty, but must not be null.
     * @param type the mimetype for the request.
     */
    protected void assertStatusCodeForRequest(int code, String method, String path, String body, String type) throws Exception {
        MockHttpServletRequest request = createRequest(path);
        request.setMethod(method);
        request.setBodyContent(body);
        request.setContentType(type);

        CodeExpectingHttpServletResponse response = new CodeExpectingHttpServletResponse(new MockHttpServletResponse());
        dispatch(request, response);
        assertEquals(code, response.getErrorCode());
    }
View Full Code Here

        Capture<TileObject> captured = new Capture<TileObject>();
        expect(mockStorageBroker.put(EasyMock.capture(captured))).andReturn(true).anyTimes();
        replay(mockStorageBroker);

        String layerId = layer.getName();
        HttpServletRequest servletReq = new MockHttpServletRequest();
        HttpServletResponse servletResp = new MockHttpServletResponse();

        long[] gridLoc = { 0, 0, 0 };// x, y, level
        MimeType mimeType = layer.getMimeTypes().get(0);
        GridSet gridSet = gridSetBroker.WORLD_EPSG4326;
View Full Code Here

        GridSetBroker gsb = new GridSetBroker(true, true);

        wmsLayer.initialize(gsb);

        MockHttpServletRequest request = new MockHttpServletRequest();
        HttpServletResponse response = null;

        request.setupAddParameter(CQL_FILTER_PARAMETER_NAME, CQL_FILTER_PARAMETER_VALUE);
        request.setupAddParameter("layers", new String[] { TEST_LAYER_NAME });
        request.setupAddParameter("zoom", "12");
        request.setupAddParameter("x", "0");
        request.setupAddParameter("y", "0");

        GMapsConverter converter = new GMapsConverter(sb, tld, gsb);

        try {
            ConveyorTile conveyorTile = converter.getConveyor(request, response);
View Full Code Here

TOP

Related Classes of com.mockrunner.mock.web.MockHttpServletRequest

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.