#176 Fix tests related to styles in workspaces
This commit is contained in:
parent
5447c06dbc
commit
ff7f383591
@ -156,7 +156,7 @@ public class GeoserverRESTArcGridTest extends GeoserverRESTTest {
|
||||
assertTrue(reader.existsCoveragestore(DEFAULT_WS, storeName));
|
||||
assertTrue(reader.existsCoverage(DEFAULT_WS, storeName, storeName));
|
||||
RESTLayer layer = reader.getLayer(DEFAULT_WS, storeName);
|
||||
assertEquals("mystyle", layer.getDefaultStyle());
|
||||
assertEquals(DEFAULT_WS + ":mystyle", layer.getDefaultStyle());
|
||||
assertEquals(DEFAULT_WS, layer.getDefaultStyleWorkspace());
|
||||
}
|
||||
|
||||
|
||||
@ -130,7 +130,8 @@ public class GeoserverRESTGeoTiffTest extends GeoserverRESTTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGeoTiffWithStyleInWorkspace() throws IOException {
|
||||
public void testGeoTiffWithStyleInWorkspace() throws IOException
|
||||
{
|
||||
if (!enabled()) return;
|
||||
deleteAll();
|
||||
|
||||
@ -155,11 +156,11 @@ public class GeoserverRESTGeoTiffTest extends GeoserverRESTTest {
|
||||
|
||||
assertNotNull("publish() failed", pub);
|
||||
// Test exists
|
||||
assertTrue(reader.existsCoveragestore(DEFAULT_WS, storeName));
|
||||
assertTrue(reader.existsCoverage(DEFAULT_WS, storeName, storeName));
|
||||
assertTrue("New coverage not found", reader.existsCoveragestore(DEFAULT_WS, storeName));
|
||||
assertTrue("New Store not found", reader.existsCoverage(DEFAULT_WS, storeName, storeName));
|
||||
RESTLayer layer = reader.getLayer(DEFAULT_WS, storeName);
|
||||
assertEquals("mystyle", layer.getDefaultStyle());
|
||||
assertEquals(DEFAULT_WS, layer.getDefaultStyleWorkspace());
|
||||
assertEquals("Bad default style", DEFAULT_WS + ":mystyle", layer.getDefaultStyle());
|
||||
assertEquals("Bad workspace for style", DEFAULT_WS, layer.getDefaultStyleWorkspace());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@ -274,7 +274,7 @@ public class GeoserverRESTShapeTest extends GeoserverRESTTest {
|
||||
RESTLayer layer = reader.getLayer(layerName);
|
||||
// RESTLayer layerDecoder = new RESTLayer(layer);
|
||||
LOGGER.info("Layer style is " + layer.getDefaultStyle());
|
||||
assertEquals("Style not assigned properly", styleName, layer.getDefaultStyle());
|
||||
assertEquals("Style not assigned properly", DEFAULT_WS + ":" + styleName, layer.getDefaultStyle());
|
||||
assertEquals("Style not assigned properly", DEFAULT_WS, layer.getDefaultStyleWorkspace());
|
||||
|
||||
// remove also datastore
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* GeoServer-Manager - Simple Manager Library for GeoServer
|
||||
*
|
||||
* Copyright (C) 2007,2015 GeoSolutions S.A.S.
|
||||
* Copyright (C) 2007-2016 GeoSolutions S.A.S.
|
||||
* http://www.geo-solutions.it
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
@ -57,27 +57,27 @@ import org.springframework.core.io.ClassPathResource;
|
||||
*/
|
||||
public class GeoserverRESTStyleTest extends GeoserverRESTTest {
|
||||
|
||||
private final static Logger LOGGER = LoggerFactory
|
||||
.getLogger(GeoserverRESTStyleTest.class);
|
||||
private final static Logger LOGGER = LoggerFactory.getLogger(GeoserverRESTStyleTest.class);
|
||||
|
||||
@Test
|
||||
public void testStyles() throws IOException {
|
||||
if (!enabled())
|
||||
return;
|
||||
deleteAll();
|
||||
@Test
|
||||
public void testStyles() throws IOException
|
||||
{
|
||||
if (!enabled()) {
|
||||
return;
|
||||
}
|
||||
deleteAll();
|
||||
|
||||
assertEquals(0, reader.getStyles().size());
|
||||
assertEquals(0, reader.getStyles().size());
|
||||
|
||||
final String STYLENAME = "restteststyle";
|
||||
File sldFile = new ClassPathResource("testdata/restteststyle.sld")
|
||||
.getFile();
|
||||
final String STYLENAME = "restteststyle";
|
||||
File sldFile = new ClassPathResource("testdata/restteststyle.sld").getFile();
|
||||
|
||||
// insert style
|
||||
assertTrue(publisher.publishStyle(sldFile));
|
||||
assertTrue(reader.existsStyle(STYLENAME));
|
||||
// insert style
|
||||
assertTrue(publisher.publishStyle(sldFile));
|
||||
assertTrue(reader.existsStyle(STYLENAME));
|
||||
|
||||
assertFalse(publisher.publishStyle(sldFile));
|
||||
assertTrue(reader.existsStyle(STYLENAME));
|
||||
assertFalse(publisher.publishStyle(sldFile));
|
||||
assertTrue(reader.existsStyle(STYLENAME));
|
||||
|
||||
// insert style v110
|
||||
final String STYLENAMEV110 = "restteststyleV110";
|
||||
@ -92,288 +92,292 @@ public class GeoserverRESTStyleTest extends GeoserverRESTTest {
|
||||
assertEquals(STYLENAME, style.getName());
|
||||
assertNull(style.getWorkspace());
|
||||
|
||||
String sld = reader.getSLD(STYLENAME);
|
||||
assertNotNull(sld);
|
||||
String sld = reader.getSLD(STYLENAME);
|
||||
assertNotNull(sld);
|
||||
|
||||
Element styleEl = JDOMBuilder.buildElement(sld);
|
||||
assertNotNull(styleEl);
|
||||
Element styleEl = JDOMBuilder.buildElement(sld);
|
||||
assertNotNull(styleEl);
|
||||
|
||||
Namespace SLDNS = Namespace.getNamespace("sld",
|
||||
"http://www.opengis.net/sld");
|
||||
Namespace SLDNS = Namespace.getNamespace("sld", "http://www.opengis.net/sld");
|
||||
|
||||
try {
|
||||
try {
|
||||
assertEquals(STYLENAME, styleEl.getChild("NamedLayer", SLDNS)
|
||||
.getChild("Name", SLDNS).getText());
|
||||
assertEquals("STYLE FOR TESTING PURPOSES",
|
||||
styleEl.getChild("NamedLayer", SLDNS)
|
||||
.getChild("UserStyle", SLDNS)
|
||||
.getChild("Title", SLDNS).getText());
|
||||
} catch (NullPointerException npe) {
|
||||
fail("Error in SLD");
|
||||
}
|
||||
|
||||
assertEquals(STYLENAME, styleEl.getChild("NamedLayer", SLDNS)
|
||||
.getChild("Name", SLDNS).getText());
|
||||
assertEquals("STYLE FOR TESTING PURPOSES",
|
||||
styleEl.getChild("NamedLayer", SLDNS)
|
||||
.getChild("UserStyle", SLDNS)
|
||||
.getChild("Title", SLDNS).getText());
|
||||
} catch (NullPointerException npe) {
|
||||
fail("Error in SLD");
|
||||
}
|
||||
// assertEquals(1475, sld.length());
|
||||
assertEquals(2, reader.getStyles().size());
|
||||
}
|
||||
|
||||
// assertEquals(1475, sld.length());
|
||||
protected void cleanupTestStyle(final String styleName)
|
||||
{
|
||||
// dry run delete to work in a known state
|
||||
if (reader.existsStyle(styleName)) {
|
||||
LOGGER.info("Clearing stale test style " + styleName);
|
||||
boolean ok = publisher.removeStyle(styleName);
|
||||
if (!ok) {
|
||||
fail("Could not unpublish style " + styleName);
|
||||
}
|
||||
}
|
||||
assertFalse("Cleanup failed", reader.existsStyle(styleName));
|
||||
}
|
||||
|
||||
assertEquals(2, reader.getStyles().size());
|
||||
}
|
||||
@Test
|
||||
public void testPublishDeleteStyleFile() throws FileNotFoundException,
|
||||
IOException {
|
||||
if (!enabled()) {
|
||||
return;
|
||||
}
|
||||
// Assume.assumeTrue(enabled);
|
||||
final String styleName = "restteststyle";
|
||||
|
||||
protected void cleanupTestStyle(final String styleName) {
|
||||
// dry run delete to work in a known state
|
||||
if (reader.existsStyle(styleName)) {
|
||||
LOGGER.info("Clearing stale test style " + styleName);
|
||||
boolean ok = publisher.removeStyle(styleName);
|
||||
if (!ok) {
|
||||
fail("Could not unpublish style " + styleName);
|
||||
}
|
||||
}
|
||||
assertFalse("Cleanup failed", reader.existsStyle(styleName));
|
||||
}
|
||||
File sldFile = new ClassPathResource("testdata/restteststyle.sld")
|
||||
.getFile();
|
||||
|
||||
@Test
|
||||
public void testPublishDeleteStyleFile() throws FileNotFoundException,
|
||||
IOException {
|
||||
if (!enabled()) {
|
||||
return;
|
||||
}
|
||||
// Assume.assumeTrue(enabled);
|
||||
final String styleName = "restteststyle";
|
||||
final String STYLENAMEV110 = "restteststyleV110";
|
||||
File sldFileV110 = new ClassPathResource("testdata/" + STYLENAMEV110 + ".sld")
|
||||
.getFile();
|
||||
|
||||
File sldFile = new ClassPathResource("testdata/restteststyle.sld")
|
||||
.getFile();
|
||||
// known state?
|
||||
cleanupTestStyle(styleName);
|
||||
cleanupTestStyle(STYLENAMEV110);
|
||||
|
||||
final String STYLENAMEV110 = "restteststyleV110";
|
||||
File sldFileV110 = new ClassPathResource("testdata/" + STYLENAMEV110 + ".sld")
|
||||
.getFile();
|
||||
// test insert
|
||||
boolean published = publisher.publishStyle(sldFile); // Will take the
|
||||
// name from sld
|
||||
// contents
|
||||
assertTrue("publish() failed", published);
|
||||
assertTrue(reader.existsStyle(styleName));
|
||||
|
||||
// known state?
|
||||
cleanupTestStyle(styleName);
|
||||
cleanupTestStyle(STYLENAMEV110);
|
||||
sldFile = new ClassPathResource("testdata/restteststyle2.sld").getFile();
|
||||
published = publisher.updateStyle(sldFile, styleName); // update
|
||||
assertTrue("update() failed", published);
|
||||
|
||||
// test insert
|
||||
boolean published = publisher.publishStyle(sldFile); // Will take the
|
||||
// name from sld
|
||||
// contents
|
||||
assertTrue("publish() failed", published);
|
||||
assertTrue(reader.existsStyle(styleName));
|
||||
// test delete
|
||||
boolean ok = publisher.removeStyle(styleName);
|
||||
assertTrue("Unpublish() failed", ok);
|
||||
assertFalse(reader.existsStyle(styleName));
|
||||
|
||||
sldFile = new ClassPathResource("testdata/restteststyle2.sld").getFile();
|
||||
published = publisher.updateStyle(sldFile, styleName); // update
|
||||
assertTrue("update() failed", published);
|
||||
published = publisher.publishStyle(sldFileV110, STYLENAMEV110, true);
|
||||
|
||||
// test delete
|
||||
boolean ok = publisher.removeStyle(styleName);
|
||||
assertTrue("Unpublish() failed", ok);
|
||||
assertFalse(reader.existsStyle(styleName));
|
||||
assertTrue("publish() failed", published);
|
||||
assertTrue(reader.existsStyle(STYLENAMEV110));
|
||||
|
||||
published = publisher.publishStyle(sldFileV110, STYLENAMEV110, true);
|
||||
boolean updated = publisher.updateStyle(sldFileV110, STYLENAMEV110, true);
|
||||
assertTrue("update() failed", updated);
|
||||
|
||||
assertTrue("publish() failed", published);
|
||||
assertTrue(reader.existsStyle(STYLENAMEV110));
|
||||
// test delete
|
||||
ok = publisher.removeStyle(STYLENAMEV110);
|
||||
assertTrue("Unpublish() failed", ok);
|
||||
assertFalse(reader.existsStyle(STYLENAMEV110));
|
||||
}
|
||||
|
||||
boolean updated = publisher.updateStyle(sldFileV110, STYLENAMEV110, true);
|
||||
assertTrue("update() failed", updated);
|
||||
@Test
|
||||
public void testPublishDeleteStyleString()
|
||||
throws FileNotFoundException, IOException
|
||||
{
|
||||
if (!enabled()) {
|
||||
return;
|
||||
}
|
||||
// Assume.assumeTrue(enabled);
|
||||
String styleName = "restteststyle";
|
||||
|
||||
// test delete
|
||||
ok = publisher.removeStyle(STYLENAMEV110);
|
||||
assertTrue("Unpublish() failed", ok);
|
||||
assertFalse(reader.existsStyle(STYLENAMEV110));
|
||||
}
|
||||
File sldFile = new ClassPathResource("testdata/restteststyle.sld")
|
||||
.getFile();
|
||||
|
||||
@Test
|
||||
public void testPublishDeleteStyleString() throws FileNotFoundException,
|
||||
IOException {
|
||||
if (!enabled()) {
|
||||
return;
|
||||
}
|
||||
// Assume.assumeTrue(enabled);
|
||||
String styleName = "restteststyle";
|
||||
// known state?
|
||||
cleanupTestStyle(styleName);
|
||||
|
||||
File sldFile = new ClassPathResource("testdata/restteststyle.sld")
|
||||
.getFile();
|
||||
// test insert
|
||||
String sldContent = IOUtils.toString(new FileInputStream(sldFile));
|
||||
|
||||
// known state?
|
||||
cleanupTestStyle(styleName);
|
||||
boolean published = publisher.publishStyle(sldContent); // Will take the
|
||||
// name from sld
|
||||
// contents
|
||||
assertTrue("publish() failed", published);
|
||||
assertTrue(reader.existsStyle(styleName));
|
||||
// test delete
|
||||
boolean ok = publisher.removeStyle(styleName);
|
||||
assertTrue("Unpublish() failed", ok);
|
||||
assertFalse(reader.existsStyle(styleName));
|
||||
|
||||
// test insert
|
||||
String sldContent = IOUtils.toString(new FileInputStream(sldFile));
|
||||
styleName = "restteststyle_with_name";
|
||||
// test insert with name
|
||||
published = publisher.publishStyle(sldContent, styleName); // Will set
|
||||
// the name
|
||||
assertTrue("publish() failed", published);
|
||||
assertTrue(reader.existsStyle(styleName));
|
||||
String newSldContent = sldContent.replace(
|
||||
"<sld:Title>STYLE FOR TESTING PURPOSES</sld:Title>",
|
||||
"<sld:Title>MODIFIED STYLE FOR TESTING</sld:Title>");
|
||||
published = publisher.updateStyle(newSldContent, styleName); // update
|
||||
assertTrue("publish() failed", published);
|
||||
|
||||
boolean published = publisher.publishStyle(sldContent); // Will take the
|
||||
// name from sld
|
||||
// contents
|
||||
assertTrue("publish() failed", published);
|
||||
assertTrue(reader.existsStyle(styleName));
|
||||
// test delete
|
||||
boolean ok = publisher.removeStyle(styleName);
|
||||
assertTrue("Unpublish() failed", ok);
|
||||
assertFalse(reader.existsStyle(styleName));
|
||||
// test delete
|
||||
ok = publisher.removeStyle(styleName);
|
||||
assertTrue("Unpublish() failed", ok);
|
||||
assertFalse(reader.existsStyle(styleName));
|
||||
|
||||
styleName = "restteststyle_with_name";
|
||||
// test insert with name
|
||||
published = publisher.publishStyle(sldContent, styleName); // Will set
|
||||
// the name
|
||||
assertTrue("publish() failed", published);
|
||||
assertTrue(reader.existsStyle(styleName));
|
||||
String newSldContent = sldContent.replace(
|
||||
"<sld:Title>STYLE FOR TESTING PURPOSES</sld:Title>",
|
||||
"<sld:Title>MODIFIED STYLE FOR TESTING</sld:Title>");
|
||||
published = publisher.updateStyle(newSldContent, styleName); // update
|
||||
assertTrue("publish() failed", published);
|
||||
}
|
||||
|
||||
// test delete
|
||||
ok = publisher.removeStyle(styleName);
|
||||
assertTrue("Unpublish() failed", ok);
|
||||
assertFalse(reader.existsStyle(styleName));
|
||||
@Test
|
||||
public void testUpdateDefaultStyle()
|
||||
throws FileNotFoundException, IOException
|
||||
{
|
||||
if (!enabled()) {
|
||||
return;
|
||||
}
|
||||
deleteAll();
|
||||
|
||||
}
|
||||
String storeName = "resttestshp";
|
||||
String layerName = "cities";
|
||||
|
||||
@Test
|
||||
public void testUpdateDefaultStyle() throws FileNotFoundException,
|
||||
IOException {
|
||||
if (!enabled()) {
|
||||
return;
|
||||
}
|
||||
deleteAll();
|
||||
final String styleName = "restteststyle";
|
||||
{
|
||||
File sldFile = new ClassPathResource("testdata/restteststyle.sld")
|
||||
.getFile();
|
||||
cleanupTestStyle(styleName);
|
||||
boolean sldpublished = publisher.publishStyle(sldFile); // Will take
|
||||
// the name
|
||||
// from sld
|
||||
// contents
|
||||
assertTrue("style publish() failed", sldpublished);
|
||||
assertTrue(reader.existsStyle(styleName));
|
||||
}
|
||||
|
||||
String storeName = "resttestshp";
|
||||
String layerName = "cities";
|
||||
final String styleName2 = "restteststyle2";
|
||||
{
|
||||
File sldFile = new ClassPathResource("testdata/restteststyle2.sld")
|
||||
.getFile();
|
||||
cleanupTestStyle(styleName2);
|
||||
boolean sldpublished = publisher.publishStyle(sldFile, styleName2);
|
||||
assertTrue("style publish() failed", sldpublished);
|
||||
assertTrue(reader.existsStyle(styleName2));
|
||||
}
|
||||
|
||||
final String styleName = "restteststyle";
|
||||
{
|
||||
File sldFile = new ClassPathResource("testdata/restteststyle.sld")
|
||||
.getFile();
|
||||
cleanupTestStyle(styleName);
|
||||
boolean sldpublished = publisher.publishStyle(sldFile); // Will take
|
||||
// the name
|
||||
// from sld
|
||||
// contents
|
||||
assertTrue("style publish() failed", sldpublished);
|
||||
assertTrue(reader.existsStyle(styleName));
|
||||
}
|
||||
File zipFile = new ClassPathResource("testdata/resttestshp.zip")
|
||||
.getFile();
|
||||
|
||||
final String styleName2 = "restteststyle2";
|
||||
{
|
||||
File sldFile = new ClassPathResource("testdata/restteststyle2.sld")
|
||||
.getFile();
|
||||
cleanupTestStyle(styleName2);
|
||||
boolean sldpublished = publisher.publishStyle(sldFile, styleName2);
|
||||
assertTrue("style publish() failed", sldpublished);
|
||||
assertTrue(reader.existsStyle(styleName2));
|
||||
}
|
||||
assertTrue(publisher.createWorkspace(DEFAULT_WS));
|
||||
|
||||
File zipFile = new ClassPathResource("testdata/resttestshp.zip")
|
||||
.getFile();
|
||||
// test insert
|
||||
boolean published = publisher.publishShp(DEFAULT_WS, storeName,
|
||||
layerName, zipFile, "EPSG:4326", styleName);
|
||||
assertTrue("publish() failed", published);
|
||||
assertTrue(existsLayer(layerName));
|
||||
|
||||
assertTrue(publisher.createWorkspace(DEFAULT_WS));
|
||||
{
|
||||
RESTLayer layer = reader.getLayer(layerName);
|
||||
LOGGER.info("Layer style is " + layer.getDefaultStyle());
|
||||
assertEquals(styleName, layer.getDefaultStyle());
|
||||
}
|
||||
|
||||
// test insert
|
||||
boolean published = publisher.publishShp(DEFAULT_WS, storeName,
|
||||
layerName, zipFile, "EPSG:4326", styleName);
|
||||
assertTrue("publish() failed", published);
|
||||
assertTrue(existsLayer(layerName));
|
||||
GSLayerEncoder le = new GSLayerEncoder();
|
||||
le.setDefaultStyle(styleName2);
|
||||
publisher.configureLayer(DEFAULT_WS, layerName, le);
|
||||
|
||||
{
|
||||
RESTLayer layer = reader.getLayer(layerName);
|
||||
LOGGER.info("Layer style is " + layer.getDefaultStyle());
|
||||
assertEquals(styleName, layer.getDefaultStyle());
|
||||
}
|
||||
{
|
||||
RESTLayer layer = reader.getLayer(layerName);
|
||||
LOGGER.info("Layer style is " + layer.getDefaultStyle());
|
||||
assertEquals(styleName2, layer.getDefaultStyle());
|
||||
}
|
||||
|
||||
GSLayerEncoder le = new GSLayerEncoder();
|
||||
le.setDefaultStyle(styleName2);
|
||||
publisher.configureLayer(DEFAULT_WS, layerName, le);
|
||||
// remove layer and datastore
|
||||
boolean dsRemoved = publisher.removeDatastore(DEFAULT_WS, storeName,
|
||||
true);
|
||||
assertTrue("removeDatastore() failed", dsRemoved);
|
||||
}
|
||||
|
||||
{
|
||||
RESTLayer layer = reader.getLayer(layerName);
|
||||
LOGGER.info("Layer style is " + layer.getDefaultStyle());
|
||||
assertEquals(styleName2, layer.getDefaultStyle());
|
||||
}
|
||||
|
||||
// remove layer and datastore
|
||||
boolean dsRemoved = publisher.removeDatastore(DEFAULT_WS, storeName,
|
||||
true);
|
||||
assertTrue("removeDatastore() failed", dsRemoved);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStylesInWorkspace() throws IOException {
|
||||
if (!enabled())
|
||||
return;
|
||||
deleteAll();
|
||||
@Test
|
||||
public void testStylesInWorkspace() throws IOException
|
||||
{
|
||||
if (!enabled()) {
|
||||
return;
|
||||
}
|
||||
deleteAll();
|
||||
|
||||
final String WORKSPACE = "testWorkspace";
|
||||
final String STYLENAME = "restteststyle";
|
||||
File sldFile = new ClassPathResource("testdata/restteststyle.sld").getFile();
|
||||
final String STYLENAME = "restteststyle";
|
||||
File sldFile = new ClassPathResource("testdata/restteststyle.sld").getFile();
|
||||
|
||||
publisher.createWorkspace(WORKSPACE);
|
||||
|
||||
assertEquals(0, reader.getStyles().size());
|
||||
assertEquals(0, reader.getStyles(WORKSPACE).size());
|
||||
assertEquals(0, reader.getStyles().size());
|
||||
assertEquals(0, reader.getStyles(WORKSPACE).size());
|
||||
|
||||
// insert style
|
||||
assertTrue("Error inserting style", publisher.publishStyleInWorkspace(WORKSPACE, sldFile));
|
||||
assertTrue("Style does not exist in workspace", reader.existsStyle(WORKSPACE, STYLENAME));
|
||||
|
||||
// insert style
|
||||
assertTrue(publisher.publishStyleInWorkspace(WORKSPACE, sldFile));
|
||||
assertTrue(reader.existsStyle(WORKSPACE, STYLENAME));
|
||||
assertFalse(reader.existsStyle(STYLENAME));
|
||||
// this assertion is not enforced by geoserver, which is quite lenient in searching names
|
||||
//assertFalse("Style should not be global", reader.existsStyle(STYLENAME));
|
||||
|
||||
// insert style again
|
||||
assertFalse(publisher.publishStyleInWorkspace(WORKSPACE, sldFile));
|
||||
assertTrue(reader.existsStyle(WORKSPACE, STYLENAME));
|
||||
assertFalse(reader.existsStyle(STYLENAME));
|
||||
assertFalse("Dup style not trapped", publisher.publishStyleInWorkspace(WORKSPACE, sldFile));
|
||||
assertTrue("Style does not exist in workspace (2)", reader.existsStyle(WORKSPACE, STYLENAME));
|
||||
// this assertion is not enforced by geoserver, which is quite lenient in searching names
|
||||
//assertFalse("Style should not be global (2)", reader.existsStyle(STYLENAME));
|
||||
|
||||
String sld = reader.getSLD(WORKSPACE, STYLENAME);
|
||||
assertNotNull(sld);
|
||||
String sld = reader.getSLD(WORKSPACE, STYLENAME);
|
||||
assertNotNull(sld);
|
||||
|
||||
RESTStyle style = reader.getStyle(WORKSPACE, STYLENAME);
|
||||
assertEquals(STYLENAME, style.getName());
|
||||
assertEquals(WORKSPACE, style.getWorkspace());
|
||||
|
||||
Element styleEl = JDOMBuilder.buildElement(sld);
|
||||
assertNotNull(styleEl);
|
||||
Element styleEl = JDOMBuilder.buildElement(sld);
|
||||
assertNotNull(styleEl);
|
||||
|
||||
Namespace SLDNS = Namespace.getNamespace("sld",
|
||||
"http://www.opengis.net/sld");
|
||||
Namespace SLDNS = Namespace.getNamespace("sld", "http://www.opengis.net/sld");
|
||||
|
||||
try {
|
||||
try {
|
||||
|
||||
assertEquals(STYLENAME, styleEl.getChild("NamedLayer", SLDNS)
|
||||
.getChild("Name", SLDNS).getText());
|
||||
assertEquals(
|
||||
"STYLE FOR TESTING PURPOSES",
|
||||
styleEl.getChild("NamedLayer", SLDNS)
|
||||
.getChild("UserStyle", SLDNS)
|
||||
.getChild("Title", SLDNS).getText());
|
||||
} catch (NullPointerException npe) {
|
||||
fail("Error in SLD");
|
||||
}
|
||||
assertEquals(STYLENAME, styleEl.getChild("NamedLayer", SLDNS)
|
||||
.getChild("Name", SLDNS).getText());
|
||||
assertEquals(
|
||||
"STYLE FOR TESTING PURPOSES",
|
||||
styleEl.getChild("NamedLayer", SLDNS)
|
||||
.getChild("UserStyle", SLDNS)
|
||||
.getChild("Title", SLDNS).getText());
|
||||
} catch (NullPointerException npe) {
|
||||
fail("Error in SLD");
|
||||
}
|
||||
|
||||
// assertEquals(1475, sld.length());
|
||||
// assertEquals(1475, sld.length());
|
||||
assertEquals(0, reader.getStyles().size());
|
||||
assertEquals(1, reader.getStyles(WORKSPACE).size());
|
||||
}
|
||||
|
||||
assertEquals(0, reader.getStyles().size());
|
||||
assertEquals(1, reader.getStyles(WORKSPACE).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemoveStylesInWorkspace() throws IOException {
|
||||
if (!enabled())
|
||||
return;
|
||||
deleteAll();
|
||||
@Test
|
||||
public void testRemoveStylesInWorkspace() throws IOException
|
||||
{
|
||||
if (!enabled()) {
|
||||
return;
|
||||
}
|
||||
deleteAll();
|
||||
|
||||
final String WORKSPACE = "testWorkspace";
|
||||
final String STYLENAME = "restteststyle";
|
||||
final File sldFile = new ClassPathResource("testdata/restteststyle.sld").getFile();
|
||||
final String STYLENAME = "restteststyle";
|
||||
final File sldFile = new ClassPathResource("testdata/restteststyle.sld").getFile();
|
||||
|
||||
publisher.createWorkspace(WORKSPACE);
|
||||
|
||||
assertEquals(0, reader.getStyles(WORKSPACE).size());
|
||||
assertEquals(0, reader.getStyles(WORKSPACE).size());
|
||||
|
||||
// insert style
|
||||
assertTrue(publisher.publishStyleInWorkspace(WORKSPACE, sldFile));
|
||||
assertEquals(1, reader.getStyles(WORKSPACE).size());
|
||||
// insert style
|
||||
assertTrue(publisher.publishStyleInWorkspace(WORKSPACE, sldFile));
|
||||
assertEquals(1, reader.getStyles(WORKSPACE).size());
|
||||
assertTrue(reader.existsStyle(WORKSPACE, STYLENAME));
|
||||
|
||||
// remove style
|
||||
assertTrue(publisher.removeStyleInWorkspace(WORKSPACE, STYLENAME, true));
|
||||
assertEquals(0, reader.getStyles(WORKSPACE).size());
|
||||
assertEquals(0, reader.getStyles(WORKSPACE).size());
|
||||
assertFalse(reader.existsStyle(WORKSPACE, STYLENAME));
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user