Created
January 12, 2015 20:36
-
-
Save pandey-adarsh147/2be5e25dc6d03bb13274 to your computer and use it in GitHub Desktop.
LRU unit test cases
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.verctordirection.test; | |
import com.vectordirection.LRUCache; | |
import org.junit.Test; | |
/** | |
* Created by adarshpandey on 1/13/15. | |
*/ | |
public class CachingTest { | |
@Test | |
public void testLRU() { | |
System.out.println("========================================="); | |
System.out.println("*********** Caching Test Start **********"); | |
System.out.println("========================================="); | |
LRUCache<Integer, Store> storeLRUCache = new LRUCache<>(3); | |
storeLRUCache.add(new Store(1, 22)); | |
storeLRUCache.add(new Store(2, 23)); | |
storeLRUCache.add(new Store(3, 27)); | |
storeLRUCache.add(new Store(4, 29)); | |
storeLRUCache.add(new Store(5, 28)); | |
storeLRUCache.add(new Store(6, 21)); | |
storeLRUCache.add(new Store(7, 24)); | |
try { | |
Thread.sleep(10); | |
} catch (InterruptedException e) { | |
e.printStackTrace(); | |
} | |
assert storeLRUCache.size() == 3; | |
assert storeLRUCache.getValue(1) == null; | |
assert storeLRUCache.getValue(7).getValue() == 24; | |
storeLRUCache.shutdown(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment