annotate gnv/src/test/java/de/intevation/gnv/action/mapviewer/parser/ExternalCallParserTestCase.java @ 683:d49e8695786c

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

http://dive4elements.wald.intevation.org