Пример #1
0
  /** Test for method {@link IndexCache#delete(byte[])}. */
  @Test
  public void testDelete() {
    final byte[] key = token("keyDelete");
    final int size = 10;
    final long pointer = 12L;

    cache.add(key, size, pointer);
    cache.delete(key);

    assertNull(cache.get(key));
  }
Пример #2
0
  /** Test for method {@link IndexCache#get(byte[])}. */
  @Test
  public void testGetNotExisting() {
    for (int i = 0; i < 4000; ++i) {
      final byte[] key = token("keyAdd" + i);
      final long pointer = i + 5000L;

      cache.add(key, i, pointer);
      assertCacheEntry(key, i, pointer);
    }
    assertNull(cache.get(token("keyAdd" + 4000)));
  }
Пример #3
0
 /**
  * Assert a cache entry is found in the cache.
  *
  * @param key key
  * @param size number of index hits
  * @param pointer pointer to id list
  */
 private void assertCacheEntry(final byte[] key, final int size, final long pointer) {
   final IndexEntry entry = cache.get(key);
   assertEquals(entry.size, size);
   assertEquals(entry.offset, pointer);
 }