001: package org.geoserver.wfs.xml;
002:
003: import java.io.InputStream;
004: import java.util.zip.GZIPInputStream;
005:
006: import org.geoserver.data.test.MockData;
007: import org.geoserver.wfs.WFSTestSupport;
008: import org.w3c.dom.Document;
009:
010: public class GMLOutputFormatTest extends WFSTestSupport {
011:
012: public void testGML2() throws Exception {
013: Document dom = getAsDOM("wfs?request=getfeature&version=1.0.0&outputFormat=gml2&typename="
014: + MockData.BASIC_POLYGONS.getPrefix()
015: + ":"
016: + MockData.BASIC_POLYGONS.getLocalPart());
017: assertEquals("FeatureCollection", dom.getDocumentElement()
018: .getLocalName());
019: assertNotNull(getFirstElementByTagName(dom,
020: "gml:outerBoundaryIs"));
021: assertNull(getFirstElementByTagName(dom, "gml:exterior"));
022:
023: dom = getAsDOM("wfs?request=getfeature&version=1.1.0&outputFormat=gml2&typename="
024: + MockData.BASIC_POLYGONS.getPrefix()
025: + ":"
026: + MockData.BASIC_POLYGONS.getLocalPart());
027: assertEquals("FeatureCollection", dom.getDocumentElement()
028: .getLocalName());
029: assertNotNull(getFirstElementByTagName(dom,
030: "gml:outerBoundaryIs"));
031: assertNull(getFirstElementByTagName(dom, "gml:exterior"));
032:
033: dom = getAsDOM("wfs?request=getfeature&version=1.0.0&outputFormat=text/xml; subtype%3Dgml/2.1.2&typename="
034: + MockData.BASIC_POLYGONS.getPrefix()
035: + ":"
036: + MockData.BASIC_POLYGONS.getLocalPart());
037: assertEquals("FeatureCollection", dom.getDocumentElement()
038: .getLocalName());
039: assertNotNull(getFirstElementByTagName(dom,
040: "gml:outerBoundaryIs"));
041: assertNull(getFirstElementByTagName(dom, "gml:exterior"));
042:
043: dom = getAsDOM("wfs?request=getfeature&version=1.1.0&outputFormat=text/xml; subtype%3Dgml/2.1.2&typename="
044: + MockData.BASIC_POLYGONS.getPrefix()
045: + ":"
046: + MockData.BASIC_POLYGONS.getLocalPart());
047: assertEquals("FeatureCollection", dom.getDocumentElement()
048: .getLocalName());
049: assertNotNull(getFirstElementByTagName(dom,
050: "gml:outerBoundaryIs"));
051: assertNull(getFirstElementByTagName(dom, "gml:exterior"));
052: }
053:
054: public void testGML2GZIP() throws Exception {
055: // InputStream input = get( "wfs?request=getfeature&version=1.0.0&outputFormat=gml2-gzip&typename=" +
056: // MockData.BASIC_POLYGONS.getPrefix() + ":" + MockData.BASIC_POLYGONS.getLocalPart());
057: // GZIPInputStream zipped = new GZIPInputStream( input );
058: //
059: // Document dom = dom( zipped );
060: // zipped.close();
061: //
062: // assertEquals( "FeatureCollection", dom.getDocumentElement().getLocalName() );
063: // assertNotNull( getFirstElementByTagName(dom, "gml:outerBoundaryIs"));
064: // assertNull( getFirstElementByTagName(dom, "gml:exterior"));
065: }
066:
067: public void testGML3() throws Exception {
068: Document dom = getAsDOM("wfs?request=getfeature&version=1.0.0&outputFormat=gml3&typename="
069: + MockData.BASIC_POLYGONS.getPrefix()
070: + ":"
071: + MockData.BASIC_POLYGONS.getLocalPart());
072: assertEquals("FeatureCollection", dom.getDocumentElement()
073: .getLocalName());
074: assertNull(getFirstElementByTagName(dom, "gml:outerBoundaryIs"));
075: assertNotNull(getFirstElementByTagName(dom, "gml:exterior"));
076:
077: dom = getAsDOM("wfs?request=getfeature&version=1.1.0&outputFormat=gml3&typename="
078: + MockData.BASIC_POLYGONS.getPrefix()
079: + ":"
080: + MockData.BASIC_POLYGONS.getLocalPart());
081: assertEquals("FeatureCollection", dom.getDocumentElement()
082: .getLocalName());
083: assertNull(getFirstElementByTagName(dom, "gml:outerBoundaryIs"));
084: assertNotNull(getFirstElementByTagName(dom, "gml:exterior"));
085:
086: dom = getAsDOM("wfs?request=getfeature&version=1.0.0&outputFormat=text/xml; subtype%3Dgml/3.1.1&typename="
087: + MockData.BASIC_POLYGONS.getPrefix()
088: + ":"
089: + MockData.BASIC_POLYGONS.getLocalPart());
090: assertEquals("FeatureCollection", dom.getDocumentElement()
091: .getLocalName());
092: assertNull(getFirstElementByTagName(dom, "gml:outerBoundaryIs"));
093: assertNotNull(getFirstElementByTagName(dom, "gml:exterior"));
094:
095: dom = getAsDOM("wfs?request=getfeature&version=1.1.0&outputFormat=text/xml; subtype%3Dgml/3.1.1&typename="
096: + MockData.BASIC_POLYGONS.getPrefix()
097: + ":"
098: + MockData.BASIC_POLYGONS.getLocalPart());
099: assertEquals("FeatureCollection", dom.getDocumentElement()
100: .getLocalName());
101: assertNull(getFirstElementByTagName(dom, "gml:outerBoundaryIs"));
102: assertNotNull(getFirstElementByTagName(dom, "gml:exterior"));
103: }
104: }
|