ns.setPrefix("ns2Prefix"); ns.setURI("ns2URI");
private static void addWorkspaceNamespace(String wsName) { WorkspaceInfoImpl ws = new WorkspaceInfoImpl(); ws.setName(wsName); catalog.add(ws); NamespaceInfo ns = new NamespaceInfoImpl(); ns.setPrefix(wsName); ns.setURI("http://www.geoserver.org/" + wsName); catalog.add(ns); }
@Test public void testAddWMTSLayer() throws Exception { testAddWMTSStore(); File d = new File(testData.getDataDirectoryRoot(), "workspaces/acme/demowmts/foo_wmts"); assertFalse(d.exists()); NamespaceInfo ns = catalog.getFactory().createNamespace(); ns.setPrefix("bar"); ns.setURI("http://bar"); catalog.add(ns); WMTSLayerInfo wmts = catalog.getFactory().createWMTSLayer(); wmts.setName("foo_wmts"); wmts.setNamespace(ns); wmts.setStore(catalog.getStoreByName("acme", "demowmts", WMTSStoreInfo.class)); catalog.add(wmts); assertTrue(d.exists()); assertTrue(new File(d, "wmtslayer.xml").exists()); }
@Test public void testAddWMSLayer() throws Exception { testAddWMSStore(); File d = new File(testData.getDataDirectoryRoot(), "workspaces/acme/demowms/foo"); assertFalse(d.exists()); NamespaceInfo ns = catalog.getFactory().createNamespace(); ns.setPrefix("bar"); ns.setURI("http://bar"); catalog.add(ns); WMSLayerInfo wms = catalog.getFactory().createWMSLayer(); wms.setName("foo"); wms.setNamespace(ns); wms.setStore(catalog.getStoreByName("acme", "demowms", WMSStoreInfo.class)); catalog.add(wms); assertTrue(d.exists()); assertTrue(new File(d, "wmslayer.xml").exists()); }
@Test public void testAutoCascadeDefaultNamespace() { CatalogFactory factory = catalog.getFactory(); NamespaceInfo ns1 = factory.createNamespace(); ns1.setPrefix("1"); ns1.setURI("http://www.geoserver.org/1"); NamespaceInfo ns2 = factory.createNamespace(); ns2.setPrefix("2"); ns2.setURI("http://www.geoserver.org/2"); catalog.add(ns1); catalog.add(ns2); assertEquals(ns1, catalog.getDefaultNamespace()); catalog.remove(ns1); assertEquals(ns2, catalog.getDefaultNamespace()); }
@Test public void testAddFeatureType() throws Exception { testAddDataStore(); File d = new File(testData.getDataDirectoryRoot(), "workspaces/acme/foostore/foo"); assertFalse(d.exists()); NamespaceInfo ns = catalog.getFactory().createNamespace(); ns.setPrefix("bar"); ns.setURI("http://bar"); catalog.add(ns); FeatureTypeInfo ft = catalog.getFactory().createFeatureType(); ft.setName("foo"); ft.setNamespace(ns); ft.setStore(catalog.getDataStoreByName("acme", "foostore")); catalog.add(ft); assertTrue(d.exists()); }
@Test public void testChangeWorkspace() { Catalog cat = createMock(Catalog.class); cat.addListener((CatalogListener) anyObject()); expectLastCall(); NamespaceInfo ns = createMock(NamespaceInfo.class); ns.setPrefix("abcd"); expectLastCall(); expect(cat.getNamespaceByPrefix("gs")).andReturn(ns); cat.save(ns); expectLastCall(); WorkspaceInfo ws = createNiceMock(WorkspaceInfo.class); CatalogModifyEvent e = createNiceMock(CatalogModifyEvent.class); expect(e.getSource()).andReturn(ws).anyTimes(); expect(e.getPropertyNames()).andReturn(Arrays.asList("name")); expect(e.getOldValues()).andReturn((List) Arrays.asList("gs")); expect(e.getNewValues()).andReturn((List) Arrays.asList("abcd")); replay(e, ws, ns, cat); new NamespaceWorkspaceConsistencyListener(cat).handleModifyEvent(e); verify(ns, cat); }
@Test public void testAddCoverage() throws Exception { testAddCoverageStore(); File d = new File(testData.getDataDirectoryRoot(), "workspaces/acme/foostore/foo"); assertFalse(d.exists()); NamespaceInfo ns = catalog.getFactory().createNamespace(); ns.setPrefix("bar"); ns.setURI("http://bar"); catalog.add(ns); CoverageInfo ft = catalog.getFactory().createCoverage(); ft.setName("foo"); ft.setNamespace(ns); ft.setStore(catalog.getCoverageStoreByName("acme", "foostore")); catalog.add(ft); assertTrue(d.exists()); }
secondaryWs.setName("secondary"); final NamespaceInfo secondaryNs = factory.createNamespace(); secondaryNs.setPrefix("secondary"); secondaryNs.setURI("http://www.geoserver.org/secondary"); catalog.add(secondaryWs);
@Test public void testOldJTSBindingConversion() throws Exception { Catalog catalog = new CatalogImpl(); CatalogFactory cFactory = catalog.getFactory(); WorkspaceInfo ws = cFactory.createWorkspace(); ws.setName("foo"); catalog.add(ws); NamespaceInfo ns = cFactory.createNamespace(); ns.setPrefix("acme"); ns.setURI("http://acme.org"); catalog.add(ns); DataStoreInfo ds = cFactory.createDataStore(); ds.setWorkspace(ws); ds.setName("foo"); catalog.add(ds); persister.setCatalog(catalog); FeatureTypeInfo ft = persister.load( getClass().getResourceAsStream("/org/geoserver/config/old_jts_binding.xml"), FeatureTypeInfo.class); assertNotNull(ft); assertEquals( org.locationtech.jts.geom.LineString.class, ft.getAttributes().get(0).getBinding()); }
ns2.setPrefix("ns2Prefix"); try { catalog.add(ns2);
ns.setPrefix("acme"); ns.setURI("http://acme.org"); catalog.add(ns);
/** Test for GEOS-6052 */ @Test public void testVirtualTableMissingEscapeSql() throws Exception { Catalog catalog = new CatalogImpl(); CatalogFactory cFactory = catalog.getFactory(); WorkspaceInfo ws = cFactory.createWorkspace(); ws.setName("foo"); catalog.add(ws); NamespaceInfo ns = cFactory.createNamespace(); ns.setPrefix("acme"); ns.setURI("http://acme.org"); catalog.add(ns); DataStoreInfo ds = cFactory.createDataStore(); ds.setWorkspace(ws); ds.setName("foo"); catalog.add(ds); persister.setCatalog(catalog); FeatureTypeInfo ft = persister.load( getClass() .getResourceAsStream( "/org/geoserver/config/virtualtable_error.xml"), FeatureTypeInfo.class); VirtualTable vt2 = (VirtualTable) ft.getMetadata().get(FeatureTypeInfo.JDBC_VIRTUAL_TABLE); assertNotNull(vt2); assertEquals(1, ft.getMetadata().size()); }
@Test public void testModifyNamespace() { catalog.add(ns); NamespaceInfo ns2 = catalog.getNamespaceByPrefix(ns.getPrefix()); ns2.setPrefix(null); ns2.setURI(null); try { catalog.save(ns2); fail("setting prefix to null should throw exception"); } catch (Exception e) { } ns2.setPrefix("ns2Prefix"); try { catalog.save(ns2); fail("setting uri to null should throw exception"); } catch (Exception e) { } ns2.setURI("ns2URI"); NamespaceInfo ns3 = catalog.getNamespaceByPrefix(ns.getPrefix()); assertEquals(ns.getPrefix(), ns3.getPrefix()); assertEquals(ns.getURI(), ns3.getURI()); catalog.save(ns2); // ns3 = catalog.getNamespaceByPrefix(ns.getPrefix()); ns3 = catalog.getNamespaceByPrefix("ns2Prefix"); assertEquals(ns2, ns3); assertEquals("ns2Prefix", ns3.getPrefix()); assertEquals("ns2URI", ns3.getURI()); }
ns.setPrefix("acme"); ns.setURI("http://acme.org"); catalog.add(ns);
@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(); }
ns.setPrefix("acme"); ns.setURI("http://acme.org"); catalog.add(ns);
ns.setPrefix("acme"); ns.setURI("http://acme.org"); catalog.add(ns);
@Test public void testGetFeatureTypeByName() { addFeatureType(); FeatureTypeInfo ft2 = catalog.getFeatureTypeByName(ft.getName()); assertNotNull(ft2); assertFalse(ft == ft2); assertEquals(ft, ft2); NamespaceInfo ns2 = catalog.getFactory().createNamespace(); ns2.setPrefix("ns2Prefix"); ns2.setURI("ns2URI"); catalog.add(ns2); FeatureTypeInfo ft3 = catalog.getFactory().createFeatureType(); ft3.setName("ft3Name"); ft3.setStore(ds); ft3.setNamespace(ns2); catalog.add(ft3); FeatureTypeInfo ft4 = catalog.getFeatureTypeByName(ns2.getPrefix(), ft3.getName()); assertNotNull(ft4); assertFalse(ft4 == ft3); assertEquals(ft3, ft4); ft4 = catalog.getFeatureTypeByName(ns2.getURI(), ft3.getName()); assertNotNull(ft4); assertFalse(ft4 == ft3); assertEquals(ft3, ft4); }