You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by sj...@apache.org on 2015/01/12 18:21:41 UTC
[02/10] incubator-brooklyn git commit: Adds
EntityTestUtils.assertAttributeNever
Adds EntityTestUtils.assertAttributeNever
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/5a73ff0a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/5a73ff0a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/5a73ff0a
Branch: refs/heads/master
Commit: 5a73ff0aa0df87a5952c9e9888f16fef37fb2c47
Parents: 63d7e4b
Author: Sam Corbett <sa...@cloudsoftcorp.com>
Authored: Fri Dec 12 18:26:19 2014 +0000
Committer: Sam Corbett <sa...@cloudsoftcorp.com>
Committed: Fri Jan 9 13:56:39 2015 +0000
----------------------------------------------------------------------
.../main/java/brooklyn/test/EntityTestUtils.java | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/5a73ff0a/usage/test-support/src/main/java/brooklyn/test/EntityTestUtils.java
----------------------------------------------------------------------
diff --git a/usage/test-support/src/main/java/brooklyn/test/EntityTestUtils.java b/usage/test-support/src/main/java/brooklyn/test/EntityTestUtils.java
index 088f29c..ae7b269 100644
--- a/usage/test-support/src/main/java/brooklyn/test/EntityTestUtils.java
+++ b/usage/test-support/src/main/java/brooklyn/test/EntityTestUtils.java
@@ -19,10 +19,12 @@
package brooklyn.test;
import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
import java.util.Collection;
import java.util.Map;
+import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
@@ -41,6 +43,7 @@ import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
public class EntityTestUtils {
@@ -160,5 +163,18 @@ public class EntityTestUtils {
assertAttributeEventually(entity, attribute,
Predicates.not(Predicates.equalTo(entity.getAttribute(attribute))));
}
-
+
+ @Beta
+ public static <T> void assertAttributeNever(final Entity entity, final AttributeSensor<T> attribute, T... disallowed) {
+ final Set<T> reject = Sets.newHashSet(disallowed);
+ Asserts.succeedsContinually(new Runnable() {
+ @Override
+ public void run() {
+ T val = entity.getAttribute(attribute);
+ assertFalse(reject.contains(val),
+ "Attribute " + attribute + " on " + entity + " has disallowed value " + val);
+ }
+ });
+ }
+
}