Search in sources :

Example 31 with IAtomicLong

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());
}
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 32 with IAtomicLong

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());
}
Also used : IAtomicLong(com.hazelcast.core.IAtomicLong) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 33 with IAtomicLong

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());
}
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 34 with IAtomicLong

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());
}
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 35 with IAtomicLong

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());
}
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)

Aggregations

IAtomicLong (com.hazelcast.core.IAtomicLong)50 ParallelTest (com.hazelcast.test.annotation.ParallelTest)45 Test (org.junit.Test)45 QuickTest (com.hazelcast.test.annotation.QuickTest)44 HazelcastInstance (com.hazelcast.core.HazelcastInstance)21 IExecutorService (com.hazelcast.core.IExecutorService)10 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)9 UndefinedErrorCodeException (com.hazelcast.client.UndefinedErrorCodeException)8 Random (java.util.Random)8 Config (com.hazelcast.config.Config)6 Member (com.hazelcast.core.Member)6 CountDownLatch (java.util.concurrent.CountDownLatch)6 ExecutionException (java.util.concurrent.ExecutionException)6 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)6 ExecutorConfig (com.hazelcast.config.ExecutorConfig)5 MultiExecutionCallback (com.hazelcast.core.MultiExecutionCallback)3 Map (java.util.Map)3 ICountDownLatch (com.hazelcast.core.ICountDownLatch)2 ClientCacheProxyFactory (com.hazelcast.client.cache.impl.ClientCacheProxyFactory)1 ProxyFactoryConfig (com.hazelcast.client.config.ProxyFactoryConfig)1