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.index.rtree.memory;
17:
18: import junit.framework.TestCase;
19: import org.geotools.index.DataDefinition;
20: import org.geotools.index.TreeException;
21: import org.geotools.index.rtree.PageStore;
22:
23: /**
24: * DOCUMENT ME!
25: *
26: * @author Tommaso Nolli
27: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/plugin/shapefile/src/test/java/org/geotools/index/rtree/memory/MemoryPageStoreTest.java $
28: */
29: public class MemoryPageStoreTest extends TestCase {
30: /**
31: * Constructor for MemoryPageStoreTest.
32: *
33: * @param arg0
34: */
35: public MemoryPageStoreTest(String arg0) {
36: super (arg0);
37: }
38:
39: /*
40: * Test for void MemoryPageStoreTest(DataDefinition)
41: */
42: public void testMemoryPageStoreTestDataDefinition()
43: throws Exception {
44: DataDefinition dd = new DataDefinition("US-ASCII");
45:
46: try {
47: MemoryPageStore ps = new MemoryPageStore(dd);
48: fail("Cannot use an empty DataDefinition");
49: } catch (TreeException e) {
50: // OK
51: }
52:
53: dd.addField(Integer.class);
54:
55: MemoryPageStore ps = new MemoryPageStore(dd);
56: ps.close();
57: }
58:
59: /*
60: * Test for void MemoryPageStore(DataDefinition, int, int, short)
61: */
62: public void testMemoryPageStoreDataDefinitionintintshort()
63: throws Exception {
64: DataDefinition dd = new DataDefinition("US-ASCII");
65: dd.addField(Integer.class);
66:
67: MemoryPageStore ps = null;
68:
69: try {
70: ps = new MemoryPageStore(dd, 10, 10,
71: PageStore.SPLIT_QUADRATIC);
72: fail("MinNodeEntries must be <= MaxNodeEntries / 2");
73: } catch (TreeException e) {
74: // OK
75: }
76:
77: try {
78: ps = new MemoryPageStore(dd, 10, 5, (short) 1000);
79: fail("SplitAlgorithm not supported");
80: } catch (TreeException e) {
81: // OK
82: }
83:
84: ps = new MemoryPageStore(dd, 50, 25, PageStore.SPLIT_QUADRATIC);
85: ps.close();
86: }
87: }
|