annotate gnv/src/test/java/de/intevation/gnv/action/mapviewer/parser/ExternalCallParserTestCase.java @ 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
children 15ac78a91d1b
rev   line source
403
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
1 package de.intevation.gnv.action.mapviewer.parser;
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
2
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
3 import java.io.File;
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
4 import java.io.FileInputStream;
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
5 import java.io.InputStream;
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
6 import java.util.Collection;
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
7 import java.util.Iterator;
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
8
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
9 import junit.framework.TestCase;
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
10
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
11 import org.apache.log4j.BasicConfigurator;
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
12 import org.apache.log4j.Logger;
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
13
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
14 import de.intevation.gnv.artifactdatabase.objects.map.Layer;
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
15 import de.intevation.gnv.artifactdatabase.objects.map.MapService;
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
16
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
17 public class ExternalCallParserTestCase extends TestCase {
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
18
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
19 /**
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
20 * the logger, used to log exceptions and additonaly information
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
21 */
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
22 private static Logger log = null;
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
23
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
24 static {
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
25 BasicConfigurator.configure();
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
26 log = Logger.getLogger(ExternalCallParserTestCase.class);
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
27 }
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
28
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
29 public ExternalCallParserTestCase() {
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
30 super();
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
31 }
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
32
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
33 public ExternalCallParserTestCase(String name) {
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
34 super(name);
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
35 }
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
36
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
37 public void testParseExternalCall() {
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
38 log.debug("Execute testParseExternalCall");
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
39 try {
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
40 InputStream inputStream = new FileInputStream(
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
41 new File("src/test/ressources/externalinterfacecall.xml"));
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
42 ExternalCallParser ecp = new XMLExternalCallParser(inputStream);
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
43 ecp.parse();
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
44 String geometry = ecp.getGeometry();
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
45 assertNotNull(geometry);
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
46 log.debug("Parsed Geometry: "+geometry);
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
47 String srs = ecp.getSRS();
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
48 assertNotNull(srs);
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
49 log.debug("Parsed SRS: "+srs);
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
50 Collection<MapService> mapServices = ecp.getMapServices();
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
51 assertNotNull(mapServices);
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
52 log.debug(mapServices.size()+"Mapservices parsed");
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
53 assertEquals(2, mapServices.size());
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
54 Iterator<MapService> it = mapServices.iterator();
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
55 MapService mapService1 = it.next();
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
56 MapService mapService2 = it.next();
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
57
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
58 log.debug("MapService 1");
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
59 log.debug("ID: "+mapService1.getID());
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
60 log.debug("URL: "+mapService1.getURL());
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
61 log.debug("TYPE: "+mapService1.getType());
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
62 Collection<Layer> layer1 = mapService1.getLayer();
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
63 log.debug("Layer parsed: "+layer1.size());
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
64 assertEquals(5, layer1.size());
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
65 Iterator<Layer> layerIt1 = layer1.iterator();
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
66 while(layerIt1.hasNext()){
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
67 log.debug(layerIt1.next().toString());
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
68 }
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
69
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
70 log.debug("MapService 2");
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
71 log.debug("ID: "+mapService2.getID());
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
72 log.debug("URL: "+mapService2.getURL());
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
73 log.debug("TYPE: "+mapService2.getType());
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
74 Collection<Layer> layer2 = mapService2.getLayer();
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
75 log.debug("Layer parsed: "+layer2.size());
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
76 assertEquals(2, layer2.size());
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
77 Iterator<Layer> layerIt2 = layer2.iterator();
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
78 while(layerIt2.hasNext()){
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
79 log.debug(layerIt2.next().toString());
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
80 }
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
81
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
82 } catch (Exception e) {
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
83 log.error(e,e);
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
84 fail();
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
85 }
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
86
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
87 }
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
88
24a6c0cb0a62 Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
89 }

http://dive4elements.wald.intevation.org