Unverified Commit 5db66edc authored by Andrea Aime's avatar Andrea Aime Committed by GitHub
Browse files

Merge pull request #3328 from aaime/wmts_rest_rewire

Follow up on GWC #724, fixes GEOS-8995, GEOS-8910
parents 8ca5943c 79f8c4b0
......@@ -43,9 +43,9 @@ public class GwcServiceDispatcherCallback extends AbstractDispatcherCallback
public static final ThreadLocal<String> GWC_OPERATION = new ThreadLocal<>();
private static final Pattern GWC_WS_VIRTUAL_SERVICE_PATTERN =
Pattern.compile("([^/]+)/gwc/service");
Pattern.compile("([^/]+)/gwc/service.*");
private static final Pattern GWC_LAYER_VIRTUAL_SERVICE_PATTERN =
Pattern.compile("([^/]+)/([^/]+)/gwc/service");
Pattern.compile("([^/]+)/([^/]+)/gwc/service.*");
private final Catalog catalog;
......
......@@ -1384,7 +1384,7 @@ public class GeoServerTileLayer extends TileLayer implements ProxyLayer {
baseUrl,
legendInfo.getOnlineResource(),
null,
URLMangler.URLType.RESOURCE));
URLMangler.URLType.SERVICE));
legends.put(styleInfo.prefixedName(), gwcLegendInfo.build());
} else {
int finalWidth = GetLegendGraphicRequest.DEFAULT_WIDTH;
......
......@@ -1782,6 +1782,51 @@ public class GWCIntegrationTest extends GeoServerSystemTestSupport {
assertContentType("text/xml;charset=UTF-8", response);
}
@Test
public void testGetCapabilitiesWithRestEndpointsWorkspaceService() throws Exception {
MockHttpServletRequest request =
createRequest(
MockData.CITE_PREFIX
+ "/gwc"
+ WMTSService.REST_PATH
+ "/WMTSCapabilities.xml");
request.setMethod("GET");
Request mockRequest = mock(Request.class);
when(mockRequest.getHttpRequest()).thenReturn(request);
Dispatcher.REQUEST.set(mockRequest);
MockHttpServletResponse response = dispatch(request, null);
Document doc = dom(new ByteArrayInputStream(response.getContentAsByteArray()), true);
print(doc);
// check legend backlink and that it has the workspace specification
assertEquals(
"http://localhost:8080/geoserver/cite/ows?service=WMS&request=GetLegendGraphic&format=image%2Fpng&width=20&height=20&layer=cite%3ABasicPolygons",
WMTS_XPATH_10.evaluate(
"//wmts:Contents/wmts:Layer[ows:Title='BasicPolygons']/wmts:Style/wmts:LegendURL/@xlink:href",
doc));
// check tile resources
assertEquals(
"http://localhost:8080/geoserver/cite/gwc/service/wmts/rest/cite:BasicPolygons/{style}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}?format=image/png",
WMTS_XPATH_10.evaluate(
"//wmts:Contents/wmts:Layer[ows:Title='BasicPolygons']/wmts:ResourceURL[@format='image/png' and @resourceType='tile']/@template",
doc));
// check featureinfo resource
assertEquals(
"http://localhost:8080/geoserver/cite/gwc/service/wmts/rest/cite:BasicPolygons/{style}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}/{J}/{I}?format=text/plain",
WMTS_XPATH_10.evaluate(
"//wmts:Contents/wmts:Layer[ows:Title='BasicPolygons']/wmts:ResourceURL[@format='text/plain' and @resourceType='FeatureInfo']/@template",
doc));
// check backlink too
assertEquals(
"1",
WMTS_XPATH_10.evaluate(
"count(//wmts:Capabilities/wmts:ServiceMetadataURL[@xlink:href='http://localhost:8080/geoserver/cite/gwc/service/wmts/rest/WMTSCapabilities.xml'])",
doc));
}
@Test
public void testGetTileWithRestEndpoints() throws Exception {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment