Merge upstream/master

This commit is contained in:
iserge 2016-04-21 15:32:55 +03:00
commit 1b5fb6350f
20 changed files with 418 additions and 367 deletions

View File

@ -7,13 +7,47 @@
* Stable on Windows + OracleJDK7 [![Build Status](http://winbuild.geo-solutions.it/jenkins/buildStatus/icon?job=GeoServer-Manager-Stable)](http://winbuild.geo-solutions.it/jenkins/view/GeoServer-Manager/job/GeoServer-Manager-Stable/)
## Intro
Client library written in Java to interact with [GeoServer](http://www.geoserver.org) through its REst administration interface.
The purpose of this project is to hold a REST client library to interact with GeoServer; a requirement for this library is to depend as less as possible on external libraries. This library aims at being lean and mean.
## Intro
Client library written in Java to interact with [GeoServer](http://www.geoserver.org) through its [ReST administration interface](http://docs.geoserver.org/stable/en/user/rest/api/index.html).
The purpose of this project is to hold a ReST client library to interact with GeoServer; a requirement for this library is to depend as less as possible on external libraries. This library aims at being lean and mean.
For general questions about this project feel free to use the mailing lists.
## Using the library
### Working with Maven
In order to include the lib and its dependencies in a Maven project, the repository to point at is this one:
```xml
<repository>
<id>GeoSolutions</id>
<url>http://maven.geo-solutions.it/</url>
</repository>
```
and the dependency tag for your pom is as follows:
```xml
<dependency>
<groupId>it.geosolutions</groupId>
<artifactId>geoserver-manager</artifactId>
<version>1.7.0</version>
</dependency>
```
### Direct Link to JAR
If you are simply looking for the JAR to download and use you can find it [here](http://maven.geo-solutions.it/it/geosolutions/geoserver-manager/1.7.0/geoserver-manager-1.7.0.jar).
### GeoServer Compatibility Matrix
**GeoServer-Manager/GeoServer** | **2.6.x** |**2.7.x** |**2.8.x** |**2.9.x**
-------------------------------- | ----------|----------|----------|---------
**1.6.0** | Y | Y | P | P
**1.7.0** | N | P | Y | Y
### Documentation
You can find some examples in the wiki.
## License
geoserver-manager is released under a permissinve [MIT](https://opensource.org/licenses/MIT) license. See [wikipedia](https://en.wikipedia.org/wiki/MIT_License) for more information.
@ -26,4 +60,9 @@ geoserver-manager is released under a permissinve [MIT](https://opensource.org/l
For more information see [this](https://github.com/geosolutions-it/geoserver-manager/wiki) page.
## Version
Current stable version is [1.7.0](https://github.com/geosolutions-it/geoserver-manager/releases/tag/v1.7.0) ([Changelog](https://github.com/geosolutions-it/geoserver-manager/wiki/Changelog)).
## Credits
The work on this library has been initiated by GeoSolutions. Over the years it has been funded by various organizations like UN FAO, German Space Agency (DLR) and others.

516
pom.xml
View File

@ -1,287 +1,301 @@
<!-- * GeoServer-Manager - Simple Manager Library for GeoServer * * Copyright
(C) 2007,2011 GeoSolutions S.A.S. * http://www.geo-solutions.it * * Permission
is hereby granted, free of charge, to any person obtaining a copy * of this
software and associated documentation files (the "Software"), to deal * in
the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is *
furnished to do so, subject to the following conditions: * * The above copyright
notice and this permission notice shall be included in * all copies or substantial
portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY
OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN * THE SOFTWARE. -->
<!--
* GeoServer-Manager - Simple Manager Library for GeoServer
*
* 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
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<groupId>it.geosolutions</groupId>
<artifactId>geoserver-manager</artifactId>
<version>1.7-SNAPSHOT</version>
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>
<groupId>it.geosolutions</groupId>
<artifactId>geoserver-manager</artifactId>
<version>1.8-SNAPSHOT</version>
<name>GeoServer 2 Manager - REST based</name>
<description>
GeoServer Manager is a library to interact with GeoServer 2.x.
<packaging>jar</packaging>
<name>GeoServer Manager - REST based</name>
<description>
GeoServer Manager is a library to interact with GeoServer
The scope of this library is to have a simple API, and use as few external
libs as possible.
</description>
<inceptionYear>2007</inceptionYear>
<inceptionYear>2007</inceptionYear>
<organization>
<name>GeoSolutions</name>
<url>http://www.geo-solutions.it</url>
</organization>
<url>https://github.com/geosolutions-it/geoserver-manager</url>
<developers>
<developer>
<id>etj</id>
<name>Emanuele Tajariol</name>
<email>etj AT geosolutions.it</email>
<organization>GeoSolutions</organization>
<organizationUrl>http://www.geo-solutions.it</organizationUrl>
<roles>
<role>architect</role>
<role>developer</role>
</roles>
<timezone>+1</timezone>
</developer>
<developer>
<id>ccancellieri</id>
<name>Carlo Cancellieri</name>
<email>carlo.cancellieri AT geosolutions.it</email>
<organization>GeoSolutions</organization>
<organizationUrl>http://www.geo-solutions.it</organizationUrl>
<roles>
<role>architect</role>
<role>developer</role>
</roles>
<timezone>+1</timezone>
</developer>
</developers>
<organization>
<name>GeoSolutions</name>
<url>http://www.geo-solutions.it</url>
</organization>
<licenses>
<license>
<name>MIT License</name>
<url>http://opensource.org/licenses/mit-license.php</url>
<distribution>repo</distribution>
</license>
</licenses>
<developers>
<developer>
<id>etj</id>
<name>Emanuele Tajariol</name>
<email>etj AT geosolutions.it</email>
<organization>GeoSolutions</organization>
<organizationUrl>http://www.geo-solutions.it</organizationUrl>
<roles>
<role>architect</role>
<role>developer</role>
</roles>
<timezone>+1</timezone>
</developer>
<developer>
<id>ccancellieri</id>
<name>Carlo Cancellieri</name>
<email>carlo.cancellieri AT geosolutions.it</email>
<organization>GeoSolutions</organization>
<organizationUrl>http://www.geo-solutions.it</organizationUrl>
<roles>
<role>architect</role>
<role>developer</role>
</roles>
<timezone>+1</timezone>
</developer>
</developers>
<url>http://code.google.com/p/geoserver-manager/</url>
<licenses>
<license>
<name>MIT License</name>
<url>http://opensource.org/licenses/mit-license.php</url>
<distribution>repo</distribution>
</license>
</licenses>
<issueManagement>
<system>googlecode</system>
<url>http://code.google.com/p/geoserver-manager/issues/list</url>
</issueManagement>
<issueManagement>
<system>GitHub</system>
<url>https://github.com/geosolutions-it/geoserver-manager/issues</url>
</issueManagement>
<mailingLists>
<mailingList>
<name>GeoServer Manager User List</name>
<post>geoserver-manager-users@googlegroups.com </post>
<archive>http://groups.google.com/group/geoserver-manager-users/topics</archive>
</mailingList>
</mailingLists>
<mailingLists>
<mailingList>
<name>GeoServer Manager User List</name>
<post>geoserver-manager-users@googlegroups.com </post>
<archive>http://groups.google.com/group/geoserver-manager-users/topics</archive>
</mailingList>
</mailingLists>
<scm>
<connection>scm:git:[fetch=]https://github.com/geosolutions-it/geoserver-manager.git[push=]git@github.com:geosolutions-it/geoserver-manager.git</connection>
<!--developerConnection>scm:git</developerConnection -->
<!--tag>master</tag -->
<url>https://github.com/geosolutions-it/geoserver-manager</url>
</scm>
<scm>
<connection>scm:git:[fetch=]https://github.com/geosolutions-it/geoserver-manager.git[push=]git@github.com:geosolutions-it/geoserver-manager.git</connection>
<url>https://github.com/geosolutions-it/geoserver-manager</url>
</scm>
<ciManagement>
<system>jenkins</system>
<url>http://ci.geo-solutions.it/</url>
</ciManagement>
<ciManagement>
<system>jenkins</system>
<url>http://build.geo-solutions.it/jenkins/view/GeoServer-manager/</url>
</ciManagement>
<distributionManagement>
<downloadUrl>http://maven.geo-solutions.it</downloadUrl>
<repository>
<uniqueVersion>false</uniqueVersion>
<id>geosolutions</id>
<url>ftp://maven.geo-solutions.it/</url>
</repository>
<site>
<id>demo.geosolutions</id>
<url>scp://demo.geo-solutions.it/var/www/share/github/gsman</url>
</site>
</distributionManagement>
<distributionManagement>
<downloadUrl>http://maven.geo-solutions.it</downloadUrl>
<repository>
<uniqueVersion>false</uniqueVersion>
<id>geosolutions</id>
<url>ftp://maven.geo-solutions.it/</url>
</repository>
<site>
<id>demo.geosolutions</id>
<url>scp://demo.geo-solutions.it/var/www/share/github/gsman</url>
</site>
</distributionManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.7</version>
<configuration>
<detectLinks />
<!-- <links> <link>http://commons.apache.org/dbcp/apidocs/</link> <link>http://commons.apache.org/fileupload/apidocs/</link>
<link>http://download.oracle.com/javase/6/docs/api</link> </links> -->
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.7</version>
<configuration>
<detectLinks />
<!-- <links> <link>http://commons.apache.org/dbcp/apidocs/</link> <link>http://commons.apache.org/fileupload/apidocs/</link>
<link>http://download.oracle.com/javase/6/docs/api</link> </links> -->
</configuration>
</plugin>
<!-- ======================================================= -->
<!-- Source packaging. -->
<!-- ======================================================= -->
<plugin>
<inherited>true</inherited>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<configuration>
<attach>true</attach>
</configuration>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- versioning -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.2.2</version>
<configuration>
<tagNameFormat>v@{project.version}</tagNameFormat>
</configuration>
</plugin>
</plugins>
<!-- ======================================================= -->
<!-- Source packaging. -->
<!-- ======================================================= -->
<plugin>
<inherited>true</inherited>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<configuration>
<attach>true</attach>
</configuration>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- versioning -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.2.2</version>
<configuration>
<tagNameFormat>v@{project.version}</tagNameFormat>
</configuration>
</plugin>
</plugins>
<!-- ======================================================== -->
<!-- Extensions settings for Deployment -->
<!-- ======================================================== -->
<extensions>
<!--............................................. -->
<!-- geo-solutions (using wagon ftp) -->
<!--............................................. -->
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ftp</artifactId>
<version>1.0-beta-7</version>
</extension>
</extensions>
</build>
<!-- ======================================================== -->
<!-- Extensions settings for Deployment -->
<!-- ======================================================== -->
<extensions>
<!--............................................. -->
<!-- geo-solutions (using wagon ftp) -->
<!--............................................. -->
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ftp</artifactId>
<version>2.6</version>
</extension>
</extensions>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<links>
<link>http://commons.apache.org/lang/api</link>
<link>http://java.sun.com/j2se/1.5.0/docs/api</link>
<link>http://www.jdom.org/docs/apidocs</link>
</links>
</configuration>
</plugin>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<links>
<link>http://commons.apache.org/lang/api</link>
<link>http://java.sun.com/j2se/1.5.0/docs/api</link>
<link>http://www.jdom.org/docs/apidocs</link>
</links>
</configuration>
</plugin>
<!-- <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>cobertura-maven-plugin</artifactId>
<version>2.2</version> </plugin> -->
</plugins>
</reporting>
</plugins>
</reporting>
<properties>
<slf4j.version>1.5.11</slf4j.version>
</properties>
<properties>
<slf4j.version>1.5.11</slf4j.version>
</properties>
<dependencies>
<dependencies>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>3.1</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>3.1</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>jdom</groupId>
<artifactId>jdom</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>jdom</groupId>
<artifactId>jdom</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>${slf4j.version}</version>
</dependency>
<!-- commons-logging can be rather simply and conveniently excluded as
a dependency by declaring it in the provided scope within the pom.xml file
of your project. The actual commons-logging classes would be provided by
jcl-over-slf4j. This translates into the following pom file snippet: -->
<!-- <dependency> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId>
<version>1.1.1</version> <scope>provided</scope> </dependency> <dependency>
<groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.16</version>
</dependency>
</dependency>-->
<!--================================================================= -->
<!-- TEST -->
<!--================================================================= -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>${slf4j.version}</version>
</dependency>
<!-- commons-logging can be rather simply and conveniently excluded as
a dependency by declaring it in the provided scope within the pom.xml file
of your project. The actual commons-logging classes would be provided by
jcl-over-slf4j.
This translates into the following pom file snippet: -->
<!-- <dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
</dependency>
</dependency>-->
<!--================================================================= -->
<!-- TEST -->
<!--================================================================= -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>2.5.6.SEC02</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>2.5.6.SEC02</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4j.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4j.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@ -1,7 +1,7 @@
/*
* GeoServer-Manager - Simple Manager Library for GeoServer
*
* Copyright (C) 2007,2013 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

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
@ -50,8 +50,13 @@ public static final String QUIET_ON_NOT_FOUND_PARAM = "quietOnNotFound=";
List<RESTStyle> styles = new ArrayList<RESTStyle>();
RESTStyle style = reader.getStyle(stylename);
if(style != null)
styles.add(style);
// We don't want geoserver to be lenient here: take only the real global style if it exists
if(style != null) {
if(style.getWorkspace() == null || style.getWorkspace().isEmpty()) {
styles.add(style);
}
}
for (String workspace : reader.getWorkspaceNames()) {
style = reader.getStyle(workspace, stylename);

View File

@ -56,7 +56,7 @@ public abstract class GSAbstractStoreEncoder extends PropertyXMLEncoder {
}
public String getType() {
return ElementUtils.contains(getRoot(), "name").getTextTrim();
return ElementUtils.contains(getRoot(), "type").getTextTrim();
}
public void setName(String name) {

View File

@ -1,6 +1,5 @@
package it.geosolutions.geoserver.decoder;
import it.geosolutions.geoserver.rest.decoder.RESTLayer;
import it.geosolutions.geoserver.rest.decoder.RESTLayer21;
import it.geosolutions.geoserver.rest.encoder.authorityurl.GSAuthorityURLInfoEncoder;
import it.geosolutions.geoserver.rest.encoder.identifier.GSIdentifierInfoEncoder;
@ -14,6 +13,8 @@ import junit.framework.Assert;
import org.apache.commons.io.FileUtils;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.io.ClassPathResource;
/**
@ -24,7 +25,9 @@ import org.springframework.core.io.ClassPathResource;
*
*/
public class LayerDecoder21Test{
private final static Logger LOGGER = LoggerFactory.getLogger(LayerDecoder21Test.class);
RESTLayer21 layer;
@Before
@ -43,7 +46,7 @@ public class LayerDecoder21Test{
public void testAuthorityURLs() {
List<GSAuthorityURLInfoEncoder> authorityURLs = layer
.getEncodedAuthorityURLInfoList();
System.out.println(authorityURLs.size());
LOGGER.debug("Number of authority URLs: " + authorityURLs.size());
Assert.assertEquals("authority1", authorityURLs.get(0).getName());
Assert.assertEquals("http://www.authority1.org", authorityURLs.get(0)
.getHref());

View File

@ -23,7 +23,6 @@ package it.geosolutions.geoserver.decoder;
import it.geosolutions.geoserver.rest.decoder.RESTCoverage;
import it.geosolutions.geoserver.rest.decoder.RESTDimensionInfo;
import it.geosolutions.geoserver.rest.encoder.metadatalink.GSMetadataLinkInfoEncoder;
import java.io.File;
import java.io.IOException;

View File

@ -21,11 +21,8 @@
*/
package it.geosolutions.geoserver.decoder;
import it.geosolutions.geoserver.rest.GeoServerRESTPublisher;
import it.geosolutions.geoserver.rest.GeoServerRESTReader;
import it.geosolutions.geoserver.rest.GeoserverRESTTest;
import it.geosolutions.geoserver.rest.decoder.about.GSVersionDecoder;
import it.geosolutions.geoserver.rest.decoder.about.GSVersionDecoder.VERSION;
import junit.framework.Assert;
import org.jdom.Element;

View File

@ -64,7 +64,7 @@ public class ConfigTest extends GeoserverRESTTest {
LOGGER.info("Existing styles: " + reader.getStyles().getNames());
String basename = FilenameUtils.getBaseName(sldFile.toString());
LOGGER.info("Publishing style " + sldFile + " as " + basename);
assertTrue("Cound not publish " + sldFile, publisher.publishStyle(sldFile, basename));
assertTrue("Could not publish " + sldFile, publisher.publishStyle(sldFile, basename));
}
}

View File

@ -25,12 +25,10 @@
package it.geosolutions.geoserver.rest;
import static org.junit.Assert.*;
import static org.junit.Assert.assertTrue;
import java.util.List;
import it.geosolutions.geoserver.rest.decoder.RESTLayerGroup;
import it.geosolutions.geoserver.rest.decoder.utils.NameLinkElem;
import org.junit.Test;
import org.slf4j.Logger;

View File

@ -35,6 +35,9 @@ import it.geosolutions.geoserver.rest.decoder.utils.NameLinkElem;
import java.util.List;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static org.junit.Assert.*;
@ -44,6 +47,8 @@ import static org.junit.Assert.*;
*/
public class GeoserverRESTReaderTest extends GeoserverRESTTest {
private final static Logger LOGGER = LoggerFactory.getLogger(GeoserverRESTReaderTest.class);
/**
* Test of getLayers method, of class GeoServerRESTReader.
*/
@ -56,16 +61,16 @@ public class GeoserverRESTReaderTest extends GeoserverRESTTest {
// assertEquals(/*CHANGEME*/19, result.getChildren("layer").size()); // value in default gs installation
// System.out.println("Layers:" + result.getChildren("layer").size());
System.out.println("Layers:" + result.size());
System.out.print("Layers:" );
LOGGER.debug("Layers: " + result.size());
// LOGGER.debug("Layers:" );
for (NameLinkElem shlayer : result) {
assertNotNull(shlayer.getName());
System.out.print(shlayer.getName() + " ");
LOGGER.debug(shlayer.getName() + " ");
}
// for (Element layer : (List<Element>)result.getChildren("layer")) {
// System.out.print(layer.getChildText("name") + " ");
// }
System.out.println();
LOGGER.debug("");
}
/**
@ -79,25 +84,25 @@ public class GeoserverRESTReaderTest extends GeoserverRESTTest {
assertNotNull(wslist);
// assertEquals(7, wslist.size()); // value in default gs installation
System.out.println("Workspaces: " + wslist.size());
LOGGER.debug("Workspaces: " + wslist.size());
int dsnum = 0;
for (RESTWorkspaceList.RESTShortWorkspace ws : wslist) {
System.out.println("Getting DSlist for WS " + ws.getName() + "..." );
LOGGER.debug("Getting DSlist for WS " + ws.getName() + "..." );
RESTDataStoreList result = reader.getDatastores(ws.getName());
assertNotNull(result);
dsnum += result.size();
for (NameLinkElem ds : result) {
assertNotNull(ds.getName());
System.out.print(ds.getName() + " " );
LOGGER.debug(ds.getName() + " " );
RESTDataStore datastore = reader.getDatastore(ws.getName(), ds.getName());
assertNotNull(datastore);
assertEquals(ds.getName(), datastore.getName());
assertEquals(ws.getName(), datastore.getWorkspaceName());
}
System.out.println();
LOGGER.debug("");
}
System.out.println();
System.out.println("Datastores:" + dsnum); // value in default gs installation
LOGGER.debug("");
LOGGER.debug("Datastores:" + dsnum); // value in default gs installation
// assertEquals(4, dsnum); // value in default gs installation
}
@ -116,7 +121,6 @@ public class GeoserverRESTReaderTest extends GeoserverRESTTest {
// assertEquals(7, wsnames.size()); // value in default gs installation
// System.out.println("Workspaces: " + wslist.size());
int dsnum = 0;
int wscnt = 0;
for (RESTWorkspaceList.RESTShortWorkspace ws : wslist) {
String wsname = wsnames.get(wscnt++);
@ -158,14 +162,14 @@ public class GeoserverRESTReaderTest extends GeoserverRESTTest {
assertNotNull(names);
assertEquals(names.size(), result.size()); // value in default gs installation
System.out.println("Namespaces:" + result.size());
System.out.print("Namespaces:" );
LOGGER.debug("Namespaces:" + result.size());
LOGGER.debug("Namespaces:" );
int namesIdx = 0;
for (RESTNamespaceList.RESTShortNamespace ns : result) {
assertEquals("namespace mismatch", names.get(namesIdx++), ns.getName());
System.out.print(ns.getName() + " " );
LOGGER.debug(ns.getName() + " " );
}
System.out.println();
LOGGER.debug("");
}
/**
@ -179,12 +183,12 @@ public class GeoserverRESTReaderTest extends GeoserverRESTTest {
assertNotNull(names);
// assertEquals(7, names.size()); // value in default gs installation
System.out.println("Namespaces:" + names.size());
System.out.print("Namespaces:");
LOGGER.debug("Namespaces:" + names.size());
LOGGER.debug("Namespaces:");
for (String name : names) {
System.out.print(name + " ");
LOGGER.debug(name + " ");
}
System.out.println();
LOGGER.debug("");
}
/**
@ -198,12 +202,12 @@ public class GeoserverRESTReaderTest extends GeoserverRESTTest {
assertNotNull(wslist);
// assertEquals(7, wslist.size()); // value in default gs installation
System.out.println("Workspaces:" + wslist.size());
System.out.print("Workspaces:");
LOGGER.debug("Workspaces:" + wslist.size());
LOGGER.debug("Workspaces:");
for (RESTWorkspaceList.RESTShortWorkspace ws : wslist) {
System.out.print(ws.getName() + " ");
LOGGER.debug(ws.getName() + " ");
}
System.out.println();
LOGGER.debug("");
assertEquals(wslist.size(), reader.getWorkspaceNames().size());
}
@ -218,12 +222,12 @@ public class GeoserverRESTReaderTest extends GeoserverRESTTest {
assertNotNull(names);
// assertEquals(7, names.size()); // value in default gs installation
System.out.println("Workspaces:" + names.size());
System.out.print("Workspaces:");
LOGGER.debug("Workspaces:" + names.size());
LOGGER.debug("Workspaces:");
for (String name : names) {
System.out.print(name + " ");
LOGGER.debug(name + " ");
}
System.out.println();
LOGGER.debug("");
}
}

View File

@ -1,7 +1,7 @@
/*
* GeoServer-Manager - Simple Manager Library for GeoServer
*
* Copyright (C) 2007,2011 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
@ -41,7 +41,6 @@ import java.util.List;
import static org.junit.Assert.*;
import org.jdom.output.EscapeStrategy;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Rule;
@ -98,7 +97,7 @@ public abstract class GeoserverRESTTest {
RESTURL = getenv("gsmgr_resturl", "http://localhost:8080/geoserver");
RESTUSER = getenv("gsmgr_restuser", "admin");
RESTPW = getenv("gsmgr_restpw", "geoserver");
GS_VERSION = getenv("gsmgr_version", "2.4");
GS_VERSION = getenv("gsmgr_version", "2.8");
// These tests will destroy data, so let's make sure we do want to run them
enabled = getenv("gsmgr_resttest", "false").equalsIgnoreCase("true");
@ -136,17 +135,17 @@ public abstract class GeoserverRESTTest {
+ RESTURL);
}
} else if (existgs == false){
System.out.println("Failing tests : geoserver not found");
LOGGER.debug("Failing tests : geoserver not found");
fail("GeoServer not found");
}
GSVersionDecoder v=reader.getGeoserverVersion();
if (v.compareTo(VERSION.getVersion(GS_VERSION))!=0){
System.out.println("Failing tests : geoserver version does not match.\nAccepted versions: "+VERSION.print());
LOGGER.debug("Failing tests : geoserver version does not match.\nAccepted versions: "+VERSION.print());
fail("GeoServer version ("+v.getVersion()+") does not match the desired one ("+GS_VERSION+")");
}
} else {
System.out.println("Skipping tests ");
LOGGER.debug("Skipping tests ");
LOGGER.warn("Tests are disabled. Please read the documentation to enable them.");
}
}

View File

@ -1,7 +1,7 @@
/*
* GeoServer-Manager - Simple Manager Library for GeoServer
*
* Copyright (C) 2007,2013 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
@ -22,20 +22,17 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package it.geosolutions.geoserver.rest;
import static it.geosolutions.geoserver.rest.GeoserverRESTTest.publisher;
import static it.geosolutions.geoserver.rest.GeoserverRESTTest.reader;
import it.geosolutions.geoserver.rest.decoder.RESTStyle;
import java.io.File;
import java.io.IOException;
import java.util.List;
import org.junit.Test;
import static org.junit.Assert.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static org.junit.Assert.*;
import org.springframework.core.io.ClassPathResource;
/**
@ -44,52 +41,66 @@ import org.springframework.core.io.ClassPathResource;
*/
public class UtilTest extends GeoserverRESTTest {
private final static Logger LOGGER = LoggerFactory.getLogger(UtilTest.class);
private final static Logger LOGGER = LoggerFactory.getLogger(UtilTest.class);
@Test
public void testSearchStyle() throws IOException {
if (!enabled())
return;
deleteAll();
@Test
public void testSearchStyle() throws IOException {
if (!enabled()) {
return;
}
deleteAll();
final String WORKSPACE = "testWorkspace";
final String STYLENAME = "restteststyle";
final String STYLENAME = "restteststyle";
File sldFile = new ClassPathResource("testdata/restteststyle.sld").getFile();
File sldFile = new ClassPathResource("testdata/restteststyle.sld").getFile();
publisher.createWorkspace(WORKSPACE);
assertEquals(0, reader.getStyles().size());
assertEquals(0, reader.getStyles(WORKSPACE).size());
assertEquals(0, reader.getStyles().size());
assertEquals(0, reader.getStyles(WORKSPACE).size());
assertEquals(0, Util.searchStyles(reader, STYLENAME).size());
// insert style in workspace
assertTrue(publisher.publishStyleInWorkspace(WORKSPACE, sldFile, STYLENAME));
assertTrue(reader.existsStyle(WORKSPACE, STYLENAME));
assertFalse(reader.existsStyle(STYLENAME));
assertEquals(0, reader.getStyles().size());
assertEquals(1, reader.getStyles(WORKSPACE).size());
// insert style in workspace
assertTrue(publisher.publishStyleInWorkspace(WORKSPACE, sldFile, STYLENAME));
assertTrue(reader.existsStyle(WORKSPACE, STYLENAME));
// GeoServer returns workspace specific names if hte name is not found as global
assertTrue(reader.existsStyle(STYLENAME));
assertEquals(0, reader.getStyles().size());
assertEquals(1, reader.getStyles(WORKSPACE).size());
assertEquals(1, Util.searchStyles(reader, STYLENAME).size());
// insert global style
assertTrue(publisher.publishStyle(sldFile, STYLENAME));
assertTrue(publisher.publishStyle(sldFile, STYLENAME));
assertTrue(reader.existsStyle(STYLENAME));
assertTrue(reader.existsStyle(WORKSPACE, STYLENAME));
assertEquals(2, Util.searchStyles(reader, STYLENAME).size());
for(RESTStyle style : Util.searchStyles(reader, STYLENAME))
{
LOGGER.debug(style.getWorkspace() + " :: " + style.getName());
}
assertEquals(1, reader.getStyles().size());
assertEquals(1, reader.getStyles(WORKSPACE).size());
// there's a bug in geoserver here: the global style will include workspace info
// https://osgeo-org.atlassian.net/browse/GEOS-7498
// Commenting out all the concerned test code
List<RESTStyle> styles = Util.searchStyles(reader, STYLENAME);
assertEquals(STYLENAME, styles.get(0).getName());
assertEquals(null, styles.get(0).getWorkspace()); // first one is the global one, if any
assertEquals(STYLENAME, styles.get(1).getName());
assertEquals(WORKSPACE, styles.get(1).getWorkspace());
}
// assertEquals(2, Util.searchStyles(reader, STYLENAME).size());
//
// assertEquals(1, reader.getStyles().size());
// assertEquals(1, reader.getStyles(WORKSPACE).size());
//
// List<RESTStyle> styles = Util.searchStyles(reader, STYLENAME);
//
// assertEquals(STYLENAME, styles.get(0).getName());
//
//
// // assertEquals(null, styles.get(0).getWorkspace()); // first one is the global one, if any
//
// assertEquals(STYLENAME, styles.get(1).getName());
// assertEquals(WORKSPACE, styles.get(1).getWorkspace());
}
}

View File

@ -19,8 +19,6 @@
*/
package it.geosolutions.geoserver.rest.encoder.coverage;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import it.geosolutions.geoserver.rest.encoder.GSResourceEncoder;
import it.geosolutions.geoserver.rest.encoder.GSResourceEncoder.ProjectionPolicy;
import it.geosolutions.geoserver.rest.encoder.dimensions.GSCoverageDimensionEncoder;

View File

@ -19,12 +19,6 @@
*/
package it.geosolutions.geoserver.rest.encoder.dimensions;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import it.geosolutions.geoserver.rest.encoder.feature.GSFeatureTypeEncoder;
import java.io.IOException;
import junit.framework.Assert;
import org.junit.Test;

View File

@ -23,14 +23,11 @@ import it.geosolutions.geoserver.rest.GeoServerRESTPublisher;
import it.geosolutions.geoserver.rest.GeoserverRESTTest;
import it.geosolutions.geoserver.rest.decoder.RESTFeatureType;
import it.geosolutions.geoserver.rest.decoder.RESTLayer;
import it.geosolutions.geoserver.rest.decoder.RESTResource;
import it.geosolutions.geoserver.rest.decoder.about.GSVersionDecoder;
import it.geosolutions.geoserver.rest.decoder.about.GSVersionDecoder.VERSION;
import it.geosolutions.geoserver.rest.encoder.GSLayerEncoder;
import it.geosolutions.geoserver.rest.encoder.GSLayerEncoder21;
import it.geosolutions.geoserver.rest.encoder.GSResourceEncoder;
import it.geosolutions.geoserver.rest.encoder.authorityurl.GSAuthorityURLInfoEncoder;
import it.geosolutions.geoserver.rest.encoder.dimensions.GSCoverageDimensionEncoder;
import it.geosolutions.geoserver.rest.encoder.identifier.GSIdentifierInfoEncoder;
import it.geosolutions.geoserver.rest.encoder.metadata.GSDimensionInfoEncoder;
import it.geosolutions.geoserver.rest.encoder.metadata.GSDimensionInfoEncoder.Presentation;

View File

@ -1,7 +1,7 @@
/*
* GeoServer-Manager - Simple Manager Library for GeoServer
*
* Copyright (C) 2007,2012 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
@ -37,6 +37,7 @@ import java.util.Map;
import org.junit.Test;
import static org.junit.Assert.*;
import org.junit.Ignore;
/**
* Test datastore handling (create, read and update):
@ -63,10 +64,12 @@ import static org.junit.Assert.*;
* <li>Read again.
* <li>Test all new values.
* </ol>
*
*
* @deprecated ignored since dir of shapes cannot be uploaded
* @author Oscar Fonts
*/
public class GeoserverRESTDatastoreManagerTest extends StoreIntegrationTest {
@Ignore
public class DirShapeStoreManagerTest extends StoreIntegrationTest {
private static final String WS_NAME = DEFAULT_WS;
@ -78,7 +81,7 @@ public class GeoserverRESTDatastoreManagerTest extends StoreIntegrationTest {
private static URL LOCATION_2;
public GeoserverRESTDatastoreManagerTest() throws Exception {
public DirShapeStoreManagerTest() throws Exception {
super(false);
LOCATION_1 = new URL("file:data/shapefiles/");
LOCATION_2 = new URL("file:data/2");
@ -104,7 +107,7 @@ public class GeoserverRESTDatastoreManagerTest extends StoreIntegrationTest {
// Create a directory of spatial files with default parameters
GSDirectoryOfShapefilesDatastoreEncoder create = new GSDirectoryOfShapefilesDatastoreEncoder(
DS_NAME, LOCATION_1);
assertTrue(manager.getStoreManager().create(WS_NAME, create));
assertTrue("Could not create create store", manager.getStoreManager().create(WS_NAME, create));
// Read the store from server; check all parameter values
RESTDataStore read = reader.getDatastore(WS_NAME, DS_NAME);
@ -131,14 +134,14 @@ public class GeoserverRESTDatastoreManagerTest extends StoreIntegrationTest {
update.setCacheAndReuseMemoryMaps(false);
// update the store
assertTrue(manager.getStoreManager().update(WS_NAME, update));
assertTrue("Could not update store " + WS_NAME, manager.getStoreManager().update(WS_NAME, update));
// Read again, check that all parameters have changed
read = reader.getDatastore(WS_NAME, DS_NAME);
assertEquals(read.getWorkspaceName(), WS_NAME);
assertEquals(read.isEnabled(), false);
assertEquals("Bad workspace name", read.getWorkspaceName(), WS_NAME);
assertEquals("Datastore should not be enabled", read.isEnabled(), false);
connParams = read.getConnectionParameters();
assertEquals(connParams.get("url"), LOCATION_2.toString());
assertEquals("Bad URL", connParams.get("url"), LOCATION_2.toString());
assertEquals(connParams.get("charset"), "UTF-8");
assertEquals(connParams.get("create spatial index"), "false");
assertEquals(connParams.get("memory mapped buffer"), "true");

View File

@ -26,8 +26,6 @@
package it.geosolutions.geoserver.rest.publisher;
import it.geosolutions.geoserver.rest.GeoserverRESTTest;
import static it.geosolutions.geoserver.rest.GeoserverRESTTest.publisher;
import static it.geosolutions.geoserver.rest.GeoserverRESTTest.reader;
import it.geosolutions.geoserver.rest.decoder.RESTLayer;
import it.geosolutions.geoserver.rest.decoder.RESTStyle;
import it.geosolutions.geoserver.rest.decoder.utils.JDOMBuilder;

View File

@ -33,8 +33,6 @@ import java.io.IOException;
import org.junit.Test;
import static org.junit.Assert.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.io.ClassPathResource;
/**
@ -47,8 +45,6 @@ import org.springframework.core.io.ClassPathResource;
*/
public class GeoserverRESTWorkspaceTest extends GeoserverRESTTest {
private final static Logger LOGGER = LoggerFactory.getLogger(GeoserverRESTWorkspaceTest.class);
@Test
public void testWorkspaces() {
if (!enabled()) return;

View File

@ -35,8 +35,6 @@ import org.apache.commons.httpclient.NameValuePair;
import org.junit.Test;
import static org.junit.Assert.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.io.ClassPathResource;
/**
@ -48,8 +46,6 @@ import org.springframework.core.io.ClassPathResource;
*/
public class GeoserverRESTWorldImageTest extends GeoserverRESTTest {
private final static Logger LOGGER = LoggerFactory.getLogger(GeoserverRESTWorldImageTest.class);
@Test
public void testPublishWorldImage() throws IOException {