@Test public void testLoadGibberish() throws Exception { // we should get a log message, but the startup should continue File service = new File(getDataDirectory().getResourceLoader().getBaseDirectory(), "service.xml"); FileUtils.writeStringToFile(service, "duDaDa"); getGeoServer().reload(); assertEquals(0, geoServer.getServices().size()); }
@RunTestSetup @Test public void testGeoServerReload() throws Exception { Catalog cat = getCatalog(); FeatureTypeInfo lakes = cat.getFeatureTypeByName( MockData.LAKES.getNamespaceURI(), MockData.LAKES.getLocalPart()); assertFalse("foo".equals(lakes.getTitle())); GeoServerDataDirectory dd = new GeoServerDataDirectory(getResourceLoader()); File info = dd.findResourceFile(lakes); // File info = getResourceLoader().find("featureTypes", "cite_Lakes", "info.xml"); FileReader in = new FileReader(info); Element dom = ReaderUtils.parse(in); Element title = ReaderUtils.getChildElement(dom, "title"); title.getFirstChild().setNodeValue("foo"); OutputStream output = new FileOutputStream(info); try { TransformerFactory.newInstance() .newTransformer() .transform(new DOMSource(dom), new StreamResult(output)); } finally { output.close(); } getGeoServer().reload(); lakes = cat.getFeatureTypeByName( MockData.LAKES.getNamespaceURI(), MockData.LAKES.getLocalPart()); assertEquals("foo", lakes.getTitle()); }
@Test public void testReloadWithRuinedCoverageStore() throws Exception { // ruin one coverage description File root = getDataDirectory().getRoot().dir(); File targetCoverage = new File(root, "workspaces/wcs/BlueMarble/coveragestore.xml"); FileUtils.writeStringToFile(targetCoverage, "boom!"); // reload and check it does not go belly up getGeoServer().reload(); // check the coverage in question is no more getCatalog().getCoverageByName(getLayerId(MockData.TASMANIA_BM)); } }
@Test public void testReloadDefaultStyles() throws Exception { // clear up all "point" styles final Resource styles = getDataDirectory().getStyles(); styles.list() .stream() .filter(r -> r.getType() == Resource.Type.RESOURCE && r.name().contains("point")) .forEach(r -> r.delete()); // reload getGeoServer().reload(); // check the default point style has been re-created final StyleInfo point = getCatalog().getStyleByName("point"); assertNotNull(point); }
@Override protected void onSetUp(SystemTestData testData) throws Exception { super.onSetUp(testData); LayerInfo li = getCatalog().getLayerByName(getLayerId(SystemTestData.BUILDINGS)); Resource resource = getDataDirectory().config(li); Document dom; try (InputStream is = resource.in()) { dom = dom(resource.in()); } Element defaultStyle = (Element) dom.getElementsByTagName("defaultStyle").item(0); Element defaultStyleId = (Element) defaultStyle.getElementsByTagName("id").item(0); defaultStyleId.setTextContent("danglingReference"); try (OutputStream os = resource.out()) { print(dom, os); } getGeoServer().reload(); }
getGeoServer().reload(); rp = getCatalog().getResourcePool();
@Test public void testDropCoverageStore() throws Exception { // build the store Catalog cat = getCatalog(); CatalogBuilder cb = new CatalogBuilder(cat); CoverageStoreInfo store = cb.buildCoverageStore("dem"); store.setURL(MockData.class.getResource("tazdem.tiff").toExternalForm()); store.setType("GeoTIFF"); cat.add(store); // build the coverage cb.setStore(store); CoverageInfo ci = cb.buildCoverage(); cat.add(ci); // build the layer LayerInfo layer = cb.buildLayer(ci); cat.add(layer); // grab a reader just to inizialize the code ci.getGridCoverage(null, null); ci.getGridCoverageReader(null, GeoTools.getDefaultHints()); // now drop the store CascadeDeleteVisitor visitor = new CascadeDeleteVisitor(cat); visitor.visit(store); // and reload (GEOS-4782 -> BOOM!) getGeoServer().reload(); }
getGeoServer().reload(); int listenersAfter = catalog.getListeners().size(); assertEquals(listenersBefore, listenersAfter);
@Test public void testReloadWithLocalServices() throws Exception { // setup a non default workspace WorkspaceInfo ws = getCatalog().getFactory().createWorkspace(); ws.setName("nonDefault"); NamespaceInfo ni = getCatalog().getFactory().createNamespace(); ni.setPrefix("nonDefault"); ni.setURI("http://www.geoserver.org/nonDefault"); getCatalog().add(ws); getCatalog().add(ni); // create a ws specific setting SettingsInfo s = geoServer.getFactory().createSettings(); s.setWorkspace(ws); geoServer.add(s); getGeoServer().reload(); }
@RequestMapping( value = "/reload", method = {RequestMethod.POST, RequestMethod.PUT} ) public void reload() throws Exception { geoServer.reload(); }
@Override public void run() { // lock during event processing eventLock.set(true); try { gs.reload(); } catch (Exception e) { LOGGER.log(Level.WARNING, "Reload failed", e); } finally { eventLock.set(false); } } });
/** * Method to reload the catalog */ protected void reloadCatalog() throws Exception { if(forceReset) { geoServer.reset(); } else { geoServer.reload(); } } }
@Override public void onClick(AjaxRequestTarget target) { try { getGeoServer().reload(); info(getLocalizer().getString("catalogConfigReloadedSuccessfully", StatusPage.this)); } catch(Throwable t) { LOGGER.log(Level.SEVERE, "An error occurred while reloading the catalog", t); error(t); } target.addComponent(feedbackPanel); } });
@Override public void onClick(AjaxRequestTarget target) { try { parent.getGeoServer().reload(); info( getLocalizer() .getString( "catalogConfigReloadedSuccessfully", StatusPanel.this)); } catch (Throwable t) { LOGGER.log( Level.SEVERE, "An error occurred while reloading the catalog", t); error(t); } parent.addFeedbackPanels(target); } });
@Test public void testWMSLifecycleHandlerGraphicCacheReset() throws Exception { Iterator<ExternalGraphicFactory> it = DynamicSymbolFactoryFinder.getExternalGraphicFactories(); Map<URL, BufferedImage> imageCache = null; while (it.hasNext()) { ExternalGraphicFactory egf = it.next(); if (egf instanceof ImageGraphicFactory) { Field cache = egf.getClass().getDeclaredField("imageCache"); cache.setAccessible(true); imageCache = (Map) cache.get(egf); URL u = new URL("http://boundless.org"); BufferedImage b = new BufferedImage(6, 6, 8); imageCache.put(u, b); } } assertNotEquals(0, imageCache.size()); getGeoServer().reload(); assertEquals(0, imageCache.size()); } }
@Before public final void setupAndLoadDataDirectory() throws Exception { if (setupDataDirectory()) { DATA_DIRECTORY.setUp(); geoServer.reload(); } }
/** * 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()); } }
public void testRemoveLayerAfterReload() throws Exception { Catalog cat = getCatalog(); TileLayerDispatcher tld = GeoWebCacheExtensions.bean(TileLayerDispatcher.class); LayerInfo li = cat.getLayerByName(super.getLayerId(MockData.MPOINTS)); String layerName = tileLayerName(li); assertNotNull(tld.getTileLayer(layerName)); // force reload getGeoServer().reload(); // now remove the layer and check it has been removed from GWC as well cat.remove(li); try { tld.getTileLayer(layerName); fail("Layer should not exist"); } catch (GeoWebCacheException gwce) { // fine } } }
/** * See GEOS-5092, check server startup is not hurt by a tile layer out of sync (say someone * manually removed the GeoServer layer) */ public void testMissingGeoServerLayerAtStartUp() throws Exception { Catalog catalog = getCatalog(); GWC mediator = GWC.get(); final String layerName = getLayerId(BASIC_POLYGONS); LayerInfo layerInfo = catalog.getLayerByName(layerName); assertNotNull(layerInfo); TileLayer tileLayer = mediator.getTileLayerByName(layerName); assertNotNull(tileLayer); assertTrue(tileLayer.isEnabled()); MockData testData = getTestData(); testData.removeFeatureType(BASIC_POLYGONS); getGeoServer().reload(); assertNull(catalog.getLayerByName(layerName)); CatalogConfiguration config = GeoServerExtensions.bean(CatalogConfiguration.class); assertNull(config.getTileLayer(layerName)); try { mediator.getTileLayerByName(layerName); fail("Expected IAE"); } catch (IllegalArgumentException e) { assertTrue(true); } }