예제 #1
0
 @Test
 public void testContainsKey() throws Exception {
   assertThat(store.containsKey(1L), is(false));
   store.put(1L, "one");
   assertThat(store.containsKey(1L), is(true));
   validateStat(store, StoreOperationOutcomes.GetOutcome.HIT, 0);
   validateStat(store, StoreOperationOutcomes.GetOutcome.MISS, 0);
 }
예제 #2
0
  @Test
  public void testClear() throws Exception {
    assertThat(store.containsKey(1L), is(false));
    store.clear();
    assertThat(store.containsKey(1L), is(false));

    store.put(1L, "one");
    store.put(2L, "two");
    store.put(3L, "three");
    assertThat(store.containsKey(1L), is(true));

    store.clear();

    assertThat(store.containsKey(1L), is(false));
    assertThat(store.containsKey(2L), is(false));
    assertThat(store.containsKey(3L), is(false));
  }
예제 #3
0
 @Test(expected = StoreAccessException.class)
 public void testContainsKeyThrowsOnlySAE() throws Exception {
   OperationsCodec<Long, String> codec = mock(OperationsCodec.class);
   ChainResolver chainResolver = mock(ChainResolver.class);
   ServerStoreProxy serverStoreProxy = mock(ServerStoreProxy.class);
   when(serverStoreProxy.get(anyLong())).thenThrow(new RuntimeException());
   TestTimeSource testTimeSource = mock(TestTimeSource.class);
   ClusteredStore<Long, String> store =
       new ClusteredStore<Long, String>(codec, chainResolver, serverStoreProxy, testTimeSource);
   store.containsKey(1L);
 }
예제 #4
0
 @Test
 public void testRemove() throws Exception {
   assertThat(store.remove(1L), is(false));
   validateStats(store, EnumSet.of(StoreOperationOutcomes.RemoveOutcome.MISS));
   store.put(1L, "one");
   assertThat(store.remove(1L), is(true));
   assertThat(store.containsKey(1L), is(false));
   validateStats(
       store,
       EnumSet.of(
           StoreOperationOutcomes.RemoveOutcome.MISS,
           StoreOperationOutcomes.RemoveOutcome.REMOVED));
 }