package skrueger.geotools.io; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import java.net.MalformedURLException; import java.net.URL; import org.junit.Test; import schmitzm.junit.TestingClass; import skrueger.geotools.io.GtWfsServerSettings.HttpProtocol; import skrueger.geotools.io.GtWfsServerSettings.WfsProtocollVersion; public class GtWfsServerSettingsTest extends TestingClass { @Test public void testParseAndSerialize1() throws MalformedURLException { GtWfsServerSettings wfs1 = new GtWfsServerSettings(new URL( "http://localhost:8085/geoserver/ows"), WfsProtocollVersion.v1_1_0); assertTrue(wfs1.isWellDefined()); GtWfsServerSettings wfs2 = new GtWfsServerSettings(wfs1 .toPropertiesString()); assertEquals(wfs1.getBaseUrl(), wfs2.getBaseUrl()); assertEquals(wfs1.getVersion(), wfs2.getVersion()); assertEquals(wfs1.getCapabilitiesUrl(), wfs2.getCapabilitiesUrl()); assertEquals(wfs1.isWellDefined(), wfs2.isWellDefined()); } @Test public void testParseAndSerialize2() throws MalformedURLException { GtWfsServerSettings wfs1 = new GtWfsServerSettings(new URL( "http://localhost:8085/geoserver/ows"), WfsProtocollVersion.v1_0_0); wfs1.setHttpProtocol(HttpProtocol.GET); wfs1.setUsername("hans"); wfs1.setPassword("***"); wfs1.setTimeout(12345); wfs1.setMaxFeatures(54321); wfs1.setTitle("sweety"); GtWfsServerSettings wfs2 = new GtWfsServerSettings(wfs1 .toPropertiesString()); assertEquals(wfs1.getBaseUrl(), wfs2.getBaseUrl()); assertEquals(wfs1.getVersion(), wfs2.getVersion()); assertEquals(HttpProtocol.GET, wfs2.getHttpProtocol()); assertEquals("hans", wfs2.getUsername()); assertEquals("***", wfs2.getPassword()); assertEquals(12345, wfs2.getTimeout(), 0.0001); assertEquals(54321, wfs2.getMaxFeatures(), 0.0001); assertEquals("sweety", wfs2.getTitle()); assertEquals(wfs1.getCapabilitiesUrl(), wfs2.getCapabilitiesUrl()); assertEquals(wfs1.isWellDefined(), wfs2.isWellDefined()); } @Test public void testSetBaseUrl() { GtWfsServerSettings wfs = new GtWfsServerSettings(); wfs.setBaseUrl("http://localhost?asd=2323"); assertEquals("http://localhost", wfs.getBaseUrl().toString()); } }