@Before public void setUp() throws Exception { gs = new GeoServerImpl(); importer = new LegacyLoggingImporter(); importer.imprt(URLs.urlToFile(getClass().getResource("services.xml")).getParentFile()); }
@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(); } }
@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()); }
public SettingsInfo getSettings() { SettingsInfo settings = null; if (LocalWorkspace.get() != null) { settings = getSettings(LocalWorkspace.get()); } return settings != null ? settings : getGlobal().getSettings(); }
protected GeoServerImpl createGeoServer() { GeoServerImpl gs = new GeoServerImpl(); gs.setCatalog(new CatalogImpl()); return gs; }
/** * Sets up the configuration objects with default values. Since they're live, specific tests can * modify their state before running the assertions */ @Before public void setUp() throws Exception { geosConfig = new GeoServerImpl(); geosInfo = new GeoServerInfoImpl(geosConfig); geosInfo.setContact(new ContactInfoImpl()); geosConfig.setGlobal(geosInfo); wmsInfo = new WMSInfoImpl(); geosConfig.add(wmsInfo); catalog = new CatalogImpl(); geosConfig.setCatalog(catalog); wmsConfig = new WMS(geosConfig); req = new GetCapabilitiesRequest(); req.setBaseUrl(baseUrl); Map<String, String> namespaces = new HashMap<String, String>(); namespaces.put("xlink", "http://www.w3.org/1999/xlink"); XMLUnit.setXpathNamespaceContext(new SimpleNamespaceContext(namespaces)); XPATH = XMLUnit.newXpathEngine(); }
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); }
GeoServerImpl geoServerImpl = new GeoServerImpl(); catalog = new CatalogImpl(); geoServerImpl.setCatalog(catalog); catalog.add(coverageLayerInfo); geoServerImpl.add(new WMSInfoImpl()); WMS wms = new WMS(geoServerImpl); request = new DescribeLayerRequest();
@Before public void init() { factory = new GeoServerImpl().getFactory(); persister = new XStreamPersisterFactory().createXMLPersister(); }
@Before public void setUp() throws Exception { geoServerImpl = new GeoServerImpl(); geoServerImpl.add(new WMSInfoImpl()); wms = new WMS(geoServerImpl); params = new HashMap<String, String>(); }
WorkspaceInfo ws1 = geoServer.getCatalog().getFactory().createWorkspace(); ws1.setName("TEST-WORKSPACE-1"); geoServer.getCatalog().add(ws1); ServiceInfo newService1 = geoServer.getFactory().createService(); newService1.setWorkspace(ws1); newService1.setName("SERVICE-1-WS-1"); newService1.setTitle("Service for WS1"); geoServer.add(newService1); ServiceInfo globalService = geoServer.getFactory().createService(); globalService.setName("SERVICE-2-GLOBAL"); globalService.setTitle("Global Service"); geoServer.add(globalService); WorkspaceInfo ws2 = geoServer.getCatalog().getFactory().createWorkspace(); ws2.setName("TEST-WORKSPACE-2"); geoServer.getCatalog().add(ws2); ServiceInfo newService2 = geoServer.getFactory().createService(); newService2.setWorkspace(ws2); newService2.setName("SERVICE-3-WS-2"); newService2.setTitle("Service for WS2"); geoServer.add(newService2); assertThat(geoServer.getService(ServiceInfo.class), equalTo(globalService)); assertThat(geoServer.getService(ws1, ServiceInfo.class), equalTo(newService1)); assertThat(geoServer.getService(ws2, ServiceInfo.class), equalTo(newService2)); assertThat(
@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 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); }
reset(); getCatalog().getResourcePool().dispose(); dispose(); Catalog catalog = getCatalog(); if (catalog instanceof Wrapper) { catalog = ((Wrapper) getCatalog()).unwrap(Catalog.class);
@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 testGetRequest() throws Exception { CatalogImpl catalog = new CatalogImpl(); geoServerImpl.setCatalog(catalog); NamespaceInfoImpl ns = new NamespaceInfoImpl(); ns.setPrefix("topp");
@Before public void internalSetUp() throws IOException { this.catalog = getCatalog(); geosConfig = new GeoServerImpl(); geosInfo = new GeoServerInfoImpl(geosConfig); geosInfo.setContact(new ContactInfoImpl()); geosConfig.setGlobal(geosInfo); wmsInfo = new WMSInfoImpl(); geosConfig.add(wmsInfo); geosConfig.setCatalog(catalog); wmsConfig = new WMS(geosConfig); wmsConfig.setApplicationContext(applicationContext); req = new GetCapabilitiesRequest(); req.setBaseUrl(baseUrl); getTestData() .copyTo( getClass().getResourceAsStream("/legendURL/BasicPolygons.png"), LegendSampleImpl.LEGEND_SAMPLES_FOLDER + "/BasicPolygons.png"); getTestData() .copyTo( getClass().getResourceAsStream("/legendURL/Bridges.png"), LegendSampleImpl.LEGEND_SAMPLES_FOLDER + "/Bridges.png"); Map<String, String> namespaces = new HashMap<String, String>(); namespaces.put("xlink", "http://www.w3.org/1999/xlink"); namespaces.put("wms", "http://www.opengis.net/wms"); namespaces.put("ows", "http://www.opengis.net/ows"); XMLUnit.setXpathNamespaceContext(new SimpleNamespaceContext(namespaces)); XPATH = XMLUnit.newXpathEngine(); }
@Test public void testLoadWithoutResaving() throws Exception { GeoServerImpl gs = new GeoServerImpl(); gs.setCatalog(catalog); // this one already calls onto loadService loader.postProcessBeforeInitialization(gs, "geoServer"); // for extra measure, also do a reload loader.reload(); assertFalse("hello.xml should not have been saved during load", helloServiceSaved); } }
@Before public void setUp() throws Exception { GeoServer gs = new GeoServerImpl(); gs.setFactory(new GeoServerFactoryImpl(gs)); importer = new LegacyConfigurationImporter(gs); importer.imprt(URLs.urlToFile(getClass().getResource("services.xml")).getParentFile()); }
@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")); }