| 106 | } |
| 107 | |
| 108 | @Test |
| 109 | public void testIteratorClose() throws Exception { |
| 110 | // make more than 1 page. Previous closed iterator would start fetching |
| 111 | // from page 1. |
| 112 | HeapFile twoPageFile = SystemTestUtil.createRandomHeapFile(2, 520, |
| 113 | null, null); |
| 114 | |
| 115 | DbFileIterator it = twoPageFile.iterator(tid); |
| 116 | it.open(); |
| 117 | assertTrue(it.hasNext()); |
| 118 | it.close(); |
| 119 | try { |
| 120 | it.next(); |
| 121 | fail("expected exception"); |
| 122 | } catch (NoSuchElementException ignored) { |
| 123 | } |
| 124 | // close twice is harmless |
| 125 | it.close(); |
| 126 | } |
| 127 | |
| 128 | /** |
| 129 | * JUnit suite target |