if ( obj instanceof LRUTestEntry ) { LRUTestEntry le = (LRUTestEntry) obj; le.setEvicted(); } else { assertTrue( "found wrong type: " + obj.getClass().getName(), false );
clock.appendEntry( nodes[i] ); if ( i % 2 == 0 ) { nodes[i].setRecentlyUsed(); assertTrue( "expected nodes[" + nodes[i].id() + "], found nodes[" + n.id() + "]", n == nodes[i] ); assertTrue( "expected nodes[" + nodes[i].id() + "], found nodes[" + n.id() + "]", n == nodes[i] );
/** * A unit test for JUnit * * @exception Exception Description of the Exception */ public void testAddToClockFace() throws Exception { NewLRUClockHand clock = getAClockHand( getARegion(), new TestEnableLRU() ); // getLRUEntry( maxScan ) LRUTestEntry[] nodes = new LRUTestEntry[10]; int i = 0; for( i = 0; i < 10; i++ ) { nodes[i] = getANode( i ); clock.appendEntry( nodes[i] ); } // getLRUEntry until empty... verify order of results. for( i = 0; i < 10; i++ ) { LRUTestEntry n = (LRUTestEntry) clock.getLRUEntry( ); assertTrue( "expected nodes[" + nodes[i].id() + "], found nodes[" + n.id() + "]", n == nodes[i] ); } assertTrue( "expected null", clock.getLRUEntry( ) == null ); }
public void testRemoveMiddle() throws Exception { NewLRUClockHand clock = getAClockHand( getARegion(), new TestEnableLRU() ); LRUTestEntry[] nodes = new LRUTestEntry[10]; int i = 0; for( i = 0; i < 10; i++ ) { nodes[i] = getANode( i ); clock.appendEntry( nodes[i] ); } clock.unlinkEntry(nodes[5]); for( i = 0; i < 5; i ++ ) { LRUTestEntry n = (LRUTestEntry) clock.getLRUEntry( ); assertTrue( "expected nodes[" + nodes[i].id() + "], found nodes[" + n.id() + "]", n == nodes[i] ); } for( i = 6; i < 10; i ++ ) { LRUTestEntry n = (LRUTestEntry) clock.getLRUEntry( ); assertTrue( "expected nodes[" + nodes[i].id() + "], found nodes[" + n.id() + "]", n == nodes[i] ); } assertEquals(null, clock.getLRUEntry( )); }
public void testEvicted() throws Exception { NewLRUClockHand clock = getAClockHand( getARegion(), new TestEnableLRU() ); // getLRUEntry( maxScan ) LRUTestEntry[] nodes = new LRUTestEntry[10]; int i = 0; for( i = 0; i < 10; i++ ) { nodes[i] = getANode( i ); clock.appendEntry( nodes[i] ); } for( i = 0; i < 10; i += 2 ) { clock.unlinkEntry( nodes[i] ); } // getLRUEntry until empty... verify order of results. for( i = 1; i < 10; i += 2 ) { LRUTestEntry n = (LRUTestEntry) clock.getLRUEntry( ); assertTrue( "expected nodes[" + nodes[i].id() + "], found nodes[" + n.id() + "]", n == nodes[i] ); } assertTrue( "expected null", clock.getLRUEntry( ) == null ); }
public void testRemoveTail() throws Exception { NewLRUClockHand clock = getAClockHand( getARegion(), new TestEnableLRU() ); LRUTestEntry[] nodes = new LRUTestEntry[10]; int i = 0; for( i = 0; i < 10; i++ ) { nodes[i] = getANode( i ); clock.appendEntry( nodes[i] ); } clock.unlinkEntry(nodes[9]); for( i = 0; i < 9; i ++ ) { LRUTestEntry n = (LRUTestEntry) clock.getLRUEntry( ); assertTrue( "expected nodes[" + nodes[i].id() + "], found nodes[" + n.id() + "]", n == nodes[i] ); } assertEquals(null, clock.getLRUEntry( )); }
public void testRemoveHead() throws Exception { NewLRUClockHand clock = getAClockHand( getARegion(), new TestEnableLRU() ); LRUTestEntry[] nodes = new LRUTestEntry[10]; int i = 0; for( i = 0; i < 10; i++ ) { nodes[i] = getANode( i ); clock.appendEntry( nodes[i] ); } clock.unlinkEntry(nodes[0]); for( i = 1; i < 10; i ++ ) { LRUTestEntry n = (LRUTestEntry) clock.getLRUEntry( ); assertTrue( "expected nodes[" + nodes[i].id() + "], found nodes[" + n.id() + "]", n == nodes[i] ); } assertEquals(null, clock.getLRUEntry( )); }