1 8 9 package com.sleepycat.je.dbi; 10 11 import java.util.Enumeration ; 12 import java.util.Hashtable ; 13 14 import com.sleepycat.je.DatabaseException; 15 import com.sleepycat.je.DbTestProxy; 16 import com.sleepycat.je.tree.BIN; 17 import com.sleepycat.je.tree.DBIN; 18 19 public class DbCursorDuplicateValidationTest extends DbCursorTestBase { 20 21 public DbCursorDuplicateValidationTest() 22 throws DatabaseException { 23 24 super(); 25 } 26 27 public void testValidateCursors() 28 throws Throwable { 29 30 initEnv(true); 31 Hashtable dataMap = new Hashtable (); 32 createRandomDuplicateData(10, 1000, dataMap, false, false); 33 34 Hashtable bins = new Hashtable (); 35 36 DataWalker dw = new DataWalker(bins) { 37 void perData(String foundKey, String foundData) 38 throws DatabaseException { 39 CursorImpl cursorImpl = DbTestProxy.dbcGetCursorImpl(cursor); 40 BIN lastBin = cursorImpl.getBIN(); 41 DBIN lastDupBin = cursorImpl.getDupBIN(); 42 if (rnd.nextInt(10) < 8) { 43 cursor.delete(); 44 } 45 dataMap.put(lastBin, lastBin); 46 dataMap.put(lastDupBin, lastDupBin); 47 } 48 }; 49 dw.setIgnoreDataMap(true); 50 dw.walkData(); 51 dw.close(); 52 Enumeration e = bins.keys(); 53 while (e.hasMoreElements()) { 54 BIN b = (BIN) e.nextElement(); 55 assertFalse(b.getCursorSet().size() > 0); 56 } 57 } 58 } 59 | Popular Tags |