more entity-config basic tests (all passing, confirm more combos work)

Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/759d67e2
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/759d67e2
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/759d67e2

Branch: refs/heads/master
Commit: 759d67e22b7841e4c2c138c341eda0b299b09498
Parents: a319357
Author: Alex Heneveld <alex.henev...@cloudsoftcorp.com>
Authored: Thu Sep 15 12:16:32 2016 +0100
Committer: Alex Heneveld <alex.henev...@cloudsoftcorp.com>
Committed: Tue Sep 20 08:47:26 2016 +0100

----------------------------------------------------------------------
 .../brooklyn/core/entity/EntityConfigTest.java  | 32 +++++++++++++++++++-
 1 file changed, 31 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/759d67e2/core/src/test/java/org/apache/brooklyn/core/entity/EntityConfigTest.java
----------------------------------------------------------------------
diff --git 
a/core/src/test/java/org/apache/brooklyn/core/entity/EntityConfigTest.java 
b/core/src/test/java/org/apache/brooklyn/core/entity/EntityConfigTest.java
index 6fad5ea..5f02d55 100644
--- a/core/src/test/java/org/apache/brooklyn/core/entity/EntityConfigTest.java
+++ b/core/src/test/java/org/apache/brooklyn/core/entity/EntityConfigTest.java
@@ -45,7 +45,6 @@ import org.apache.brooklyn.core.test.entity.TestEntity;
 import org.apache.brooklyn.util.core.flags.SetFromFlag;
 import org.apache.brooklyn.util.core.task.BasicTask;
 import org.apache.brooklyn.util.core.task.DeferredSupplier;
-import org.apache.brooklyn.util.core.task.DeferredSupplier;
 import org.apache.brooklyn.util.core.task.Tasks;
 import org.apache.brooklyn.util.exceptions.Exceptions;
 import org.testng.Assert;
@@ -285,6 +284,13 @@ public class EntityConfigTest extends 
BrooklynAppUnitTestSupport {
 
     @Test
     public void testConfigureFromKey() throws Exception {
+        MyBaseEntity entity = 
app.addChild(EntitySpec.create(MyBaseEntity.class)
+                .configure(MyBaseEntity.SUPER_KEY_1, "changed"));
+        assertEquals(entity.getConfig(MyBaseEntity.SUPER_KEY_1), "changed");
+    }
+
+    @Test
+    public void testConfigureFromOverriddenKey() throws Exception {
         MySubEntity entity = app.addChild(EntitySpec.create(MySubEntity.class)
                 .configure(MySubEntity.SUPER_KEY_1, "changed"));
         assertEquals(entity.getConfig(MySubEntity.SUPER_KEY_1), "changed");
@@ -292,12 +298,36 @@ public class EntityConfigTest extends 
BrooklynAppUnitTestSupport {
 
     @Test
     public void testConfigureFromSuperKey() throws Exception {
+        // use parent key to set
         MySubEntity entity = app.addChild(EntitySpec.create(MySubEntity.class)
                 .configure(MyBaseEntity.SUPER_KEY_1, "changed"));
         assertEquals(entity.getConfig(MySubEntity.SUPER_KEY_1), "changed");
     }
 
     @Test
+    public void testConfigureFromStringGetByKey() throws Exception {
+        MySubEntity entity = app.addChild(EntitySpec.create(MySubEntity.class)
+            .configure(MySubEntity.SUPER_KEY_1.getName(), "changed"));
+        assertEquals(entity.getConfig(MySubEntity.SUPER_KEY_1), "changed");
+    }
+    
+    @Test
+    public void testConfigureFromStringGetByExternalKey() throws Exception {
+        // config key is not present on the entity
+        MyBaseEntity entity = 
app.addChild(EntitySpec.create(MyBaseEntity.class)
+            .configure(MySubEntity.SUB_KEY_2.getName(), "changed"));
+        assertEquals(entity.getConfig(MySubEntity.SUB_KEY_2), "changed");
+        assertEquals(entity.getConfig(ConfigKeys.newConfigKey(Object.class, 
MySubEntity.SUB_KEY_2.getName())), "changed");
+    }
+    
+    @Test
+    public void testConfigureFromStringGetBySuperKey() throws Exception {
+        MySubEntity entity = app.addChild(EntitySpec.create(MySubEntity.class)
+            .configure(MySubEntity.SUPER_KEY_2.getName(), "changed"));
+        assertEquals(entity.getConfig(MySubEntity.SUPER_KEY_2), "changed");
+    }
+    
+    @Test
     public void testConfigSubMap() throws Exception {
         MySubEntity entity = 
app.addChild(EntitySpec.create(MySubEntity.class));
         entity.config().set(MyBaseEntity.SUPER_KEY_1, "s1");

Reply via email to