コード例 #1
0
 @Test
 public void testConditionalReplace() throws Exception {
   assertThat(store.replace(1L, "one", "another one"), is(Store.ReplaceStatus.MISS_NOT_PRESENT));
   validateStats(store, EnumSet.of(StoreOperationOutcomes.ConditionalReplaceOutcome.MISS));
   store.put(1L, "some other one");
   assertThat(store.replace(1L, "one", "another one"), is(Store.ReplaceStatus.MISS_PRESENT));
   validateStat(store, StoreOperationOutcomes.ConditionalReplaceOutcome.MISS, 2);
   validateStat(store, StoreOperationOutcomes.ConditionalReplaceOutcome.REPLACED, 0);
   assertThat(store.replace(1L, "some other one", "another one"), is(Store.ReplaceStatus.HIT));
   validateStat(store, StoreOperationOutcomes.ConditionalReplaceOutcome.REPLACED, 1);
   validateStat(store, StoreOperationOutcomes.ConditionalReplaceOutcome.MISS, 2);
 }
コード例 #2
0
 @Test
 public void testReplace() throws Exception {
   assertThat(store.replace(1L, "one"), nullValue());
   validateStats(store, EnumSet.of(StoreOperationOutcomes.ReplaceOutcome.MISS));
   store.put(1L, "one");
   assertThat(store.replace(1L, "another one").value(), is("one"));
   validateStats(
       store,
       EnumSet.of(
           StoreOperationOutcomes.ReplaceOutcome.MISS,
           StoreOperationOutcomes.ReplaceOutcome.REPLACED));
 }
コード例 #3
0
 @Test(expected = StoreAccessException.class)
 public void testConditionalReplaceThrowsOnlySAE() 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.replace(1L, "one", "another one");
 }