/** * Resets the file. * <p> * @throws IOException */ protected synchronized void reset() throws IOException { this.numberOfBlocks.set(0); this.emptyBlocks.clear(); fc.truncate(0); fc.force(true); }
/** * Verify that after calling clear all items are removed adn the size is 0. */ public void testAddABunchAndClear() { // SETUP SingleLinkedList<Integer> list = new SingleLinkedList<Integer>(); // DO WORK int numToPut = 100; for ( int i = 0; i < numToPut; i++ ) { list.addLast( Integer.valueOf( i ) ); } // VERIFY assertEquals( "Wrong number in list.", numToPut, list.size() ); // DO WORK list.clear(); Integer result = list.takeFirst(); // VERIFY assertEquals( "Wrong number in list.", 0, list.size() ); assertNull( "Shouldn't have anything left.", result ); } }