001: /*
002: * GeoTools - OpenSource mapping toolkit
003: * http://geotools.org
004: * (C) 2004-2006, Geotools Project Managment Committee (PMC)
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or (at your option) any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: */
016: package org.geotools.data.wfs;
017:
018: import java.io.InputStream;
019: import java.util.HashMap;
020: import java.util.Map;
021: import java.util.logging.Level;
022:
023: import org.geotools.TestData;
024: import org.geotools.data.ows.WFSCapabilities;
025: import org.geotools.filter.FilterCapabilities;
026: import org.geotools.filter.function.FilterFunction_distance;
027: import org.geotools.filter.function.FilterFunction_geometryType;
028: import org.geotools.filter.function.math.FilterFunction_abs;
029: import org.geotools.xml.DocumentFactory;
030:
031: import junit.framework.TestCase;
032:
033: /**
034: * Test the ability to read a capabilities document. The emphasis is in making sure that
035: * the Function expressions are constructed correctly.
036: *
037: * @author Jesse
038: */
039: public class ParseCapabilitesTest extends TestCase {
040:
041: protected void setUp() throws Exception {
042: super .setUp();
043: }
044:
045: public void testNoSupportedFunctionExpression() throws Exception {
046: Map hints = new HashMap();
047: InputStream in = TestData
048: .openStream("xml/capabilities/WFSGetCapsNoFunctionExpressions.xml");
049: WFSCapabilities obj = (WFSCapabilities) DocumentFactory
050: .getInstance(in, hints, Level.WARNING);
051: FilterCapabilities filterCapabilities = obj
052: .getFilterCapabilities();
053: assertFalse(filterCapabilities
054: .supports(FilterCapabilities.FUNCTIONS));
055:
056: assertTrue(filterCapabilities
057: .supports(FilterCapabilities.SPATIAL_DISJOINT));
058: assertTrue(filterCapabilities
059: .supports(FilterCapabilities.SPATIAL_EQUALS));
060: assertTrue(filterCapabilities
061: .supports(FilterCapabilities.SPATIAL_DWITHIN));
062: assertTrue(filterCapabilities
063: .supports(FilterCapabilities.SPATIAL_BEYOND));
064: assertTrue(filterCapabilities
065: .supports(FilterCapabilities.SPATIAL_INTERSECT));
066: assertTrue(filterCapabilities
067: .supports(FilterCapabilities.SPATIAL_TOUCHES));
068: assertTrue(filterCapabilities
069: .supports(FilterCapabilities.SPATIAL_CROSSES));
070: assertTrue(filterCapabilities
071: .supports(FilterCapabilities.SPATIAL_WITHIN));
072: assertTrue(filterCapabilities
073: .supports(FilterCapabilities.SPATIAL_CONTAINS));
074: assertTrue(filterCapabilities
075: .supports(FilterCapabilities.SPATIAL_OVERLAPS));
076: assertTrue(filterCapabilities
077: .supports(FilterCapabilities.SPATIAL_BBOX));
078:
079: assertTrue(filterCapabilities
080: .supports(FilterCapabilities.LOGICAL));
081: assertTrue(filterCapabilities
082: .supports(FilterCapabilities.SIMPLE_ARITHMETIC));
083: assertTrue(filterCapabilities
084: .supports(FilterCapabilities.SIMPLE_COMPARISONS));
085:
086: assertTrue(filterCapabilities
087: .supports(FilterCapabilities.BETWEEN));
088: assertTrue(filterCapabilities
089: .supports(FilterCapabilities.NULL_CHECK));
090: assertTrue(filterCapabilities.supports(FilterCapabilities.LIKE));
091:
092: }
093:
094: public void testSomeSupportedFunctionExpression() throws Exception {
095: Map hints = new HashMap();
096: InputStream in = TestData
097: .openStream("xml/capabilities/WFSGetCapsSomeFunctionExpressions.xml");
098: WFSCapabilities obj = (WFSCapabilities) DocumentFactory
099: .getInstance(in, hints, Level.WARNING);
100: FilterCapabilities filterCapabilities = obj
101: .getFilterCapabilities();
102: assertTrue(filterCapabilities
103: .supports(FilterCapabilities.FUNCTIONS));
104:
105: assertTrue(filterCapabilities
106: .supports(FilterFunction_distance.class));
107: assertFalse(filterCapabilities
108: .supports(FilterFunction_abs.class));
109: assertFalse(filterCapabilities
110: .supports(FilterFunction_geometryType.class));
111:
112: assertTrue(filterCapabilities
113: .supports(FilterCapabilities.SPATIAL_DISJOINT));
114: assertTrue(filterCapabilities
115: .supports(FilterCapabilities.SPATIAL_EQUALS));
116: assertTrue(filterCapabilities
117: .supports(FilterCapabilities.SPATIAL_DWITHIN));
118: assertTrue(filterCapabilities
119: .supports(FilterCapabilities.SPATIAL_BEYOND));
120: assertTrue(filterCapabilities
121: .supports(FilterCapabilities.SPATIAL_INTERSECT));
122: assertTrue(filterCapabilities
123: .supports(FilterCapabilities.SPATIAL_TOUCHES));
124: assertTrue(filterCapabilities
125: .supports(FilterCapabilities.SPATIAL_CROSSES));
126: assertTrue(filterCapabilities
127: .supports(FilterCapabilities.SPATIAL_WITHIN));
128: assertTrue(filterCapabilities
129: .supports(FilterCapabilities.SPATIAL_CONTAINS));
130: assertTrue(filterCapabilities
131: .supports(FilterCapabilities.SPATIAL_OVERLAPS));
132: assertTrue(filterCapabilities
133: .supports(FilterCapabilities.SPATIAL_BBOX));
134:
135: assertTrue(filterCapabilities
136: .supports(FilterCapabilities.LOGICAL));
137: assertTrue(filterCapabilities
138: .supports(FilterCapabilities.SIMPLE_ARITHMETIC));
139: assertTrue(filterCapabilities
140: .supports(FilterCapabilities.SIMPLE_COMPARISONS));
141:
142: assertTrue(filterCapabilities
143: .supports(FilterCapabilities.BETWEEN));
144: assertTrue(filterCapabilities
145: .supports(FilterCapabilities.NULL_CHECK));
146: assertTrue(filterCapabilities.supports(FilterCapabilities.LIKE));
147: }
148:
149: public void testGeoserverSupportedFunctionExpression()
150: throws Exception {
151: Map hints = new HashMap();
152: InputStream in = TestData
153: .openStream("xml/capabilities/WFSGetCapsGeoserverFunctionExpressions.xml");
154: WFSCapabilities obj = (WFSCapabilities) DocumentFactory
155: .getInstance(in, hints, Level.WARNING);
156: FilterCapabilities filterCapabilities = obj
157: .getFilterCapabilities();
158: assertTrue(filterCapabilities
159: .supports(FilterCapabilities.FUNCTIONS));
160:
161: assertTrue(filterCapabilities
162: .supports(FilterFunction_distance.class));
163: assertTrue(filterCapabilities
164: .supports(FilterFunction_abs.class));
165: assertTrue(filterCapabilities
166: .supports(FilterFunction_geometryType.class));
167:
168: assertTrue(filterCapabilities
169: .supports(FilterCapabilities.SPATIAL_DISJOINT));
170: assertTrue(filterCapabilities
171: .supports(FilterCapabilities.SPATIAL_EQUALS));
172: assertTrue(filterCapabilities
173: .supports(FilterCapabilities.SPATIAL_DWITHIN));
174: assertTrue(filterCapabilities
175: .supports(FilterCapabilities.SPATIAL_BEYOND));
176: assertTrue(filterCapabilities
177: .supports(FilterCapabilities.SPATIAL_INTERSECT));
178: assertTrue(filterCapabilities
179: .supports(FilterCapabilities.SPATIAL_TOUCHES));
180: assertTrue(filterCapabilities
181: .supports(FilterCapabilities.SPATIAL_CROSSES));
182: assertTrue(filterCapabilities
183: .supports(FilterCapabilities.SPATIAL_WITHIN));
184: assertTrue(filterCapabilities
185: .supports(FilterCapabilities.SPATIAL_CONTAINS));
186: assertTrue(filterCapabilities
187: .supports(FilterCapabilities.SPATIAL_OVERLAPS));
188: assertTrue(filterCapabilities
189: .supports(FilterCapabilities.SPATIAL_BBOX));
190:
191: assertTrue(filterCapabilities
192: .supports(FilterCapabilities.LOGICAL));
193: assertTrue(filterCapabilities
194: .supports(FilterCapabilities.SIMPLE_ARITHMETIC));
195: assertTrue(filterCapabilities
196: .supports(FilterCapabilities.SIMPLE_COMPARISONS));
197:
198: assertTrue(filterCapabilities
199: .supports(FilterCapabilities.BETWEEN));
200: assertTrue(filterCapabilities
201: .supports(FilterCapabilities.NULL_CHECK));
202: assertTrue(filterCapabilities.supports(FilterCapabilities.LIKE));
203: }
204:
205: }
|