// ensure no stores
clearCatalog();
removeExistingNS();
NamespaceInfo namespace = catalog.getFactory().createNamespace();
namespace.setPrefix(getName());
namespace.setURI("http://" + getName() + ".openplans.org");
catalog.add(namespace);
// store needs a workspace...
WorkspaceInfo ws = catalog.getFactory().createWorkspace();
ws.setName("testFeatureTypeWorkspace");
catalog.add(ws);
StyleInfo style = catalog.getFactory().createStyle();
style.setName("style_testFeatureType");
style.setFilename("style_testFeatureType");
catalog.add(style);
DataStoreInfo dataStore = catalog.getFactory().createDataStore();
dataStore.setName("dataStore2");
dataStore.setDescription("store description");
dataStore.setEnabled(true);
dataStore.setWorkspace(ws);
catalog.add(dataStore);
FeatureTypeInfo refFeatureType = catalog.getFactory().createFeatureType();
refFeatureType.setName("featureType");
refFeatureType.setNativeName("nativefeatureType");
refFeatureType.setTitle("featureType title");
refFeatureType.setDescription("featureType description");
refFeatureType.setAbstract("featureType abstract");
refFeatureType.setSRS("EPSG:4326");
refFeatureType.setNamespace(namespace);
FilterFactory factory = CommonFactoryFinder.getFilterFactory(null);
Filter filter = factory.id(Collections.EMPTY_SET);
refFeatureType.setFilter(filter);
CoordinateReferenceSystem crsNative = CRS
.parseWKT("PROJCS[\"NAD83 / BC Albers\",GEOGCS[\"NAD83\",DATUM[\"North_American_Datum_1983\",SPHEROID[\"GRS 1980\",6378137,298.257222101,AUTHORITY[\"EPSG\",\"7019\"]],TOWGS84[0,0,0],AUTHORITY[\"EPSG\",\"6269\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.01745329251994328,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4269\"]],PROJECTION[\"Albers_Conic_Equal_Area\"],PARAMETER[\"standard_parallel_1\",50],PARAMETER[\"standard_parallel_2\",58.5],PARAMETER[\"latitude_of_center\",45],PARAMETER[\"longitude_of_center\",-126],PARAMETER[\"false_easting\",1000000],PARAMETER[\"false_northing\",0],UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]],AUTHORITY[\"EPSG\",\"3005\"]]");
BoundingBox nativeBoundingBox = new ReferencedEnvelope(0, 0, 0, 0, crsNative);
BoundingBox latLonBoundingBox = new ReferencedEnvelope(-180, 180, -90, 90,
DefaultGeographicCRS.WGS84);
refFeatureType.setNativeBoundingBox((ReferencedEnvelope) nativeBoundingBox);
refFeatureType.setLatLonBoundingBox((ReferencedEnvelope) latLonBoundingBox);
refFeatureType.setStore(dataStore);
catalog.add(refFeatureType);
endTransaction();
startNewTransaction();
FeatureTypeInfo loadedFeatureType = catalog.getFeatureType(refFeatureType.getId());
assertNotNull(loadedFeatureType);
assertFalse(refFeatureType == loadedFeatureType);
refFeatureType = loadedFeatureType;
assertEquals("featureType", refFeatureType.getName());
assertEquals("featureType title", refFeatureType.getTitle());
assertEquals("featureType description", refFeatureType.getDescription());
assertEquals("featureType abstract", refFeatureType.getAbstract());
assertEquals("EPSG:4326", refFeatureType.getSRS());
BoundingBox box = refFeatureType.getNativeBoundingBox();
assertNotNull("Native BBox is null", box);
assertEquals(0d, box.getMinX(), 0d);
assertEquals(0d, box.getMinY(), 0d);
assertEquals(0d, box.getMaxX(), 0d);
assertEquals(0d, box.getMaxY(), 0d);
assertTrue(CRS.equalsIgnoreMetadata(crsNative, box.getCoordinateReferenceSystem()));
box = refFeatureType.getLatLonBoundingBox();
assertNotNull(box);
assertEquals(-180d, box.getMinX(), 0d);
assertEquals(-90d, box.getMinY(), 0d);
assertEquals(180d, box.getMaxX(), 0d);
assertEquals(90d, box.getMaxY(), 0d);
assertTrue(CRS.equalsIgnoreMetadata(DefaultGeographicCRS.WGS84, box
.getCoordinateReferenceSystem()));
assertNotNull(refFeatureType.getNamespace());
assertEquals(getName(), refFeatureType.getNamespace().getPrefix());
assertNotNull(refFeatureType.getStore());
assertEquals("dataStore2", refFeatureType.getStore().getName());
endTransaction();
startNewTransaction();
loadedFeatureType = catalog.getFeatureTypeByName(namespace.getPrefix(), refFeatureType
.getName());
assertNotNull(loadedFeatureType);
loadedFeatureType = catalog.getFeatureTypeByName(namespace.getURI(), refFeatureType
.getName());
assertNotNull(loadedFeatureType);
}