01: package org.example.geotools.base;
02:
03: import java.io.IOException;
04:
05: import junit.framework.TestCase;
06:
07: import org.geotools.catalog.Catalog;
08: import org.geotools.catalog.Service;
09: import org.geotools.data.FeatureSource;
10: import org.geotools.data.shapefile.ShapefileDataStore;
11: import org.geotools.feature.Feature;
12: import org.geotools.feature.FeatureCollection;
13: import org.geotools.styling.Style;
14:
15: public class DemoTest extends TestCase {
16:
17: DemoBase demoBase;
18:
19: protected void setUp() throws Exception {
20: demoBase = new DemoBase();
21: }
22:
23: public void testCreateLondonPointFeatureFromScratch() {
24:
25: Feature f = demoBase.createLondonPointFeatureFromScratch();
26: assertNotNull(f);
27:
28: FeatureCollection fc = demoBase.makeLondonFeatureCollection(f);
29: assertNotNull(fc);
30: assertFalse(fc.isEmpty());
31:
32: }
33:
34: public void testLoadShapefileIntoCatalog() throws IOException {
35:
36: demoBase.loadShapefileIntoCatalog(demoBase.SHAPEFILENAME);
37: Catalog catalog = demoBase.demoData.getLocalCatalog();
38: assertEquals(1, catalog.members(null).size());
39:
40: Service service = (Service) catalog.members(null).get(0);
41: assertTrue(service.canResolve(ShapefileDataStore.class));
42:
43: }
44:
45: public void testLoadShapefileFeatureSource() throws IOException {
46:
47: demoBase.loadShapefileIntoCatalog(demoBase.SHAPEFILENAME);
48: FeatureSource featureSource = demoBase
49: .getAShapefileFeatureSourceFromCatalog();
50: assertNotNull(featureSource);
51: assertFalse(featureSource.getFeatures().isEmpty());
52:
53: }
54:
55: public void testCreateStyleFromScratch() throws Exception {
56:
57: Style style = demoBase.createLondonStyleFromScratch();
58: assertNotNull(style);
59: assertEquals(1, style.getFeatureTypeStyles().length);
60:
61: }
62:
63: public void testCreateStyleFromFile() throws Exception {
64:
65: Style style = demoBase
66: .createShapefileStyleFromSLDFile(demoBase.SHAPEFILESLDNAME);
67: assertNotNull(style);
68: assertEquals(1, style.getFeatureTypeStyles().length);
69: }
70:
71: }
|