KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sleepycat > je > recovery > LevelRecorderTest


1 /*-
2  * See the file LICENSE for redistribution information.
3  *
4  * Copyright (c) 2004,2006 Oracle. All rights reserved.
5  *
6  * $Id: LevelRecorderTest.java,v 1.3 2006/10/30 21:14:48 bostic Exp $
7  */

8
9 package com.sleepycat.je.recovery;
10
11 import java.util.Set JavaDoc;
12
13 import junit.framework.TestCase;
14
15 import com.sleepycat.je.dbi.DatabaseId;
16 import com.sleepycat.je.tree.IN;
17
18 public class LevelRecorderTest extends TestCase {
19
20     public LevelRecorderTest() {
21     }
22
23     public void testRecording () {
24         LevelRecorder recorder = new LevelRecorder();
25
26         DatabaseId id1 = new DatabaseId(1);
27         DatabaseId id5 = new DatabaseId(5);
28         DatabaseId id10 = new DatabaseId(10);
29
30         int level1 = IN.BIN_LEVEL;
31         int level2 = level1 + 1;
32         int level3 = level1 + 2;
33         int level4 = level1 + 3;
34
35         /* Mimic the recording of various INs for various databases. */
36         recorder.record(id10, level1);
37         recorder.record(id5, level3);
38         recorder.record(id5, level2);
39         recorder.record(id10, level1);
40         recorder.record(id1, level1);
41         recorder.record(id10, level1);
42         recorder.record(id1, level4);
43
44         /*
45          * We should only have to redo recovery for dbs 1 and 5. Db 10 had
46          * INs all of the same level.
47          */

48         Set JavaDoc reprocessSet = recorder.getDbsWithDifferentLevels();
49         assertEquals(2, reprocessSet.size());
50         assertTrue(reprocessSet.contains(id5));
51         assertTrue(reprocessSet.contains(id1));
52         assertFalse(reprocessSet.contains(id10));
53     }
54 }
55
Popular Tags