@Test public void testAutoSetDefaultStore() { catalog.add(ws); catalog.add(ds); assertEquals(1, catalog.getDataStores().size()); assertEquals(ds, catalog.getDefaultDataStore(ws)); }
@Test public void testAddLayerGroupNameConflict() throws Exception { addLayerGroup(); LayerGroupInfo lg2 = catalog.getFactory().createLayerGroup(); lg2.setName("layerGroup"); lg2.getLayers().add(l); lg2.getStyles().add(s); try { catalog.add(lg2); fail("should have failed because same name and no workspace set"); } catch (IllegalArgumentException expected) { } // setting a workspace shluld pass lg2.setWorkspace(ws); catalog.add(lg2); }
@Test public void testAddDataStoreDefaultWorkspace() { catalog.add(ws); catalog.setDefaultWorkspace(ws); DataStoreInfo ds2 = catalog.getFactory().createDataStore(); ds2.setName("ds2Name"); catalog.add(ds2); assertEquals(ws, ds2.getWorkspace()); }
store = catalog.getFactory().createDataStore(); store.setName(prefix); store.setWorkspace(catalog.getWorkspaceByName(prefix)); catalog.add(store); FeatureTypeInfo featureType = catalog.getFactory().createFeatureType(); featureType.setStore(store); featureType.setNamespace(catalog.getNamespaceByPrefix(prefix)); featureType.getKeywords().add(new Keyword(name)); featureType.setEnabled(true); featureType.setProjectionPolicy( if (ft == null) { ft = featureType; catalog.add(featureType); } else { if (layer == null) { catalog.add(featureType); } else { new CatalogBuilder(catalog).updateFeatureType(ft, featureType); catalog.add(layer); } else { catalog.save(layer);
@Test public void testAddWorkspace() throws Exception { File ws = new File(testData.getDataDirectoryRoot(), "workspaces/acme"); assertFalse(ws.exists()); WorkspaceInfo acme = catalog.getFactory().createWorkspace(); acme.setName("acme"); catalog.add(acme); assertTrue(ws.exists()); }
/** Keys for overriding default layer properties */ public static class StyleProperty<T> { T get(Map<StyleProperty, Object> map, T def) { return map != null && map.containsKey(this) ? (T) map.get(this) : def; } public static StyleProperty<String> FORMAT = new StyleProperty<String>(); public static StyleProperty<Version> FORMAT_VERSION = new StyleProperty<Version>(); public static StyleProperty<LegendInfo> LEGEND_INFO = new StyleProperty<LegendInfo>(); }
@Test public void testAddLayerGroupWithWorkspaceWithResourceFromAnotherWorkspace() { WorkspaceInfo ws = catalog.getFactory().createWorkspace(); ws.setName("other"); catalog.add(ws); LayerGroupInfo lg2 = catalog.getFactory().createLayerGroup(); lg2.setWorkspace(ws); lg2.setName("layerGroup2"); lg2.getLayers().add(l); lg2.getStyles().add(s); try { catalog.add(lg2); fail(); } catch (IllegalArgumentException expected) { } }
@Test public void testAutoCascadeDefaultWorksapce() { CatalogFactory factory = catalog.getFactory(); WorkspaceInfo ws1 = factory.createWorkspace(); ws1.setName("ws1Name"); WorkspaceInfo ws2 = factory.createWorkspace(); ws2.setName("ws2Name"); catalog.add(ws1); catalog.add(ws2); assertEquals(ws1, catalog.getDefaultWorkspace()); catalog.remove(ws1); assertEquals(ws2, catalog.getDefaultWorkspace()); }
@Test public void testAutoSetDefaultNamespace() { catalog.add(ns); assertEquals(1, catalog.getNamespaces().size()); assertEquals(ns, catalog.getDefaultNamespace()); }
@Test public void testAddStyle() throws Exception { File f = new File(testData.getDataDirectoryRoot(), "styles/foostyle.xml"); assertFalse(f.exists()); StyleInfo s = catalog.getFactory().createStyle(); s.setName("foostyle"); s.setFilename("foostyle.sld"); catalog.add(s); assertTrue(f.exists()); }
private void addLocalGroup(CatalogFactory factory, WorkspaceInfo citeWs) { LayerGroupInfo localGroup = factory.createLayerGroup(); localGroup.setName(LOCAL_GROUP); localGroup.setWorkspace(citeWs); localGroup.getLayers().add(getBuildingsLayer()); localGroup.getLayers().add(getBridgesLayer()); localGroup.getStyles().add(null); localGroup.getStyles().add(null); catalog.add(localGroup); }
@Test public void testAddWorkspace() { assertTrue(catalog.getWorkspaces().isEmpty()); catalog.add(ws); assertEquals(1, catalog.getWorkspaces().size()); WorkspaceInfo ws2 = catalog.getFactory().createWorkspace(); try { catalog.getWorkspaces().add(ws2); fail("adding directly should throw an exception"); } catch (Exception e) { } try { catalog.add(ws2); fail("addign without a name should throw an exception"); } catch (Exception e) { } ws2.setName("ws2"); catalog.add(ws2); }
@Test public void testAutoSetDefaultWorkspace() { catalog.add(ws); assertEquals(1, catalog.getWorkspaces().size()); assertEquals(ws, catalog.getDefaultWorkspace()); assertNull(catalog.getDefaultNamespace()); }
@Test public void testAddCoverageStore() throws Exception { testAddWorkspace(); File dir = new File(testData.getDataDirectoryRoot(), "workspaces/acme/foostore"); assertFalse(dir.exists()); CoverageStoreInfo cs = catalog.getFactory().createCoverageStore(); cs.setName("foostore"); cs.setWorkspace(catalog.getWorkspaceByName("acme")); catalog.add(cs); assertTrue(dir.exists()); assertTrue(new File(dir, "coveragestore.xml").exists()); }
@Test public void testInvalidStyleGroup() throws Exception { Catalog catalog = getCatalog(); LayerGroupInfo lg = catalog.getFactory().createLayerGroup(); StyleInfo s = catalog.getStyleByName("polygon"); lg.setWorkspace(null); lg.setName("invalidStyleLayerGroup"); lg.getLayers().add(null); lg.getStyles().add(s); try { catalog.add(lg); fail("Should not be able to add an invalid style group to the catalog"); } catch (Exception e) { assertEquals( "Invalid style group: No layer or layer group named 'Default Polygon' found in the catalog", e.getMessage()); } }
@Test public void testAddWMSStore() { assertTrue(catalog.getStores(WMSStoreInfo.class).isEmpty()); addWMSStore(); assertEquals(1, catalog.getStores(WMSStoreInfo.class).size()); WMSStoreInfo retrieved = catalog.getStore(wms.getId(), WMSStoreInfo.class); WMSStoreInfo wms2 = catalog.getFactory().createWebMapServer(); wms2.setName("wms2Name"); wms2.setWorkspace(ws); catalog.add(wms2); assertEquals(2, catalog.getStores(WMSStoreInfo.class).size()); }
@Test public void testFullTextSearchLayerGroupName() { addLayer(); // geos-6882 catalog.add(lg); Filter filter = Predicates.fullTextSearch("Group"); assertEquals(newHashSet(lg), asSet(catalog.list(LayerGroupInfo.class, filter))); }