public List<ILoggingEvent> assertHasEventEventually() { Asserts.succeedsEventually(new Runnable() { @Override public void run() { assertFalse(events.isEmpty()); }}); return getEvents(); }
public static void assertHttpStatusCodeEventuallyEquals(Map<String,?> flags, final String url, final int expectedCode) { Asserts.succeedsEventually(flags, new Runnable() { @Override public void run() { assertHttpStatusCodeEquals(url, expectedCode); } }); }
/** Asserts that two iterables return iterators with the same elements in the same order. If they do not, * an AssertionError is thrown. * @param actual the actual value * @param expected the expected value */ static public void assertEquals(Iterable<?> actual, Iterable<?> expected) { assertEquals(actual, expected, null); }
public static <T> void assertAttributeEqualsContinually(Map<?,?> flags, final Entity entity, final AttributeSensor<T> attribute, final T expected) { Asserts.succeedsContinually(flags, new Runnable() { @Override public void run() { assertAttributeEquals(entity, attribute, expected); }}); }
@Override public void run() { assertUrlUnreachable(url); } });
public static void assertUrlUnreachableEventually(Map<String,?> flags, final String url) { Asserts.succeedsEventually(flags, new Runnable() { @Override public void run() { assertUrlUnreachable(url); } }); }
/** * Asserts that two objects are equal. * @param actual the actual value * @param expected the expected value * * @throws AssertionError if the values are not equal. */ static public void assertEquals(Object actual, Object expected) { assertEquals(actual, expected, null); }
private void assertFeedIsPollingContinuously() { Asserts.succeedsContinually(new Runnable() { @Override public void run() { assertFeedIsPolling(); } }); }
public static void assertContentEventuallyMatches(Map<String,?> flags, final String url, final String regex) { Asserts.succeedsEventually(flags, new Runnable() { @Override public void run() { assertContentMatches(url, regex); } }); }
/** * Asserts that two Strings are equal. If they are not, * an AssertionError is thrown. * @param actual the actual value * @param expected the expected value */ static public void assertEquals(String actual, String expected) { assertEquals(actual, expected, null); }
public void assertHasEventEventually(final Predicate<? super SensorEvent<T>> filter) { Asserts.succeedsEventually(new Runnable() { @Override public void run() { assertHasEvent(filter); }}); }
/** * Asserts that two booleans are equal. If they are not, * an AssertionError is thrown. * @param actual the actual value * @param expected the expected value */ static public void assertEquals(boolean actual, boolean expected) { assertEquals(actual, expected, null); }
private void assertStateEventually(Entity entity, Lifecycle expectedState, Lifecycle state, Boolean isUp) { Asserts.succeedsEventually(new Runnable() { @Override public void run() { assertState(entity, expectedState, state, isUp); }}); }
/** * Asserts that two ints are equal. If they are not, * an AssertionError is thrown. * @param actual the actual value * @param expected the expected value */ static public void assertEquals(int actual, int expected) { assertEquals(actual, expected, null); }
protected void assertTaskCountForEntityEventually(final Entity entity, final int expectedCount) { // Dead task (and initialization task) should have been GC'd on completion. // However, the GC'ing happens in a listener, executed in a different thread - the task.get() // doesn't block for it. Therefore can't always guarantee it will be GC'ed by now. Asserts.succeedsEventually(new Runnable() { @Override public void run() { forceGc(); Collection<Task<?>> tasks = BrooklynTaskTags.getTasksInEntityContext(((EntityInternal)entity).getManagementContext().getExecutionManager(), entity); Assert.assertEquals(tasks.size(), expectedCount, "Tasks were "+tasks); }}); }
private void assertOnlyAppEventually(final ManagementContext managementContext, final Class<? extends Application> expectedType) { Asserts.succeedsEventually(new Runnable() { @Override public void run() { assertOnlyApp(managementContext, expectedType); }}); } }
private void assertMgmtStartedEventually(final ManagementContext mgmt) { Asserts.succeedsEventually(new Runnable() { @Override public void run() { assertTrue(mgmt.isStartupComplete()); }}); } });
private void assertStateEventually(Entity entity, Lifecycle expectedState, Lifecycle state, Boolean isUp) { Asserts.succeedsEventually(new Runnable() { @Override public void run() { assertState(entity, expectedState, state, isUp); }}); }
private void assertEffectorBlockingDetailsEventually(final Entity entity, final String blockingDetailsSnippet) { Asserts.succeedsEventually(new Runnable() { @Override public void run() { Task<?> entityTask = Iterables.getOnlyElement(entity.getApplication().getManagementContext().getExecutionManager().getTasksWithAllTags( ImmutableList.of(BrooklynTaskTags.EFFECTOR_TAG, BrooklynTaskTags.tagForContextEntity(entity)))); String blockingDetails = getBlockingDetails(entityTask); assertTrue(blockingDetails.contains(blockingDetailsSnippet)); }}); }
private void assertRecordedSshCmdContainsEventually(final String expected) { Asserts.succeedsEventually(new Runnable() { public void run() { List<ExecCmd> cmds = RecordingSshTool.getExecCmds(); for (ExecCmd cmd : cmds) { if (cmd.commands.toString().contains(expected)) { return; } } fail("Commands (" + expected + ") not contain in " + cmds); }}); }