01: /*
02: * Geotools2 - OpenSource mapping toolkit
03: * http://geotools.org
04: * (C) 2002, Geotools Project Managment Committee (PMC)
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation;
09: * version 2.1 of the License.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: *
16: */
17: package org.geotools.data.geometryless;
18:
19: /*
20: * GmlSuite.java
21: * JUnit based test
22: *
23: * Created on 04 March 2002, 16:09
24: */
25: import java.util.Iterator;
26:
27: import junit.framework.Test;
28: import junit.framework.TestCase;
29: import junit.framework.TestSuite;
30:
31: import org.geotools.data.DataStoreFactorySpi;
32: import org.geotools.data.DataStoreFinder;
33:
34: /**
35: *
36: * @author ian
37: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/unsupported/geometryless/src/test/java/org/geotools/data/geometryless/ServiceTest.java $
38: */
39: public class ServiceTest extends TestCase {
40:
41: final String TEST_FILE = "statepop.shp";
42:
43: public ServiceTest(java.lang.String testName) {
44: super (testName);
45: }
46:
47: public static void main(java.lang.String[] args) {
48: junit.textui.TestRunner.run(suite(ServiceTest.class));
49: }
50:
51: public static Test suite(Class c) {
52: return new TestSuite(c);
53: }
54:
55: /**
56: * Make sure that the loading mechanism is working properly.
57: */
58: public void testIsAvailable() {
59: Iterator list = DataStoreFinder.getAvailableDataStores();
60: boolean found = false;
61: while (list.hasNext()) {
62: DataStoreFactorySpi fac = (DataStoreFactorySpi) list.next();
63: if (fac instanceof JDBCDataStoreFactory) {
64: found = true;
65: assertNotNull(fac.getDescription());
66: break;
67: }
68: }
69: assertTrue("JDBCDataSourceFactory not registered", found);
70: }
71:
72: /**
73: * Ensure that we can create a DataStore using url OR string url.
74:
75: public void testShapefileDataStore() throws Exception{
76: HashMap params = new HashMap();
77: params.put("url", getTestResource(TEST_FILE));
78: DataStore ds = DataStoreFinder.getDataStore(params);
79: assertNotNull(ds);
80: params.put("url", getTestResource(TEST_FILE).toString());
81: assertNotNull(ds);
82: }
83:
84: public void testBadURL() {
85: HashMap params = new HashMap();
86: params.put("url","aaa://bbb.ccc");
87: try {
88: ShapefileDataStoreFactory f = new ShapefileDataStoreFactory();
89: f.createDataStore(params);
90: fail("did not throw error");
91: } catch (java.io.IOException ioe) {
92: // this is actually good
93: }
94:
95: }
96: */
97: }
|