01: package org.geoserver.wfs.v1_1;
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.geoserver.wfs.WFSGetFeatureOutputFormat;
09: import org.geoserver.wfs.WFSTestSupport;
10: import org.w3c.dom.Document;
11: import org.w3c.dom.Element;
12: import org.w3c.dom.NodeList;
13:
14: public class GetCapabilitiesTest extends WFSTestSupport {
15:
16: public void testGet() throws Exception {
17: Document doc = getAsDOM("wfs?service=WFS&request=getCapabilities&version=1.1.0");
18:
19: assertEquals("wfs:WFS_Capabilities", doc.getDocumentElement()
20: .getNodeName());
21: assertEquals("1.1.0", doc.getDocumentElement().getAttribute(
22: "version"));
23: }
24:
25: public void testPost() throws Exception {
26:
27: String xml = "<GetCapabilities service=\"WFS\" "
28: + " xmlns=\"http://www.opengis.net/wfs\" "
29: + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
30: + " xsi:schemaLocation=\"http://www.opengis.net/wfs "
31: + " http://schemas.opengis.net/wfs/1.1.0/wfs.xsd\"/>";
32:
33: Document doc = postAsDOM("wfs", xml);
34: assertEquals("wfs:WFS_Capabilities", doc.getDocumentElement()
35: .getNodeName());
36: assertEquals("1.1.0", doc.getDocumentElement().getAttribute(
37: "version"));
38: }
39:
40: public void testPostNoSchemaLocation() throws Exception {
41: String xml = "<GetCapabilities service=\"WFS\" "
42: + " xmlns=\"http://www.opengis.net/wfs\" "
43: + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" />";
44:
45: Document doc = postAsDOM("wfs", xml);
46: assertEquals("wfs:WFS_Capabilities", doc.getDocumentElement()
47: .getNodeName());
48: assertEquals("1.1.0", doc.getDocumentElement().getAttribute(
49: "version"));
50: }
51:
52: public void testOutputFormats() throws Exception {
53: Document doc = getAsDOM("wfs?service=WFS&request=getCapabilities&version=1.1.0");
54:
55: Element outputFormats = getFirstElementByTagName(doc,
56: "OutputFormats");
57: NodeList formats = outputFormats.getElementsByTagName("Format");
58:
59: TreeSet s1 = new TreeSet();
60: for (int i = 0; i < formats.getLength(); i++) {
61: String format = formats.item(i).getFirstChild()
62: .getNodeValue();
63: s1.add(format);
64: }
65:
66: List extensions = GeoServerExtensions
67: .extensions(WFSGetFeatureOutputFormat.class);
68:
69: TreeSet s2 = new TreeSet();
70: for (Iterator e = extensions.iterator(); e.hasNext();) {
71: WFSGetFeatureOutputFormat extension = (WFSGetFeatureOutputFormat) e
72: .next();
73: s2.addAll(extension.getOutputFormats());
74: }
75:
76: assertEquals(s1, s2);
77: }
78:
79: }
|