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