| 82 | } |
| 83 | |
| 84 | @Test |
| 85 | public void testIteratorBasic() throws Exception { |
| 86 | HeapFile smallFile = SystemTestUtil.createRandomHeapFile(2, 3, null, |
| 87 | null); |
| 88 | |
| 89 | DbFileIterator it = smallFile.iterator(tid); |
| 90 | // Not open yet |
| 91 | assertFalse(it.hasNext()); |
| 92 | try { |
| 93 | it.next(); |
| 94 | fail("expected exception"); |
| 95 | } catch (NoSuchElementException ignored) { |
| 96 | } |
| 97 | |
| 98 | it.open(); |
| 99 | int count = 0; |
| 100 | while (it.hasNext()) { |
| 101 | assertNotNull(it.next()); |
| 102 | count += 1; |
| 103 | } |
| 104 | assertEquals(3, count); |
| 105 | it.close(); |
| 106 | } |
| 107 | |
| 108 | @Test |
| 109 | public void testIteratorClose() throws Exception { |