01: package org.geotools.data.jdbc;
02:
03: import org.geotools.data.FeatureSource;
04: import org.geotools.feature.FeatureCollection;
05: import org.geotools.feature.FeatureType;
06:
07: import org.opengis.filter.FilterFactory;
08: import org.opengis.filter.PropertyIsEqualTo;
09:
10: import com.vividsolutions.jts.geom.Geometry;
11:
12: public class JDBCFeatureSourceTest extends JDBCTestSupport {
13:
14: FeatureSource fs;
15:
16: protected void setUp() throws Exception {
17: super .setUp();
18:
19: fs = dataStore.getFeatureSource("ft1");
20: }
21:
22: public void testGetDataStore() {
23: assertEquals(dataStore, fs.getDataStore());
24: }
25:
26: public void testGetSchema() {
27: FeatureType ft1 = fs.getSchema();
28: assertEquals("ft1", ft1.getTypeName());
29:
30: assertNotNull(ft1.getAttributeType("geometry"));
31: assertNotNull(ft1.getAttributeType("intProperty"));
32: assertNotNull(ft1.getAttributeType("doubleProperty"));
33: assertNotNull(ft1.getAttributeType("stringProperty"));
34:
35: assertEquals(Geometry.class, ft1.getAttributeType("geometry")
36: .getType());
37: assertEquals(Integer.class, ft1.getAttributeType("intProperty")
38: .getType());
39: assertEquals(Double.class, ft1.getAttributeType(
40: "doubleProperty").getType());
41: assertEquals(String.class, ft1.getAttributeType(
42: "stringProperty").getType());
43: }
44:
45: public void testGetFeatures() throws Exception {
46: FeatureCollection features = fs.getFeatures();
47: assertNotNull(features);
48:
49: assertEquals(3, features.size());
50: }
51:
52: public void testGetFeaturesWithFilter() throws Exception {
53: FilterFactory ff = dataStore.getFilterFactory();
54: PropertyIsEqualTo filter = ff.equal(ff.property("intProperty"),
55: ff.literal(1), false);
56:
57: FeatureCollection features = fs.getFeatures(filter);
58: assertNotNull(features);
59:
60: assertEquals(1, features.size());
61: }
62: }
|