Mercurial > dive4elements > gnv-client
changeset 403:24a6c0cb0a62
Added Junit-TestCase for the ExternalCallParser Interface
gnv/trunk@574 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Tim Englich <tim.englich@intevation.de> |
---|---|
date | Tue, 19 Jan 2010 14:50:39 +0000 |
parents | b88e881e8e94 |
children | 3a286c9e186c |
files | gnv/ChangeLog gnv/src/test/java/de/intevation/gnv/action/mapviewer/parser/ExternalCallParserTestCase.java gnv/src/test/ressources/externalinterfacecall.xml |
diffstat | 3 files changed, 117 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/gnv/ChangeLog Tue Jan 19 14:47:36 2010 +0000 +++ b/gnv/ChangeLog Tue Jan 19 14:50:39 2010 +0000 @@ -1,5 +1,12 @@ 2010-01-19 Tim Englich <tim.englich@intevation.de> + * src/test/ressources/externalinterfacecall.xml: + Added an Request-Document which contains an Call which might be + send from the MapViewer to the GNV. + * src/test/java/de/intevation/gnv/action/mapviewer/parser/ExternalCallParserTestCase.java: + Added TestCase for testing the functionality of the XMLExternalCallParser-Implementation. + +2010-01-19 Tim Englich <tim.englich@intevation.de> * src/main/java/de/intevation/gnv/artifactdatabase/objects/map/DefaultMapService.java: DefaultImplementation of the Interface MapService. * src/main/java/de/intevation/gnv/artifactdatabase/objects/map/MapService.java :
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gnv/src/test/java/de/intevation/gnv/action/mapviewer/parser/ExternalCallParserTestCase.java Tue Jan 19 14:50:39 2010 +0000 @@ -0,0 +1,89 @@ +package de.intevation.gnv.action.mapviewer.parser; + +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStream; +import java.util.Collection; +import java.util.Iterator; + +import junit.framework.TestCase; + +import org.apache.log4j.BasicConfigurator; +import org.apache.log4j.Logger; + +import de.intevation.gnv.artifactdatabase.objects.map.Layer; +import de.intevation.gnv.artifactdatabase.objects.map.MapService; + +public class ExternalCallParserTestCase extends TestCase { + + /** + * the logger, used to log exceptions and additonaly information + */ + private static Logger log = null; + + static { + BasicConfigurator.configure(); + log = Logger.getLogger(ExternalCallParserTestCase.class); + } + + public ExternalCallParserTestCase() { + super(); + } + + public ExternalCallParserTestCase(String name) { + super(name); + } + + public void testParseExternalCall() { + log.debug("Execute testParseExternalCall"); + try { + InputStream inputStream = new FileInputStream( + new File("src/test/ressources/externalinterfacecall.xml")); + ExternalCallParser ecp = new XMLExternalCallParser(inputStream); + ecp.parse(); + String geometry = ecp.getGeometry(); + assertNotNull(geometry); + log.debug("Parsed Geometry: "+geometry); + String srs = ecp.getSRS(); + assertNotNull(srs); + log.debug("Parsed SRS: "+srs); + Collection<MapService> mapServices = ecp.getMapServices(); + assertNotNull(mapServices); + log.debug(mapServices.size()+"Mapservices parsed"); + assertEquals(2, mapServices.size()); + Iterator<MapService> it = mapServices.iterator(); + MapService mapService1 = it.next(); + MapService mapService2 = it.next(); + + log.debug("MapService 1"); + log.debug("ID: "+mapService1.getID()); + log.debug("URL: "+mapService1.getURL()); + log.debug("TYPE: "+mapService1.getType()); + Collection<Layer> layer1 = mapService1.getLayer(); + log.debug("Layer parsed: "+layer1.size()); + assertEquals(5, layer1.size()); + Iterator<Layer> layerIt1 = layer1.iterator(); + while(layerIt1.hasNext()){ + log.debug(layerIt1.next().toString()); + } + + log.debug("MapService 2"); + log.debug("ID: "+mapService2.getID()); + log.debug("URL: "+mapService2.getURL()); + log.debug("TYPE: "+mapService2.getType()); + Collection<Layer> layer2 = mapService2.getLayer(); + log.debug("Layer parsed: "+layer2.size()); + assertEquals(2, layer2.size()); + Iterator<Layer> layerIt2 = layer2.iterator(); + while(layerIt2.hasNext()){ + log.debug(layerIt2.next().toString()); + } + + } catch (Exception e) { + log.error(e,e); + fail(); + } + + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gnv/src/test/ressources/externalinterfacecall.xml Tue Jan 19 14:50:39 2010 +0000 @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="UTF-8"?> +<gnviewer> + <mapservices> + <mapservice id="foo" type="arcims" url="http://foo.bar.de"> + <layer id="layer0" name="Layer 0"/> + <layer id="layer1" name="Layer 1"> + <layer id="layer2" name="Layer 2"/> + <layer id="layer3" name="Layer 3"/> + </layer> + <layer id="layern" name="Layer N"/> + </mapservice> + <mapservice id="foo1" type="wms" url="http://foo1.bar.de"> + <layer id="layer0" name="Layer 0"/> + <layer id="layer1" name="Layer 1"/> + </mapservice> + </mapservices> + <location> + <srs>EPSG:4324</srs> + <data>POINT(8.6 56.0)</data> + </location> +</gnviewer> \ No newline at end of file