public static void assertCompletesEventually(final Future f) { assertTrueEventually(new AssertTask() { @Override public void run() throws Exception { assertTrue("future has not completed", f.isDone()); } }); }
/** * Assert that a certain task is going to assert to true eventually. * <p> * This method makes use of an exponential back-off mechanism. So initially it will ask frequently, but the * more times it fails the less frequent the task is going to be retried. * <p> * Uses the default timeout of {@link #ASSERT_TRUE_EVENTUALLY_TIMEOUT} milliseconds. * * @param task AssertTask to execute * @throws NullPointerException if task is null. */ public static void assertTrueEventually(AssertTask task) { assertTrueEventually(task, ASSERT_TRUE_EVENTUALLY_TIMEOUT); }
/** * Assert that a certain task is going to assert to true eventually. * * This method makes use of an exponential back-off mechanism. So initially it will ask frequently, but the * more times it fails the less frequent the task is going to be retried. * * Uses the default timeout of {@link #ASSERT_TRUE_EVENTUALLY_TIMEOUT} milliseconds. * * @param task AssertTask to execute * @throws NullPointerException if task is null. */ public static void assertTrueEventually(AssertTask task) { assertTrueEventually(task, ASSERT_TRUE_EVENTUALLY_TIMEOUT); }
@Verify(global = false) public void verify() { assertTrueEventually(new AssertTask() { @Override public void run() throws Exception { long totalEntryCount = totalEntryCountOnNode(name, targetInstance); assertEquals("totalEntryCount=" + totalEntryCount, 0, totalEntryCount); } }, 600); }
@Verify(global = true) public void verify() { if (maxVerificationTimeSeconds < 0) { return; } final long expectedCount = totalExpectedCounter.get(); assertTrueEventually(new AssertTask() { @Override public void run() throws Exception { long actualCount = 0; for (TopicListener topicListener : listeners) { actualCount += topicListener.count; } assertEquals("published messages don't match received messages", expectedCount, actualCount); } }, maxVerificationTimeSeconds); }
@Verify(global = true) public void verify() { final long expectedCount = listenersPerTopic * totalMessagesSend.get(); assertTrueEventually(new AssertTask() { @Override public void run() throws Exception { long actualCount = 0; for (MessageListenerImpl topicListener : listeners) { actualCount += topicListener.received.get(); } assertEquals("published messages don't match received messages", expectedCount, actualCount); } }); assertEquals("Failures found", 0, failures.get()); } }
@Verify(global = true) public void globalVerify() { sleepSeconds(61); // provoke expire after TTL for (int i = 0; i < keyCount; i++) { cache.containsKey(i); } assertTrueEventually(new AssertTask() { @Override public void run() throws Exception { int cacheSize = cache.size(); logger.info(name + " ICache size: " + cacheSize); assertEquals(name + " ICache should be empty, but TTL events are not processed", 0, cacheSize); } }); } }
@Verify public void globalVerify() { MapOperationCounter total = new MapOperationCounter(); for (MapOperationCounter counter : results) { total.add(counter); } logger.info(name + ": " + total + " total of " + results.size()); assertTrueEventually(new AssertTask() { @Override public void run() throws Exception { assertEquals(name + ": Map should be empty, some TTL events are not processed", 0, map.size()); } }); } }
@Verify(global = false) public void localVerify() { MapOperationCounter total = new MapOperationCounter(); for (MapOperationCounter counter : results) { total.add(counter); } logger.info(name + ": " + total + " total of " + results.size()); assertTrueEventually(new AssertTask() { @Override public void run() throws Exception { logger.info(name + ": " + "assert map Size = " + map.size()); assertEquals(name + ": Replicated Map should be empty, some TTL events are not processed", 0, map.size()); } }); } }
@Verify public void globalVerify() { MapOperationCounter total = new MapOperationCounter(); for (MapOperationCounter counter : results) { total.add(counter); } logger.info(name + ": " + total + " total of " + results.size()); assertTrueEventually(new AssertTask() { @Override public void run() throws Exception { assertEquals(name + ": Map should be empty, some TTL events are not processed", 0, map.size()); } }); } }
@Verify public void verify() { if (isClient(targetInstance)) { return; } final String serviceName = totalCounter.getServiceName(); final long expected = totalCounter.get(); // since the operations are asynchronous, we have no idea when they complete assertTrueEventually(new AssertTask() { @Override public void run() throws Exception { // hack to prevent overloading the system with get calls, else it is done many times a second sleepSeconds(10); long actual = 0; for (DistributedObject distributedObject : targetInstance.getDistributedObjects()) { String key = distributedObject.getName(); if (serviceName.equals(distributedObject.getServiceName()) && key.startsWith(name)) { actual += targetInstance.getAtomicLong(key).get(); } } assertEquals(expected, actual); } }, assertEventuallySeconds); }
logger.info(name + ": map store = " + mapStore); assertTrueEventually(new AssertTask() { @Override public void run() { assertTrueEventually(new AssertTask() { @Override public void run() {
logger.info(name + ": map store = " + mapStore); assertTrueEventually(new AssertTask() { @Override public void run() { assertTrueEventually(new AssertTask() { @Override public void run() {