Package com.mockrunner.mock.web

Examples of com.mockrunner.mock.web.MockHttpServletResponse


    public void testKvpBasic() throws Exception {
        String request = "wcs?service=WCS&version=1.1.1&request=GetCoverage" + "&identifier="
                + layerId(TASMANIA_BM)
                + "&BoundingBox=-90,-180,90,180,urn:ogc:def:crs:EPSG:4326"
                + "&GridBaseCRS=urn:ogc:def:crs:EPSG:4326" + "&format=geotiff";
        MockHttpServletResponse response = getAsServletResponse(request);
        // System.out.println(response.getOutputStreamContent());
        // make sure we got a multipart
        assertTrue(response.getContentType().matches("multipart/related;\\s*boundary=\".*\""));

        // parse the multipart, check there are two parts
        Multipart multipart = getMultipart(response);
        assertEquals(2, multipart.getCount());

View Full Code Here


    public void testTiffOutput() throws Exception {
        String request = "wcs?service=WCS&version=1.1.1&request=GetCoverage" + "&identifier="
                + layerId(TASMANIA_BM)
                + "&BoundingBox=-90,-180,90,180,urn:ogc:def:crs:EPSG:4326"
                + "&GridBaseCRS=urn:ogc:def:crs:EPSG:4326" + "&format=image/tiff";
        MockHttpServletResponse response = getAsServletResponse(request);

        // parse the multipart, check there are two parts
        Multipart multipart = getMultipart(response);
        assertEquals(2, multipart.getCount());
        BodyPart coveragePart = multipart.getBodyPart(1);
View Full Code Here

    public void testPngOutput() throws Exception {
        String request = "wcs?service=WCS&version=1.1.1&request=GetCoverage" + "&identifier="
                + layerId(TASMANIA_BM)
                + "&BoundingBox=-90,-180,90,180,urn:ogc:def:crs:EPSG:4326"
                + "&GridBaseCRS=urn:ogc:def:crs:EPSG:4326" + "&format=image/png";
        MockHttpServletResponse response = getAsServletResponse(request);

        // parse the multipart, check there are two parts
        Multipart multipart = getMultipart(response);
        assertEquals(2, multipart.getCount());
        BodyPart coveragePart = multipart.getBodyPart(1);
View Full Code Here

              "<maxy>1.0</maxy>"+
              "<crs>EPSG:4326</crs>" +
            "</nativeBoundingBox>"+
            "<store>pds</store>" +
          "</featureType>";
        MockHttpServletResponse response =
            postAsServletResponse( "/rest/workspaces/gs/datastores/pds/featuretypes/", xml, "text/xml");
       
        assertEquals( 201, response.getStatusCode() );
        assertNotNull( response.getHeader( "Location") );
        assertTrue( response.getHeader("Location").endsWith( "/workspaces/gs/datastores/pds/featuretypes/pdsa" ) );
       
        dom = getAsDOM( "wfs?request=getfeature&typename=gs:pdsa");
        assertEquals( "wfs:FeatureCollection", dom.getDocumentElement().getNodeName());
        assertEquals( 2, dom.getElementsByTagName( "gs:pdsa").getLength());
    }
View Full Code Here

              "}," +
              "'nativeCRS':'EPSG:4326'," +
              "'store':'pds'" +
             "}" +
          "}";
        MockHttpServletResponse response = 
            postAsServletResponse( "/rest/workspaces/gs/datastores/pds/featuretypes/", json, "text/json");
       
        assertEquals( 201, response.getStatusCode() );
        assertNotNull( response.getHeader( "Location") );
        assertTrue( response.getHeader("Location").endsWith( "/workspaces/gs/datastores/pds/featuretypes/pdsa" ) );
       
        dom = getAsDOM( "wfs?request=getfeature&typename=gs:pdsa");
        assertEquals( "wfs:FeatureCollection", dom.getDocumentElement().getNodeName());
        assertEquals( 2, dom.getElementsByTagName( "gs:pdsa").getLength());
    }
View Full Code Here

        String xml =
            "<featureType>"+
              "<name>pdsa</name>"+
            "</featureType>";
       
        MockHttpServletResponse response =
            postAsServletResponse( "/rest/workspaces/gs/datastores/pds/featuretypes/pdsa", xml, "text/xml");
        assertEquals( 405, response.getStatusCode() );
    }
View Full Code Here

    public void testPut() throws Exception {
        String xml =
          "<featureType>" +
            "<title>new title</title>"
          "</featureType>";
        MockHttpServletResponse response =
            putAsServletResponse("/rest/workspaces/sf/datastores/sf/featuretypes/PrimitiveGeoFeature", xml, "text/xml");
        assertEquals( 200, response.getStatusCode() );
       
        Document dom = getAsDOM("/rest/workspaces/sf/datastores/sf/featuretypes/PrimitiveGeoFeature.xml");
        assertXpathEvaluatesTo("new title", "/featureType/title", dom );
       
        FeatureTypeInfo ft = catalog.getFeatureTypeByName( "sf", "PrimitiveGeoFeature");
View Full Code Here

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

        String xml =
            "<featureType>" +
              "<name>ngpdsa</name>" +
            "</featureType>";
       
      MockHttpServletResponse response =
          postAsServletResponse("/rest/workspaces/gs/datastores/ngpds/featuretypes", xml, "text/xml");
      assertEquals( 201, response.getStatusCode() );
      assertNotNull( response.getHeader( "Location") );
      assertTrue( response.getHeader("Location").endsWith( "/workspaces/gs/datastores/ngpds/featuretypes/ngpdsa" ) );
    }
View Full Code Here

    public void testWorldImageUploadZipped() throws Exception {
        URL zip = getClass().getResource( "test-data/usa.zip" );
        byte[] bytes = FileUtils.readFileToByteArray( DataUtilities.urlToFile(zip) );
       
        MockHttpServletResponse response =
            putAsServletResponse( "/rest/workspaces/gs/coveragestores/usa/file.worldimage", bytes, "application/zip");
        assertEquals( 201, response.getStatusCode() );
       
        String content = response.getOutputStreamContent();
        Document d = dom( new ByteArrayInputStream( content.getBytes() ));
        assertEquals( "coverageStore", d.getDocumentElement().getNodeName());

    }
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.