use of com.hazelcast.core.IAtomicLong in project hazelcast by hazelcast.
the class ClientAtomicLongTest method alterAndGetAsync_whenException.
@Test
public void alterAndGetAsync_whenException() {
IAtomicLong ref = client.getAtomicLong("alterAndGetAsync_whenException");
ref.set(10);
try {
ICompletableFuture<Long> future = ref.alterAndGetAsync(new FailingFunction());
future.get();
} catch (InterruptedException e) {
fail();
} catch (ExecutionException e) {
assertEquals(e.getCause().getClass(), UndefinedErrorCodeException.class);
assertEquals(((UndefinedErrorCodeException) e.getCause()).getOriginClassName(), ExpectedRuntimeException.class.getName());
}
assertEquals(10, ref.get());
}
use of com.hazelcast.core.IAtomicLong in project hazelcast by hazelcast.
the class ClientAtomicLongTest method getAndAlter.
@Test
public void getAndAlter() {
IAtomicLong ref = client.getAtomicLong("getAndAlter");
ref.set(10);
assertEquals(10, ref.getAndAlter(new AddOneFunction()));
assertEquals(11, ref.get());
}
use of com.hazelcast.core.IAtomicLong in project hazelcast by hazelcast.
the class ClientAtomicLongTest method getAndAlterAsync_whenException.
@Test
public void getAndAlterAsync_whenException() {
IAtomicLong ref = client.getAtomicLong("getAndAlterAsync_whenException");
ref.set(10);
try {
ICompletableFuture<Long> future = ref.getAndAlterAsync(new FailingFunction());
future.get();
fail();
} catch (InterruptedException e) {
assertEquals(e.getCause().getClass().getName(), UndefinedErrorCodeException.class.getName());
assertEquals(((UndefinedErrorCodeException) e.getCause()).getOriginClassName(), ExpectedRuntimeException.class.getName());
} catch (ExecutionException e) {
assertEquals(e.getCause().getClass().getName(), UndefinedErrorCodeException.class.getName());
assertEquals(((UndefinedErrorCodeException) e.getCause()).getOriginClassName(), ExpectedRuntimeException.class.getName());
}
assertEquals(10, ref.get());
}
use of com.hazelcast.core.IAtomicLong in project hazelcast by hazelcast.
the class ClientAtomicLongTest method getAndAlter_whenException.
@Test
public void getAndAlter_whenException() {
IAtomicLong ref = client.getAtomicLong("getAndAlter_whenException");
ref.set(10);
try {
ref.getAndAlter(new FailingFunction());
fail();
} catch (UndefinedErrorCodeException expected) {
assertEquals(expected.getOriginClassName(), ExpectedRuntimeException.class.getName());
}
assertEquals(10, ref.get());
}
use of com.hazelcast.core.IAtomicLong in project hazelcast by hazelcast.
the class ClientAtomicLongTest method alterAsync_whenException.
@Test
public void alterAsync_whenException() {
IAtomicLong ref = client.getAtomicLong("alterAsync_whenException");
ref.set(10);
try {
ICompletableFuture<Void> future = ref.alterAsync(new FailingFunction());
future.get();
} catch (InterruptedException e) {
fail();
} catch (ExecutionException e) {
assertEquals(e.getCause().getClass(), UndefinedErrorCodeException.class);
assertEquals(((UndefinedErrorCodeException) e.getCause()).getOriginClassName(), ExpectedRuntimeException.class.getName());
}
assertEquals(10, ref.get());
}
Aggregations