1 package org.melati.poem.test;
2
3 import java.util.NoSuchElementException;
4
5 import org.melati.poem.Setting;
6 import org.melati.poem.TableMap;
7 import org.melati.poem.TableSortedMap;
8
9
10
11
12
13
14 public class TableSortedMapTest extends TableMapTest {
15 private TableSortedMap<org.melati.poem.User> it;
16 private TableSortedMap<Setting> noArg;
17
18 public TableSortedMapTest(String name) {
19 super(name);
20 }
21
22 protected void setUp() throws Exception {
23 super.setUp();
24 }
25
26 protected void createObjectsUnderTest() {
27 it = new TableSortedMap<org.melati.poem.User>(getDb().getUserTable());
28 noArg = new TableSortedMap<Setting>();
29 }
30 protected TableMap<org.melati.poem.User> getObjectUnderTest() {
31 return it;
32 }
33 protected TableMap<Setting> getNoArgObjectUnderTest() {
34 return noArg;
35 }
36
37
38
39
40
41 protected void tearDown() throws Exception {
42 super.tearDown();
43 }
44
45
46
47
48 public void testTableSortedMap() {
49
50 }
51
52
53
54
55 public void testTableSortedMapTable() {
56
57 }
58
59
60
61
62 public void testComparator() {
63 assertNull(it.comparator());
64 assertNull(noArg.comparator());
65 }
66
67
68
69
70 public void testFirstKey() {
71 assertEquals(new Integer(0), it.firstKey());
72 noArg.setTable(getDb().getSettingTable());
73 try {
74 noArg.firstKey();
75 fail("Should have bombed.");
76 } catch (NoSuchElementException e) {
77 e = null;
78 }
79 Setting s1 = getDb().getSettingTable().ensure("s1", "s1", "S1", "test setting S1");
80 Integer troid = it.firstKey();
81 Setting s2 = getDb().getSettingTable().ensure("s2", "s2", "S2", "test setting S2");
82 s1.delete();
83 assertEquals(new Integer(troid.intValue()), it.firstKey());
84 s2.delete();
85 try {
86 noArg.firstKey();
87 fail("Should have bombed");
88 } catch (NoSuchElementException e) {
89 e = null;
90 }
91 }
92
93
94
95
96 public void testLastKey() {
97 assertEquals(new Integer(1), it.lastKey());
98 noArg.setTable(getDb().getSettingTable());
99 try {
100 noArg.lastKey();
101 fail("Should have bombed.");
102 } catch (NoSuchElementException e) {
103 e = null;
104 }
105 try {
106 noArg.lastKey();
107 fail("Should have bombed");
108 } catch (NoSuchElementException e) {
109 e = null;
110 }
111 }
112
113
114
115
116 public void testSubMap() {
117 try {
118 it.subMap(new Integer(0),new Integer(1));
119 fail("Should have bombed");
120 } catch (UnsupportedOperationException e) {
121 e = null;
122 }
123 }
124
125
126
127
128 public void testHeadMap() {
129 try {
130 it.headMap(new Integer(1));
131 fail("Should have bombed");
132 } catch (UnsupportedOperationException e) {
133 e = null;
134 }
135 }
136
137
138
139
140 public void testTailMap() {
141 try {
142 it.tailMap(new Integer(1));
143 fail("Should have bombed");
144 } catch (UnsupportedOperationException e) {
145 e = null;
146 }
147 }
148
149 }