public String getContentType() { return getHeader("Content-Type"); }
public String getContentType() { return getHeader("Content-Type"); }
public String getContentType() { return getHeader("Content-Type"); }
public void testDirectWMSIntegrationResponseHeaders() throws Exception { final GWC gwc = GWC.get(); gwc.getConfig().setDirectWMSIntegrationEnabled(true); final String layerName = BASIC_POLYGONS.getPrefix() + ":" + BASIC_POLYGONS.getLocalPart(); String request = buildGetMap(true, layerName, "EPSG:4326", null) + "&tiled=true"; MockHttpServletResponse response = getAsServletResponse(request); assertEquals(200, response.getStatusCode()); assertEquals("image/png", response.getContentType()); assertEquals(layerName, response.getHeader("geowebcache-layer")); assertEquals("[0, 0, 0]", response.getHeader("geowebcache-tile-index")); assertEquals("-180.0,-90.0,0.0,90.0", response.getHeader("geowebcache-tile-bounds")); assertEquals("EPSG:4326", response.getHeader("geowebcache-gridset")); assertEquals("EPSG:4326", response.getHeader("geowebcache-crs")); }
@Test public void eTagDoesNotContainJSessionIdNorFilename() throws IOException, ServletException { // GIVEN final String filename = "dummy.txt"; final RangeSupportFilter filter = new RangeSupportFilter(); final FilterChain chain = new FilterChain() { @Override public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException { response.getOutputStream().println("dummy string"); } }; final MockHttpServletRequest request = new MockHttpServletRequest(); request.setMethod("GET"); request.setRequestURI(String.format("/some/path/%s;JSESSIONID=EE3DB6042B1B57AD55C2633428F44496", filename)); request.setHeader("Range", "bytes=0-56000"); final MockHttpServletResponse response = new MockHttpServletResponse(); // WHEN filter.doFilter(request, response, chain); // THEN assertThat(response.getHeader("ETag"), not(containsString("JSESSIONID"))); assertThat(response.getHeader("ETag"), not(containsString(filename))); }
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 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 ); }
assertEquals("attachment; filename=Buildings.zip", resp.getHeader("Content-Disposition"));
/** * Test basic extension functionality: mime/type, headers, * not empty output generation. * @param resp * @param featureName * @return * @throws Exception */ public String testBasicResult(MockHttpServletResponse resp, String featureName) throws Exception { // check mime type assertEquals("application/dxf", resp.getContentType()); // check the content disposition assertEquals("attachment; filename=" + featureName + ".dxf", resp .getHeader("Content-Disposition")); // check for content (without checking in detail) String sResponse = resp.getOutputStreamContent(); assertNotNull(sResponse); return sResponse; }
public void testDirectWMSIntegrationMaxAge() throws Exception { final GWC gwc = GWC.get(); gwc.getConfig().setDirectWMSIntegrationEnabled(true); final String layerName = BASIC_POLYGONS.getPrefix() + ":" + BASIC_POLYGONS.getLocalPart(); final String path = buildGetMap(true, layerName, "EPSG:4326", null) + "&tiled=true"; final String qualifiedName = super.getLayerId(BASIC_POLYGONS); final GeoServerTileLayer tileLayer = (GeoServerTileLayer) gwc.getTileLayerByName(qualifiedName); tileLayer.getLayerInfo().getResource().getMetadata().put("cachingEnabled", "true"); tileLayer.getLayerInfo().getResource().getMetadata().put("cacheAgeMax", 3456); MockHttpServletResponse response = getAsServletResponse(path); String cacheControl = response.getHeader("Cache-Control"); assertEquals("max-age=3456", cacheControl); assertNotNull(response.getHeader("Last-Modified")); tileLayer.getLayerInfo().getResource().getMetadata().put("cachingEnabled", "false"); response = getAsServletResponse(path); cacheControl = response.getHeader("Cache-Control"); assertEquals("no-cache", cacheControl); // make sure a boolean is handled, too - see comment in CachingWebMapService tileLayer.getLayerInfo().getResource().getMetadata().put("cachingEnabled", Boolean.FALSE); response = getAsServletResponse(path); cacheControl = response.getHeader("Cache-Control"); assertEquals("no-cache", cacheControl); }
assertEquals("attachment; filename=result.tiff",response.getHeader("Content-Disposition")); InputStream is = getBinaryInputStream(response);
public void testDirectWMSIntegrationWithVirtualServices() throws Exception { final GWC gwc = GWC.get(); gwc.getConfig().setDirectWMSIntegrationEnabled(true); final String qualifiedName = super.getLayerId(BASIC_POLYGONS); final String localName = BASIC_POLYGONS.getLocalPart(); final TileLayer tileLayer = gwc.getTileLayerByName(qualifiedName); assertNotNull(tileLayer); boolean directWMSIntegrationEndpoint = true; String request = MockData.CITE_PREFIX + "/" + buildGetMap(directWMSIntegrationEndpoint, localName, "EPSG:4326", null, tileLayer) + "&tiled=true"; MockHttpServletResponse response = getAsServletResponse(request); assertEquals(200, response.getStatusCode()); assertEquals("image/png", response.getContentType()); assertEquals(qualifiedName, response.getHeader("geowebcache-layer")); }
/** * If direct WMS integration is enabled, a GetMap requests that hits the regular WMS but matches * a gwc tile should return with the proper {@code geowebcache-tile-index} HTTP response header. */ public void testDirectWMSIntegration() throws Exception { final GWC gwc = GWC.get(); gwc.getConfig().setDirectWMSIntegrationEnabled(true); final String layerName = BASIC_POLYGONS.getPrefix() + ":" + BASIC_POLYGONS.getLocalPart(); String request; MockHttpServletResponse response; request = buildGetMap(true, layerName, "EPSG:4326", null); response = getAsServletResponse(request); assertEquals(200, response.getStatusCode()); assertEquals("image/png", response.getContentType()); assertNull(response.getHeader("geowebcache-tile-index")); request = request + "&tiled=true"; response = getAsServletResponse(request); assertEquals(200, response.getErrorCode()); assertEquals("image/png", response.getContentType()); }
public void testDirectWMSIntegrationIfModifiedSinceSupport() throws Exception { final GWC gwc = GWC.get(); gwc.getConfig().setDirectWMSIntegrationEnabled(true); final String layerName = BASIC_POLYGONS.getPrefix() + ":" + BASIC_POLYGONS.getLocalPart(); final String path = buildGetMap(true, layerName, "EPSG:4326", null) + "&tiled=true"; MockHttpServletResponse response = getAsServletResponse(path); assertEquals(200, response.getStatusCode()); assertEquals("image/png", response.getContentType()); String lastModifiedHeader = response.getHeader("Last-Modified"); assertNotNull(lastModifiedHeader); Date lastModified = DateUtil.parseDate(lastModifiedHeader); MockHttpServletRequest httpReq = createRequest(path); httpReq.setMethod("GET"); httpReq.setBodyContent(new byte[] {}); httpReq.setHeader("If-Modified-Since", lastModifiedHeader); response = dispatch(httpReq, "UTF-8"); assertEquals(HttpServletResponse.SC_NOT_MODIFIED, response.getErrorCode()); // set the If-Modified-Since header to some point in the past of the last modified value Date past = new Date(lastModified.getTime() - 5000); String ifModifiedSince = DateUtil.formatDate(past); httpReq.setHeader("If-Modified-Since", ifModifiedSince); response = dispatch(httpReq, "UTF-8"); assertEquals(HttpServletResponse.SC_OK, response.getErrorCode()); Date future = new Date(lastModified.getTime() + 5000); ifModifiedSince = DateUtil.formatDate(future); httpReq.setHeader("If-Modified-Since", ifModifiedSince); response = dispatch(httpReq, "UTF-8"); assertEquals(HttpServletResponse.SC_NOT_MODIFIED, response.getErrorCode()); }
public void testCount() throws Exception { String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<wps:Execute version=\"1.0.0\" service=\"WPS\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://www.opengis.net/wps/1.0.0\" xmlns:wfs=\"http://www.opengis.net/wfs\" xmlns:wps=\"http://www.opengis.net/wps/1.0.0\" xmlns:ows=\"http://www.opengis.net/ows/1.1\" xmlns:gml=\"http://www.opengis.net/gml\" xmlns:ogc=\"http://www.opengis.net/ogc\" xmlns:wcs=\"http://www.opengis.net/wcs/1.1.1\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xsi:schemaLocation=\"http://www.opengis.net/wps/1.0.0 http://schemas.opengis.net/wps/1.0.0/wpsAll.xsd\">\n" + " <ows:Identifier>gs:Count</ows:Identifier>\n" + " <wps:DataInputs>\n" + " <wps:Input>\n" + " <ows:Identifier>features</ows:Identifier>\n" + " <wps:Reference mimeType=\"text/xml; subtype=wfs-collection/1.0\" xlink:href=\"http://geoserver/wfs\" method=\"POST\">\n" + " <wps:Body>\n" + " <wfs:GetFeature service=\"WFS\" version=\"1.0.0\" outputFormat=\"GML2\">\n" + " <wfs:Query typeName=\"" + getLayerId(MockData.PRIMITIVEGEOFEATURE) + "\"/>\n" + " </wfs:GetFeature>\n" + " </wps:Body>\n" + " </wps:Reference>\n" + " </wps:Input>\n" + " </wps:DataInputs>\n" + " <wps:ResponseForm>\n" + " <wps:RawDataOutput>\n" + " <ows:Identifier>result</ows:Identifier>\n" + " </wps:RawDataOutput>\n" + " </wps:ResponseForm>\n" + "</wps:Execute>"; MockHttpServletResponse resp = postAsServletResponse(root(), xml); assertEquals("text/plain", resp.getContentType()); assertEquals("5", resp.getOutputStreamContent()); resp = postAsServletResponse(root() + "content-disposition=attachment",xml); assertEquals("attachment; filename=result.txt",resp.getHeader("Content-Disposition")); } }
String redirectURL = response.getHeader("Location"); assertTrue(redirectURL.contains(GeoServerCasConstants.LOGIN_URI)); assertTrue(redirectURL.endsWith("bar")); assertEquals(HttpServletResponse.SC_OK, response.getErrorCode()); assertTrue(response.wasRedirectSent()); redirectURL = response.getHeader("Location"); assertTrue(redirectURL.contains("login")); ctx = (SecurityContext) request.getSession(true).getAttribute( assertEquals(HttpServletResponse.SC_OK, response.getErrorCode()); assertTrue(response.wasRedirectSent()); redirectURL = response.getHeader("Location"); assertTrue(redirectURL.contains(GeoServerCasConstants.LOGIN_URI)); ctx = (SecurityContext) request.getSession(true).getAttribute(
assertEquals(HttpServletResponse.SC_OK, response.getErrorCode()); assertTrue(response.wasRedirectSent()); String redirectUrl = response.getHeader("Location"); assertNotNull(redirectUrl); assertTrue(redirectUrl.contains(GeoServerCasConstants.LOGOUT_URI)); assertEquals(HttpServletResponse.SC_OK, response.getErrorCode()); assertTrue(response.wasRedirectSent()); redirectUrl = response.getHeader("Location"); assertNotNull(redirectUrl); assertFalse(redirectUrl.contains(GeoServerCasConstants.LOGOUT_URI));