Added Test for wmsStore parser

This commit is contained in:
Federico C. Guizzardi 2015-06-08 10:53:26 +02:00
parent 9ebfaaafed
commit c76e60205c
2 changed files with 107 additions and 0 deletions

View File

@ -0,0 +1,85 @@
package it.geosolutions.geoserver.decoder;
import it.geosolutions.geoserver.rest.decoder.RESTWmsStore;
import java.io.File;
import java.io.IOException;
import org.apache.commons.io.FileUtils;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.springframework.core.io.ClassPathResource;
/**
* WmsStoreDecoderTest
*
* @author cip (cippinofg at gmail.com)
*
*/
public class WmsStoreDecoderTest {
RESTWmsStore wmsstore;
@Before
public void setup() throws IOException {
File wmsstoreFile = new ClassPathResource("testdata/wmsstoreExample.xml").getFile();
String wmsstoreContent = FileUtils.readFileToString(wmsstoreFile);
wmsstore = RESTWmsStore.build(wmsstoreContent);
}
@Test
public void testName() {
Assert.assertEquals(wmsstore.getName(), "wmsstore001");
}
@Test
public void testType() {
Assert.assertEquals(wmsstore.getType(), "WMS");
}
@Test
public void testEnabled() {
Assert.assertEquals(wmsstore.getEnabled(), true);
}
@Test
public void testWorkspace() {
Assert.assertEquals(wmsstore.getWorkspaceName(), "ws001");
}
@Test
public void testUseConnectionPooling() {
Assert.assertEquals(wmsstore.getUseConnectionPooling(),true);
}
@Test
public void testCapabilitiesURL() {
Assert.assertEquals(wmsstore.getCapabilitiesURL(), "http://myhost/geoserver/wms");
}
@Test
public void testUser() {
Assert.assertEquals(wmsstore.getUser(), "admin");
}
@Test
public void testPassword() {
Assert.assertEquals(wmsstore.getPassword(), "geoserver");
}
@Test
public void testMaxConnections() {
Assert.assertEquals(wmsstore.getMaxConnections(), "6");
}
@Test
public void testReadTimeout() {
Assert.assertEquals(wmsstore.getReadTimeout(), "60");
}
@Test
public void testConnectTimeout() {
Assert.assertEquals(wmsstore.getConnectTimeout(), "30");
}
}

View File

@ -0,0 +1,22 @@
<wmsStore>
<name>wmsstore001</name>
<type>WMS</type>
<enabled>true</enabled>
<workspace>
<name>ws001</name>
<atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="alternate" href="http://172.27.30.25:8080/geoserver/rest/workspaces/ws001.xml" type="application/xml"/>
</workspace>
<metadata>
<entry key="useConnectionPooling">true</entry>
</metadata>
<__default>false</__default>
<capabilitiesURL>http://myhost/geoserver/wms</capabilitiesURL>
<user>admin</user>
<password>geoserver</password>
<maxConnections>6</maxConnections>
<readTimeout>60</readTimeout>
<connectTimeout>30</connectTimeout>
<wmsLayers>
<atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="alternate" href="http://172.27.30.25:8080/geoserver/rest/workspaces/ws001/wmsstores/wmsstore001/wmslayers.xml" type="application/xml"/>
</wmsLayers>
</wmsStore>