@Override public void setMode(Mode mode) { delegate.setMode(mode); }
@Test public void testChangeGroupMode() throws Exception { LayerGroupSummary summary = cc.groupCache.get(nature.getId()); assertEquals(Mode.SINGLE, summary.getMode()); nature.setMode(Mode.OPAQUE_CONTAINER); catalog.save(nature); summary = cc.groupCache.get(nature.getId()); assertEquals(Mode.OPAQUE_CONTAINER, summary.getMode()); } }
@Test public void testLayerGroupType() { addLayer(); LayerGroupInfo lg2 = catalog.getFactory().createLayerGroup(); lg2.setWorkspace(null); lg2.setName("layerGroup2"); lg2.setMode(LayerGroupInfo.Mode.NAMED); lg2.getLayers().add(l); lg2.getStyles().add(s); catalog.add(lg2); assertEquals(1, catalog.getLayerGroups().size()); lg2 = catalog.getLayerGroupByName("layerGroup2"); assertEquals(LayerGroupInfo.Mode.NAMED, lg2.getMode()); lg2.setMode(LayerGroupInfo.Mode.SINGLE); catalog.save(lg2); lg2 = catalog.getLayerGroupByName("layerGroup2"); assertEquals(LayerGroupInfo.Mode.SINGLE, lg2.getMode()); }
neatlineLayer = buildLayer(MockData.MAP_NEATLINE); lakesNeatline = buildGroup("lakesNeatline", lakesLayer, neatlineLayer); lakesNeatline.setMode(Mode.EO); roadSegmentsLayer = buildLayer(MockData.ROAD_SEGMENTS); lakesNeatline.setRootLayer(roadSegmentsLayer); container.setMode(LayerGroupInfo.Mode.CONTAINER); containerParent = buildGroup("containerParent", container); containerParent.getStyles().add(null);
private LayerGroupInfo addLayerGroup( String name, Mode mode, WorkspaceInfo ws, PublishedInfo... layers) throws Exception { CatalogBuilder cb = new CatalogBuilder(catalog); LayerGroupInfo group = catalog.getFactory().createLayerGroup(); group.setName(name); group.setMode(mode); if (ws != null) { group.setWorkspace(ws); } if (layers != null) { for (PublishedInfo layer : layers) { group.getLayers().add(layer); group.getStyles().add(null); } } cb.calculateLayerGroupBounds(group); catalog.add(group); if (ws != null) { return catalog.getLayerGroupByName(ws.getName(), name); } else { return catalog.getLayerGroupByName(name); } }
lg2.setRootLayerStyle(s); lg2.setMode(LayerGroupInfo.Mode.SINGLE); assertEquals(lg2.getLayers(), lg2.layers()); assertEquals(lg2.getStyles(), lg2.styles()); lg2.setMode(LayerGroupInfo.Mode.OPAQUE_CONTAINER); assertEquals(lg2.getLayers(), lg2.layers()); assertEquals(lg2.getStyles(), lg2.styles()); lg2.setMode(LayerGroupInfo.Mode.NAMED); assertEquals(lg2.getLayers(), lg2.layers()); assertEquals(lg2.getStyles(), lg2.styles()); lg2.setMode(LayerGroupInfo.Mode.CONTAINER); try { assertEquals(lg2.getLayers(), lg2.layers()); lg2.setMode(LayerGroupInfo.Mode.EO); assertEquals(1, lg2.layers().size()); assertEquals(1, lg2.styles().size());
private void testSerializationWithMode(Mode mode) throws Exception { Catalog catalog = new CatalogImpl(); CatalogFactory cFactory = catalog.getFactory(); LayerGroupInfo group1 = cFactory.createLayerGroup(); group1.setName("foo"); group1.setTitle("foo title"); group1.setAbstract("foo abstract"); group1.setMode(mode); ByteArrayOutputStream out = out(); persister.save(group1, out); // print(in(out)); ByteArrayInputStream in = in(out); LayerGroupInfo group2 = persister.load(in, LayerGroupInfo.class); assertEquals(group1.getName(), group2.getName()); assertEquals(group1.getTitle(), group2.getTitle()); assertEquals(group1.getAbstract(), group2.getAbstract()); assertEquals(group1.getMode(), group2.getMode()); Document dom = dom(in(out)); assertEquals("layerGroup", dom.getDocumentElement().getNodeName()); }
globalGroup.setMode(Mode.NAMED); catalog.save(globalGroup);
@Test public void testLayerGroupEoBounds() throws Exception { Catalog cat = getCatalog(); CatalogBuilder cb = new CatalogBuilder(cat); cb.setStore(cat.getDataStoreByName(MockData.LINES.getPrefix())); FeatureTypeInfo fti = cb.buildFeatureType(toName(MockData.LINES)); cb.setupBounds(fti); LayerInfo layer = cat.getFactory().createLayer(); layer.setResource(fti); layer.setName(fti.getName()); layer.setEnabled(true); layer.setType(PublishedType.VECTOR); LayerGroupInfo group = cat.getFactory().createLayerGroup(); group.setMode(LayerGroupInfo.Mode.EO); group.setName("group_EO"); group.setRootLayer(layer); assertNull(group.getBounds()); // force bounds computation cb.calculateLayerGroupBounds(group); assertNotNull(group.getBounds()); assertEquals(fti.getNativeBoundingBox(), group.getBounds()); }
@Test public void testNestedNamedGetMap() throws Exception { Catalog cat = getCatalog(); nested = createLayerGroup(cat, "nested", "nested", layer(cat, MockData.BRIDGES), global); nested.setMode(Mode.NAMED); cat.add(nested); LayerGroupInfo global = cat.getLayerGroupByName("base"); global.setMode(Mode.NAMED); cat.save(global); Document dom = getAsDOM("wms?request=reflect&layers=nested&format=rss"); // print(dom); assertXpathExists( "rss/channel/title[text() = 'cite:Bridges,cite:Lakes,cite:Forests']", dom); }
@Test public void testNestedNamedGetMap() throws Exception { Catalog cat = getCatalog(); nested = createLayerGroup(cat, "nested", "nested", layer(cat, MockData.BRIDGES), global); nested.setMode(Mode.NAMED); cat.add(nested); LayerGroupInfo global = cat.getLayerGroupByName("base"); global.setMode(Mode.NAMED); cat.save(global); Document dom = getAsDOM("wms?request=reflect&layers=nested&format=rss"); // print(dom); assertXpathExists( "rss/channel/title[text() = 'cite:Bridges,cite:Lakes,cite:Forests']", dom); }
@Test public void testNestedSharedGetMap() throws Exception { Catalog cat = getCatalog(); nested = createLayerGroup(cat, "nested", "nested", global, global2); nested.setMode(Mode.NAMED); cat.add(nested); Document dom = getAsDOM("wms?request=reflect&layers=nested&format=rss"); assertXpathExists( "rss/channel/title[text() = 'cite:Lakes,cite:Forests,cite:Lakes,cite:Forests']", dom); }
@Test public void testNestedSharedGetMap() throws Exception { Catalog cat = getCatalog(); nested = createLayerGroup(cat, "nested", "nested", global, global2); nested.setMode(Mode.NAMED); cat.add(nested); Document dom = getAsDOM("wms?request=reflect&layers=nested&format=rss"); assertXpathExists( "rss/channel/title[text() = 'cite:Lakes,cite:Forests,cite:Lakes,cite:Forests']", dom); }
protected void setupOpaqueGroup(Catalog catalog) throws Exception { // setup an opaque group too LayerGroupInfo opaqueGroup = catalog.getFactory().createLayerGroup(); LayerInfo roadSegments = catalog.getLayerByName(getLayerId(MockData.ROAD_SEGMENTS)); LayerInfo neatline = catalog.getLayerByName(getLayerId(MockData.MAP_NEATLINE)); if (roadSegments != null && neatline != null) { opaqueGroup.setName(OPAQUE_GROUP); opaqueGroup.setMode(Mode.OPAQUE_CONTAINER); opaqueGroup.getLayers().add(roadSegments); opaqueGroup.getLayers().add(neatline); opaqueGroup.getStyles().add(null); opaqueGroup.getStyles().add(null); CatalogBuilder cb = new CatalogBuilder(catalog); cb.calculateLayerGroupBounds(opaqueGroup); catalog.add(opaqueGroup); } }
@Test public void testNestedSingleGetMap() throws Exception { Catalog cat = getCatalog(); nested = createLayerGroup(cat, "nested", "nested", layer(cat, MockData.BRIDGES), global); nested.setMode(Mode.NAMED); cat.add(nested); Document dom = getAsDOM("wms?request=reflect&layers=nested&format=rss"); // print(dom); assertXpathExists( "rss/channel/title[text() = 'cite:Bridges,cite:Lakes,cite:Forests']", dom); }
@Test public void testNestedSingleGetMap() throws Exception { Catalog cat = getCatalog(); nested = createLayerGroup(cat, "nested", "nested", layer(cat, MockData.BRIDGES), global); nested.setMode(Mode.NAMED); cat.add(nested); Document dom = getAsDOM("wms?request=reflect&layers=nested&format=rss"); // print(dom); assertXpathExists( "rss/channel/title[text() = 'cite:Bridges,cite:Lakes,cite:Forests']", dom); }
@Override protected void onSetUp(SystemTestData testData) throws Exception { super.onSetUp(testData); Catalog catalog = getCatalog(); for (FeatureTypeInfo ft : catalog.getFeatureTypes()) { ft.setLatLonBoundingBox(null); catalog.save(ft); } // create a misconfigured layer group LayerGroupInfo lg = catalog.getFactory().createLayerGroup(); lg.getLayers().add(catalog.getLayerByName(getLayerId(MockData.LAKES))); lg.getStyles().add(null); lg.setName("test"); lg.setMode(Mode.NAMED); catalog.add(lg); }
@Test public void testContainerLayerGroup() throws Exception { String layerId = getLayerId(MockData.BUILDINGS); LayerInfo layer = getCatalog().getLayerByName(layerId); LayerGroupInfo group = getCatalog().getFactory().createLayerGroup(); group.setName("testContainerLayerGroup"); group.setMode(LayerGroupInfo.Mode.CONTAINER); group.getLayers().add(layer); getCatalog().add(group); try { PreviewLayerProvider provider = new PreviewLayerProvider(); PreviewLayer pl = getPreviewLayer(provider, group.prefixedName()); assertNull(pl); } finally { getCatalog().remove(group); } }
@Test public void testWorkspacedLayerGroup() throws Exception { String layerId = getLayerId(MockData.BUILDINGS); LayerInfo layer = getCatalog().getLayerByName(layerId); WorkspaceInfo ws = getCatalog().getWorkspaceByName("cite"); LayerGroupInfo group = getCatalog().getFactory().createLayerGroup(); group.setName("testWorkspacedLayerGroup"); group.setMode(LayerGroupInfo.Mode.SINGLE); group.setWorkspace(ws); group.getLayers().add(layer); getCatalog().add(group); try { PreviewLayerProvider provider = new PreviewLayerProvider(); PreviewLayer pl = getPreviewLayer(provider, group.prefixedName()); assertNotNull(pl); assertEquals("cite:testWorkspacedLayerGroup", pl.getName()); } finally { getCatalog().remove(group); } }