diff --git a/src/test/java/it/geosolutions/geoserver/decoder/WmsStoreDecoderTest.java b/src/test/java/it/geosolutions/geoserver/decoder/WmsStoreDecoderTest.java new file mode 100644 index 0000000..5efce3f --- /dev/null +++ b/src/test/java/it/geosolutions/geoserver/decoder/WmsStoreDecoderTest.java @@ -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"); + } +} diff --git a/src/test/resources/testdata/wmsstoreExample.xml b/src/test/resources/testdata/wmsstoreExample.xml new file mode 100644 index 0000000..2898119 --- /dev/null +++ b/src/test/resources/testdata/wmsstoreExample.xml @@ -0,0 +1,22 @@ + + wmsstore001 + WMS + true + + ws001 + + + + true + + <__default>false + http://myhost/geoserver/wms + admin + geoserver + 6 + 60 + 30 + + + + \ No newline at end of file