01: /*
02: * GeoTools - OpenSource mapping toolkit
03: * http://geotools.org
04: * (C) 2002-2006, 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: package org.geotools.data.mysql;
17:
18: import java.io.IOException;
19: import java.nio.charset.Charset;
20: import java.util.HashMap;
21: import java.util.Map;
22: import java.util.Properties;
23: import java.util.PropertyResourceBundle;
24:
25: import junit.framework.Test;
26: import junit.framework.TestCase;
27: import junit.framework.TestSuite;
28:
29: import org.geotools.data.DataSourceException;
30: import org.geotools.data.DataStore;
31: import org.geotools.data.FeatureSource;
32: import org.geotools.data.DataStoreFactorySpi.Param;
33: import org.geotools.feature.FeatureType;
34:
35: /**
36: * Test Params used by PostgisDataStoreFactory.
37: *
38: * @author jgarnett, Refractions Research, Inc.
39: * @author $Author: aaime $ (last modification)
40: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/unsupported/mysql/src/test/java/org/geotools/data/mysql/MySQLDataStoreFactoryTest.java $
41: * @version $Id: MySQLDataStoreFactoryTest.java 26511 2007-08-10 07:21:13Z aaime $
42: */
43: public class MySQLDataStoreFactoryTest extends TestCase {
44: static MySQLDataStoreFactory factory = new MySQLDataStoreFactory();
45:
46: Map local;
47:
48: public static void main(String[] args) {
49: junit.textui.TestRunner.run(suite());
50: }
51:
52: public static Test suite() {
53: TestSuite suite = new TestSuite(MySQLDataStoreFactoryTest.class);
54: return suite;
55: }
56:
57: /*
58: * @see TestCase#setUp()
59: */
60: protected void setUp() throws Exception {
61:
62: Properties resource = new Properties();
63: resource.load(this .getClass().getResourceAsStream(
64: "fixture.properties"));
65: this .local = resource;
66: }
67:
68: public void testLocal() throws Exception {
69: assertTrue("canProcess", factory.canProcess(local));
70: try {
71: DataStore temp = factory.createDataStore(local);
72: assertNotNull("created", temp);
73: } catch (DataSourceException expected) {
74: expected.printStackTrace();
75: assertEquals("Could not get connection", expected
76: .getMessage());
77: }
78: }
79:
80: public void testNamespace() throws Exception {
81: DataStore ds = factory.createDataStore(local);
82: FeatureType ft = ds.getSchema("road");
83: assertEquals(local.get("namespace"), ft.getNamespace()
84: .toString());
85: }
86: }
|