@Test public void testGlobal() throws Exception { GeoServerInfo global = geoServer.getFactory().createGlobal(); geoServer.setGlobal(global); assertEquals(global, geoServer.getGlobal()); // GEOS-7890 GeoServerInfo global1 = geoServer.getFactory().createGlobal(); GeoServerInfo global2 = geoServer.getFactory().createGlobal(); global1.setGlobalServices(Boolean.valueOf(true)); global1.setXmlExternalEntitiesEnabled(Boolean.valueOf(false)); global1.setVerbose(Boolean.valueOf(false)); global1.setVerboseExceptions(Boolean.valueOf(false)); global2.setGlobalServices(Boolean.valueOf(true)); global2.setXmlExternalEntitiesEnabled(Boolean.valueOf(false)); global2.setVerbose(Boolean.valueOf(false)); global2.setVerboseExceptions(Boolean.valueOf(false)); assertEquals(global1, global2); }
@Before public void init() { factory = new GeoServerImpl().getFactory(); persister = new XStreamPersisterFactory().createXMLPersister(); }
@Test public void testGlobalEvents() throws Exception { TestListener tl = new TestListener(); geoServer.addListener(tl); GeoServerInfo global = geoServer.getFactory().createGlobal(); geoServer.setGlobal(global); global = geoServer.getGlobal(); global.setAdminPassword("foo"); global.setOnlineResource("bar"); assertEquals(0, tl.gPropertyNames.size()); geoServer.save(global); assertEquals(2, tl.gPropertyNames.size()); assertTrue(tl.gPropertyNames.contains("adminPassword")); assertTrue(tl.gPropertyNames.contains("onlineResource")); }
protected void createConfig() { GeoServerImpl geoServer = new GeoServerImpl(); geoServer.addListener( new GeoServerConfigPersister( new GeoServerResourceLoader(data), createXStreamPersister())); catalog.addListener(new GeoServerResourcePersister(catalog.getResourceLoader())); GeoServerInfo global = geoServer.getFactory().createGlobal(); geoServer.setGlobal(global); addSettings(null, geoServer); LoggingInfo logging = geoServer.getFactory().createLogging(); geoServer.setLogging(logging); }
@Test public void testAddService() throws Exception { ServiceInfo service = geoServer.getFactory().createService(); service.setName("foo"); geoServer.add(service); ServiceInfo s2 = geoServer.getFactory().createService(); ((ServiceInfoImpl) s2).setId(service.getId()); try { geoServer.add(s2); fail("adding service with duplicate id should throw exception"); } catch (Exception e) { } ServiceInfo s = geoServer.getServiceByName("foo", ServiceInfo.class); assertTrue(s != service); assertEquals(service, s); }
@Test public void testModifyGlobal() throws Exception { GeoServerInfo global = geoServer.getFactory().createGlobal(); geoServer.setGlobal(global); GeoServerInfo g1 = geoServer.getGlobal(); g1.setAdminPassword("newAdminPassword"); GeoServerInfo g2 = geoServer.getGlobal(); assertNull(g2.getAdminPassword()); geoServer.save(g1); g2 = geoServer.getGlobal(); assertEquals("newAdminPassword", g2.getAdminPassword()); }
ServiceInfo newService1 = geoServer.getFactory().createService(); newService1.setWorkspace(ws1); newService1.setName("SERVICE-1-WS-1"); ServiceInfo globalService = geoServer.getFactory().createService(); globalService.setName("SERVICE-2-GLOBAL"); globalService.setTitle("Global Service"); ServiceInfo newService2 = geoServer.getFactory().createService(); newService2.setWorkspace(ws2); newService2.setName("SERVICE-3-WS-2");
@Test public void testModifyService() throws Exception { ServiceInfo service = geoServer.getFactory().createService(); ((ServiceInfoImpl) service).setId("id"); service.setName("foo"); service.setTitle("bar"); geoServer.add(service); ServiceInfo s1 = geoServer.getServiceByName("foo", ServiceInfo.class); s1.setTitle("changed"); ServiceInfo s2 = geoServer.getServiceByName("foo", ServiceInfo.class); assertEquals("bar", s2.getTitle()); geoServer.save(s1); s2 = geoServer.getServiceByName("foo", ServiceInfo.class); assertEquals("changed", s2.getTitle()); }
@Test public void testGetSettings() throws Exception { GeoServerInfo global = geoServer.getFactory().createGlobal(); geoServer.setGlobal(global); SettingsInfo s = geoServer.getSettings(); assertNotNull(s); assertEquals(4, s.getNumDecimals()); WorkspaceInfo ws = geoServer.getCatalog().getFactory().createWorkspace(); ws.setName("acme"); geoServer.getCatalog().add(ws); SettingsInfo t = geoServer.getFactory().createSettings(); t.setNumDecimals(7); t.setWorkspace(ws); geoServer.add(t); assertNotNull(geoServer.getSettings(ws)); assertEquals(7, geoServer.getSettings(ws).getNumDecimals()); assertEquals(4, geoServer.getSettings().getNumDecimals()); LocalWorkspace.set(ws); try { assertNotNull(geoServer.getSettings()); assertEquals(7, geoServer.getSettings().getNumDecimals()); } finally { LocalWorkspace.remove(); } }