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