Пример #1
0
 @Test
 public void testPutIfAbsent() throws Exception {
   assertThat(store.putIfAbsent(1L, "one"), nullValue());
   validateStats(store, EnumSet.of(StoreOperationOutcomes.PutIfAbsentOutcome.PUT));
   assertThat(store.putIfAbsent(1L, "another one").value(), is("one"));
   validateStats(
       store,
       EnumSet.of(
           StoreOperationOutcomes.PutIfAbsentOutcome.PUT,
           StoreOperationOutcomes.PutIfAbsentOutcome.HIT));
 }
Пример #2
0
 @Test(expected = StoreAccessException.class)
 public void testPutIfAbsentThrowsOnlySAE() 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.putIfAbsent(1L, "one");
 }