/** * Test DXF-ZIP format. * @throws Exception */ @Test public void testZipOutput() throws Exception { MockHttpServletResponse resp = getAsServletResponse("wfs?request=GetFeature&version=1.1.0&typeName=Points&outputFormat=dxf-zip"); // check mime type assertEquals("application/zip", resp.getContentType()); }
public void testExcel97OutputFormat() throws Exception { // grab the real binary stream, avoiding mangling to due char conversion MockHttpServletResponse resp = getAsServletResponse("wfs?request=GetFeature&version=1.0.0&typeName=sf:PrimitiveGeoFeature&outputFormat=excel"); InputStream in = getBinaryInputStream(resp); // check the mime type assertEquals("application/msexcel", resp.getContentType()); // check the content disposition assertEquals("attachment; filename=PrimitiveGeoFeature.xls", resp.getHeader("Content-Disposition")); HSSFWorkbook wb = new HSSFWorkbook(in); testExcelOutputFormat( wb ); }
public void testElevationFirst() throws Exception { String request = getWaterTempElevationRequest("0.0"); MockHttpServletResponse response = postAsServletResponse("wcs", request); assertEquals("image/tiff;subtype=\"geotiff\"", response.getContentType()); // same result as time first checkTimeCurrent(response); }
public void testProcessChainingKVP() throws Exception { String nested = "http://geoserver/wps?service=WPS&version=1.0.0&request=Execute&Identifier=JTS:buffer" + "&DataInputs=" + urlEncode("geom=POINT(0 0)@mimetype=application/wkt;distance=10") + "&RawDataOutput=result"; String request = "wps?service=WPS&version=1.0.0&request=Execute&Identifier=JTS:area" + "&DataInputs=" + urlEncode("geom=@href=" + nested) + "&RawDataOutput=result"; MockHttpServletResponse resp = getAsServletResponse(request); assertEquals("text/plain", resp.getContentType()); // the result is inaccurate since the buffer is just a poor approximation of a circle assertTrue(resp.getOutputStreamContent().matches("312\\..*")); }
public void testExcel2007OutputFormat() throws Exception { // grab the real binary stream, avoiding mangling to due char conversion MockHttpServletResponse resp = getAsServletResponse("wfs?request=GetFeature&version=1.0.0&typeName=sf:PrimitiveGeoFeature&outputFormat=excel2007"); InputStream in = getBinaryInputStream(resp); // check the mime type assertEquals("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", resp.getContentType()); // check the content disposition assertEquals("attachment; filename=PrimitiveGeoFeature.xlsx", resp.getHeader("Content-Disposition")); XSSFWorkbook wb = new XSSFWorkbook(in); testExcelOutputFormat( wb ); }
public void testPngIntegration() throws Exception { String layerId = getLayerId(MockData.BASIC_POLYGONS); MockHttpServletResponse sr = getAsServletResponse("gwc/service/wmts?request=GetTile&layer=" + layerId + "&format=image/png&tilematrixset=EPSG:4326&tilematrix=EPSG:4326:0&tilerow=0&tilecol=0"); assertEquals(200, sr.getErrorCode()); assertEquals("image/png", sr.getContentType()); }
@Test public void testGetAllCount() throws Exception { MockHttpServletResponse response = getAsServletResponse(root() + "data/sf:PrimitiveGeoFeature?mode=count"); assertEquals(200, response.getStatusCode()); assertTrue(response.getContentType().startsWith(MediaType.TEXT_PLAIN.getName())); assertEquals("5", response.getOutputStreamContent()); }
@Test public void testSort() throws Exception { // property data store does not support sorting MockHttpServletResponse response = getAsServletResponse(root() + "data/cite:Buildings?order_by=ADDRESS"); assertEquals(500, response.getStatusCode()); assertEquals(MediaType.TEXT_PLAIN.getName(), response.getContentType()); }
@Test public void testLimitOffset() throws Exception { // property data store does not support offset MockHttpServletResponse response = getAsServletResponse(root() + "data/cite:Buildings?limit=1&offset=2"); assertEquals(500, response.getStatusCode()); assertEquals(MediaType.TEXT_PLAIN.getName(), response.getContentType()); }
@Test public void testGetAll() throws Exception { MockHttpServletResponse response = getAsServletResponse(root() + "data/sf:PrimitiveGeoFeature"); assertEquals(200, response.getStatusCode()); assertEquals(MediaType.APPLICATION_JSON.getName(), response.getContentType()); JSONObject features = (JSONObject) json(response); // print(features); assertEquals("FeatureCollection", features.getString("type")); assertEquals(5 , features.getJSONArray("features").size()); }
public void testWKTInlineKVPRawOutput() throws Exception { String request = "wps?service=WPS&version=1.0.0&request=Execute&Identifier=JTS:buffer" + "&DataInputs=" + urlEncode("geom=POLYGON((1 1, 2 1, 2 2, 1 2, 1 1))@mimetype=application/wkt;distance=1") + "&RawDataOutput=" + urlEncode("result=@mimetype=application/wkt"); MockHttpServletResponse response = getAsServletResponse(request); // System.out.println(response.getOutputStreamContent()); assertEquals("application/wkt", response.getContentType()); Geometry g = new WKTReader().read(response.getOutputStreamContent()); assertTrue(g instanceof Polygon); }
@Test public void testGetMissingLayer() throws Exception { MockHttpServletResponse response = getAsServletResponse(root() + "data/abc:notThere"); assertEquals(404, response.getStatusCode()); assertEquals(MediaType.TEXT_PLAIN.getName(), response.getContentType()); assertEquals("No such layer: abc:notThere", response.getOutputStreamContent()); }
@Test public void testLimit() throws Exception { MockHttpServletResponse response = getAsServletResponse(root() + "data/cite:Buildings?limit=1"); assertEquals(200, response.getStatusCode()); assertEquals(MediaType.APPLICATION_JSON.getName(), response.getContentType()); JSONObject collection = (JSONObject) json(response); testFirstBuilding(collection); }
@Test public void testPointFilter() throws Exception { MockHttpServletResponse response = getAsServletResponse(root() + "data/cite:Buildings?lon=0.0008&lat=0.0005&tolerance=0.0001"); assertEquals(200, response.getStatusCode()); assertEquals(MediaType.APPLICATION_JSON.getName(), response.getContentType()); JSONObject collection = (JSONObject) json(response); testFirstBuilding(collection); }
@Test public void testPointFilterLarge() throws Exception { MockHttpServletResponse response = getAsServletResponse(root() + "data/cite:Buildings?lon=0.0008&lat=0.0005&tolerance=0.01"); assertEquals(200, response.getStatusCode()); assertEquals(MediaType.APPLICATION_JSON.getName(), response.getContentType()); JSONObject collection = (JSONObject) json(response); // print(collection); testAllBuildings(collection); }
@Test public void testEqualityFilter() throws Exception { MockHttpServletResponse response = getAsServletResponse(root() + "data/cite:Buildings?queryable=FID&FID__eq=113"); assertEquals(200, response.getStatusCode()); assertEquals(MediaType.APPLICATION_JSON.getName(), response.getContentType()); JSONObject collection = (JSONObject) json(response); testFirstBuilding(collection); }
@Test public void testILikeFilter() throws Exception { MockHttpServletResponse response = getAsServletResponse(root() + "data/cite:Buildings?queryable=ADDRESS&ADDRESS__ilike=123%20m%25"); assertEquals(200, response.getStatusCode()); assertEquals(MediaType.APPLICATION_JSON.getName(), response.getContentType()); JSONObject collection = (JSONObject) json(response); // print(collection); testFirstBuilding(collection); }
@Test public void testDescribeMissingLayer() throws Exception { MockHttpServletResponse response = getAsServletResponse(root() + "describe/abc:notThere"); assertEquals(404, response.getStatusCode()); assertEquals(MediaType.TEXT_PLAIN.getName(), response.getContentType()); assertEquals("No such layer: abc:notThere", response.getOutputStreamContent()); }
@Test public void testGetCoverage() throws Exception { final String tasmania = getLayerId(MockData.TASMANIA_BM); MockHttpServletResponse response = getAsServletResponse(root() + "data/" + tasmania); assertEquals(404, response.getStatusCode()); assertEquals(MediaType.TEXT_PLAIN.getName(), response.getContentType()); assertEquals("No such layer: " + tasmania, response.getOutputStreamContent()); }
@Test public void testDescribeCoverage() throws Exception { final String tasmania = getLayerId(MockData.TASMANIA_BM); MockHttpServletResponse response = getAsServletResponse(root() + "describe/" + tasmania); assertEquals(404, response.getStatusCode()); assertEquals(MediaType.TEXT_PLAIN.getName(), response.getContentType()); assertEquals("No such layer: " + tasmania, response.getOutputStreamContent()); } }