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