@Override protected void setUpInternal() { GWC.get().getConfig().setDirectWMSIntegrationEnabled(false); }
/** * Before using {@code gwc-gs.xml} to hold the integrated GWC configuration, the only property * configured was whether the direct WMS integration option was enabled, and it was saved as * part of the {@link WMSInfo} metadata map under the {@code GWC_WMS_Integration} key. This * method removes that key from WMSInfo if present and sets its value to the {@code gwcConfig} * instead. */ private void upgradeWMSIntegrationConfig(final GeoServer geoServer, final GWCConfig gwcConfig) throws IOException { // Check whether we're using the old way of storing this information, and get rid of it WMSInfo service = geoServer.getService(WMSInfo.class); if (service != null) { MetadataMap metadata = service.getMetadata(); if (service != null && metadata != null) { Boolean storedValue = metadata.get(WMS_INTEGRATION_ENABLED_KEY, Boolean.class); if (storedValue != null) { boolean enabled = storedValue.booleanValue(); gwcConfig.setDirectWMSIntegrationEnabled(enabled); metadata.remove(WMS_INTEGRATION_ENABLED_KEY); geoServer.save(service); } } } }
/** * Before using {@code gwc-gs.xml} to hold the integrated GWC configuration, the only property * configured was whether the direct WMS integration option was enabled, and it was saved as * part of the {@link WMSInfo} metadata map under the {@code GWC_WMS_Integration} key. This * method removes that key from WMSInfo if present and sets its value to the {@code gwcConfig} * instead. */ private void upgradeWMSIntegrationConfig(final GeoServer geoServer, final GWCConfig gwcConfig) throws IOException { // Check whether we're using the old way of storing this information, and get rid of it WMSInfo service = geoServer.getService(WMSInfo.class); if (service != null) { MetadataMap metadata = service.getMetadata(); if (service != null && metadata != null) { Boolean storedValue = metadata.get(WMS_INTEGRATION_ENABLED_KEY, Boolean.class); if (storedValue != null) { boolean enabled = storedValue.booleanValue(); gwcConfig.setDirectWMSIntegrationEnabled(enabled); metadata.remove(WMS_INTEGRATION_ENABLED_KEY); geoServer.save(service); } } } }
@Override protected void setUpInternal() { GWC.get().getConfig().setDirectWMSIntegrationEnabled(false); }
private void setOldDefaults() { setCacheLayersByDefault(true); setMetaTilingX(4); setMetaTilingY(4); setGutter(0); // this is not an old default, but a new feature so we enabled it anyway setCacheNonDefaultStyles(true); setDefaultCachingGridSetIds(new HashSet<String>(Arrays.asList("EPSG:4326", "EPSG:900913"))); Set<String> oldDefaultFormats = new HashSet<String>(Arrays.asList("image/png", "image/jpeg")); setDefaultCoverageCacheFormats(oldDefaultFormats); setDefaultOtherCacheFormats(oldDefaultFormats); setDefaultVectorCacheFormats(oldDefaultFormats); setDirectWMSIntegrationEnabled(false); setWMSCEnabled(true); setTMSEnabled(true); setEnabledPersistence(true); setInnerCachingEnabled(false); HashMap<String, CacheConfiguration> map = new HashMap<String, CacheConfiguration>(); map.put(GuavaCacheProvider.class.toString(), new CacheConfiguration()); setCacheConfigurations(map); setCacheProviderClass(GuavaCacheProvider.class.toString()); }
private void setOldDefaults() { setCacheLayersByDefault(true); setMetaTilingX(4); setMetaTilingY(4); setGutter(0); // this is not an old default, but a new feature so we enabled it anyway setCacheNonDefaultStyles(true); setDefaultCachingGridSetIds(new HashSet<String>(Arrays.asList("EPSG:4326", "EPSG:900913"))); Set<String> oldDefaultFormats = new HashSet<String>( Arrays.asList("image/png", "image/jpeg")); setDefaultCoverageCacheFormats(oldDefaultFormats); setDefaultOtherCacheFormats(oldDefaultFormats); setDefaultVectorCacheFormats(oldDefaultFormats); setDirectWMSIntegrationEnabled(false); setWMSCEnabled(true); setWMTSEnabled(true); setTMSEnabled(true); }
config.setDirectWMSIntegrationEnabled(true);
public void testCapabilitiesContributedInternalDTD() throws Exception { GWC.get().getConfig().setDirectWMSIntegrationEnabled(false); assertTrue(internalSubset == null || !internalSubset.contains("TileSet")); GWC.get().getConfig().setDirectWMSIntegrationEnabled(true); dom = dom(get("wms?request=getCapabilities&version=1.1.1&tiled=true"), false); doctype = dom.getDoctype();
public void testDirectWMSIntegrationWithVirtualServicesHiddenLayer() throws Exception { /* * Nothing special needs to be done at the GWC integration level for this to work. The hard * work should already be done by WMSWorkspaceQualifier so that when the request hits GWC * the layer name is already qualified */ 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.CDF_PREFIX // asking /geoserver/cdf/wms? for cite:BasicPolygons + "/" + buildGetMap(directWMSIntegrationEndpoint, localName, "EPSG:4326", null, tileLayer) + "&tiled=true"; MockHttpServletResponse response = getAsServletResponse(request); assertEquals(200, response.getStatusCode()); assertTrue(response.getContentType(), response.getContentType().startsWith("application/vnd.ogc.se_xml")); assertTrue(response.getOutputStreamContent(), response.getOutputStreamContent() .contains("Could not find layer cdf:BasicPolygons")); }
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")); }
/** * 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 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")); }
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()); }
GWC.get().getConfig().setDirectWMSIntegrationEnabled(false); Document dom = dom(get("wms?request=getCapabilities&version=1.1.1&tiled=true"), false); GWC.get().getConfig().setDirectWMSIntegrationEnabled(true); dom = dom(get("wms?request=getCapabilities&version=1.1.1&tiled=true"), false);
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); }