@Test
  public void test() {

    // Test insertion order
    LRUCache<Integer, String> cache = new LRUCache<Integer, String>(10);
    int i;
    for (i = 0; i < keys.length; ++i) {
      cache.put(keys[i], values[i]);
    }

    i = 0;
    for (Iterator<Integer> iter = cache.keySet().iterator(); iter.hasNext();) {
      Integer key = iter.next();
      Assert.assertEquals(keys[i], key);
      ++i;
    }

    i = 0;
    for (Iterator<String> iter = cache.values().iterator(); iter.hasNext();) {
      String value = iter.next();
      Assert.assertEquals(values[i], value);
      ++i;
    }

    // Access in reverse order and check
    for (i = keys.length - 1; i >= 0; --i) {
      cache.get(keys[i]);
    }
    i = keys.length;
    for (Iterator<Integer> iter = cache.keySet().iterator(); iter.hasNext();) {
      --i;
      Integer key = iter.next();
      Assert.assertEquals(keys[i], key);
    }

    i = keys.length;
    for (Iterator<String> iter = cache.values().iterator(); iter.hasNext();) {
      --i;
      String value = iter.next();
      Assert.assertEquals(values[i], value);
    }

    // Access in forward order and check
    for (i = 0; i < keys.length; ++i) {
      cache.get(keys[i]);
    }
    i = 0;
    for (Iterator<Integer> iter = cache.keySet().iterator(); iter.hasNext();) {
      Integer key = iter.next();
      Assert.assertEquals(keys[i], key);
      ++i;
    }

    i = 0;
    for (Iterator<String> iter = cache.values().iterator(); iter.hasNext();) {
      String value = iter.next();
      Assert.assertEquals(values[i], value);
      ++i;
    }
  }