Search in sources :

Example 6 with UndefinedErrorCodeException

use of com.hazelcast.client.UndefinedErrorCodeException 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());
}
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 7 with UndefinedErrorCodeException

use of com.hazelcast.client.UndefinedErrorCodeException 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());
}
Also used : UndefinedErrorCodeException(com.hazelcast.client.UndefinedErrorCodeException) 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 8 with UndefinedErrorCodeException

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

the class ClientAtomicLongTest method apply_whenException.

@Test
public void apply_whenException() {
    IAtomicLong ref = client.getAtomicLong("apply_whenException");
    ref.set(1);
    try {
        ref.apply(new FailingFunction());
        fail();
    } catch (UndefinedErrorCodeException expected) {
        assertEquals(expected.getOriginClassName(), ExpectedRuntimeException.class.getName());
    }
    assertEquals(1, 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 9 with UndefinedErrorCodeException

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

the class ClientExceptionFactory method createException.

private Throwable createException(int errorCode, String className, String message, Throwable cause) {
    ExceptionFactory exceptionFactory = intToFactory.get(errorCode);
    Throwable throwable;
    if (exceptionFactory == null) {
        throwable = new UndefinedErrorCodeException(message, className);
    } else {
        throwable = exceptionFactory.createException(message, cause);
    }
    return throwable;
}
Also used : UndefinedErrorCodeException(com.hazelcast.client.UndefinedErrorCodeException)

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