001: package org.geotools.data.gml;
002:
003: import java.io.IOException;
004: import java.util.Arrays;
005: import java.util.Iterator;
006: import java.util.List;
007:
008: import junit.framework.TestCase;
009:
010: import org.geotools.feature.Feature;
011: import org.geotools.feature.FeatureCollection;
012: import org.geotools.feature.FeatureType;
013: import org.geotools.gml3.ApplicationSchemaConfiguration;
014:
015: public class GMLDataStoreSimpleFeatureProfileTest extends TestCase {
016:
017: GMLDataStore dataStore;
018:
019: protected void setUp() throws Exception {
020:
021: String location = getClass().getResource("dataset-sf0a.xml")
022: .toString();
023:
024: String namespace = "http://cite.opengeospatial.org/gmlsf";
025: String schemaLocation = getClass().getResource(
026: "cite-gmlsf0a.xsd").toString();
027:
028: dataStore = new GMLDataStore(location,
029: new ApplicationSchemaConfiguration(namespace,
030: schemaLocation));
031: }
032:
033: public void testGetTypeNames() throws Exception {
034: List names = Arrays.asList(dataStore.getTypeNames());
035:
036: assertTrue(names.contains("PrimitiveGeoFeature"));
037: assertTrue(names.contains("AggregateGeoFeature"));
038: assertTrue(names.contains("Entit\u00e9G\u00e9n\u00e9rique"));
039: }
040:
041: public void testGetSchema1() throws IOException {
042: FeatureType featureType = dataStore
043: .getSchema("PrimitiveGeoFeature");
044: assertNotNull(featureType);
045:
046: assertNotNull(featureType.getAttributeType("pointProperty"));
047: assertNotNull(featureType.getAttributeType("curveProperty"));
048: assertNotNull(featureType.getAttributeType("surfaceProperty"));
049: }
050:
051: public void testGetSchema2() throws IOException {
052: FeatureType featureType = dataStore
053: .getSchema("AggregateGeoFeature");
054: assertNotNull(featureType);
055:
056: assertNotNull(featureType
057: .getAttributeType("multiPointProperty"));
058: assertNotNull(featureType
059: .getAttributeType("multiCurveProperty"));
060: assertNotNull(featureType
061: .getAttributeType("multiSurfaceProperty"));
062: }
063:
064: public void testGetSchema3() throws Exception {
065: FeatureType featureType = dataStore
066: .getSchema("Entit\u00e9G\u00e9n\u00e9rique");
067: assertNotNull(featureType);
068: assertNotNull(featureType
069: .getAttributeType("attribut.G\u00e9om\u00e9trie"));
070:
071: }
072:
073: public void testGetFeatures1() throws Exception {
074: FeatureCollection features = dataStore.getFeatureSource(
075: "PrimitiveGeoFeature").getFeatures();
076: assertEquals(5, features.size());
077:
078: Iterator iterator = features.iterator();
079: assertTrue(iterator.hasNext());
080: try {
081: Feature f = (Feature) iterator.next();
082: assertEquals("f001", f.getID());
083: } finally {
084: features.close(iterator);
085: }
086: }
087:
088: public void testGetFeatures2() throws Exception {
089: FeatureCollection features = dataStore.getFeatureSource(
090: "AggregateGeoFeature").getFeatures();
091: assertEquals(4, features.size());
092:
093: Iterator iterator = features.iterator();
094: assertTrue(iterator.hasNext());
095: try {
096: Feature f = (Feature) iterator.next();
097: assertEquals("f005", f.getID());
098: } finally {
099: features.close(iterator);
100: }
101: }
102: }
|