Package com.mockrunner.mock.web

Examples of com.mockrunner.mock.web.MockHttpServletResponse


                   "<string>bar</string>" +
                "</foo>" +
              "</metadata>" +
            "</workspace>";
       
        MockHttpServletResponse response =
            putAsServletResponse("/rest/workspaces/gs", xml, "text/xml" );
        assertEquals( 200, response.getStatusCode() );
       
        Document dom = getAsDOM( "/rest/workspaces/gs.xml" );
        assertXpathEvaluatesTo("1", "count(//name[text()='gs'])", dom );
        assertXpathEvaluatesTo("1", "count(//entry[@key='foo' and text()='bar'])", dom );
       
View Full Code Here


        String xml =
            "<workspace>" +
              "<name>changed</name>" +
            "</workspace>";
       
        MockHttpServletResponse response =
            putAsServletResponse("/rest/workspaces/gs", xml, "text/xml" );
        assertEquals( 403, response.getStatusCode() );
    }
View Full Code Here

               "<string>bar</string>" +
            "</entry>" +
          "</metadata>" +
            "</workspace>";
       
        MockHttpServletResponse response =
            putAsServletResponse("/rest/workspaces/nonExistant", xml, "text/xml" );
        assertEquals( 404, response.getStatusCode() );
    }
View Full Code Here

   
    void addCoverageStore(boolean autoConfigureCoverage) throws Exception {
        URL zip = getClass().getResource( "test-data/usa.zip" );
        byte[] bytes = FileUtils.readFileToByteArray( DataUtilities.urlToFile(zip)  );
       
        MockHttpServletResponse response =
            putAsServletResponse( "/rest/workspaces/gs/coveragestores/usaWorldImage/file.worldimage" +
                (!autoConfigureCoverage ? "?configure=none" : ""), bytes, "application/zip");
        assertEquals( 201, response.getStatusCode() );
    }
View Full Code Here

                  "<string>EPSG:4326</string>"+
                "</responseSRS>"+
                "<store>usaWorldImage</store>"+
                "<namespace>gs</namespace>"+
              "</coverage>";
        MockHttpServletResponse response =
            postAsServletResponse( "/rest/workspaces/gs/coveragestores/usaWorldImage/coverages/", xml, "text/xml");
       
        assertEquals( 201, response.getStatusCode() );
        assertNotNull( response.getHeader( "Location") );
        assertTrue( response.getHeader("Location").endsWith( "/workspaces/gs/coveragestores/usaWorldImage/coverages/usa" ) );
       
        dom = getAsDOM( req );
        assertEquals( "wcs:Coverages", dom.getDocumentElement().getNodeName() );
    }
View Full Code Here

        String xml =
            "<coverage>"+
              "<name>foo</name>"+
            "</coverage>";
       
        MockHttpServletResponse response =
            postAsServletResponse( "/rest/workspaces/wcs/coveragestores/BlueMarble/coverages/BlueMarble", xml, "text/xml");
        assertEquals( 405, response.getStatusCode() );
    }
View Full Code Here

    public void testPut() throws Exception {
        String xml =
          "<coverage>" +
            "<title>new title</title>"
          "</coverage>";
        MockHttpServletResponse response =
            putAsServletResponse("/rest/workspaces/wcs/coveragestores/BlueMarble/coverages/BlueMarble", xml, "text/xml");
        assertEquals( 200, response.getStatusCode() );
       
        Document dom = getAsDOM("/rest/workspaces/wcs/coveragestores/BlueMarble/coverages/BlueMarble.xml");
        assertXpathEvaluatesTo("new title", "/coverage/title", dom );
       
        CoverageInfo c = catalog.getCoverageByName( "wcs", "BlueMarble");
View Full Code Here

    public void testPutNonExistant() throws Exception {
        String xml =
            "<coverage>" +
              "<title>new title</title>"
            "</coverage>";
          MockHttpServletResponse response =
              putAsServletResponse("/rest/workspaces/wcs/coveragestores/BlueMarble/coverages/NonExistant", xml, "text/xml");
          assertEquals( 404, response.getStatusCode() );
    }
View Full Code Here


public class CSVOutputFormatTest extends WFSTestSupport {

    public void testFullRequest() throws Exception {
        MockHttpServletResponse resp = getAsServletResponse("wfs?request=GetFeature&typeName=sf:PrimitiveGeoFeature&outputFormat=csv");
       
        FeatureSource fs = getFeatureSource(MockData.PRIMITIVEGEOFEATURE);
       
//        System.out.println(resp.getOutputStreamContent());
       
        // check the mime type
        assertEquals("text/csv", resp.getContentType());
       
        // check the content disposition
        assertEquals("attachment; filename=PrimitiveGeoFeature.csv", resp.getHeader("Content-Disposition"));
       
        // read the response back with a parser that can handle escaping, newlines and what not
        List<String[]> lines = readLines(resp.getOutputStreamContent());
       
        // we should have one header line and then all the features in that feature type
        assertEquals(fs.getCount(Query.ALL) + 1, lines.size());
       
        for (String[] line : lines) {
View Full Code Here

     * @return An input stream which is the result of the request.
     *
     * @throws Exception
     */
    protected InputStream get( String path ) throws Exception {
        MockHttpServletResponse response = getAsServletResponse(path);
        return new ByteArrayInputStream( response.getOutputStreamContent().getBytes() );
    }
View Full Code Here

TOP

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

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.