@Test public void testCASUpdateWithNullInitialNoExistingVal() throws Throwable { assertNull(client.get("x")); Long rv = mutator.cas("x", (Long) null, 0, mutation); assertNull(rv); assertNull(client.get("x")); }
@Test public void testIncorrectTypeInCAS() throws Throwable { // Stick something for this CAS in the cache. client.set("x", 0, "not a long"); try { Long rv = mutator.cas("x", 1L, 0, mutation); fail("Expected RuntimeException on invalid type mutation, got " + rv); } catch (RuntimeException e) { assertEquals("Couldn't get a CAS in 50 attempts", e.getMessage()); } }
@Test public void testCASUpdateWithNullInitial() throws Throwable { client.set("x", 0, 1L); Long rv = mutator.cas("x", (Long) null, 0, mutation); assertEquals(rv, (Long) 2L); }