From: <tr...@hy...> - 2009-12-15 17:44:47
|
Author: trader Date: 2009-12-15 09:44:35 -0800 (Tue, 15 Dec 2009) New Revision: 14092 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=14092 Modified: trunk/unittest/src/org/hyperic/util/file/DiskListTest.java Log: Added one unittest Modified: trunk/unittest/src/org/hyperic/util/file/DiskListTest.java =================================================================== --- trunk/unittest/src/org/hyperic/util/file/DiskListTest.java 2009-12-15 08:52:17 UTC (rev 14091) +++ trunk/unittest/src/org/hyperic/util/file/DiskListTest.java 2009-12-15 17:44:35 UTC (rev 14092) @@ -104,6 +104,56 @@ } } + public void testFillAndReopen() throws Exception { + + DiskListDataHolder holder = null; + + try { + + try { + holder = new DiskListDataHolder(); + } catch (Exception e) { + e.printStackTrace(); + fail(e.toString()); + } + + String toPut = String.valueOf("dummystring"); + + // Insert until we *almost* spill over + long nRecs = 0; + while (holder.list.dataFile.length() < MAXSIZE) { + holder.list.addToList(toPut); + nRecs++; + } + + holder.list.close(); + + // Check that we can read the proper number after close/reopen, and that they can be cleanly deleted + holder.list = new DiskList(holder.dataFile, + RECSIZE, + CHKSIZE, + CHKPERC, + MAXSIZE); + + assertTrue(holder.list.freeList.size() == 0); + + Iterator it = holder.list.getListIterator(); + long nIterated = 0; + while (it.hasNext()) { + it.next(); + nIterated++; + } + + assertTrue("Expected " + nRecs + " records, got " + nIterated, + nIterated == nRecs); + + } finally { + + holder.dispose(); + + } + } + public void testFreeListWithInsertsAndNoDeletes() throws Exception { DiskListDataHolder holder = null; |