Mercurial > dive4elements > gnv-client
annotate gnv/src/test/java/de/intevation/gnv/action/mapviewer/parser/ExternalCallParserTestCase.java @ 1145:dfe1ac687c7f tip
added tags
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Fri, 28 Sep 2012 12:16:15 +0200 |
parents | 28a0628b11b0 |
children |
rev | line source |
---|---|
1022
28a0628b11b0
Added license file and license header.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
683
diff
changeset
|
1 /* |
28a0628b11b0
Added license file and license header.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
683
diff
changeset
|
2 * Copyright (c) 2010 by Intevation GmbH |
28a0628b11b0
Added license file and license header.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
683
diff
changeset
|
3 * |
28a0628b11b0
Added license file and license header.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
683
diff
changeset
|
4 * This program is free software under the LGPL (>=v2.1) |
28a0628b11b0
Added license file and license header.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
683
diff
changeset
|
5 * Read the file LGPL.txt coming with the software for details |
28a0628b11b0
Added license file and license header.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
683
diff
changeset
|
6 * or visit http://www.gnu.org/licenses/ if it does not exist. |
28a0628b11b0
Added license file and license header.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
683
diff
changeset
|
7 */ |
28a0628b11b0
Added license file and license header.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
683
diff
changeset
|
8 |
403
24a6c0cb0a62
Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
9 package de.intevation.gnv.action.mapviewer.parser; |
24a6c0cb0a62
Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
10 |
683
d49e8695786c
Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
681
diff
changeset
|
11 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
|
12 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
|
13 |
403
24a6c0cb0a62
Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
14 import java.io.File; |
24a6c0cb0a62
Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
15 import java.io.FileInputStream; |
24a6c0cb0a62
Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
16 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
|
17 |
403
24a6c0cb0a62
Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
18 import java.util.Collection; |
24a6c0cb0a62
Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
19 import java.util.Iterator; |
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 import junit.framework.TestCase; |
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 import org.apache.log4j.BasicConfigurator; |
24a6c0cb0a62
Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
24 import org.apache.log4j.Logger; |
24a6c0cb0a62
Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
25 |
24a6c0cb0a62
Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
26 public class ExternalCallParserTestCase extends TestCase { |
681
15ac78a91d1b
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
403
diff
changeset
|
27 |
403
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 * 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
|
30 */ |
24a6c0cb0a62
Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
31 private static Logger log = null; |
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 static { |
24a6c0cb0a62
Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
34 BasicConfigurator.configure(); |
24a6c0cb0a62
Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
35 log = Logger.getLogger(ExternalCallParserTestCase.class); |
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 ExternalCallParserTestCase() { |
24a6c0cb0a62
Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
39 super(); |
24a6c0cb0a62
Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
40 } |
24a6c0cb0a62
Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
41 |
24a6c0cb0a62
Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
42 public ExternalCallParserTestCase(String name) { |
24a6c0cb0a62
Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
43 super(name); |
24a6c0cb0a62
Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
44 } |
681
15ac78a91d1b
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
403
diff
changeset
|
45 |
403
24a6c0cb0a62
Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
46 public void testParseExternalCall() { |
24a6c0cb0a62
Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
47 log.debug("Execute testParseExternalCall"); |
24a6c0cb0a62
Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
48 try { |
24a6c0cb0a62
Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
49 InputStream inputStream = new FileInputStream( |
24a6c0cb0a62
Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
50 new File("src/test/ressources/externalinterfacecall.xml")); |
24a6c0cb0a62
Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
51 ExternalCallParser ecp = new XMLExternalCallParser(inputStream); |
24a6c0cb0a62
Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
52 ecp.parse(); |
24a6c0cb0a62
Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
53 String geometry = ecp.getGeometry(); |
24a6c0cb0a62
Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
54 assertNotNull(geometry); |
24a6c0cb0a62
Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
55 log.debug("Parsed Geometry: "+geometry); |
24a6c0cb0a62
Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
56 String srs = ecp.getSRS(); |
24a6c0cb0a62
Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
57 assertNotNull(srs); |
24a6c0cb0a62
Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
58 log.debug("Parsed SRS: "+srs); |
24a6c0cb0a62
Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
59 Collection<MapService> mapServices = ecp.getMapServices(); |
24a6c0cb0a62
Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
60 assertNotNull(mapServices); |
24a6c0cb0a62
Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
61 log.debug(mapServices.size()+"Mapservices parsed"); |
24a6c0cb0a62
Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
62 assertEquals(2, mapServices.size()); |
24a6c0cb0a62
Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
63 Iterator<MapService> it = mapServices.iterator(); |
24a6c0cb0a62
Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
64 MapService mapService1 = it.next(); |
24a6c0cb0a62
Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
65 MapService mapService2 = it.next(); |
681
15ac78a91d1b
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
403
diff
changeset
|
66 |
403
24a6c0cb0a62
Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
67 log.debug("MapService 1"); |
24a6c0cb0a62
Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
68 log.debug("ID: "+mapService1.getID()); |
24a6c0cb0a62
Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
69 log.debug("URL: "+mapService1.getURL()); |
24a6c0cb0a62
Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
70 log.debug("TYPE: "+mapService1.getType()); |
24a6c0cb0a62
Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
71 Collection<Layer> layer1 = mapService1.getLayer(); |
24a6c0cb0a62
Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
72 log.debug("Layer parsed: "+layer1.size()); |
24a6c0cb0a62
Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
73 assertEquals(5, layer1.size()); |
24a6c0cb0a62
Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
74 Iterator<Layer> layerIt1 = layer1.iterator(); |
24a6c0cb0a62
Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
75 while(layerIt1.hasNext()){ |
24a6c0cb0a62
Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
76 log.debug(layerIt1.next().toString()); |
24a6c0cb0a62
Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
77 } |
681
15ac78a91d1b
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
403
diff
changeset
|
78 |
403
24a6c0cb0a62
Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
79 log.debug("MapService 2"); |
24a6c0cb0a62
Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
80 log.debug("ID: "+mapService2.getID()); |
24a6c0cb0a62
Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
81 log.debug("URL: "+mapService2.getURL()); |
24a6c0cb0a62
Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
82 log.debug("TYPE: "+mapService2.getType()); |
24a6c0cb0a62
Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
83 Collection<Layer> layer2 = mapService2.getLayer(); |
24a6c0cb0a62
Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
84 log.debug("Layer parsed: "+layer2.size()); |
24a6c0cb0a62
Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
85 assertEquals(2, layer2.size()); |
24a6c0cb0a62
Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
86 Iterator<Layer> layerIt2 = layer2.iterator(); |
24a6c0cb0a62
Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
87 while(layerIt2.hasNext()){ |
24a6c0cb0a62
Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
88 log.debug(layerIt2.next().toString()); |
24a6c0cb0a62
Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
89 } |
681
15ac78a91d1b
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
403
diff
changeset
|
90 |
403
24a6c0cb0a62
Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
91 } catch (Exception e) { |
24a6c0cb0a62
Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
92 log.error(e,e); |
24a6c0cb0a62
Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
93 fail(); |
24a6c0cb0a62
Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
94 } |
681
15ac78a91d1b
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
403
diff
changeset
|
95 |
403
24a6c0cb0a62
Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
96 } |
24a6c0cb0a62
Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
97 |
24a6c0cb0a62
Added Junit-TestCase for the ExternalCallParser Interface
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
98 } |