#176 Fix tests related to styles in workspaces

This commit is contained in:
etj 2016-04-08 19:28:54 +02:00
parent 5447c06dbc
commit ff7f383591
4 changed files with 392 additions and 387 deletions

View File

@ -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());
}

View File

@ -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

View File

@ -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

View File

@ -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,20 +57,20 @@ 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())
public void testStyles() throws IOException
{
if (!enabled()) {
return;
}
deleteAll();
assertEquals(0, reader.getStyles().size());
final String STYLENAME = "restteststyle";
File sldFile = new ClassPathResource("testdata/restteststyle.sld")
.getFile();
File sldFile = new ClassPathResource("testdata/restteststyle.sld").getFile();
// insert style
assertTrue(publisher.publishStyle(sldFile));
@ -98,11 +98,9 @@ public class GeoserverRESTStyleTest extends GeoserverRESTTest {
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 {
assertEquals(STYLENAME, styleEl.getChild("NamedLayer", SLDNS)
.getChild("Name", SLDNS).getText());
assertEquals("STYLE FOR TESTING PURPOSES",
@ -114,11 +112,11 @@ public class GeoserverRESTStyleTest extends GeoserverRESTTest {
}
// assertEquals(1475, sld.length());
assertEquals(2, reader.getStyles().size());
}
protected void cleanupTestStyle(final String styleName) {
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);
@ -181,8 +179,9 @@ public class GeoserverRESTStyleTest extends GeoserverRESTTest {
}
@Test
public void testPublishDeleteStyleString() throws FileNotFoundException,
IOException {
public void testPublishDeleteStyleString()
throws FileNotFoundException, IOException
{
if (!enabled()) {
return;
}
@ -228,8 +227,9 @@ public class GeoserverRESTStyleTest extends GeoserverRESTTest {
}
@Test
public void testUpdateDefaultStyle() throws FileNotFoundException,
IOException {
public void testUpdateDefaultStyle()
throws FileNotFoundException, IOException
{
if (!enabled()) {
return;
}
@ -295,9 +295,11 @@ public class GeoserverRESTStyleTest extends GeoserverRESTTest {
}
@Test
public void testStylesInWorkspace() throws IOException {
if (!enabled())
public void testStylesInWorkspace() throws IOException
{
if (!enabled()) {
return;
}
deleteAll();
final String WORKSPACE = "testWorkspace";
@ -309,16 +311,18 @@ public class GeoserverRESTStyleTest extends GeoserverRESTTest {
assertEquals(0, reader.getStyles().size());
assertEquals(0, reader.getStyles(WORKSPACE).size());
// insert style
assertTrue(publisher.publishStyleInWorkspace(WORKSPACE, sldFile));
assertTrue(reader.existsStyle(WORKSPACE, STYLENAME));
assertFalse(reader.existsStyle(STYLENAME));
assertTrue("Error inserting style", publisher.publishStyleInWorkspace(WORKSPACE, sldFile));
assertTrue("Style does not exist in workspace", reader.existsStyle(WORKSPACE, 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);
@ -330,8 +334,7 @@ public class GeoserverRESTStyleTest extends GeoserverRESTTest {
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 {
@ -347,15 +350,16 @@ public class GeoserverRESTStyleTest extends GeoserverRESTTest {
}
// assertEquals(1475, sld.length());
assertEquals(0, reader.getStyles().size());
assertEquals(1, reader.getStyles(WORKSPACE).size());
}
@Test
public void testRemoveStylesInWorkspace() throws IOException {
if (!enabled())
public void testRemoveStylesInWorkspace() throws IOException
{
if (!enabled()) {
return;
}
deleteAll();
final String WORKSPACE = "testWorkspace";