use of com.hazelcast.test.AssertTask in project hazelcast by hazelcast.
the class ReducerTaskSchedulerTest method requestExecution_whenTriggeredWhileAlreadyRequested_thenExecuteTaskTwice.
@Test
public void requestExecution_whenTriggeredWhileAlreadyRequested_thenExecuteTaskTwice() {
scheduler.requestExecution();
scheduler.requestExecution();
scheduler.requestExecution();
semaphore.release();
semaphore.release();
semaphore.release();
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
assertEquals(2, task.getExecutionCount());
}
});
}
use of com.hazelcast.test.AssertTask in project hazelcast by hazelcast.
the class MultiMapLockTest method testTryLockLeaseTime_lockIsReleasedEventually.
@Test
public void testTryLockLeaseTime_lockIsReleasedEventually() throws InterruptedException {
final MultiMap multiMap = getMultiMapForLock();
final String key = randomString();
multiMap.tryLock(key, 1000, TimeUnit.MILLISECONDS, 1000, TimeUnit.MILLISECONDS);
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
Assert.assertFalse(multiMap.isLocked(key));
}
}, 30);
}
use of com.hazelcast.test.AssertTask in project hazelcast by hazelcast.
the class PartitionLostListenerRegistrationTest method assertRegistrationsSizeEventually.
private void assertRegistrationsSizeEventually(final HazelcastInstance instance, final int expectedSize) {
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
final InternalEventService eventService = getNode(instance).getNodeEngine().getEventService();
assertEquals(expectedSize, eventService.getRegistrations(SERVICE_NAME, PARTITION_LOST_EVENT_TOPIC).size());
}
});
}
});
}
use of com.hazelcast.test.AssertTask in project hazelcast by hazelcast.
the class TcpIpConnection_BaseTest method write_whenNonUrgent.
@Test
public void write_whenNonUrgent() {
TcpIpConnection c = connect(connManagerA, addressB);
Packet packet = new Packet(serializationService.toBytes("foo"));
boolean result = c.write(packet);
assertTrue(result);
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
assertEquals(1, packetsB.size());
}
});
Packet found = packetsB.get(0);
assertEquals(packet, found);
}
use of com.hazelcast.test.AssertTask in project hazelcast by hazelcast.
the class TcpIpConnection_BaseTest method lastWriteTimeMillis_whenPacketWritten.
@Test
public void lastWriteTimeMillis_whenPacketWritten() {
TcpIpConnection connAB = connect(connManagerA, addressB);
// we need to sleep some so that the lastWriteTime of the connection gets nice and old.
// we need this so we can determine the lastWriteTime got updated
sleepSeconds(LAST_READ_WRITE_SLEEP_SECONDS);
Packet packet = new Packet(serializationService.toBytes("foo"));
connAB.write(packet);
// wait for the packet to get written.
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
assertEquals(1, packetsB.size());
}
});
long lastWriteTimeMs = connAB.lastWriteTimeMillis();
long nowMs = currentTimeMillis();
// make sure that the lastWrite time is within the given MARGIN_OF_ERROR_MS
// last write time should be equal or smaller than now
assertTrue("nowMs = " + nowMs + ", lastWriteTimeMs = " + lastWriteTimeMs, lastWriteTimeMs <= nowMs);
// last write time should be larger or equal than the now - MARGIN_OF_ERROR_MS
assertTrue("nowMs = " + nowMs + ", lastWriteTimeMs = " + lastWriteTimeMs, lastWriteTimeMs >= nowMs - MARGIN_OF_ERROR_MS);
}
Aggregations