Search in sources :

Example 1 with UndefinedErrorCodeException

use of com.hazelcast.client.UndefinedErrorCodeException in project hazelcast by hazelcast.

the class ClientAtomicLongTest method alter_whenException.

@Test
public void alter_whenException() {
    IAtomicLong ref = client.getAtomicLong("alter_whenException");
    ref.set(10);
    try {
        ref.alter(new FailingFunction());
        fail();
    } catch (UndefinedErrorCodeException expected) {
        assertEquals(expected.getOriginClassName(), ExpectedRuntimeException.class.getName());
    }
    assertEquals(10, ref.get());
}
Also used : UndefinedErrorCodeException(com.hazelcast.client.UndefinedErrorCodeException) IAtomicLong(com.hazelcast.core.IAtomicLong) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 2 with UndefinedErrorCodeException

use of com.hazelcast.client.UndefinedErrorCodeException in project hazelcast by hazelcast.

the class ClientAtomicLongTest method alterAndGet_whenException.

@Test
public void alterAndGet_whenException() {
    IAtomicLong ref = client.getAtomicLong("alterAndGet_whenException");
    ref.set(10);
    try {
        ref.alterAndGet(new FailingFunction());
        fail();
    } catch (UndefinedErrorCodeException expected) {
        assertEquals(expected.getOriginClassName(), ExpectedRuntimeException.class.getName());
    }
    assertEquals(10, ref.get());
}
Also used : UndefinedErrorCodeException(com.hazelcast.client.UndefinedErrorCodeException) IAtomicLong(com.hazelcast.core.IAtomicLong) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 3 with UndefinedErrorCodeException

use of com.hazelcast.client.UndefinedErrorCodeException in project hazelcast by hazelcast.

the class ClientAtomicLongTest method applyAsync_whenException.

@Test
public void applyAsync_whenException() {
    IAtomicLong ref = client.getAtomicLong("applyAsync_whenException");
    ref.set(1);
    try {
        ICompletableFuture<Long> future = ref.applyAsync(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(1, ref.get());
}
Also used : UndefinedErrorCodeException(com.hazelcast.client.UndefinedErrorCodeException) IAtomicLong(com.hazelcast.core.IAtomicLong) IAtomicLong(com.hazelcast.core.IAtomicLong) ExecutionException(java.util.concurrent.ExecutionException) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 4 with UndefinedErrorCodeException

use of com.hazelcast.client.UndefinedErrorCodeException 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());
}
Also used : UndefinedErrorCodeException(com.hazelcast.client.UndefinedErrorCodeException) IAtomicLong(com.hazelcast.core.IAtomicLong) IAtomicLong(com.hazelcast.core.IAtomicLong) ExecutionException(java.util.concurrent.ExecutionException) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 5 with UndefinedErrorCodeException

use of com.hazelcast.client.UndefinedErrorCodeException 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());
}
Also used : UndefinedErrorCodeException(com.hazelcast.client.UndefinedErrorCodeException) IAtomicLong(com.hazelcast.core.IAtomicLong) IAtomicLong(com.hazelcast.core.IAtomicLong) ExecutionException(java.util.concurrent.ExecutionException) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Aggregations

UndefinedErrorCodeException (com.hazelcast.client.UndefinedErrorCodeException)9 IAtomicLong (com.hazelcast.core.IAtomicLong)8 ParallelTest (com.hazelcast.test.annotation.ParallelTest)8 QuickTest (com.hazelcast.test.annotation.QuickTest)8 Test (org.junit.Test)8 ExecutionException (java.util.concurrent.ExecutionException)4