Readded old configureLayer as deprecated for backward compat.
Fixed some tests.
This commit is contained in:
parent
562600f386
commit
0c4229df6b
@ -726,18 +726,34 @@ public class GeoServerRESTPublisher {
|
||||
//===
|
||||
//==========================================================================
|
||||
|
||||
/**
|
||||
* @deprecated please use {@link configureLayer(String workspace, String layerName, GSLayerEncoder layer) }
|
||||
*/
|
||||
public boolean configureLayer(final GSLayerEncoder layer, final String layerName)
|
||||
{
|
||||
return configureLayer(null, layerName, layer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows to configure some layer attributes such as WmsPath and DefaultStyle
|
||||
*
|
||||
*/
|
||||
public boolean configureLayer(final String workspace, final String layerName, final GSLayerEncoder layer) {
|
||||
|
||||
// TODO: check this usecase, layer should always be defined
|
||||
if (layer.isEmpty()) {
|
||||
LOGGER.warn("Null layer name while configuring layer -- This behavior is suspicious.");
|
||||
return true;
|
||||
}
|
||||
|
||||
String fqLayerName = workspace + ":" + layerName;
|
||||
|
||||
// this null check is here only for backward compatibility. workspace shall be mandatory.
|
||||
if(workspace == null) {
|
||||
LOGGER.warn("Null workspace while configuring layer : " + layerName + " -- This behavior is deprecated.");
|
||||
fqLayerName = layerName;
|
||||
}
|
||||
|
||||
final String url = restURL + "/rest/layers/" + fqLayerName;
|
||||
|
||||
String layerXml = layer.toString();
|
||||
|
||||
@ -50,7 +50,6 @@ import org.springframework.core.io.ClassPathResource;
|
||||
public class GeoserverRESTPublisherTest extends GeoserverRESTTest {
|
||||
|
||||
private final static Logger LOGGER = Logger.getLogger(GeoserverRESTPublisherTest.class);
|
||||
private static final String DEFAULT_WS = "it.geosolutions";
|
||||
|
||||
public GeoserverRESTPublisherTest(String testName) {
|
||||
super(testName);
|
||||
@ -152,6 +151,7 @@ public class GeoserverRESTPublisherTest extends GeoserverRESTTest {
|
||||
if (publisher.removeDatastore(ns, storeName)) {
|
||||
LOGGER.info("Cleared stale datastore " + storeName);
|
||||
}
|
||||
|
||||
assertFalse("Cleanup failed", existsLayer(layerName));
|
||||
}
|
||||
|
||||
@ -172,18 +172,20 @@ public class GeoserverRESTPublisherTest extends GeoserverRESTTest {
|
||||
return;
|
||||
}
|
||||
// Assume.assumeTrue(enabled);
|
||||
deleteAllWorkspaces();
|
||||
assertTrue(publisher.createWorkspace(DEFAULT_WS));
|
||||
|
||||
String ns = "it.geosolutions";
|
||||
// String ns = "it.geosolutions";
|
||||
String storeName = "resttestshp";
|
||||
String layerName = "cities";
|
||||
|
||||
File zipFile = new ClassPathResource("testdata/resttestshp.zip").getFile();
|
||||
|
||||
// known state?
|
||||
cleanupTestFT(layerName, ns, storeName);
|
||||
cleanupTestFT(layerName, DEFAULT_WS, storeName);
|
||||
|
||||
// test insert
|
||||
boolean published = publisher.publishShp(ns, storeName, layerName, zipFile);
|
||||
boolean published = publisher.publishShp(DEFAULT_WS, storeName, layerName, zipFile);
|
||||
assertTrue("publish() failed", published);
|
||||
assertTrue(existsLayer(layerName));
|
||||
|
||||
@ -192,12 +194,12 @@ public class GeoserverRESTPublisherTest extends GeoserverRESTTest {
|
||||
LOGGER.info("Layer style is " + layer.getDefaultStyle());
|
||||
|
||||
//test delete
|
||||
boolean ok = publisher.unpublishFeatureType(ns, storeName, layerName);
|
||||
boolean ok = publisher.unpublishFeatureType(DEFAULT_WS, storeName, layerName);
|
||||
assertTrue("Unpublish() failed", ok);
|
||||
assertFalse(existsLayer(layerName));
|
||||
|
||||
// remove also datastore
|
||||
boolean dsRemoved = publisher.removeDatastore(ns, storeName);
|
||||
boolean dsRemoved = publisher.removeDatastore(DEFAULT_WS, storeName);
|
||||
assertTrue("removeDatastore() failed", dsRemoved);
|
||||
|
||||
}
|
||||
@ -208,7 +210,7 @@ public class GeoserverRESTPublisherTest extends GeoserverRESTTest {
|
||||
}
|
||||
// Assume.assumeTrue(enabled);
|
||||
|
||||
String ns = "it.geosolutions";
|
||||
String ns = "geosolutions";
|
||||
String storeName = "resttestshp";
|
||||
String layerName = "cities";
|
||||
|
||||
@ -344,7 +346,6 @@ public class GeoserverRESTPublisherTest extends GeoserverRESTTest {
|
||||
return;
|
||||
}
|
||||
|
||||
String ws = "it.geosolutions";
|
||||
String storeName = "resttestshp";
|
||||
String layerName = "cities";
|
||||
|
||||
@ -370,10 +371,10 @@ public class GeoserverRESTPublisherTest extends GeoserverRESTTest {
|
||||
File zipFile = new ClassPathResource("testdata/resttestshp.zip").getFile();
|
||||
|
||||
// known state?
|
||||
cleanupTestFT(layerName, ws, storeName);
|
||||
cleanupTestFT(layerName, DEFAULT_WS, storeName);
|
||||
|
||||
// test insert
|
||||
boolean published = publisher.publishShp(ws, storeName, layerName, zipFile, "EPSG:4326", styleName);
|
||||
boolean published = publisher.publishShp(DEFAULT_WS, storeName, layerName, zipFile, "EPSG:4326", styleName);
|
||||
assertTrue("publish() failed", published);
|
||||
assertTrue(existsLayer(layerName));
|
||||
|
||||
@ -385,7 +386,7 @@ public class GeoserverRESTPublisherTest extends GeoserverRESTTest {
|
||||
|
||||
GSLayerEncoder le = new GSLayerEncoder();
|
||||
le.addDefaultStyle(styleName2);
|
||||
publisher.configureLayer(ws, layerName, le);
|
||||
publisher.configureLayer(DEFAULT_WS, layerName, le);
|
||||
|
||||
{
|
||||
RESTLayer layer = reader.getLayer(layerName);
|
||||
@ -395,9 +396,9 @@ public class GeoserverRESTPublisherTest extends GeoserverRESTTest {
|
||||
|
||||
|
||||
// remove layer and datastore
|
||||
boolean ok = publisher.unpublishFeatureType(ws, storeName, layerName);
|
||||
boolean ok = publisher.unpublishFeatureType(DEFAULT_WS, storeName, layerName);
|
||||
assertFalse(existsLayer(layerName));
|
||||
boolean dsRemoved = publisher.removeDatastore(ws, storeName);
|
||||
boolean dsRemoved = publisher.removeDatastore(DEFAULT_WS, storeName);
|
||||
assertTrue("removeDatastore() failed", dsRemoved);
|
||||
}
|
||||
|
||||
|
||||
@ -56,6 +56,8 @@ import org.apache.log4j.Logger;
|
||||
public abstract class GeoserverRESTTest extends TestCase {
|
||||
private final static Logger LOGGER = Logger.getLogger(GeoserverRESTTest.class);
|
||||
|
||||
protected static final String DEFAULT_WS = "geosolutions";
|
||||
|
||||
public static final String RESTURL;
|
||||
public static final String RESTUSER;
|
||||
public static final String RESTPW;
|
||||
@ -68,13 +70,6 @@ public abstract class GeoserverRESTTest extends TestCase {
|
||||
private static Boolean existgs = null;
|
||||
|
||||
static {
|
||||
// for (String propName : System.getProperties().stringPropertyNames()) {
|
||||
// System.out.println("PROP " + propName);
|
||||
// }
|
||||
for (String envName : System.getenv().keySet()) {
|
||||
System.out.println("ENVVAR " + envName + " = \""+System.getenv(envName)+"\"");
|
||||
}
|
||||
|
||||
RESTURL = getenv("gsmgr_resturl", "http://localhost:8080/geoserver");
|
||||
RESTUSER = getenv("gsmgr_restuser", "admin");
|
||||
RESTPW = getenv("gsmgr_restpw", "geoserver");
|
||||
@ -221,7 +216,7 @@ public abstract class GeoserverRESTTest extends TestCase {
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteAllWorkspaces() {
|
||||
protected void deleteAllWorkspaces() {
|
||||
List<String> workspaces = reader.getWorkspaceNames();
|
||||
for (String workspace : workspaces) {
|
||||
LOGGER.warn("Deleting Workspace " + workspace );
|
||||
|
||||
Loading…
Reference in New Issue
Block a user