/** * @see org.geowebcache.layer.TileLayer#isQueryable() * @see WMS#isQueryable(LayerGroupInfo) * @see WMS#isQueryable(LayerInfo) */ @Override public boolean isQueryable() { boolean queryable = GWC.get().isQueryable(this); return queryable; }
@Override protected void setUpInternal() { GWC.get().getConfig().setDirectWMSIntegrationEnabled(false); }
private String buildGetMap(final boolean directWMSIntegrationEndpoint, final String layerName, final String gridsetId, String styles) { final GWC gwc = GWC.get(); final TileLayer tileLayer = gwc.getTileLayerByName(layerName); return buildGetMap(directWMSIntegrationEndpoint, layerName, gridsetId, styles, tileLayer); }
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 testGetLayersList() throws Exception { final String url = "gwc/rest/layers.xml"; MockHttpServletResponse sr = getAsServletResponse(url); assertEquals(200, sr.getErrorCode()); assertTrue(sr.getContentType(), sr.getContentType().startsWith("text/xml")); Document dom = getAsDOM(url); // print(dom); ArrayList<String> tileLayerNames = Lists.newArrayList(GWC.get().getTileLayerNames()); Collections.sort(tileLayerNames); XMLUnit.setXpathNamespaceContext(new SimpleNamespaceContext(ImmutableMap.of("atom", "http://www.w3.org/2005/Atom"))); for (String name : tileLayerNames) { String xpath = "//layers/layer/name[text() = '" + name + "']"; assertXpathExists(xpath, dom); xpath = "//layers/layer/atom:link[@href = 'http://localhost/geoserver/gwc/rest/layers/" + ServletUtils.URLEncode(name) + ".xml']"; assertXpathExists(xpath, dom); } }
/** Helper method that finds a GWC store by is id. */ private MbtilesInfo findStore(String storeId) { List<BlobStoreInfo> configurations = GWC.get().getBlobStores(); for (BlobStoreInfo candidateConfiguration : configurations) { if (candidateConfiguration instanceof MbtilesInfo && candidateConfiguration.getId().equals(storeId)) { return (MbtilesInfo) candidateConfiguration; } } return null; } }
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")); }
@Override protected void setUpInternal() { GWC.get().getConfig().setDirectWMSIntegrationEnabled(false); }
/** * * @see org.geowebcache.layer.TileLayer#isQueryable() * @see WMS#isQueryable(LayerGroupInfo) * @see WMS#isQueryable(LayerInfo) */ @Override public boolean isQueryable() { boolean queryable = GWC.get().isQueryable(this); return queryable; }
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); }
/** * Commented out for the moment, we need a new release of GWC public void testPreserveHeaders() throws Exception { MockHttpServletResponse response = getAsServletResponse("gwc/service/wms?service=wms&version=1.1.0&request=GetCapabilities"); assertEquals("application/vnd.ogc.wms_xml", response.getContentType()); assertEquals("inline;filename=wms-getcapabilities.xml", response.getHeader("content-disposition")); } */ public void testSaveConfig() throws Exception { GWCConfig config = GWC.get().getConfig(); // set a large gutter config.setGutter(100); // save the config GWC.get().saveConfig(config); // force a reload getGeoServer().reload(); // grab the config, make sure it was saved as expected assertEquals(100, GWC.get().getConfig().getGutter()); } }
private RenderedImageMap dispatchGetMap(final ConveyorTile tile, final MetaTile metaTile) throws Exception { Map<String, String> params = buildGetMap(tile, metaTile); WebMap map; try { HttpServletRequest actualRequest = tile.servletReq; Cookie[] cookies = actualRequest == null ? null : actualRequest.getCookies(); GWC.get().dispatchOwsRequest(params, cookies); map = WEB_MAP.get(); if (!(map instanceof RenderedImageMap)) { throw new IllegalStateException("Expected: RenderedImageMap, got " + map); } } finally { WEB_MAP.remove(); } return (RenderedImageMap) map; }
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")); }
private WebMap dispatchGetMap(final ConveyorTile tile, final MetaTile metaTile) throws Exception { Map<String, String> params = buildGetMap(tile, metaTile); WebMap map; try { HttpServletRequest actualRequest = tile.servletReq; Cookie[] cookies = actualRequest == null ? null : actualRequest.getCookies(); GWC.get().dispatchOwsRequest(params, cookies); map = WEB_MAP.get(); if (!(map instanceof WebMap)) { throw new IllegalStateException("Expected: RenderedImageMap, got " + map); } } finally { WEB_MAP.remove(); } return map; }
/** * 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()); }
@Override public void proxyRequest(ConveyorTile tile) throws GeoWebCacheException { try { GWC.get().proxyOwsRequest(tile); } catch (Exception e) { throw new GeoWebCacheException("Failed to cascade request", e); } }
/** * @see org.geowebcache.layer.TileLayer#getFeatureInfo * @see GWC#dispatchOwsRequest */ @Override public Resource getFeatureInfo(ConveyorTile convTile, BoundingBox bbox, int height, int width, int x, int y) throws GeoWebCacheException { Map<String, String> params = buildGetFeatureInfo(convTile, bbox, height, width, x, y); Resource response; try { response = GWC.get().dispatchOwsRequest(params, (Cookie[]) null); } catch (Exception e) { throw new GeoWebCacheException(e); } return response; }
/** * @see org.geowebcache.layer.TileLayer#getFeatureInfo * @see GWC#dispatchOwsRequest */ @Override public Resource getFeatureInfo( ConveyorTile convTile, BoundingBox bbox, int height, int width, int x, int y) throws GeoWebCacheException { Map<String, String> params = buildGetFeatureInfo(convTile, bbox, height, width, x, y); Resource response; try { response = GWC.get().dispatchOwsRequest(params, (Cookie[]) null); } catch (Exception e) { throw new GeoWebCacheException(e); } return response; }
public void testDelete() throws Exception { final String layerName = getLayerId(MockData.BRIDGES); final GWC mediator = GWC.get(); assertTrue(mediator.tileLayerExists(layerName)); final String url = "gwc/rest/layers/" + layerName + ".xml"; MockHttpServletResponse response = super.deleteAsServletResponse(url); assertEquals(HttpServletResponse.SC_OK, response.getStatusCode()); assertFalse(mediator.tileLayerExists(layerName)); }
public void testPutSuccess() throws Exception { final String layerName = getLayerId(MockData.FORESTS); final String id = getCatalog().getLayerByName(layerName).getId(); final GWC mediator = GWC.get(); assertTrue(mediator.tileLayerExists(layerName)); mediator.removeTileLayers(Lists.newArrayList(layerName)); assertFalse(mediator.tileLayerExists(layerName)); final String url = "gwc/rest/layers/" + layerName + ".xml"; MockHttpServletResponse response = putLayer(url, id, layerName); assertEquals(HttpServletResponse.SC_OK, response.getStatusCode()); assertTrue(mediator.tileLayerExists(layerName)); }