TestCase of the new publishWorldImage() implementations

This commit is contained in:
Marco Paulo Ollivier 2016-04-11 17:37:08 -03:00
parent 356a3a08a7
commit c0e4170f5c
2 changed files with 39 additions and 22 deletions

View File

@ -24,6 +24,21 @@
*/ */
package it.geosolutions.geoserver.rest; package it.geosolutions.geoserver.rest;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
import java.net.URLEncoder;
import java.util.zip.ZipFile;
import org.apache.commons.httpclient.NameValuePair;
import org.apache.commons.io.FilenameUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import it.geosolutions.geoserver.rest.decoder.RESTCoverage; import it.geosolutions.geoserver.rest.decoder.RESTCoverage;
import it.geosolutions.geoserver.rest.decoder.RESTCoverageStore; import it.geosolutions.geoserver.rest.decoder.RESTCoverageStore;
import it.geosolutions.geoserver.rest.decoder.RESTStructuredCoverageGranulesList; import it.geosolutions.geoserver.rest.decoder.RESTStructuredCoverageGranulesList;
@ -43,21 +58,6 @@ import it.geosolutions.geoserver.rest.manager.GeoServerRESTStructuredGridCoverag
import it.geosolutions.geoserver.rest.manager.GeoServerRESTStructuredGridCoverageReaderManager.ConfigureCoveragesOption; import it.geosolutions.geoserver.rest.manager.GeoServerRESTStructuredGridCoverageReaderManager.ConfigureCoveragesOption;
import it.geosolutions.geoserver.rest.manager.GeoServerRESTStyleManager; import it.geosolutions.geoserver.rest.manager.GeoServerRESTStyleManager;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
import java.net.URLEncoder;
import java.util.zip.ZipFile;
import org.apache.commons.httpclient.NameValuePair;
import org.apache.commons.io.FilenameUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* Connect to a GeoServer instance to publish or modify its contents via REST API. * Connect to a GeoServer instance to publish or modify its contents via REST API.
* <P> * <P>
@ -1695,6 +1695,8 @@ public class GeoServerRESTPublisher {
/** /**
* Publish a external worldimage file. * Publish a external worldimage file.
* *
* @author Marco Paulo Ollivier - github.com/marcopollivier/
*
* @param workspace Workspace to use * @param workspace Workspace to use
* @param coveragestore Name of the coveragestore * @param coveragestore Name of the coveragestore
* @param fileUri the uri of the file containing the WorldImage. * @param fileUri the uri of the file containing the WorldImage.
@ -1711,12 +1713,13 @@ public class GeoServerRESTPublisher {
return createCoverageStore(workspace, coveragestore, UploadMethod.EXTERNAL, CoverageStoreExtension.WORLDIMAGE, return createCoverageStore(workspace, coveragestore, UploadMethod.EXTERNAL, CoverageStoreExtension.WORLDIMAGE,
"text/plain", fileURI, configure, params); "text/plain", fileURI, configure, params);
} }
/** /**
* Publish a external worldimage file. * Publish a external worldimage file.
* *
* @author Marco Paulo Ollivier - github.com/marcopollivier/
*
* @param workspace Workspace to use * @param workspace Workspace to use
* @param coveragestore Name of the coveragestore * @param coveragestore Name of the coveragestore
* @param fileUri the uri of the file containing the WorldImage. * @param fileUri the uri of the file containing the WorldImage.
@ -1725,7 +1728,6 @@ public class GeoServerRESTPublisher {
public boolean publishWorldImage(String workspace, String coveragestore, URI fileURI) throws FileNotFoundException { public boolean publishWorldImage(String workspace, String coveragestore, URI fileURI) throws FileNotFoundException {
return createCoverageStore(workspace, coveragestore, UploadMethod.EXTERNAL, CoverageStoreExtension.WORLDIMAGE, return createCoverageStore(workspace, coveragestore, UploadMethod.EXTERNAL, CoverageStoreExtension.WORLDIMAGE,
"text/plain", fileURI, ParameterConfigure.FIRST, (NameValuePair) null); "text/plain", fileURI, ParameterConfigure.FIRST, (NameValuePair) null);
} }
// ========================================================================== // ==========================================================================

View File

@ -25,20 +25,20 @@
package it.geosolutions.geoserver.rest.publisher; package it.geosolutions.geoserver.rest.publisher;
import it.geosolutions.geoserver.rest.GeoServerRESTPublisher.ParameterConfigure; import static org.junit.Assert.assertTrue;
import it.geosolutions.geoserver.rest.GeoserverRESTTest;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import org.apache.commons.httpclient.NameValuePair; import org.apache.commons.httpclient.NameValuePair;
import org.junit.Test; import org.junit.Test;
import static org.junit.Assert.*;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.ClassPathResource;
import it.geosolutions.geoserver.rest.GeoServerRESTPublisher.ParameterConfigure;
import it.geosolutions.geoserver.rest.GeoserverRESTTest;
/** /**
* Testcase for publishing layers on geoserver. * Testcase for publishing layers on geoserver.
* We need a running GeoServer to properly run the tests. * We need a running GeoServer to properly run the tests.
@ -92,5 +92,20 @@ public class GeoserverRESTWorldImageTest extends GeoserverRESTTest {
assertTrue("Publish worldfile configuring all available layers, failed.", wp); assertTrue("Publish worldfile configuring all available layers, failed.", wp);
assertTrue("Unpublish() failed", publisher.removeCoverageStore(DEFAULT_WS, storeName, true)); assertTrue("Unpublish() failed", publisher.removeCoverageStore(DEFAULT_WS, storeName, true));
// --
wp = publisher.publishWorldImage(DEFAULT_WS, storeName, worldImageFile.toURI(), ParameterConfigure.FIRST, new NameValuePair("coverageName", "worldImage_test"));
assertTrue("Publish worldfile configuring all available layers, failed.", wp);
assertTrue("Unpublish() failed", publisher.removeCoverageStore(DEFAULT_WS, storeName, true));
wp = publisher.publishWorldImage(DEFAULT_WS, storeName, worldImageFile.toURI());
assertTrue("Publish worldfile configuring all available layers, failed.", wp);
assertTrue("Unpublish() failed", publisher.removeCoverageStore(DEFAULT_WS, storeName, true));
} }
} }