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.gml;
18:
19: import java.util.HashMap;
20: import java.util.Map;
21:
22: /**
23: * Tests that the GMLDatastoreFactory will correctly create {@link
24: * GMLDataStore} and {@link FileGMLDataStore} objects
25: *
26: * @author Jesse
27: */
28: public class GMLDataStoreFactoryTest extends AbstractGMLTestCase {
29: private GMLDataStoreFactory factory;
30:
31: protected void setUp() throws Exception {
32: super .setUp();
33: factory = new GMLDataStoreFactory();
34: }
35:
36: /**
37: * Test method for {@link
38: * org.geotools.data.gml.GMLDataStoreFactory#createDataStore(java.util.Map)}.
39: *
40: * @throws Exception DOCUMENT ME!
41: */
42: public void testCreateDataStoreMapFile() throws Exception {
43: Map params = new HashMap();
44: params.put(GMLDataStoreFactory.URLP.key, gmlFile.toURL());
45:
46: FileGMLDataStore ds = (FileGMLDataStore) factory
47: .createDataStore(params);
48: assertEquals(1, ds.getTypeNames().length);
49: assertSame(ds, factory.createDataStore(params));
50: }
51:
52: public void testCreateDataStoreMapDirectory() throws Exception {
53: Map params = new HashMap();
54: params.put(GMLDataStoreFactory.URLP.key, gmlFile
55: .getParentFile().toURL());
56:
57: GMLDataStore ds = (GMLDataStore) factory
58: .createDataStore(params);
59: assertEquals(1, ds.getTypeNames().length);
60: assertSame(ds, factory.createDataStore(params));
61: }
62:
63: /**
64: * Test method for {@link
65: * org.geotools.data.gml.GMLDataStoreFactory#createNewDataStore(java.util.Map)}.
66: *
67: * @throws Exception DOCUMENT ME!
68: */
69: public void testCreateNewDataStoreFile() throws Exception {
70: Map params = new HashMap();
71: params.put(GMLDataStoreFactory.URLP.key, gmlFile.toURL());
72:
73: FileGMLDataStore ds = (FileGMLDataStore) factory
74: .createNewDataStore(params);
75: assertEquals(1, ds.getTypeNames().length);
76: assertNotSame(ds, factory.createNewDataStore(params));
77: }
78:
79: public void testCreateNewDataStoreDirectory() throws Exception {
80: Map params = new HashMap();
81: params.put(GMLDataStoreFactory.URLP.key, gmlFile
82: .getParentFile().toURL());
83:
84: GMLDataStore ds = (GMLDataStore) factory
85: .createNewDataStore(params);
86: assertEquals(1, ds.getTypeNames().length);
87: assertNotSame(ds, factory.createNewDataStore(params));
88: }
89: }
|