public void testInitializeLayersToOldDefaults() throws Exception { // no gwc-gs.xml exists when(configPersister.findConfigFile()).thenReturn(null); // ignore the upgrade of the direct wms integration flag on this test when(geoServer.getService(eq(WMSInfo.class))).thenReturn(null); // let the catalog have something to initialize LayerInfo layer = mockLayer("testLayer", new String[]{}, LayerInfo.Type.RASTER); LayerGroupInfo group = mockGroup("testGroup", layer); when(rawCatalog.getLayers()).thenReturn(Lists.newArrayList(layer)); when(rawCatalog.getLayerGroups()).thenReturn(Lists.newArrayList(group)); // run layer initialization initializer.initialize(geoServer); // make sure default tile layers were created GWCConfig oldDefaults = GWCConfig.getOldDefaults(); GeoServerTileLayerInfo tileLayer = TileLayerInfoUtil.loadOrCreate(layer, oldDefaults); GeoServerTileLayerInfo tileLayerGroup = TileLayerInfoUtil.loadOrCreate(group, oldDefaults); verify(tileLayerCatalog, times(1)).save(eq(tileLayer)); verify(tileLayerCatalog, times(1)).save(eq(tileLayerGroup)); }
public void testUpgradeDirectWMSIntegrationFlag() throws Exception { // no gwc-gs.xml exists, so that initialization runs when(configPersister.findConfigFile()).thenReturn(null); // no catalog layers for this test List<LayerInfo> layers = ImmutableList.of(); List<LayerGroupInfo> groups = ImmutableList.of(); when(rawCatalog.getLayers()).thenReturn(layers); when(rawCatalog.getLayerGroups()).thenReturn(groups); WMSInfoImpl wmsInfo = new WMSInfoImpl(); // initialize wmsInfo with a value for the old direct wms integration flag wmsInfo.getMetadata().put(GWCInitializer.WMS_INTEGRATION_ENABLED_KEY, Boolean.TRUE); // make sure WMSInfo exists when(geoServer.getService(eq(WMSInfo.class))).thenReturn(wmsInfo); ArgumentCaptor<GWCConfig> captor = ArgumentCaptor.forClass(GWCConfig.class); // run layer initialization initializer.initialize(geoServer); verify(configPersister, times(2)).save(captor.capture()); assertTrue(captor.getAllValues().get(0).isDirectWMSIntegrationEnabled()); assertFalse(wmsInfo.getMetadata().containsKey(GWCInitializer.WMS_INTEGRATION_ENABLED_KEY)); verify(geoServer).save(same(wmsInfo)); }
initializer.initialize(geoServer);