Set up initial resources for each unit test.
()
| 28 | * Set up initial resources for each unit test. |
| 29 | */ |
| 30 | @Before public void setUp() throws Exception { |
| 31 | super.setUp(); |
| 32 | |
| 33 | // clear all state from the buffer pool |
| 34 | bp = Database.resetBufferPool(BufferPool.DEFAULT_PAGES); |
| 35 | |
| 36 | // create a new empty HeapFile and populate it with three pages. |
| 37 | // we should be able to add 504 tuples on an empty page. |
| 38 | TransactionId tid = new TransactionId(); |
| 39 | for (int i = 0; i < 1025; ++i) { |
| 40 | empty.insertTuple(tid, Utility.getHeapTuple(i, 2)); |
| 41 | } |
| 42 | |
| 43 | // if this fails, complain to the TA |
| 44 | assertEquals(3, empty.numPages()); |
| 45 | |
| 46 | this.p0 = new HeapPageId(empty.getId(), 0); |
| 47 | this.p1 = new HeapPageId(empty.getId(), 1); |
| 48 | PageId p2 = new HeapPageId(empty.getId(), 2); |
| 49 | this.tid1 = new TransactionId(); |
| 50 | this.tid2 = new TransactionId(); |
| 51 | |
| 52 | // forget about locks associated to tid, so they don't conflict with |
| 53 | // test cases |
| 54 | bp.getPage(tid, p0, Permissions.READ_WRITE).markDirty(true, tid); |
| 55 | bp.getPage(tid, p1, Permissions.READ_WRITE).markDirty(true, tid); |
| 56 | bp.getPage(tid, p2, Permissions.READ_WRITE).markDirty(true, tid); |
| 57 | bp.flushAllPages(); |
| 58 | bp = Database.resetBufferPool(BufferPool.DEFAULT_PAGES); |
| 59 | } |
| 60 | |
| 61 | /** |
| 62 | * Generic unit test structure for BufferPool.getPage() assuming locking. |
nothing calls this directly
no test coverage detected