01: package org.geoserver.wfs;
02:
03: import java.util.Iterator;
04: import java.util.List;
05: import java.util.TreeSet;
06:
07: import org.geoserver.platform.GeoServerExtensions;
08: import org.w3c.dom.Document;
09: import org.w3c.dom.Element;
10: import org.w3c.dom.NodeList;
11:
12: public class GetCapabilitiesTest extends WFSTestSupport {
13:
14: public void testGet() throws Exception {
15: Document doc = getAsDOM("wfs?service=WFS&request=getCapabilities");
16: assertEquals("wfs:WFS_Capabilities", doc.getDocumentElement()
17: .getNodeName());
18: }
19:
20: public void testPost() throws Exception {
21: String xml = "<GetCapabilities service=\"WFS\" version=\"1.0.0\""
22: + " xmlns=\"http://www.opengis.net/wfs\" "
23: + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
24: + " xsi:schemaLocation=\"http://www.opengis.net/wfs "
25: + " http://schemas.opengis.net/wfs/1.0.0/WFS-basic.xsd\"/>";
26: Document doc = postAsDOM("wfs", xml);
27:
28: assertEquals("WFS_Capabilities", doc.getDocumentElement()
29: .getNodeName());
30:
31: }
32:
33: public void testOutputFormats() throws Exception {
34: Document doc = getAsDOM("wfs?service=WFS&request=getCapabilities&version=1.0.0");
35:
36: Element outputFormats = getFirstElementByTagName(doc,
37: "ResultFormat");
38: NodeList formats = outputFormats.getChildNodes();
39:
40: TreeSet s1 = new TreeSet();
41: for (int i = 0; i < formats.getLength(); i++) {
42: String format = formats.item(i).getNodeName();
43: s1.add(format);
44: }
45:
46: List extensions = GeoServerExtensions
47: .extensions(WFSGetFeatureOutputFormat.class);
48:
49: TreeSet s2 = new TreeSet();
50: for (Iterator e = extensions.iterator(); e.hasNext();) {
51: WFSGetFeatureOutputFormat extension = (WFSGetFeatureOutputFormat) e
52: .next();
53: s2.add(extension.getCapabilitiesElementName());
54: }
55:
56: assertEquals(s1, s2);
57: }
58: }
|