@Test
 public void testIterator() throws CacheAccessException {
   store.put(KEY, VALUE);
   Store.Iterator<Cache.Entry<Long, Store.ValueHolder<Value>>> iterator = store.iterator();
   assertThat(iterator.hasNext(), is(true));
   while (iterator.hasNext()) {
     Cache.Entry<Long, Store.ValueHolder<Value>> entry = iterator.next();
     compareValues(entry.getValue().value(), VALUE);
   }
 }
예제 #2
0
  @Test
  public void testKeyUniqueObject() throws Exception {
    OnHeapStore<Serializable, Serializable> store = newStore();

    List<String> key = new ArrayList<String>();
    key.add("key");
    String value = "value";

    store.put((Serializable) key, value);

    // mutate the key -- should not affect cache
    key.clear();

    Serializable storeKey = store.iterator().next().getKey();
    if (storeKey == key || !storeKey.equals(Collections.singletonList("key"))) {
      throw new AssertionError();
    }
  }