public List<StyleInfo> getStyles() { return delegate.getStyles(); }
@Test public void testGetStyles() { addWorkspace(); addStyle(); assertEquals(1, catalog.getStyles().size()); assertEquals(0, catalog.getStylesByWorkspace(ws.getName()).size()); assertEquals(0, catalog.getStylesByWorkspace(ws).size()); assertEquals(0, catalog.getStylesByWorkspace((WorkspaceInfo) null).size()); StyleInfo s2 = catalog.getFactory().createStyle(); s2.setName("styleNameWithWorkspace"); s2.setFilename("styleFilenameWithWorkspace"); s2.setWorkspace(ws); catalog.add(s2); assertEquals(2, catalog.getStyles().size()); assertEquals(1, catalog.getStylesByWorkspace(ws.getName()).size()); assertEquals(1, catalog.getStylesByWorkspace(ws).size()); assertEquals(1, catalog.getStylesByWorkspace((WorkspaceInfo) null).size()); }
public List<StyleInfo> getStyles() { return filterStyles(delegate.getStyles()); }
expect(catalog.getStyles()).andReturn(styles).anyTimes();
public List<StyleInfo> getStyles() { return filterStyles(user(), delegate.getStyles()); }
for (StyleInfo style : catalog.getStyles()) { SLDNamedLayerRenameVisitor visitor = new SLDNamedLayerRenameVisitor(catalog, doRename); try {
@Test public void testAddStyle() { assertTrue(catalog.getStyles().isEmpty()); addStyle(); assertEquals(1, catalog.getStyles().size()); StyleInfo s2 = catalog.getFactory().createStyle(); try { catalog.add(s2); fail("adding without name should throw exception"); } catch (Exception e) { } s2.setName("s2Name"); try { catalog.add(s2); fail("adding without fileName should throw exception"); } catch (Exception e) { } s2.setFilename("s2Filename"); try { catalog.getStyles().add(s2); fail("adding directly should throw exception"); } catch (Exception e) { } catalog.add(s2); assertEquals(2, catalog.getStyles().size()); }
@Test public void testProxyListBehaviour() throws Exception { catalog.add(s); StyleInfo s2 = catalog.getFactory().createStyle(); s2.setName("a" + s.getName()); s2.setFilename("a.sld"); catalog.add(s2); List<StyleInfo> styles = catalog.getStyles(); assertEquals(2, styles.size()); // test immutability Comparator<StyleInfo> comparator = new Comparator<StyleInfo>() { public int compare(StyleInfo o1, StyleInfo o2) { return o1.getName().compareTo(o2.getName()); } }; try { Collections.sort(styles, comparator); fail("Expected runtime exception, immutable collection"); } catch (RuntimeException e) { assertTrue(true); } styles = new ArrayList<StyleInfo>(styles); Collections.sort(styles, comparator); assertEquals("a" + s.getName(), styles.get(0).getName()); assertEquals(s.getName(), styles.get(1).getName()); }
@Test public void testParseStyleTwiceLock() throws Exception { StyleInfo style = getCatalog().getStyles().get(0); FileSystemResourceStore store = (FileSystemResourceStore) getDataDirectory().getResourceStore(); store.setLockProvider(new MemoryLockProvider()); // parse twice to check we are not locking on it Resource resource = getDataDirectory().style(style); Styles.handler(style.getFormat()) .parse(resource, style.getFormatVersion(), new DefaultResourceLocator(), null); Styles.handler(style.getFormat()) .parse(resource, style.getFormatVersion(), new DefaultResourceLocator(), null); }
@Override protected List<StyleInfo> getItems() { return getCatalog().getStyles(); }
@Override protected List<StyleInfo> getItems() { return getCatalog().getStyles(); }
private ArrayList<String> getStyles() { ArrayList<String> styleNames = new ArrayList<String>(); for (StyleInfo si : getCatalog().getStyles()) { styleNames.add(si.getName()); } return styleNames; }
@Override protected List<StyleInfo> load() { List<StyleInfo> styles = new ArrayList<StyleInfo>(GeoServerApplication.get().getCatalog().getStyles()); Collections.sort(styles, new StyleNameComparator()); return styles; } }
@Test public void testGetAllAsXML() throws Exception { Document dom = getAsDOM(RestBaseController.ROOT_PATH + "/styles.xml"); List<StyleInfo> styles = catalog.getStyles(); assertXpathEvaluatesTo("" + styles.size(), "count(//style)", dom); }
@Test public void testGetAllASJSON() throws Exception { JSON json = getAsJSON(RestBaseController.ROOT_PATH + "/styles.json"); List<StyleInfo> styles = catalog.getStyles(); assertEquals( styles.size(), ((JSONObject) json).getJSONObject("styles").getJSONArray("style").size()); }
public void testStyleAllPageAsAdmin() throws Exception { login(); tester.startPage(StylePage.class); tester.assertRenderedPage(StylePage.class); tester.debugComponentTrees(); Catalog cat = getCatalog(); DataView view = (DataView) tester.getComponentFromLastRenderedPage("table:listContainer:items"); assertEquals(cat.getStyles().size(), view.getItemCount()); }
@After public void cleanCatalog() throws IOException { for (StoreInfo s : getCatalog().getStores(StoreInfo.class)) { removeStore(s.getWorkspace().getName(), s.getName()); } for (StyleInfo s : getCatalog().getStyles()) { String styleName = s.getName(); if (!DEFAULT_STYLEs.contains(styleName)) { removeStyle(null, styleName); } } }