Skip to content

Commit

Permalink
Update MapMLBaseProxyTest.jav to check the cascaded request against the
Browse files Browse the repository at this point in the history
request URL from the capabilities document.
  • Loading branch information
prushforth committed Oct 15, 2024
1 parent e376a43 commit dddab5c
Showing 1 changed file with 30 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,14 @@
import com.github.tomakehurst.wiremock.client.WireMock;
import com.github.tomakehurst.wiremock.core.WireMockConfiguration;
import java.io.ByteArrayInputStream;
import java.net.URL;
import java.util.Map;
import org.custommonkey.xmlunit.XMLUnit;
import org.custommonkey.xmlunit.XpathEngine;
import org.geotools.ows.wms.WMSCapabilities;
import org.geotools.ows.wms.WebMapServer;
import org.geotools.ows.wmts.WebMapTileServer;
import org.geotools.ows.wmts.model.WMTSCapabilities;
import org.junit.AfterClass;
import org.junit.Before;
import org.springframework.http.MediaType;
Expand Down Expand Up @@ -105,11 +110,32 @@ protected void checkCascading(
}
}

protected void assertCascading(boolean shouldCascade, String url) {
protected void assertCascading(boolean shouldCascade, String url) throws Exception {

if (shouldCascade) {
assertTrue(
url.startsWith(
"http://localhost:" + mockService.port() + MOCK_SERVER + CONTEXT));
URL getResourceURL = null;
boolean cascadingWMS = getCapabilitiesURL().matches(".*SERVICE=WMS.*");
if (cascadingWMS) {
WebMapServer wms = new WebMapServer(new URL(getCapabilitiesURL()));
WMSCapabilities capabilities = wms.getCapabilities();
getResourceURL = capabilities.getRequest().getGetMap().getGet();
} else {
WebMapTileServer wmts = new WebMapTileServer(new URL(getCapabilitiesURL()));
WMTSCapabilities capabilities = wmts.getCapabilities();
getResourceURL = capabilities.getRequest().getGetTile().getGet();
}
URL base =
new URL(
getResourceURL.getProtocol()
+ "://"
+ getResourceURL.getHost()
+ (getResourceURL.getPort() == -1
? ""
: ":" + getResourceURL.getPort())
+ "/");
String path = getResourceURL.getPath();

assertTrue(url.startsWith((new URL(base, path)).toString()));
assertTrue(url.contains("layers=topp:states"));
} else {
assertTrue(url.startsWith("http://localhost:8080/geoserver" + CONTEXT));
Expand Down

0 comments on commit dddab5c

Please sign in to comment.