@Override
 protected void tearDown() {
   try {
     _store.close();
     FileUtils.deleteDirectory(_homeDir);
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
  public void testKeyIndexedIterator() throws Exception {
    IndexedIterator<byte[]> keyIter;

    _store.clear();
    keyIter = _store.keyIterator();
    assertFalse(keyIter.hasNext());

    // Generate keys
    HashSet<String> keySet = new HashSet<String>(199);
    while (keySet.size() < 100) {
      keySet.add(UUID.randomUUID().toString());
    }
    assertEquals(100, keySet.size());

    // Populate store
    for (String key : keySet) {
      byte[] value = RandomBytes.getBytes();
      _store.put(key.getBytes(), value);
    }

    // Check keys
    keyIter = _store.keyIterator();
    byte[] key1a = keyIter.next();

    keyIter.reset(0);
    byte[] key1b = keyIter.next();

    for (int i = 0; i < 10; i++) {
      keyIter.next();
    }
    keyIter.reset(keyIter.index());
    byte[] key1c = keyIter.next();

    assertTrue(Arrays.equals(key1a, key1b));

    // Re-open store
    _store.close();
    _store.open();

    // check keys
    keyIter = _store.keyIterator();
    byte[] key2a = keyIter.next();

    keyIter.reset(0);
    byte[] key2b = keyIter.next();

    for (int i = 0; i < 10; i++) {
      keyIter.next();
    }
    keyIter.reset(keyIter.index());
    byte[] key2c = keyIter.next();

    assertTrue(Arrays.equals(key1a, key2a));
    assertTrue(Arrays.equals(key1b, key2b));
    assertTrue(Arrays.equals(key1c, key2c));
  }