Skip to content

Commit

Permalink
fixed failing GWC instance test issue
Browse files Browse the repository at this point in the history
  • Loading branch information
turingtestfail committed Mar 4, 2025
1 parent fd6defc commit 80d594b
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public class MapMLFeatureUtil {
public static final String BBOX_DISPLAY_NONE = ".bbox {display:none}";
private static final MapMLMapTemplate mapMLMapTemplate = new MapMLMapTemplate();
private static final MapMLEncoder encoder;
private static final GWC gwc = GWC.get();
protected static GWC gwc = GWC.get();

static {
try {
Expand Down Expand Up @@ -877,4 +877,8 @@ private static int calculateBestZoomLevel(double minx, double maxx, GridSet grid

return bestMatch;
}

protected static void setGWC(GWC gwc) {
MapMLFeatureUtil.gwc = gwc;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.geoserver.mapml.xml.Mapml;
import org.geoserver.platform.ServiceException;
import org.geoserver.wms.GetMapRequest;
import org.geoserver.wms.MapLayerInfo;
import org.geoserver.wms.WMSMapContent;
import org.geotools.api.data.FeatureSource;
import org.geotools.api.data.Query;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ protected Mapml mapml(MockHttpServletResponse response) throws JAXBException, Un
}

protected void enableTileCaching(QName layerName, Catalog catalog) {
GWC gwc = applicationContext.getBean(GWC.class);
enableTileCaching(layerName, getCatalog(), GWC.get());
}

protected void enableTileCaching(QName layerName, Catalog catalog, GWC gwc) {
GWCConfig defaults = GWCConfig.getOldDefaults();
// it seems just the fact of retrieving the bean causes the
// GridSets to be added to the gwc GridSetBroker, but if you don't do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.geoserver.catalog.LayerInfo;
import org.geoserver.data.test.MockData;
import org.geoserver.data.test.SystemTestData;
import org.geoserver.gwc.GWC;
import org.geoserver.mapml.xml.Coordinates;
import org.geoserver.mapml.xml.Feature;
import org.geoserver.mapml.xml.LineString;
Expand Down Expand Up @@ -181,7 +182,9 @@ public void testMapMLUseFeaturesLayerGroupRaster() throws Exception {
@Test
public void testUseFeaturesRasterTileCache() throws Exception {
Catalog cat = getCatalog();
enableTileCaching(MockData.WORLD, cat);
GWC gwc = GWC.get();
MapMLFeatureUtil.setGWC(gwc);
enableTileCaching(MockData.WORLD, cat, gwc);
Mapml mapmlFeatures3 = new MapMLWMSRequest()
.name("layerGroupWithRaster2")
.bbox("-89,-44,-87,-42")
Expand Down Expand Up @@ -723,7 +726,7 @@ public void testExceptionBecauseBecauseRaster() throws Exception {
.getAsString();

assertTrue(
"MapML response contains a map-tile representation of the raster layer",
"MapML response contains an exception due to non-vector type",
response.contains("map-tile col=\"0\" row=\"0\""));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -560,18 +560,14 @@ public void testMapMLMultiLayer() throws Exception {
"query_layers should contain all layer names",
queryLinksForSingle.get(0).getTref().contains("query_layers=layerGroup,Polygons&"));
List<Link> tileLinksForSingle = getLinkByRelType(extentLinksForSingle, RelType.TILE);
assertEquals("Tile links not supported for combined layers", 0, tileLinksForSingle.size());
List<Link> imageLinksForSingle = getLinkByRelType(extentLinksForSingle, RelType.IMAGE);
assertTrue(
"Image link tref should contain all layer names",
imageLinksForSingle.get(0).getTref().contains("layers=layerGroup,Polygons&"));
assertEquals("Tile links supported for combined layers", 1, tileLinksForSingle.size());
List<Input> inputsSingleExtent = getTypeFromInputOrDataListOrLink(
mapmlSingleExtent.getBody().getExtents().get(0).getInputOrDatalistOrLink(), Input.class);
List<String> inputNamesSingleExtent =
inputsSingleExtent.stream().map(input -> input.getName()).collect(java.util.stream.Collectors.toList());
assertTrue(
"Input names should include all extent attributes",
inputNamesSingleExtent.containsAll(List.of("xmin", "ymin", "xmax", "ymax", "w", "h")));
inputNamesSingleExtent.containsAll(List.of("txmin", "tymin", "txmax", "tymax", "i", "j")));

JAXBContext context = JAXBContext.newInstance(Mapml.class);
StringWriter reader = new StringWriter();
Expand Down

0 comments on commit 80d594b

Please sign in to comment.