01: /*
02: * GeoTools - OpenSource mapping toolkit
03: * http://geotools.org
04: * (C) 2003-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; either
09: * version 2.1 of the License, or (at your option) any later version.
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: * Created on May 20, 2003, 11:26 AM
17: */
18: package org.geotools.feature;
19:
20: import junit.framework.Test;
21: import junit.framework.TestCase;
22: import junit.framework.TestSuite;
23:
24: /**
25: *
26: * @author jamesm
27: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/main/src/test/java/org/geotools/feature/FlatFeatureFactorySpiTest.java $
28: */
29: public class FlatFeatureFactorySpiTest extends TestCase {
30:
31: public FlatFeatureFactorySpiTest(java.lang.String testName) {
32: super (testName);
33: }
34:
35: public static Test suite() {
36: TestSuite suite = new TestSuite(FlatFeatureFactorySpiTest.class);
37: return suite;
38: }
39:
40: public void testObtainFactory() {
41: FeatureTypeFactory factory = FeatureTypeFactory
42: .newInstance("test");
43: assertNotNull(factory);
44: }
45:
46: public void testDefaultFactory() {
47: FeatureTypeFactory factory = FeatureTypeFactory
48: .newInstance("test");
49: AttributeType a1 = AttributeTypeFactory.newAttributeType("X",
50: Integer.class);
51: AttributeType a2 = AttributeTypeFactory.newAttributeType("Y",
52: Double.class);
53: factory.addType(0, a1);
54: assertEquals(a1, factory.get(factory.getAttributeCount() - 1));
55: factory.addType(1, a2);
56: assertEquals(a2, factory.get(factory.getAttributeCount() - 1));
57: factory.removeType(1);
58: factory.removeType(0);
59: assertEquals(factory.getAttributeCount(), 0);
60: factory.addType(a1);
61: factory.addType(a2);
62: factory.swap(0, 1);
63: assertEquals(a1, factory.get(1));
64: assertEquals(a2, factory.get(0));
65: factory.removeType(a1);
66: factory.removeType(a2);
67: assertEquals(factory.getAttributeCount(), 0);
68: }
69:
70: public static void main(String[] args) {
71: junit.textui.TestRunner.run(suite());
72: }
73:
74: }
|