diff --git a/src/main/java/it/geosolutions/geoserver/rest/GeoServerRESTPublisher.java b/src/main/java/it/geosolutions/geoserver/rest/GeoServerRESTPublisher.java
index 613b75c..3635208 100644
--- a/src/main/java/it/geosolutions/geoserver/rest/GeoServerRESTPublisher.java
+++ b/src/main/java/it/geosolutions/geoserver/rest/GeoServerRESTPublisher.java
@@ -61,7 +61,9 @@ import org.slf4j.LoggerFactory;
*/
public class GeoServerRESTPublisher {
- /** The logger for this class */
+ public static final String DEFAULT_CRS = "EPSG:4326";
+
+ /** The logger for this class */
private static final Logger LOGGER = LoggerFactory.getLogger(GeoServerRESTPublisher.class);
/**
@@ -1069,7 +1071,7 @@ public class GeoServerRESTPublisher {
/**
* Upload an publish a local shapefile.
*
- * The defaultCRS will be set to EPSG:4326.
+ * The SRS will be set to EPSG:4326.
*
* @see {@link #publishShp(String, String, NameValuePair[], String, UploadMethod, URI, String, ProjectionPolicy, String)}
*
@@ -1088,7 +1090,7 @@ public class GeoServerRESTPublisher {
*/
public boolean publishShp(String workspace, String storename,
String datasetname, File zipFile) throws FileNotFoundException, IllegalArgumentException {
- return publishShp(workspace, storename, new NameValuePair[0], datasetname,UploadMethod.FILE, zipFile.toURI(), "EPSG:4326", ProjectionPolicy.NONE,null);
+ return publishShp(workspace, storename, new NameValuePair[0], datasetname,UploadMethod.FILE, zipFile.toURI(), DEFAULT_CRS,null);
}
/**
@@ -1116,7 +1118,9 @@ public class GeoServerRESTPublisher {
*
A zip file if 'method' is uri (UNTESTED)
*
* @param srs
- * the native CRS
+ * the SRS for this shapefile. It must be an ESPG code or GeoServer will choke.
+ * @param nativeCRS
+ * the nativeCRS for this shapefile. It can be an EPSG code (for {@link ProjectionPolicy#NONE} or a WKT for {@link ProjectionPolicy#REPROJECT_TO_DECLARED}.
* @param policy
* {@link ProjectionPolicy}
* @param defaultStyle
@@ -1130,11 +1134,33 @@ public class GeoServerRESTPublisher {
*/
public boolean publishShp(String workspace, String storeName,
NameValuePair[] storeParams, String datasetName, UploadMethod method, URI shapefile,
- String srs, ProjectionPolicy policy, String defaultStyle)
+ String srs, String nativeCRS, ProjectionPolicy policy, String defaultStyle)
throws FileNotFoundException, IllegalArgumentException {
if (workspace == null || storeName == null || shapefile == null
- || datasetName == null || srs == null || policy == null)
+ || datasetName == null || policy == null){
throw new IllegalArgumentException("Unable to run: null parameter");
+ }
+
+ //
+ // SRS Policy Management
+ //
+ boolean srsNull=!(srs!=null&&srs.length()!=0);
+ boolean nativeSrsNull=!(nativeCRS!=null&&nativeCRS.length()!=0);
+ // if we are asking to use the reproject policy we must have the native crs
+ if(policy==ProjectionPolicy.REPROJECT_TO_DECLARED && (nativeSrsNull||srsNull)){
+ throw new IllegalArgumentException("Unable to run: you can't ask GeoServer to reproject while not specifying a native CRS");
+ }
+
+ // if we are asking to use the NONE policy we must have the native crs.
+ if(policy==ProjectionPolicy.NONE && nativeSrsNull){
+ throw new IllegalArgumentException("Unable to run: you can't ask GeoServer to use a native srs which is null");
+ }
+
+ // if we are asking to use the reproject policy we must have the native crs
+ if(policy==ProjectionPolicy.FORCE_DECLARED && srsNull){
+ throw new IllegalArgumentException("Unable to run: you can't force GeoServer to use an srs which is null");
+ }
+
//
final String mimeType;
switch (method){
@@ -1164,7 +1190,17 @@ public class GeoServerRESTPublisher {
final GSFeatureTypeEncoder featureTypeEncoder = new GSFeatureTypeEncoder();
featureTypeEncoder.setName(datasetName);
featureTypeEncoder.setTitle(datasetName);
- featureTypeEncoder.setSRS(srs);
+ // set destination srs
+ if(!srsNull){
+ featureTypeEncoder.setSRS(srs);
+ } else {
+ // this under the assumption that when the destination srs is null the nativeCRS has an EPSG one so we force them to be the same
+ featureTypeEncoder.setSRS(nativeCRS);
+ }
+ // set native srs
+ if(!nativeSrsNull){
+ featureTypeEncoder.setNativeCRS(nativeCRS);
+ }
featureTypeEncoder.setProjectionPolicy(policy);
if (!createResource(workspace, DataStoreType.DATASTORES, storeName,
@@ -1181,6 +1217,95 @@ public class GeoServerRESTPublisher {
return configureLayer(workspace, datasetName, layerEncoder);
}
+
+ /**
+ * Publish a shapefile.
+ *
+ * @param workspace
+ * the name of the workspace to use
+ * @param storename
+ * the name of the store to create
+ * @param storeParams
+ * parameters to append to the url (can be null).
+ * Accepted parameters are:
+ *
+ * - charset used to set the charset
+ *
+ * @param layername
+ * the name of the layer to configure
+ * @param method
+ * {@link UploadMethod}
+ * @param fileUri
+ * the uri of the file containing the shapefile.It should be:
+ *
+ * - A zip file if 'method' is file
+ * - A shp file if 'method' is external
+ * - A zip file if 'method' is uri (UNTESTED)
+ *
+ * @param srs
+ * the SRS for this shapefile. It must be an ESPG code or GeoServer will choke.
+ * Notice that we can only use {@link ProjectionPolicy#FORCE_DECLARED}.
+ * @param policy
+ * {@link ProjectionPolicy}
+ * @param defaultStyle
+ * the default style to set (can be null).
+ * @return true if success false otherwise
+ *
+ * @throws FileNotFoundException
+ * if file to upload is not found
+ * @throws IllegalArgumentException
+ * if any of the mandatory arguments are {@code null}.
+ * @deprecated use {@link #publishShp(String, String, NameValuePair[], String, UploadMethod, URI, String, String)} instead as the behaviour
+ * of this method is misleading as it allows you to use wrong ProjectionPolicy values.
+ */
+ public boolean publishShp(String workspace, String storeName,
+ NameValuePair[] storeParams, String datasetName, UploadMethod method, URI shapefile,
+ String srs, ProjectionPolicy policy, String defaultStyle)
+ throws FileNotFoundException, IllegalArgumentException {
+ return publishShp(workspace, storeName, storeParams, datasetName, method, shapefile, srs, null, policy, defaultStyle);
+ }
+
+ /**
+ * Publish a shapefile.
+ *
+ * @param workspace
+ * the name of the workspace to use
+ * @param storename
+ * the name of the store to create
+ * @param storeParams
+ * parameters to append to the url (can be null).
+ * Accepted parameters are:
+ *
+ * - charset used to set the charset
+ *
+ * @param layername
+ * the name of the layer to configure
+ * @param method
+ * {@link UploadMethod}
+ * @param fileUri
+ * the uri of the file containing the shapefile.It should be:
+ *
+ * - A zip file if 'method' is file
+ * - A shp file if 'method' is external
+ * - A zip file if 'method' is uri (UNTESTED)
+ *
+ * @param srs
+ * the SRS for this shapefile. It must be an ESPG code or GeoServer will choke.
+ * @param defaultStyle
+ * the default style to set (can be null).
+ * @return true if success false otherwise
+ *
+ * @throws FileNotFoundException
+ * if file to upload is not found
+ * @throws IllegalArgumentException
+ * if any of the mandatory arguments are {@code null}.
+ */
+ public boolean publishShp(String workspace, String storeName,
+ NameValuePair[] storeParams, String datasetName, UploadMethod method, URI shapefile,
+ String srs, String defaultStyle)
+ throws FileNotFoundException, IllegalArgumentException {
+ return publishShp(workspace, storeName, storeParams, datasetName, method, shapefile, srs, null, ProjectionPolicy.FORCE_DECLARED, defaultStyle);
+ }
/**
* Publish a zipped shapefile.
@@ -1195,8 +1320,8 @@ public class GeoServerRESTPublisher {
* the name of the layer to configure
* @param zipFile
* The zipped file to publish
- * @param nativeCrs
- * the native CRS
+ * @param srs
+ * the srs for this shapefile. It will be forced to use this one in GeoServer using {@link ProjectionPolicy#FORCE_DECLARED}.
* @param defaultStyle
* the default style to set (can be null).
*
@@ -1207,16 +1332,15 @@ public class GeoServerRESTPublisher {
* if any of the mandatory arguments are {@code null}.
*/
public boolean publishShp(String workspace, String storename,
- String layerName, File zipFile, String nativeCrs,
+ String layerName, File zipFile, String srs,
String defaultStyle) throws FileNotFoundException, IllegalArgumentException {
return publishShp(workspace, storename, (NameValuePair[]) null,
- layerName, UploadMethod.FILE, zipFile.toURI(), nativeCrs,
- ProjectionPolicy.FORCE_DECLARED, defaultStyle);
+ layerName, UploadMethod.FILE, zipFile.toURI(), srs, defaultStyle);
}
- /**
- * Publish a zipped shapefile.
+ /**
+ * Publish a zipped shapefile forcing the srs to the one provided.
*
* @see {@link #publishShp(String, String, NameValuePair[], String, UploadMethod, URI, String, ProjectionPolicy, String)}
*
@@ -1229,7 +1353,7 @@ public class GeoServerRESTPublisher {
* @param zipFile
* The zipped file to publish
* @param srs
- * the native CRS
+ * the CRS for this shapefile. It must be an EPSG CODE !
*
* @return {@code true} if the operation completed successfully.
* @throws FileNotFoundException
@@ -1240,21 +1364,7 @@ public class GeoServerRESTPublisher {
public boolean publishShp(String workspace, String storename,
String layername, File zipFile, String srs)
throws FileNotFoundException {
- /*
- * These are the equivalent calls with cUrl:
- *
- * {@code curl -u admin:geoserver -XPUT -H 'Content-type:
- * application/zip' \ --data-binary @$ZIPFILE \
- * http://$GSIP:$GSPORT/$SERVLET
- * /rest/workspaces/$WORKSPACE/datastores/$STORENAME/file.shp
- *
- * curl -u admin:geoserver -XPOST -H 'Content-type: text/xml' \ -d
- * "$BAREEPSG:4326true"
- * \
- * http://$GSIP:$GSPORT/$SERVLET/rest/workspaces/$WORKSPACE/datastores/
- * $STORENAME/featuretypes/$LAYERNAME }
- */
- return publishShp(workspace, storename, (NameValuePair[])null, layername, UploadMethod.FILE, zipFile.toURI(), srs, ProjectionPolicy.NONE,null);
+ return publishShp(workspace, storename, (NameValuePair[])null, layername, UploadMethod.FILE, zipFile.toURI(), srs,null);
}
/**
@@ -1271,7 +1381,7 @@ public class GeoServerRESTPublisher {
* @param zipFile
* the zip file containing the shapefile
* @param srs
- * the native CRS
+ * the shapefile srs. This must be an EPSG Codefor this code to work!
* @param params
* parameters to append to the url (can be null).
* Accepted parameters are:
@@ -1288,7 +1398,7 @@ public class GeoServerRESTPublisher {
String layername, File zipFile, String srs, NameValuePair... params)
throws FileNotFoundException, IllegalArgumentException {
- return publishShp(workspace, storename, params, layername, UploadMethod.FILE, zipFile.toURI(), srs, ProjectionPolicy.NONE,null);
+ return publishShp(workspace, storename, params, layername, UploadMethod.FILE, zipFile.toURI(), srs,null);
}
@@ -1645,7 +1755,7 @@ public class GeoServerRESTPublisher {
coverageEncoder.setSRS(srs);
coverageEncoder.setProjectionPolicy(policy);
if(bbox != null && bbox.length == 4) {
- coverageEncoder.setLatLonBoundingBox(bbox[0], bbox[1], bbox[2], bbox[3], "EPSG:4326");
+ coverageEncoder.setLatLonBoundingBox(bbox[0], bbox[1], bbox[2], bbox[3], DEFAULT_CRS);
}
if (!createCoverage(workspace, storeName, coverageEncoder)) {
diff --git a/src/main/java/it/geosolutions/geoserver/rest/GeoServerRESTReader.java b/src/main/java/it/geosolutions/geoserver/rest/GeoServerRESTReader.java
index d594e3b..4265f24 100644
--- a/src/main/java/it/geosolutions/geoserver/rest/GeoServerRESTReader.java
+++ b/src/main/java/it/geosolutions/geoserver/rest/GeoServerRESTReader.java
@@ -45,6 +45,8 @@ import it.geosolutions.geoserver.rest.decoder.RESTWorkspaceList;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
import org.slf4j.Logger;
@@ -524,10 +526,13 @@ public class GeoServerRESTReader {
* Get the names of all the Workspaces.
*
* This is a shortcut call: These info could be retrieved using {@link #getWorkspaces getWorkspaces}
- * @return the list of the names of all Workspaces.
+ * @return the list of the names of all Workspaces or an empty list.
*/
public List getWorkspaceNames() {
RESTWorkspaceList list = getWorkspaces();
+ if(list==null){
+ return Collections.emptyList();
+ }
List names = new ArrayList(list.size());
for (RESTWorkspaceList.RESTShortWorkspace item : list) {
names.add(item.getName());
diff --git a/src/main/java/it/geosolutions/geoserver/rest/encoder/GSResourceEncoder.java b/src/main/java/it/geosolutions/geoserver/rest/encoder/GSResourceEncoder.java
index df84b31..dffc20c 100644
--- a/src/main/java/it/geosolutions/geoserver/rest/encoder/GSResourceEncoder.java
+++ b/src/main/java/it/geosolutions/geoserver/rest/encoder/GSResourceEncoder.java
@@ -148,7 +148,7 @@ public abstract class GSResourceEncoder
REPROJECT_TO_DECLARED,
/** Use the declared CRS (ignore native) */
FORCE_DECLARED,
- /** No reprojection */
+ /** Keep native */
NONE
}
@@ -227,6 +227,22 @@ public abstract class GSResourceEncoder
public void setSRS(final String srs) {
set(SRS, srs);
}
+
+ private final static String NATIVECRS = "nativeCRS";
+
+ /**
+ * Add the 'nativeCRS' node with a text value from 'nativeCRS'
+ */
+ protected void addNativeCRS(final String nativeCRS) {
+ add(NATIVECRS, nativeCRS);
+ }
+
+ /**
+ * Set or modify the 'nativeCRS' node with a text value from 'nativeCRS'
+ */
+ public void setNativeCRS(final String nativeCRS) {
+ set(NATIVECRS, nativeCRS);
+ }
private final static String LATLONBBMINX = "latLonBoundingBox/minx";
private final static String LATLONBBMAXX = "latLonBoundingBox/maxx";
diff --git a/src/test/java/it/geosolutions/geoserver/rest/ConfigTest.java b/src/test/java/it/geosolutions/geoserver/rest/ConfigTest.java
index a1c96a1..855d300 100644
--- a/src/test/java/it/geosolutions/geoserver/rest/ConfigTest.java
+++ b/src/test/java/it/geosolutions/geoserver/rest/ConfigTest.java
@@ -35,6 +35,7 @@ import java.io.IOException;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.io.filefilter.SuffixFileFilter;
+import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.io.ClassPathResource;
@@ -53,13 +54,12 @@ public class ConfigTest extends GeoserverRESTTest {
private static final String DEFAULT_WS = "geosolutions";
-
- public ConfigTest(String testName) {
- super(testName);
- }
-
+ @Test
public void testEtj() throws FileNotFoundException, IOException {
- if (!enabled()) return;
+ if(!enabled()){
+ LOGGER.info("Skipping test "+"testEtj"+"for class:"+this.getClass().getSimpleName());
+ return;
+ }
deleteAll();
assertTrue(reader.getWorkspaces().isEmpty());
@@ -73,8 +73,12 @@ public class ConfigTest extends GeoserverRESTTest {
// assertTrue(ok);
}
+ @Test
public void insertStyles() throws FileNotFoundException, IOException {
-
+ if(!enabled()){
+ LOGGER.info("Skipping test "+"insertStyles"+"for class:"+this.getClass().getSimpleName());
+ return;
+ }
File sldDir = new ClassPathResource("testdata").getFile();
for(File sldFile : sldDir.listFiles((FilenameFilter)new SuffixFileFilter(".sld"))) {
LOGGER.info("Existing styles: " + reader.getStyles().getNames());
@@ -84,9 +88,12 @@ public class ConfigTest extends GeoserverRESTTest {
}
}
-
+ @Test
public void insertExternalGeotiff() throws FileNotFoundException, IOException {
-
+ if(!enabled()){
+ LOGGER.info("Skipping test "+"insertExternalGeotiff"+"for class:"+this.getClass().getSimpleName());
+ return;
+ }
String storeName = "testRESTStoreGeotiff";
String layerName = "resttestdem";
@@ -95,9 +102,12 @@ public class ConfigTest extends GeoserverRESTTest {
assertTrue(pc);
}
-
+ @Test
public void insertExternalShape() throws FileNotFoundException, IOException {
-
+ if(!enabled()){
+ LOGGER.info("Skipping test "+"insertExternalShape"+"for class:"+this.getClass().getSimpleName());
+ return;
+ }
File zipFile = new ClassPathResource("testdata/resttestshp.zip").getFile();
boolean published = publisher.publishShp(DEFAULT_WS, "anyname", "cities", zipFile, "EPSG:41001", "default_point");
diff --git a/src/test/java/it/geosolutions/geoserver/rest/GeoserverRESTReaderTest.java b/src/test/java/it/geosolutions/geoserver/rest/GeoserverRESTReaderTest.java
index 773066c..b3d2717 100644
--- a/src/test/java/it/geosolutions/geoserver/rest/GeoserverRESTReaderTest.java
+++ b/src/test/java/it/geosolutions/geoserver/rest/GeoserverRESTReaderTest.java
@@ -25,14 +25,17 @@
package it.geosolutions.geoserver.rest;
-import it.geosolutions.geoserver.rest.decoder.utils.NameLinkElem;
-import it.geosolutions.geoserver.rest.decoder.RESTDataStoreList;
import it.geosolutions.geoserver.rest.decoder.RESTDataStore;
+import it.geosolutions.geoserver.rest.decoder.RESTDataStoreList;
import it.geosolutions.geoserver.rest.decoder.RESTLayerList;
import it.geosolutions.geoserver.rest.decoder.RESTNamespaceList;
import it.geosolutions.geoserver.rest.decoder.RESTWorkspaceList;
+import it.geosolutions.geoserver.rest.decoder.utils.NameLinkElem;
+
import java.util.List;
+import org.junit.Test;
+
/**
*
@@ -40,13 +43,10 @@ import java.util.List;
*/
public class GeoserverRESTReaderTest extends GeoserverRESTTest {
- public GeoserverRESTReaderTest(String testName) {
- super(testName);
- }
-
/**
* Test of getLayers method, of class GeoServerRESTReader.
*/
+ @Test
public void testGetLayers() {
if(!enabled()) return;
@@ -70,6 +70,7 @@ public class GeoserverRESTReaderTest extends GeoserverRESTTest {
/**
* Test of getDatastores method, of class GeoServerRESTReader.
*/
+ @Test
public void testGetDatastores() {
if(!enabled()) return;
@@ -100,6 +101,7 @@ public class GeoserverRESTReaderTest extends GeoserverRESTTest {
}
+ @Test
public void testGetWSDSNames() {
if(!enabled())
return;
@@ -129,6 +131,7 @@ public class GeoserverRESTReaderTest extends GeoserverRESTTest {
/**
* Test of getDatastore method, of class GeoServerRESTReader.
*/
+ @Test
public void testGetDatastore() {
//tested in testGetDatastores()
}
@@ -136,12 +139,14 @@ public class GeoserverRESTReaderTest extends GeoserverRESTTest {
/**
* Test of getLayer method, of class GeoServerRESTReader.
*/
+ @Test
public void testGetLayer() {
}
/**
* Test of getNamespaceNames method, of class GeoServerRESTReader.
*/
+ @Test
public void testGetNamespaces() {
if(!enabled()) return;
@@ -165,6 +170,7 @@ public class GeoserverRESTReaderTest extends GeoserverRESTTest {
/**
* Test of getWorkspaceNames method, of class GeoServerRESTReader.
*/
+ @Test
public void testGetNamespaceNames() {
if(!enabled()) return;
@@ -183,6 +189,7 @@ public class GeoserverRESTReaderTest extends GeoserverRESTTest {
/**
* Test of getWorkspaceNames method, of class GeoServerRESTReader.
*/
+ @Test
public void testGetWorkspaces() {
if(!enabled()) return;
@@ -202,6 +209,7 @@ public class GeoserverRESTReaderTest extends GeoserverRESTTest {
/**
* Test of getWorkspaceNames method, of class GeoServerRESTReader.
*/
+ @Test
public void testGetWorkspaceNames() {
if(!enabled()) return;
diff --git a/src/test/java/it/geosolutions/geoserver/rest/GeoserverRESTTest.java b/src/test/java/it/geosolutions/geoserver/rest/GeoserverRESTTest.java
index 4db9e7c..12e6243 100644
--- a/src/test/java/it/geosolutions/geoserver/rest/GeoserverRESTTest.java
+++ b/src/test/java/it/geosolutions/geoserver/rest/GeoserverRESTTest.java
@@ -39,6 +39,8 @@ import java.util.List;
import junit.framework.TestCase;
+import org.junit.Assert;
+import org.junit.BeforeClass;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -56,7 +58,7 @@ import org.slf4j.LoggerFactory;
*
* @author etj
*/
-public abstract class GeoserverRESTTest extends TestCase {
+public abstract class GeoserverRESTTest extends Assert {
private final static Logger LOGGER = LoggerFactory.getLogger(GeoserverRESTTest.class);
protected static final String DEFAULT_WS = "geosolutions";
@@ -100,15 +102,10 @@ public abstract class GeoserverRESTTest extends TestCase {
return ret != null? ret : envDefault;
}
- public GeoserverRESTTest(String testName) {
- super(testName);
- }
+ @BeforeClass
+ public static void setUp() throws Exception {
- @Override
- protected void setUp() throws Exception {
- super.setUp();
-
if(enabled) {
if(existgs == null) {
existgs = reader.existGeoserver();
@@ -120,12 +117,11 @@ public abstract class GeoserverRESTTest extends TestCase {
}
if ( ! existgs ) {
- System.out.println("Failing test " + this.getClass().getSimpleName() + "::" + this.getName() + " : geoserver not found");
+ System.out.println("Failing tests : geoserver not found");
fail("GeoServer not found");
}
- System.out.println("\n-------------------> RUNNING TEST " + this.getName());
} else {
- System.out.println("Skipping test " + this.getClass().getSimpleName() + "::" + this.getName());
+ System.out.println("Skipping tests ");
}
}
diff --git a/src/test/java/it/geosolutions/geoserver/rest/datastore/GSArcSDEDatastoreEncoderTest.java b/src/test/java/it/geosolutions/geoserver/rest/datastore/GSArcSDEDatastoreEncoderTest.java
index dbeaf99..12e343f 100644
--- a/src/test/java/it/geosolutions/geoserver/rest/datastore/GSArcSDEDatastoreEncoderTest.java
+++ b/src/test/java/it/geosolutions/geoserver/rest/datastore/GSArcSDEDatastoreEncoderTest.java
@@ -28,6 +28,7 @@ import it.geosolutions.geoserver.rest.GeoserverRESTTest;
import it.geosolutions.geoserver.rest.decoder.RESTDataStore;
import it.geosolutions.geoserver.rest.encoder.datastore.GSArcSDEDatastoreEncoder;
+import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -68,8 +69,7 @@ public class GSArcSDEDatastoreEncoderTest extends GeoserverRESTTest {
private final String pgUser;
private final String pgPassword;
- public GSArcSDEDatastoreEncoderTest(String testName) {
- super(testName);
+ public GSArcSDEDatastoreEncoderTest() {
pgIgnore = System.getProperty("pgIgnore", "false").equalsIgnoreCase("true");
pgServer = System.getProperty("pgServer", "localhost");
@@ -79,6 +79,7 @@ public class GSArcSDEDatastoreEncoderTest extends GeoserverRESTTest {
pgPassword = System.getProperty("pgPassword", "ptest");
}
+ @Test
public void testCreateDeleteArcSDEDatastore() {
if (!enabled()) {
return;
diff --git a/src/test/java/it/geosolutions/geoserver/rest/datastore/GSOracleNGDatastoreEncoderTest.java b/src/test/java/it/geosolutions/geoserver/rest/datastore/GSOracleNGDatastoreEncoderTest.java
index e8d7e86..b470860 100644
--- a/src/test/java/it/geosolutions/geoserver/rest/datastore/GSOracleNGDatastoreEncoderTest.java
+++ b/src/test/java/it/geosolutions/geoserver/rest/datastore/GSOracleNGDatastoreEncoderTest.java
@@ -28,6 +28,7 @@ import it.geosolutions.geoserver.rest.GeoserverRESTTest;
import it.geosolutions.geoserver.rest.decoder.RESTDataStore;
import it.geosolutions.geoserver.rest.encoder.datastore.GSOracleNGDatastoreEncoder;
+import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -69,8 +70,7 @@ public class GSOracleNGDatastoreEncoderTest extends GeoserverRESTTest {
private final String pgUser;
private final String pgPassword;
- public GSOracleNGDatastoreEncoderTest(String testName) {
- super(testName);
+ public GSOracleNGDatastoreEncoderTest() {
pgIgnore = System.getProperty("pgIgnore", "false").equalsIgnoreCase("true");
pgHost = System.getProperty("pgHost", "localhost");
@@ -81,6 +81,7 @@ public class GSOracleNGDatastoreEncoderTest extends GeoserverRESTTest {
pgPassword = System.getProperty("pgPassword", "ptest");
}
+ @Test
public void testCreateDeleteOracleNGDatastore() {
if (!enabled()) {
return;
diff --git a/src/test/java/it/geosolutions/geoserver/rest/encoder/GSBackupEncoderTest.java b/src/test/java/it/geosolutions/geoserver/rest/encoder/GSBackupEncoderTest.java
index 3471450..47a5dd2 100644
--- a/src/test/java/it/geosolutions/geoserver/rest/encoder/GSBackupEncoderTest.java
+++ b/src/test/java/it/geosolutions/geoserver/rest/encoder/GSBackupEncoderTest.java
@@ -37,9 +37,6 @@ public class GSBackupEncoderTest extends TestCase
*/
protected static final Logger LOGGER = Logger.getLogger(GSBackupEncoderTest.class);
- public GSBackupEncoderTest()
- {
- }
@Test
public void testAll()
diff --git a/src/test/java/it/geosolutions/geoserver/rest/encoder/GSWorkspaceEncoderTest.java b/src/test/java/it/geosolutions/geoserver/rest/encoder/GSWorkspaceEncoderTest.java
index 3fbb068..d81e12d 100644
--- a/src/test/java/it/geosolutions/geoserver/rest/encoder/GSWorkspaceEncoderTest.java
+++ b/src/test/java/it/geosolutions/geoserver/rest/encoder/GSWorkspaceEncoderTest.java
@@ -31,9 +31,6 @@ import org.slf4j.LoggerFactory;
*/
public class GSWorkspaceEncoderTest extends TestCase {
- public GSWorkspaceEncoderTest() {
- }
-
/**
* Default logger
*/
diff --git a/src/test/java/it/geosolutions/geoserver/rest/encoder/coverage/GSCoverageEncoderTest.java b/src/test/java/it/geosolutions/geoserver/rest/encoder/coverage/GSCoverageEncoderTest.java
index d25fbe9..2803ca4 100644
--- a/src/test/java/it/geosolutions/geoserver/rest/encoder/coverage/GSCoverageEncoderTest.java
+++ b/src/test/java/it/geosolutions/geoserver/rest/encoder/coverage/GSCoverageEncoderTest.java
@@ -37,6 +37,13 @@ import org.slf4j.LoggerFactory;
* @author Carlo Cancellieri - carlo.cancellieri@geo-solutions.it
*/
public class GSCoverageEncoderTest extends TestCase {
+ public static final String WGS84="GEOGCS[\"WGS84(DD)," +
+ "DATUM[\"WGS84\"," +
+ "SPHEROID[\"WGS84\", 6378137.0, 298.257223563]]," +
+ "PRIMEM[\"Greenwich\", 0.0]," +
+ "UNIT[\"degree\", 0.017453292519943295]," +
+ "AXIS[\"Geodetic longitude\", EAST]," +
+ "AXIS[\"Geodetic latitude\", NORTH]]";
public GSCoverageEncoderTest() {
}
@@ -54,11 +61,22 @@ public class GSCoverageEncoderTest extends TestCase {
GSResourceEncoder/**/ re=new GSCoverageEncoder();
re.setProjectionPolicy(ProjectionPolicy.FORCE_DECLARED);
+ re.setSRS("EPSG:4326");
Assert.assertNotNull(ElementUtils.contains(re.getRoot(),"projectionPolicy",ProjectionPolicy.FORCE_DECLARED.toString()));
+ Assert.assertNotNull(ElementUtils.contains(re.getRoot(),"srs","EPSG:4326"));
re.setProjectionPolicy(ProjectionPolicy.NONE);
+ re.setNativeCRS("EPSG:4326");
Assert.assertNull(ElementUtils.contains(re.getRoot(),"projectionPolicy",ProjectionPolicy.FORCE_DECLARED.toString()));
Assert.assertNotNull(ElementUtils.contains(re.getRoot(),"projectionPolicy",ProjectionPolicy.NONE.toString()));
+ Assert.assertNotNull(ElementUtils.contains(re.getRoot(),"nativeCRS","EPSG:4326"));
+
+ re.setProjectionPolicy(ProjectionPolicy.REPROJECT_TO_DECLARED);
+ re.setNativeCRS(WGS84);
+ re.setSRS("EPSG:4326");
+ Assert.assertNull(ElementUtils.contains(re.getRoot(),"projectionPolicy",ProjectionPolicy.FORCE_DECLARED.toString()));
+ Assert.assertNotNull(ElementUtils.contains(re.getRoot(),"nativeCRS",WGS84));
+ Assert.assertNotNull(ElementUtils.contains(re.getRoot(),"srs","EPSG:4326"));
}
/**
@@ -68,13 +86,15 @@ public class GSCoverageEncoderTest extends TestCase {
public void testBB(){
GSResourceEncoder/**/ re=new GSCoverageEncoder();
- re.setLatLonBoundingBox(-180d, 90d, 180d, -90d, null);
+ re.setLatLonBoundingBox(-180d, 90d, 180d, -90d, WGS84);
Assert.assertNotNull(ElementUtils.contains(re.getRoot(),"minx","-180.0"));
+ Assert.assertNotNull(ElementUtils.contains(re.getRoot(),"crs",WGS84));
- re.setLatLonBoundingBox(-90d, 45d, 180d, -90d, null);
+ re.setLatLonBoundingBox(-90d, 45d, 180d, -90d, WGS84);
Assert.assertNull(ElementUtils.contains(re.getRoot(),"minx","-180.0"));
Assert.assertNotNull(ElementUtils.contains(re.getRoot(),"minx","-90.0"));
+ Assert.assertNotNull(ElementUtils.contains(re.getRoot(),"crs",WGS84));
}
@Test
diff --git a/src/test/java/it/geosolutions/geoserver/rest/encoder/feature/GSFeatureEncoderTest.java b/src/test/java/it/geosolutions/geoserver/rest/encoder/feature/GSFeatureEncoderTest.java
index 29ce77e..9e71009 100644
--- a/src/test/java/it/geosolutions/geoserver/rest/encoder/feature/GSFeatureEncoderTest.java
+++ b/src/test/java/it/geosolutions/geoserver/rest/encoder/feature/GSFeatureEncoderTest.java
@@ -43,9 +43,6 @@ import org.slf4j.LoggerFactory;
*/
public class GSFeatureEncoderTest extends TestCase {
protected final static Logger LOGGER = LoggerFactory.getLogger(GSFeatureEncoderTest.class);
-
- public GSFeatureEncoderTest() {
- }
@Test
public void testAll() {
diff --git a/src/test/java/it/geosolutions/geoserver/rest/encoder/utils/EntryKeyListEncoderTest.java b/src/test/java/it/geosolutions/geoserver/rest/encoder/utils/EntryKeyListEncoderTest.java
index 994fabb..ef38e74 100644
--- a/src/test/java/it/geosolutions/geoserver/rest/encoder/utils/EntryKeyListEncoderTest.java
+++ b/src/test/java/it/geosolutions/geoserver/rest/encoder/utils/EntryKeyListEncoderTest.java
@@ -19,11 +19,10 @@
*/
package it.geosolutions.geoserver.rest.encoder.utils;
-import java.util.List;
import junit.framework.TestCase;
+
import org.jdom.Element;
import org.junit.Test;
-import static org.junit.Assert.*;
/**
*
diff --git a/src/test/java/it/geosolutions/geoserver/rest/manager/GeoserverRESTDatastoreManagerTest.java b/src/test/java/it/geosolutions/geoserver/rest/manager/GeoserverRESTDatastoreManagerTest.java
index 5d296cd..82273a6 100644
--- a/src/test/java/it/geosolutions/geoserver/rest/manager/GeoserverRESTDatastoreManagerTest.java
+++ b/src/test/java/it/geosolutions/geoserver/rest/manager/GeoserverRESTDatastoreManagerTest.java
@@ -24,17 +24,17 @@
*/
package it.geosolutions.geoserver.rest.manager;
-import org.junit.Test;
+import it.geosolutions.geoserver.rest.GeoserverRESTTest;
+import it.geosolutions.geoserver.rest.decoder.RESTDataStore;
+import it.geosolutions.geoserver.rest.encoder.datastore.GSAbstractDatastoreEncoder;
+import it.geosolutions.geoserver.rest.encoder.datastore.GSDirectoryOfShapefilesDatastoreEncoder;
+import it.geosolutions.geoserver.rest.encoder.datastore.GSShapefileDatastoreEncoder;
import java.net.URL;
import java.nio.charset.Charset;
import java.util.Map;
-import it.geosolutions.geoserver.rest.GeoserverRESTTest;
-import it.geosolutions.geoserver.rest.decoder.RESTDataStore;
-import it.geosolutions.geoserver.rest.encoder.datastore.GSAbstractDatastoreEncoder;
-import it.geosolutions.geoserver.rest.encoder.datastore.GSShapefileDatastoreEncoder;
-import it.geosolutions.geoserver.rest.encoder.datastore.GSDirectoryOfShapefilesDatastoreEncoder;
+import org.junit.Test;
/**
* Test datastore handling (create, read and update):
@@ -70,9 +70,7 @@ public class GeoserverRESTDatastoreManagerTest extends GeoserverRESTTest {
private static URL LOCATION_1;
private static URL LOCATION_2;
- public GeoserverRESTDatastoreManagerTest(String testName) throws Exception {
- super(testName);
-
+ public GeoserverRESTDatastoreManagerTest() throws Exception {
LOCATION_1 = new URL("file:data/1");
LOCATION_2 = new URL("file:data/2");
}
diff --git a/src/test/java/it/geosolutions/geoserver/rest/publisher/GeoserverRESTGeoTiffTest.java b/src/test/java/it/geosolutions/geoserver/rest/publisher/GeoserverRESTGeoTiffTest.java
index d518e56..6541b76 100644
--- a/src/test/java/it/geosolutions/geoserver/rest/publisher/GeoserverRESTGeoTiffTest.java
+++ b/src/test/java/it/geosolutions/geoserver/rest/publisher/GeoserverRESTGeoTiffTest.java
@@ -33,6 +33,7 @@ import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
+import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.io.ClassPathResource;
@@ -48,10 +49,7 @@ public class GeoserverRESTGeoTiffTest extends GeoserverRESTTest {
private final static Logger LOGGER = LoggerFactory.getLogger(GeoserverRESTGeoTiffTest.class);
- public GeoserverRESTGeoTiffTest(String testName) {
- super(testName);
- }
-
+ @Test
public void testExternalGeotiff() throws FileNotFoundException, IOException {
if (!enabled()) return;
deleteAll();
@@ -83,7 +81,8 @@ public class GeoserverRESTGeoTiffTest extends GeoserverRESTTest {
assertFalse("Bad unpublish()", publisher.unpublishCoverage(DEFAULT_WS, storeName, layerName));
assertFalse(existsLayer(layerName));
}
-
+
+ @Test
public void testGeotiff() throws FileNotFoundException, IOException {
if (!enabled()) return;
deleteAll();
diff --git a/src/test/java/it/geosolutions/geoserver/rest/publisher/GeoserverRESTImageMosaicTest.java b/src/test/java/it/geosolutions/geoserver/rest/publisher/GeoserverRESTImageMosaicTest.java
index d2137e3..9b655aa 100644
--- a/src/test/java/it/geosolutions/geoserver/rest/publisher/GeoserverRESTImageMosaicTest.java
+++ b/src/test/java/it/geosolutions/geoserver/rest/publisher/GeoserverRESTImageMosaicTest.java
@@ -40,6 +40,7 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import org.apache.commons.httpclient.NameValuePair;
+import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.io.ClassPathResource;
@@ -71,11 +72,7 @@ public class GeoserverRESTImageMosaicTest extends GeoserverRESTTest {
private final static Logger LOGGER = LoggerFactory.getLogger(GeoserverRESTImageMosaicTest.class);
-
- public GeoserverRESTImageMosaicTest(String testName) {
- super(testName);
- }
-
+ @Test
public void testCreateDeleteImageMosaicDatastore() {
if (!enabled()) {
return;
@@ -170,6 +167,7 @@ public class GeoserverRESTImageMosaicTest extends GeoserverRESTTest {
assertTrue(publisher.removeWorkspace(wsName));
}
+ @Test
public void testPublishImageMosaic() throws IOException {
if (!enabled()) {
diff --git a/src/test/java/it/geosolutions/geoserver/rest/publisher/GeoserverRESTNamespaceTest.java b/src/test/java/it/geosolutions/geoserver/rest/publisher/GeoserverRESTNamespaceTest.java
index 7a9f60a..29995a4 100644
--- a/src/test/java/it/geosolutions/geoserver/rest/publisher/GeoserverRESTNamespaceTest.java
+++ b/src/test/java/it/geosolutions/geoserver/rest/publisher/GeoserverRESTNamespaceTest.java
@@ -40,11 +40,7 @@ import java.net.URI;
* @author Oscar Fonts
*/
public class GeoserverRESTNamespaceTest extends GeoserverRESTTest {
-
- public GeoserverRESTNamespaceTest(String testName) {
- super(testName);
- }
-
+
/**
* Test Namespace create
*/
diff --git a/src/test/java/it/geosolutions/geoserver/rest/publisher/GeoserverRESTPostgisDatastoreTest.java b/src/test/java/it/geosolutions/geoserver/rest/publisher/GeoserverRESTPostgisDatastoreTest.java
index 2d76af5..c809d42 100644
--- a/src/test/java/it/geosolutions/geoserver/rest/publisher/GeoserverRESTPostgisDatastoreTest.java
+++ b/src/test/java/it/geosolutions/geoserver/rest/publisher/GeoserverRESTPostgisDatastoreTest.java
@@ -30,6 +30,7 @@ import it.geosolutions.geoserver.rest.GeoserverRESTTest;
import it.geosolutions.geoserver.rest.decoder.RESTDataStore;
import it.geosolutions.geoserver.rest.encoder.GSPostGISDatastoreEncoder;
+import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -70,8 +71,7 @@ public class GeoserverRESTPostgisDatastoreTest extends GeoserverRESTTest {
private final String pgUser;
private final String pgPassword;
- public GeoserverRESTPostgisDatastoreTest(String testName) {
- super(testName);
+ public GeoserverRESTPostgisDatastoreTest() {
pgIgnore = System.getProperty("pgIgnore", "false").equalsIgnoreCase("true");
pgHost = System.getProperty("pgHost", "localhost");
@@ -82,6 +82,7 @@ public class GeoserverRESTPostgisDatastoreTest extends GeoserverRESTTest {
pgPassword = System.getProperty("pgPassword", "ptest");
}
+ @Test
public void testCreateDeletePostGISDatastore() {
if (!enabled()) {
return;
diff --git a/src/test/java/it/geosolutions/geoserver/rest/publisher/GeoserverRESTPublishShpCollectionTest.java b/src/test/java/it/geosolutions/geoserver/rest/publisher/GeoserverRESTPublishShpCollectionTest.java
index 8463bbe..f6a1037 100644
--- a/src/test/java/it/geosolutions/geoserver/rest/publisher/GeoserverRESTPublishShpCollectionTest.java
+++ b/src/test/java/it/geosolutions/geoserver/rest/publisher/GeoserverRESTPublishShpCollectionTest.java
@@ -24,12 +24,13 @@
*/
package it.geosolutions.geoserver.rest.publisher;
-import org.junit.Test;
+import it.geosolutions.geoserver.rest.GeoserverRESTTest;
+
import java.net.URI;
import java.util.List;
-import org.springframework.core.io.ClassPathResource;
-import it.geosolutions.geoserver.rest.GeoserverRESTTest;
+import org.junit.Test;
+import org.springframework.core.io.ClassPathResource;
/**
* @author Oscar Fonts
@@ -39,10 +40,6 @@ public class GeoserverRESTPublishShpCollectionTest extends GeoserverRESTTest {
final String workspace = DEFAULT_WS;
final String storeName = "testshpcollection";
- public GeoserverRESTPublishShpCollectionTest(String testName) {
- super(testName);
- }
-
@Test
public void testLocalZip() throws Exception {
if (!enabled()) {
diff --git a/src/test/java/it/geosolutions/geoserver/rest/publisher/GeoserverRESTPublisherTest.java b/src/test/java/it/geosolutions/geoserver/rest/publisher/GeoserverRESTPublisherTest.java
index 4ca9a21..0c31f2d 100644
--- a/src/test/java/it/geosolutions/geoserver/rest/publisher/GeoserverRESTPublisherTest.java
+++ b/src/test/java/it/geosolutions/geoserver/rest/publisher/GeoserverRESTPublisherTest.java
@@ -31,6 +31,7 @@ import it.geosolutions.geoserver.rest.decoder.RESTLayer;
import java.io.FileNotFoundException;
import java.io.IOException;
+import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -47,10 +48,6 @@ public class GeoserverRESTPublisherTest extends GeoserverRESTTest {
private final static Logger LOGGER = LoggerFactory.getLogger(GeoserverRESTPublisherTest.class);
- public GeoserverRESTPublisherTest(String testName) {
- super(testName);
- }
-
protected void cleanupTestFT(String layerName, String ns, String storeName) {
// dry run delete to work in a known state
RESTLayer testLayer = reader.getLayer(layerName);
@@ -68,6 +65,7 @@ public class GeoserverRESTPublisherTest extends GeoserverRESTTest {
assertFalse("Cleanup failed", existsLayer(layerName));
}
+ @Test
public void testDeleteUnexistingCoverage() throws FileNotFoundException, IOException {
if (!enabled()) {
return;
@@ -82,6 +80,7 @@ public class GeoserverRESTPublisherTest extends GeoserverRESTTest {
assertFalse("unpublished not existing layer", ok);
}
+ @Test
public void testDeleteUnexistingFeatureType() throws FileNotFoundException, IOException {
if (!enabled()) {
return;
@@ -96,6 +95,7 @@ public class GeoserverRESTPublisherTest extends GeoserverRESTTest {
assertFalse("unpublished not existing layer", ok);
}
+ @Test
public void testDeleteUnexistingDatastore() throws FileNotFoundException, IOException {
if (!enabled()) {
return;
diff --git a/src/test/java/it/geosolutions/geoserver/rest/publisher/GeoserverRESTShapeTest.java b/src/test/java/it/geosolutions/geoserver/rest/publisher/GeoserverRESTShapeTest.java
index 960b001..4f5816b 100644
--- a/src/test/java/it/geosolutions/geoserver/rest/publisher/GeoserverRESTShapeTest.java
+++ b/src/test/java/it/geosolutions/geoserver/rest/publisher/GeoserverRESTShapeTest.java
@@ -29,12 +29,17 @@ import it.geosolutions.geoserver.rest.GeoServerRESTPublisher.UploadMethod;
import it.geosolutions.geoserver.rest.GeoserverRESTTest;
import it.geosolutions.geoserver.rest.decoder.RESTLayer;
import it.geosolutions.geoserver.rest.encoder.GSResourceEncoder.ProjectionPolicy;
+import it.geosolutions.geoserver.rest.encoder.coverage.GSCoverageEncoderTest;
+import it.geosolutions.geoserver.rest.encoder.feature.GSFeatureEncoderTest;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import org.apache.commons.httpclient.NameValuePair;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.io.ClassPathResource;
@@ -50,18 +55,20 @@ import org.springframework.core.io.ClassPathResource;
public class GeoserverRESTShapeTest extends GeoserverRESTTest {
private final static Logger LOGGER = LoggerFactory.getLogger(GeoserverRESTShapeTest.class);
-
- public GeoserverRESTShapeTest(String testName) {
- super(testName);
- }
+ @After
+ public void cleanUp(){
+ if(enabled()){
+ deleteAllWorkspaces();
+ }
+ }
+ @Test
public void testPublishDeleteShapeZip() throws FileNotFoundException, IOException {
if (!enabled()) {
return;
}
// Assume.assumeTrue(enabled);
- deleteAllWorkspaces();
assertTrue(publisher.createWorkspace(DEFAULT_WS));
String storeName = "resttestshp";
@@ -91,12 +98,12 @@ public class GeoserverRESTShapeTest extends GeoserverRESTTest {
}
+ @Test
public void testPublishDeleteExternalComplexShapeZip() throws FileNotFoundException, IOException {
if (!enabled()) {
return;
}
// Assume.assumeTrue(enabled);
- deleteAllWorkspaces();
assertTrue(publisher.createWorkspace(DEFAULT_WS));
String storeName = "resttestshp_complex";
@@ -105,7 +112,7 @@ public class GeoserverRESTShapeTest extends GeoserverRESTTest {
File zipFile = new ClassPathResource("testdata/shapefile/cities.shp").getFile();
// test insert
- boolean published = publisher.publishShp(DEFAULT_WS, storeName, new NameValuePair[]{new NameValuePair("charset", "UTF-8")},datasetName, UploadMethod.EXTERNAL, zipFile.toURI(), "EPSG:4326",ProjectionPolicy.REPROJECT_TO_DECLARED,"polygon");
+ boolean published = publisher.publishShp(DEFAULT_WS, storeName, new NameValuePair[]{new NameValuePair("charset", "UTF-8")},datasetName, UploadMethod.EXTERNAL, zipFile.toURI(), "EPSG:4326",GSCoverageEncoderTest.WGS84,ProjectionPolicy.REPROJECT_TO_DECLARED,"polygon");
assertTrue("publish() failed", published);
assertTrue(existsLayer(datasetName));
@@ -124,12 +131,12 @@ public class GeoserverRESTShapeTest extends GeoserverRESTTest {
assertTrue("removeDatastore() failed", dsRemoved);
}
+ @Test
public void testPublishDeleteComplexShapeZip() throws FileNotFoundException, IOException {
if (!enabled()) {
return;
}
// Assume.assumeTrue(enabled);
- deleteAllWorkspaces();
assertTrue(publisher.createWorkspace(DEFAULT_WS));
String storeName = "resttestshp_complex";
@@ -138,7 +145,7 @@ public class GeoserverRESTShapeTest extends GeoserverRESTTest {
File zipFile = new ClassPathResource("testdata/resttestshp.zip").getFile();
// test insert
- boolean published = publisher.publishShp(DEFAULT_WS, storeName, new NameValuePair[]{new NameValuePair("charset", "UTF-8")},datasetName, UploadMethod.FILE, zipFile.toURI(), "EPSG:4326",ProjectionPolicy.REPROJECT_TO_DECLARED,"polygon");
+ boolean published = publisher.publishShp(DEFAULT_WS, storeName, new NameValuePair[]{new NameValuePair("charset", "UTF-8")},datasetName, UploadMethod.FILE, zipFile.toURI(), "EPSG:4326",GSCoverageEncoderTest.WGS84,ProjectionPolicy.REPROJECT_TO_DECLARED,"polygon");
assertTrue("publish() failed", published);
assertTrue(existsLayer(datasetName));
@@ -157,11 +164,13 @@ public class GeoserverRESTShapeTest extends GeoserverRESTTest {
assertTrue("removeDatastore() failed", dsRemoved);
}
+ @Test
public void testPublishDeleteStyledShapeZip() throws FileNotFoundException, IOException {
if (!enabled()) {
return;
}
// Assume.assumeTrue(enabled);
+ assertTrue(publisher.createWorkspace(DEFAULT_WS));
String ns = "geosolutions";
String storeName = "resttestshp";
@@ -199,12 +208,12 @@ public class GeoserverRESTShapeTest extends GeoserverRESTTest {
assertFalse(reader.existsStyle(styleName));
}
+ @Test
public void testPublishDeleteShapeZipWithParams() throws FileNotFoundException, IOException {
if (!enabled()) {
return;
}
// Assume.assumeTrue(enabled);
- deleteAllWorkspaces();
assertTrue(publisher.createWorkspace(DEFAULT_WS));
String storeName = "resttestshp";
@@ -242,6 +251,7 @@ public class GeoserverRESTShapeTest extends GeoserverRESTTest {
* @throws IllegalArgumentException
* @throws FileNotFoundException
*/
+ @Test
public void testPublishShpUsingDeclaredNativeCRS() throws Exception {
if (!enabled())
return;
@@ -265,16 +275,48 @@ public class GeoserverRESTShapeTest extends GeoserverRESTTest {
// Read CRS. Should be using the one indicated at publication time.
assertNotNull(reader.getLayer(layerName));
+
+ // remove also datastore
+ boolean dsRemoved = publisher.removeDatastore(DEFAULT_WS, storename,true);
+ assertTrue("removeDatastore() failed", dsRemoved);
+ }
+
+ /**
+ * Test case to solve error described in:
+ * https://github.com/geosolutions-it/geoserver-manager/issues/11
+ *
+ * @throws IllegalArgumentException
+ * @throws FileNotFoundException
+ */
+ @Test
+ public void testPublishShpUsingWKTNativeCRS() throws Exception {
+ if (!enabled())
+ return;
+
+ // layer publication params
+ String workspace = DEFAULT_WS;
+ String storename = "resttestshp";
+ String layerName = "10m_populated_places";
+ File zipFile = new ClassPathResource("testdata/test_noepsg.zip")
+ .getFile();
+ String nativeCrs = "EPSG:4326";
+ String defaultStyle = null;
+
+ // Cleanup
+ deleteAllWorkspacesRecursively();
+ assertTrue(publisher.createWorkspace(workspace));
+
+ // Publish layer
+ assertTrue(publisher.publishShp(workspace, storename, layerName,
+ zipFile, nativeCrs, defaultStyle));
+
+ // Read CRS. Should be using the one indicated at publication time.
+ assertNotNull(reader.getLayer(layerName));
+
+ // remove also datastore
+ boolean dsRemoved = publisher.removeDatastore(DEFAULT_WS, storename,true);
+ assertTrue("removeDatastore() failed", dsRemoved);
}
-
- // public void testDeleteUnexistingFT() throws FileNotFoundException, IOException {
-// String wsName = "this_ws_does_not_exist";
-// String storeName = "this_store_does_not_exist";
-// String layerName = "this_layer_does_not_exist";
-//
-// boolean ok = publisher.unpublishFT(wsName, storeName, layerName);
-// assertFalse("unpublished not existing layer", ok);
-// }
}
diff --git a/src/test/java/it/geosolutions/geoserver/rest/publisher/GeoserverRESTStyleTest.java b/src/test/java/it/geosolutions/geoserver/rest/publisher/GeoserverRESTStyleTest.java
index 11eea6f..b29abca 100644
--- a/src/test/java/it/geosolutions/geoserver/rest/publisher/GeoserverRESTStyleTest.java
+++ b/src/test/java/it/geosolutions/geoserver/rest/publisher/GeoserverRESTStyleTest.java
@@ -38,6 +38,7 @@ import java.io.IOException;
import org.apache.commons.io.IOUtils;
import org.jdom.Element;
import org.jdom.Namespace;
+import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.io.ClassPathResource;
@@ -55,10 +56,7 @@ public class GeoserverRESTStyleTest extends GeoserverRESTTest {
private final static Logger LOGGER = LoggerFactory
.getLogger(GeoserverRESTStyleTest.class);
- public GeoserverRESTStyleTest(String testName) {
- super(testName);
- }
-
+ @Test
public void testStyles() throws IOException {
if (!enabled())
return;
@@ -116,6 +114,7 @@ public class GeoserverRESTStyleTest extends GeoserverRESTTest {
assertFalse("Cleanup failed", reader.existsStyle(styleName));
}
+ @Test
public void testPublishDeleteStyleFile() throws FileNotFoundException,
IOException {
if (!enabled()) {
@@ -147,6 +146,7 @@ public class GeoserverRESTStyleTest extends GeoserverRESTTest {
assertFalse(reader.existsStyle(styleName));
}
+ @Test
public void testPublishDeleteStyleString() throws FileNotFoundException,
IOException {
if (!enabled()) {
@@ -193,6 +193,7 @@ public class GeoserverRESTStyleTest extends GeoserverRESTTest {
}
+ @Test
public void testUpdateDefaultStyle() throws FileNotFoundException,
IOException {
if (!enabled()) {
diff --git a/src/test/java/it/geosolutions/geoserver/rest/publisher/GeoserverRESTWorkspaceTest.java b/src/test/java/it/geosolutions/geoserver/rest/publisher/GeoserverRESTWorkspaceTest.java
index 6730ea4..244c93d 100644
--- a/src/test/java/it/geosolutions/geoserver/rest/publisher/GeoserverRESTWorkspaceTest.java
+++ b/src/test/java/it/geosolutions/geoserver/rest/publisher/GeoserverRESTWorkspaceTest.java
@@ -31,6 +31,7 @@ import it.geosolutions.geoserver.rest.encoder.GSResourceEncoder.ProjectionPolicy
import java.io.File;
import java.io.IOException;
+import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.io.ClassPathResource;
@@ -47,10 +48,7 @@ public class GeoserverRESTWorkspaceTest extends GeoserverRESTTest {
private final static Logger LOGGER = LoggerFactory.getLogger(GeoserverRESTWorkspaceTest.class);
- public GeoserverRESTWorkspaceTest(String testName) {
- super(testName);
- }
-
+ @Test
public void testWorkspaces() {
if (!enabled()) return;
deleteAll();
@@ -69,6 +67,7 @@ public class GeoserverRESTWorkspaceTest extends GeoserverRESTTest {
* remove workspace and all of its contents
* @throws IOException
*/
+ @Test
public void testWorkspaceRemoval() throws IOException {
if (!enabled()) return;
deleteAll();
diff --git a/src/test/java/it/geosolutions/geoserver/rest/publisher/GeoserverRESTWorldImageTest.java b/src/test/java/it/geosolutions/geoserver/rest/publisher/GeoserverRESTWorldImageTest.java
index f67aaee..9491362 100644
--- a/src/test/java/it/geosolutions/geoserver/rest/publisher/GeoserverRESTWorldImageTest.java
+++ b/src/test/java/it/geosolutions/geoserver/rest/publisher/GeoserverRESTWorldImageTest.java
@@ -32,6 +32,7 @@ import java.io.File;
import java.io.IOException;
import org.apache.commons.httpclient.NameValuePair;
+import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.io.ClassPathResource;
@@ -47,10 +48,7 @@ public class GeoserverRESTWorldImageTest extends GeoserverRESTTest {
private final static Logger LOGGER = LoggerFactory.getLogger(GeoserverRESTWorldImageTest.class);
- public GeoserverRESTWorldImageTest(String testName) {
- super(testName);
- }
-
+ @Test
public void testPublishWorldImage() throws IOException {
if (!enabled()) {
diff --git a/src/test/resources/testdata/test_noepsg.zip b/src/test/resources/testdata/test_noepsg.zip
new file mode 100644
index 0000000..8e4e550
Binary files /dev/null and b/src/test/resources/testdata/test_noepsg.zip differ