コード例 #1
0
  @Test
  @ClientCompatibleTest
  public void apply() {
    HazelcastInstance hazelcastInstance = createHazelcastInstance();
    IAtomicReference<String> ref = hazelcastInstance.getAtomicReference("apply");

    assertEquals("null", ref.apply(new AppendFunction("")));
    assertEquals(null, ref.get());

    ref.set("foo");
    assertEquals("foobar", ref.apply(new AppendFunction("bar")));
    assertEquals("foo", ref.get());

    assertEquals(null, ref.apply(new NullFunction()));
    assertEquals("foo", ref.get());
  }
コード例 #2
0
  @Test(expected = IllegalArgumentException.class)
  @ClientCompatibleTest
  public void apply_whenCalledWithNullFunction() {
    HazelcastInstance hazelcastInstance = createHazelcastInstance();
    IAtomicReference<String> ref =
        hazelcastInstance.getAtomicReference("apply_whenCalledWithNullFunction");

    ref.apply(null);
  }
コード例 #3
0
  @Test
  @ClientCompatibleTest
  public void apply_whenException() {
    HazelcastInstance hazelcastInstance = createHazelcastInstance();
    IAtomicReference<String> ref = hazelcastInstance.getAtomicReference("apply");
    ref.set("foo");

    try {
      ref.apply(new FailingFunction());
      fail();
    } catch (WoohaaException expected) {
    }

    assertEquals("foo", ref.get());
  }