Search in sources :

Example 6 with ISemaphore

use of com.hazelcast.core.ISemaphore in project hazelcast by hazelcast.

the class ClientSemaphoreTest method testRelease.

@Test
public void testRelease() throws Exception {
    final ISemaphore semaphore = client.getSemaphore(randomString());
    semaphore.init(0);
    semaphore.release();
    assertEquals(1, semaphore.availablePermits());
}
Also used : ISemaphore(com.hazelcast.core.ISemaphore) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 7 with ISemaphore

use of com.hazelcast.core.ISemaphore in project hazelcast by hazelcast.

the class ClientSemaphoreTest method testMulitReleaseTryAcquire.

@Test
public void testMulitReleaseTryAcquire() throws Exception {
    final ISemaphore semaphore = client.getSemaphore(randomString());
    semaphore.init(0);
    semaphore.release(5);
    assertTrue(semaphore.tryAcquire(5));
}
Also used : ISemaphore(com.hazelcast.core.ISemaphore) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 8 with ISemaphore

use of com.hazelcast.core.ISemaphore in project hazelcast by hazelcast.

the class ClientSemaphoreTest method testdrainPermits.

@Test
public void testdrainPermits() throws Exception {
    final ISemaphore semaphore = client.getSemaphore(randomString());
    semaphore.init(10);
    assertEquals(10, semaphore.drainPermits());
}
Also used : ISemaphore(com.hazelcast.core.ISemaphore) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 9 with ISemaphore

use of com.hazelcast.core.ISemaphore in project hazelcast by hazelcast.

the class ClientSemaphoreTest method testTryAcquire_whenDrainPermits.

@Test
public void testTryAcquire_whenDrainPermits() throws Exception {
    final ISemaphore semaphore = client.getSemaphore(randomString());
    semaphore.init(10);
    semaphore.drainPermits();
    assertFalse(semaphore.tryAcquire());
}
Also used : ISemaphore(com.hazelcast.core.ISemaphore) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 10 with ISemaphore

use of com.hazelcast.core.ISemaphore in project hazelcast by hazelcast.

the class ClientSemaphoreTest method testTryAcquire_afterRelease.

@Test
public void testTryAcquire_afterRelease() throws Exception {
    final ISemaphore semaphore = client.getSemaphore(randomString());
    semaphore.init(0);
    semaphore.release();
    assertTrue(semaphore.tryAcquire());
}
Also used : ISemaphore(com.hazelcast.core.ISemaphore) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Aggregations

ISemaphore (com.hazelcast.core.ISemaphore)30 ParallelTest (com.hazelcast.test.annotation.ParallelTest)29 QuickTest (com.hazelcast.test.annotation.QuickTest)29 Test (org.junit.Test)29 HazelcastInstance (com.hazelcast.core.HazelcastInstance)6 CountDownLatch (java.util.concurrent.CountDownLatch)4 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)3 SemaphoreService (com.hazelcast.concurrent.semaphore.SemaphoreService)1 Config (com.hazelcast.config.Config)1 AssertTask (com.hazelcast.test.AssertTask)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1