brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henev...@apache.org
Subject [21/28] brooklyn-server git commit: Config inheritance: test improvements
Date Wed, 15 Feb 2017 18:31:14 GMT
Config inheritance: test improvements

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

Branch: refs/heads/master
Commit: 49835acf3581d208350af184a4c0fdfca34ef6b5
Parents: b1b8443
Author: Aled Sage <aled.sage@gmail.com>
Authored: Fri Feb 10 12:33:51 2017 +0000
Committer: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Committed: Tue Feb 14 00:13:10 2017 +0000

----------------------------------------------------------------------
 .../brooklyn/ConfigInheritanceYamlTest.java     | 201 ++++++++++++++++---
 .../camp/brooklyn/ConfigParametersYamlTest.java |  39 +++-
 .../catalog/SpecParameterUnwrappingTest.java    |   8 +-
 .../core/config/BasicConfigInheritance.java     |   2 +-
 4 files changed, 207 insertions(+), 43 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/49835acf/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/ConfigInheritanceYamlTest.java
----------------------------------------------------------------------
diff --git a/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/ConfigInheritanceYamlTest.java
b/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/ConfigInheritanceYamlTest.java
index bfe7312..9814a33 100644
--- a/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/ConfigInheritanceYamlTest.java
+++ b/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/ConfigInheritanceYamlTest.java
@@ -29,9 +29,12 @@ import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 
 import org.apache.brooklyn.api.entity.Entity;
+import org.apache.brooklyn.api.entity.EntityType;
 import org.apache.brooklyn.api.entity.ImplementedBy;
 import org.apache.brooklyn.api.location.Location;
 import org.apache.brooklyn.api.sensor.AttributeSensor;
+import org.apache.brooklyn.config.ConfigKey;
+import org.apache.brooklyn.core.config.ConfigKeys;
 import org.apache.brooklyn.core.config.MapConfigKey;
 import org.apache.brooklyn.core.entity.Entities;
 import org.apache.brooklyn.core.entity.EntityAsserts;
@@ -410,9 +413,9 @@ public class ConfigInheritanceYamlTest extends AbstractYamlTest {
                 "        type: java.util.Map",
                 "        inheritance.type: deep_merge",
                 "        default: {myDefaultKey: myDefaultVal}",
-                "      - name: map.type-always",
+                "      - name: map.type-overwrite",
                 "        type: java.util.Map",
-                "        inheritance.type: always",
+                "        inheritance.type: overwrite",
                 "        default: {myDefaultKey: myDefaultVal}",
                 "      - name: map.type-never",
                 "        type: java.util.Map",
@@ -424,7 +427,7 @@ public class ConfigInheritanceYamlTest extends AbstractYamlTest {
                 "      brooklyn.config:",
                 "        map.type-merged:",
                 "          mykey: myval",
-                "        map.type-always:",
+                "        map.type-overwrite:",
                 "          mykey: myval",
                 "        map.type-never:",
                 "          mykey: myval");
@@ -438,9 +441,9 @@ public class ConfigInheritanceYamlTest extends AbstractYamlTest {
             Entity app = createStartWaitAndLogApplication(yaml);
             TestEntity entity = (TestEntity) Iterables.getOnlyElement(app.getChildren());
     
-            assertEquals(entity.config().get(entity.getEntityType().getConfigKey("map.type-merged")),
ImmutableMap.of("myDefaultKey", "myDefaultVal"));
-            assertEquals(entity.config().get(entity.getEntityType().getConfigKey("map.type-always")),
ImmutableMap.of("myDefaultKey", "myDefaultVal"));
-            assertEquals(entity.config().get(entity.getEntityType().getConfigKey("map.type-never")),
ImmutableMap.of("myDefaultKey", "myDefaultVal"));
+            assertConfigEquals(entity, "map.type-merged", ImmutableMap.of("myDefaultKey",
"myDefaultVal"));
+            assertConfigEquals(entity, "map.type-overwrite", ImmutableMap.of("myDefaultKey",
"myDefaultVal"));
+            assertConfigEquals(entity, "map.type-never", ImmutableMap.of("myDefaultKey",
"myDefaultVal"));
         }
 
         // Test override defaults
@@ -451,7 +454,7 @@ public class ConfigInheritanceYamlTest extends AbstractYamlTest {
                     "  brooklyn.config:",
                     "    map.type-merged:",
                     "      mykey2: myval2",
-                    "    map.type-always:",
+                    "    map.type-overwrite:",
                     "      mykey2: myval2",
                     "    map.type-never:",
                     "      mykey2: myval2");
@@ -459,9 +462,9 @@ public class ConfigInheritanceYamlTest extends AbstractYamlTest {
             Entity app = createStartWaitAndLogApplication(yaml);
             TestEntity entity = (TestEntity) Iterables.getOnlyElement(app.getChildren());
     
-            assertEquals(entity.config().get(entity.getEntityType().getConfigKey("map.type-merged")),
ImmutableMap.of("mykey2", "myval2"));
-            assertEquals(entity.config().get(entity.getEntityType().getConfigKey("map.type-always")),
ImmutableMap.of("mykey2", "myval2"));
-            assertEquals(entity.config().get(entity.getEntityType().getConfigKey("map.type-never")),
ImmutableMap.of("mykey2", "myval2"));
+            assertConfigEquals(entity, "map.type-merged", ImmutableMap.of("mykey2", "myval2"));
+            assertConfigEquals(entity, "map.type-overwrite", ImmutableMap.of("mykey2", "myval2"));
+            assertConfigEquals(entity, "map.type-never", ImmutableMap.of("mykey2", "myval2"));
         }
 
         // Test retrieval of explicit config
@@ -474,9 +477,9 @@ public class ConfigInheritanceYamlTest extends AbstractYamlTest {
             Entity app = createStartWaitAndLogApplication(yaml);
             TestEntity entity = (TestEntity) Iterables.getOnlyElement(app.getChildren());
     
-            assertEquals(entity.config().get(entity.getEntityType().getConfigKey("map.type-merged")),
ImmutableMap.of("mykey", "myval"));
-            assertEquals(entity.config().get(entity.getEntityType().getConfigKey("map.type-always")),
ImmutableMap.of("mykey", "myval"));
-            assertEquals(entity.config().get(entity.getEntityType().getConfigKey("map.type-never")),
ImmutableMap.of("myDefaultKey", "myDefaultVal"));
+            assertConfigEquals(entity, "map.type-merged", ImmutableMap.of("mykey", "myval"));
+            assertConfigEquals(entity, "map.type-overwrite", ImmutableMap.of("mykey", "myval"));
+            assertConfigEquals(entity, "map.type-never", ImmutableMap.of("myDefaultKey",
"myDefaultVal"));
         }
         
         // Test merging/overriding of explicit config
@@ -487,7 +490,7 @@ public class ConfigInheritanceYamlTest extends AbstractYamlTest {
                     "  brooklyn.config:",
                     "    map.type-merged:",
                     "      mykey2: myval2",
-                    "    map.type-always:",
+                    "    map.type-overwrite:",
                     "      mykey2: myval2",
                     "    map.type-never:",
                     "      mykey2: myval2");
@@ -495,9 +498,9 @@ public class ConfigInheritanceYamlTest extends AbstractYamlTest {
             Entity app = createStartWaitAndLogApplication(yaml);
             TestEntity entity = (TestEntity) Iterables.getOnlyElement(app.getChildren());
     
-            assertEquals(entity.config().get(entity.getEntityType().getConfigKey("map.type-merged")),
ImmutableMap.of("mykey", "myval", "mykey2", "myval2"));
-            assertEquals(entity.config().get(entity.getEntityType().getConfigKey("map.type-always")),
ImmutableMap.of("mykey2", "myval2"));
-            assertEquals(entity.config().get(entity.getEntityType().getConfigKey("map.type-never")),
ImmutableMap.of("mykey2", "myval2"));
+            assertConfigEquals(entity, "map.type-merged", ImmutableMap.of("mykey", "myval",
"mykey2", "myval2"));
+            assertConfigEquals(entity, "map.type-overwrite", ImmutableMap.of("mykey2", "myval2"));
+            assertConfigEquals(entity, "map.type-never", ImmutableMap.of("mykey2", "myval2"));
         }
     }
     
@@ -515,15 +518,41 @@ public class ConfigInheritanceYamlTest extends AbstractYamlTest {
                 "        type: java.util.Map",
                 "        inheritance.parent: deep_merge",
                 "        default: {myDefaultKey: myDefaultVal}",
-                "      - name: map.type-always",
+                "      - name: map.type-overwrite",
                 "        type: java.util.Map",
-                "        inheritance.parent: always",
+                "        inheritance.parent: overwrite",
                 "        default: {myDefaultKey: myDefaultVal}",
                 "      - name: map.type-never",
                 "        type: java.util.Map",
                 "        inheritance.parent: never",
+                "        default: {myDefaultKey: myDefaultVal}",
+                "      - name: map.type-not-reinherited",
+                "        type: java.util.Map",
+                "        inheritance.parent: not_reinherited",
                 "        default: {myDefaultKey: myDefaultVal}");
         
+        // An entity with same key names as "entity-with-keys", but no default values.
+        addCatalogItems(
+                "brooklyn.catalog:",
+                "  itemType: entity",
+                "  items:",
+                "  - id: entity-with-keys-dups-no-defaults",
+                "    item:",
+                "      type: org.apache.brooklyn.core.test.entity.TestEntity",
+                "      brooklyn.parameters:",
+                "      - name: map.type-merged",
+                "        type: java.util.Map",
+                "        inheritance.parent: deep_merge",
+                "      - name: map.type-overwrite",
+                "        type: java.util.Map",
+                "        inheritance.parent: overwrite",
+                "      - name: map.type-never",
+                "        type: java.util.Map",
+                "        inheritance.parent: never",
+                "      - name: map.type-not-reinherited",
+                "        type: java.util.Map",
+                "        inheritance.parent: not_reinherited");
+
         // Test retrieval of defaults
         {
             String yaml = Joiner.on("\n").join(
@@ -535,9 +564,10 @@ public class ConfigInheritanceYamlTest extends AbstractYamlTest {
             Entity app = createStartWaitAndLogApplication(yaml);
             TestEntity entity = (TestEntity) Iterables.getOnlyElement(app.getChildren());
     
-            assertEquals(entity.config().get(entity.getEntityType().getConfigKey("map.type-merged")),
ImmutableMap.of("myDefaultKey", "myDefaultVal"));
-            assertEquals(entity.config().get(entity.getEntityType().getConfigKey("map.type-always")),
ImmutableMap.of("myDefaultKey", "myDefaultVal"));
-            assertEquals(entity.config().get(entity.getEntityType().getConfigKey("map.type-never")),
ImmutableMap.of("myDefaultKey", "myDefaultVal"));
+            assertConfigEquals(entity, "map.type-merged", ImmutableMap.of("myDefaultKey",
"myDefaultVal"));
+            assertConfigEquals(entity, "map.type-overwrite", ImmutableMap.of("myDefaultKey",
"myDefaultVal"));
+            assertConfigEquals(entity, "map.type-never", ImmutableMap.of("myDefaultKey",
"myDefaultVal"));
+            assertConfigEquals(entity, "map.type-not-reinherited", ImmutableMap.of("myDefaultKey",
"myDefaultVal"));
         }
 
         // Test override defaults in parent entity
@@ -548,19 +578,22 @@ public class ConfigInheritanceYamlTest extends AbstractYamlTest {
                     "  brooklyn.config:",
                     "    map.type-merged:",
                     "      mykey: myval",
-                    "    map.type-always:",
+                    "    map.type-overwrite:",
                     "      mykey: myval",
                     "    map.type-never:",
                     "      mykey: myval",
+                    "    map.type-not-reinherited:",
+                    "      mykey: myval",
                     "  brooklyn.children:",
                     "  - type: entity-with-keys");
             
             Entity app = createStartWaitAndLogApplication(yaml);
             TestEntity entity = (TestEntity) Iterables.getOnlyElement(app.getChildren());
     
-            assertEquals(entity.config().get(entity.getEntityType().getConfigKey("map.type-merged")),
ImmutableMap.of("mykey", "myval"));
-            assertEquals(entity.config().get(entity.getEntityType().getConfigKey("map.type-always")),
ImmutableMap.of("mykey", "myval"));
-            assertEquals(entity.config().get(entity.getEntityType().getConfigKey("map.type-never")),
ImmutableMap.of("myDefaultKey", "myDefaultVal"));
+            assertConfigEquals(entity, "map.type-merged", ImmutableMap.of("mykey", "myval"));
+            assertConfigEquals(entity, "map.type-overwrite", ImmutableMap.of("mykey", "myval"));
+            assertConfigEquals(entity, "map.type-never", ImmutableMap.of("myDefaultKey",
"myDefaultVal"));
+            assertConfigEquals(entity, "map.type-not-reinherited", ImmutableMap.of("mykey",
"myval"));
         }
 
         // Test merging/overriding of explicit config
@@ -571,26 +604,118 @@ public class ConfigInheritanceYamlTest extends AbstractYamlTest {
                     "  brooklyn.config:",
                     "    map.type-merged:",
                     "      mykey: myval",
-                    "    map.type-always:",
+                    "    map.type-overwrite:",
                     "      mykey: myval",
                     "    map.type-never:",
                     "      mykey: myval",
+                    "    map.type-not-reinherited:",
+                    "      mykey: myval",
                     "  brooklyn.children:",
                     "  - type: entity-with-keys",
                     "    brooklyn.config:",
                     "      map.type-merged:",
                     "        mykey2: myval2",
-                    "      map.type-always:",
+                    "      map.type-overwrite:",
                     "        mykey2: myval2",
                     "      map.type-never:",
+                    "        mykey2: myval2",
+                    "      map.type-not-reinherited:",
                     "        mykey2: myval2");
             
             Entity app = createStartWaitAndLogApplication(yaml);
             TestEntity entity = (TestEntity) Iterables.getOnlyElement(app.getChildren());
     
-            assertEquals(entity.config().get(entity.getEntityType().getConfigKey("map.type-merged")),
ImmutableMap.of("mykey", "myval", "mykey2", "myval2"));
-            assertEquals(entity.config().get(entity.getEntityType().getConfigKey("map.type-always")),
ImmutableMap.of("mykey2", "myval2"));
-            assertEquals(entity.config().get(entity.getEntityType().getConfigKey("map.type-never")),
ImmutableMap.of("mykey2", "myval2"));
+            assertConfigEquals(entity, "map.type-merged", ImmutableMap.of("mykey", "myval",
"mykey2", "myval2"));
+            assertConfigEquals(entity, "map.type-overwrite", ImmutableMap.of("mykey2", "myval2"));
+            assertConfigEquals(entity, "map.type-never", ImmutableMap.of("mykey2", "myval2"));
+            assertConfigEquals(entity, "map.type-not-reinherited", ImmutableMap.of("mykey2",
"myval2"));
+        }
+        
+        // Test inheritance by child that does not explicitly declare those keys itself
+        {
+            String yaml = Joiner.on("\n").join(
+                    "services:",
+                    "- type: entity-with-keys",
+                    "  brooklyn.config:",
+                    "    map.type-merged:",
+                    "      mykey: myval",
+                    "    map.type-overwrite:",
+                    "      mykey: myval",
+                    "    map.type-never:",
+                    "      mykey: myval",
+                    "    map.type-not-reinherited:",
+                    "      mykey: myval",
+                    "  brooklyn.children:",
+                    "  - type: " + TestEntity.class.getName());
+            
+            Entity app = createStartWaitAndLogApplication(yaml);
+            TestEntity entity = (TestEntity) Iterables.getOnlyElement(app.getChildren());
+            TestEntity child = (TestEntity) Iterables.getOnlyElement(entity.getChildren());
+
+            // Not using `assertConfigEquals(child, ...)`, bacause child.getEntityType().getConfigKey()

+            // will not find these keys.
+            //
+            // TODO Note the different behaviour for "never" and "not-reinherited" keys for
if an 
+            // untyped key is used, versus the strongly typed key. We can live with that
- I wouldn't
+            // expect an implementation of TestEntity to try to use such keys that it doesn't
know 
+            // about!
+            assertEquals(child.config().get(entity.getEntityType().getConfigKey("map.type-merged")),
ImmutableMap.of("mykey", "myval"));
+            assertEquals(child.config().get(entity.getEntityType().getConfigKey("map.type-overwrite")),
ImmutableMap.of("mykey", "myval"));
+            assertEquals(child.config().get(entity.getEntityType().getConfigKey("map.type-never")),
ImmutableMap.of("myDefaultKey", "myDefaultVal"));
+            assertEquals(child.config().get(entity.getEntityType().getConfigKey("map.type-not-reinherited")),
ImmutableMap.of("myDefaultKey", "myDefaultVal"));
+            
+            assertEquals(child.config().get(ConfigKeys.newConfigKey(Map.class, "map.type-merged")),
ImmutableMap.of("mykey", "myval"));
+            assertEquals(child.config().get(ConfigKeys.newConfigKey(Map.class, "map.type-overwrite")),
ImmutableMap.of("mykey", "myval"));
+            assertEquals(child.config().get(ConfigKeys.newConfigKey(Map.class, "map.type-never")),
null);
+            assertEquals(child.config().get(ConfigKeys.newConfigKey(Map.class, "map.type-not-reinherited")),
null);
+        }
+        
+        // Test inheritance by child with duplicated keys that have no defaults - does it
get runtime-management parent's defaults?
+        {
+            String yaml = Joiner.on("\n").join(
+                    "services:",
+                    "- type: entity-with-keys",
+                    "  brooklyn.children:",
+                    "  - type: entity-with-keys-dups-no-defaults");
+            
+            Entity app = createStartWaitAndLogApplication(yaml);
+            TestEntity entity = (TestEntity) Iterables.getOnlyElement(app.getChildren());
+            TestEntity child = (TestEntity) Iterables.getOnlyElement(entity.getChildren());
+    
+            // Note this merges the default values from the parent and child (i.e. the child's
default 
+            // value does not override the parent's.
+            assertConfigEquals(child, "map.type-merged", ImmutableMap.of("myDefaultKey",
"myDefaultVal"));
+            assertConfigEquals(child, "map.type-overwrite", ImmutableMap.of("myDefaultKey",
"myDefaultVal"));
+            assertConfigEquals(child, "map.type-never", null);
+            assertConfigEquals(child, "map.type-not-reinherited", null);
+        }
+        
+        // Test inheritance by child with duplicated keys that have no defaults - does it
get runtime-management parent's explicit vals?
+        {
+            String yaml = Joiner.on("\n").join(
+                    "services:",
+                    "- type: entity-with-keys",
+                    "  brooklyn.config:",
+                    "    map.type-merged:",
+                    "      mykey: myval",
+                    "    map.type-overwrite:",
+                    "      mykey: myval",
+                    "    map.type-never:",
+                    "      mykey: myval",
+                    "    map.type-not-reinherited:",
+                    "      mykey: myval",
+                    "  brooklyn.children:",
+                    "  - type: entity-with-keys-dups-no-defaults");
+            
+            Entity app = createStartWaitAndLogApplication(yaml);
+            TestEntity entity = (TestEntity) Iterables.getOnlyElement(app.getChildren());
+            TestEntity child = (TestEntity) Iterables.getOnlyElement(entity.getChildren());
+    
+            
+            assertConfigEquals(child, "map.type-merged", ImmutableMap.of("mykey", "myval"));
+            assertConfigEquals(child, "map.type-overwrite", ImmutableMap.of("mykey", "myval"));
+            assertConfigEquals(child, "map.type-never", null);
+            assertConfigEquals(child, "map.type-not-reinherited", null);
         }
     }
     
@@ -867,4 +992,18 @@ public class ConfigInheritanceYamlTest extends AbstractYamlTest {
         
         EntityAsserts.assertConfigEquals(entity, EmptySoftwareProcess.PROVISIONING_PROPERTIES,
MutableMap.<String, Object>copyOf(expectedProvisioningProps));
     }
+
+    /**
+     * Retrieves a config value using the named key - the key is looked up in two ways:
+     * <ul>
+     *   <li>Lookup the key on the entity (see {@link EntityType#getConfigKey(String)})
+     *   <li>Construct a new untyped key (see {@link ConfigKeys#newConfigKey(Class,
String)})
+     * </ul>
+     */
+    private void assertConfigEquals(Entity entity, String keyName, Object expected) {
+        ConfigKey<?> key1 = entity.getEntityType().getConfigKey(keyName);
+        ConfigKey<?> key2 = ConfigKeys.newConfigKey(Object.class, keyName);
+        assertEquals(entity.config().get(key1), expected, "key="+keyName);
+        assertEquals(entity.config().get(key2), expected, "key="+keyName);
+    }
 }

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/49835acf/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/ConfigParametersYamlTest.java
----------------------------------------------------------------------
diff --git a/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/ConfigParametersYamlTest.java
b/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/ConfigParametersYamlTest.java
index f57c494..e3960d4 100644
--- a/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/ConfigParametersYamlTest.java
+++ b/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/ConfigParametersYamlTest.java
@@ -554,7 +554,7 @@ public class ConfigParametersYamlTest extends AbstractYamlRebindTest {
                 "        type: string",
                 "        default: myDefaultVal",
                 "      brooklyn.config:",
-                "        my.other.key: $brooklyn:config(\"my.param.key\")");
+                "        key2: $brooklyn:config(\"my.param.key\")");
 
         addCatalogItems(
                 "brooklyn.catalog:",
@@ -566,15 +566,26 @@ public class ConfigParametersYamlTest extends AbstractYamlRebindTest
{
                 "      - name: my.param.key",
                 "        type: string",
                 "        default: myDefaultValInOuter",
-                "      type: entity-with-keys");
+                "      type: entity-with-keys",
+                "      brooklyn.config:",
+                "        key3: $brooklyn:config(\"my.param.key\")",
+                "        key3.from.root: $brooklyn:scopeRoot().config(\"my.param.key\")");
         
         String yaml = Joiner.on("\n").join(
                 "services:",
-                "- type: wrapper-entity");
+                "- type: wrapper-entity",
+                "  brooklyn.config:",
+                "    key4: $brooklyn:config(\"my.param.key\")",
+                "    key4.from.root: $brooklyn:scopeRoot().config(\"my.param.key\")");
         
         Entity app = createStartWaitAndLogApplication(yaml);
         final TestEntity entity = (TestEntity) Iterables.getOnlyElement(app.getChildren());
-        assertEquals(entity.config().get(ConfigKeys.newStringConfigKey("my.other.key")),
"myDefaultValInOuter");
+        assertEquals(entity.config().get(ConfigKeys.newStringConfigKey("my.param.key")),
"myDefaultValInOuter");
+        assertEquals(entity.config().get(ConfigKeys.newStringConfigKey("key2")), "myDefaultValInOuter");
+        assertEquals(entity.config().get(ConfigKeys.newStringConfigKey("key3")), "myDefaultValInOuter");
+        assertEquals(entity.config().get(ConfigKeys.newStringConfigKey("key3.from.root")),
"myDefaultValInOuter");
+        assertEquals(entity.config().get(ConfigKeys.newStringConfigKey("key4")), "myDefaultValInOuter");
+        assertEquals(entity.config().get(ConfigKeys.newStringConfigKey("key4.from.root")),
"myDefaultValInOuter");
     }
     
     @Test
@@ -595,7 +606,7 @@ public class ConfigParametersYamlTest extends AbstractYamlRebindTest {
                 "        description: description one",
                 "        default: myDefaultVal",
                 "      brooklyn.config:",
-                "        my.other.key: $brooklyn:config(\"my.param.key\")");
+                "        key2: $brooklyn:config(\"my.param.key\")");
 
         addCatalogItems(
                 "brooklyn.catalog:",
@@ -606,11 +617,18 @@ public class ConfigParametersYamlTest extends AbstractYamlRebindTest
{
                 "      brooklyn.parameters:",
                 "      - name: my.param.key",
                 "        description: description two",
-                "      type: entity-with-keys");
+                "      type: entity-with-keys",
+                "      brooklyn.config:",
+                "        key3: $brooklyn:config(\"my.param.key\")",
+                "        key3.from.root: $brooklyn:scopeRoot().config(\"my.param.key\")");
+
         
         String yaml = Joiner.on("\n").join(
                 "services:",
-                "- type: wrapper-entity");
+                "- type: wrapper-entity",
+                "  brooklyn.config:",
+                "    key4: $brooklyn:config(\"my.param.key\")",
+                "    key4.from.root: $brooklyn:scopeRoot().config(\"my.param.key\")");
         
         Entity app = createStartWaitAndLogApplication(yaml);
         final TestEntity entity = (TestEntity) Iterables.getOnlyElement(app.getChildren());
@@ -618,6 +636,13 @@ public class ConfigParametersYamlTest extends AbstractYamlRebindTest
{
         ConfigKey<?> key = Iterables.getOnlyElement( entity.config().findKeysDeclared(ConfigPredicates.nameEqualTo("my.param.key"))
);
         assertEquals(key.getDescription(), "description two");
         assertEquals(entity.config().get(key), "myDefaultVal");
+        
+        assertEquals(entity.config().get(ConfigKeys.newStringConfigKey("my.param.key")),
"myDefaultVal");
+        assertEquals(entity.config().get(ConfigKeys.newStringConfigKey("key2")), "myDefaultVal");
+        assertEquals(entity.config().get(ConfigKeys.newStringConfigKey("key3")), "myDefaultVal");
+        assertEquals(entity.config().get(ConfigKeys.newStringConfigKey("key3.from.root")),
"myDefaultVal");
+        assertEquals(entity.config().get(ConfigKeys.newStringConfigKey("key4")), "myDefaultVal");
+        assertEquals(entity.config().get(ConfigKeys.newStringConfigKey("key4.from.root")),
"myDefaultVal");
     }
     
     @Test

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/49835acf/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/SpecParameterUnwrappingTest.java
----------------------------------------------------------------------
diff --git a/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/SpecParameterUnwrappingTest.java
b/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/SpecParameterUnwrappingTest.java
index cf2097f..f9f456c 100644
--- a/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/SpecParameterUnwrappingTest.java
+++ b/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/SpecParameterUnwrappingTest.java
@@ -176,13 +176,13 @@ public class SpecParameterUnwrappingTest extends AbstractYamlTest {
         AbstractBrooklynObjectSpec<?,?> spec = catalog.peekSpec(item);
         List<SpecParameter<?>> params = spec.getParameters();
         // should have simple in parent yaml type and sample from parent java type
-        Asserts.assertSize(params, getDefaultsFor(type.getSimpleName()) + 2);
+        Asserts.assertSize(params, getNumDefaultConfigKeysFor(type.getSimpleName()) + 2);
         assertTrue(Iterables.tryFind(params, nameEqualTo("simple")).isPresent());
         assertTrue(Iterables.tryFind(params, labelEqualTo("simple")).isPresent());
         assertTrue(Iterables.tryFind(params, nameEqualTo(SHARED_CONFIG.getName())).isPresent());
     }
 
-    private int getDefaultsFor(String simpleName) {
+    private int getNumDefaultConfigKeysFor(String simpleName) {
         switch (simpleName) {
         case "ConfigEntityForTest":
             return NUM_ENTITY_DEFAULT_CONFIG_KEYS;
@@ -216,7 +216,7 @@ public class SpecParameterUnwrappingTest extends AbstractYamlTest {
         AbstractBrooklynObjectSpec<?,?> spec = catalog.peekSpec(item);
         List<SpecParameter<?>> params = spec.getParameters();
         // should have override locally, simple in parent yaml type, and sample from parent
java type
-        Asserts.assertSize(params, getDefaultsFor(type.getSimpleName()) + 3);
+        Asserts.assertSize(params, getNumDefaultConfigKeysFor(type.getSimpleName()) + 3);
         assertTrue(Iterables.tryFind(params, nameEqualTo("simple")).isPresent());
         assertTrue(Iterables.tryFind(params, nameEqualTo("override")).isPresent());
     }
@@ -244,7 +244,7 @@ public class SpecParameterUnwrappingTest extends AbstractYamlTest {
         AbstractBrooklynObjectSpec<?,?> spec = catalog.peekSpec(item);
         List<SpecParameter<?>> params = spec.getParameters();
         // should have simple locally (and in parent yaml type) and sample from parent java
type
-        Asserts.assertSize(params, getDefaultsFor(type.getSimpleName()) + 2);
+        Asserts.assertSize(params, getNumDefaultConfigKeysFor(type.getSimpleName()) + 2);
         assertTrue(Iterables.tryFind(params, nameEqualTo("simple")).isPresent());
         assertTrue(Iterables.tryFind(params, labelEqualTo("override")).isPresent());
     }

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/49835acf/core/src/main/java/org/apache/brooklyn/core/config/BasicConfigInheritance.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/config/BasicConfigInheritance.java
b/core/src/main/java/org/apache/brooklyn/core/config/BasicConfigInheritance.java
index 221263f..943c9b1 100644
--- a/core/src/main/java/org/apache/brooklyn/core/config/BasicConfigInheritance.java
+++ b/core/src/main/java/org/apache/brooklyn/core/config/BasicConfigInheritance.java
@@ -169,7 +169,7 @@ public class BasicConfigInheritance implements ConfigInheritance {
      * if a key is not defined at an ancestor, a descendant setting this value false will
not prevent it 
      * from inheriting values from ancestors.
      * <p> 
-     * typical use case for setting this is false is where a key is consumed and descendants
should not
+     * typical use case for setting this to false is where a key is consumed and descendants
should not
      * "reconsume" it.  for example setting files to install on a VM need only be applied
once,
      * and if it has <b>runtime management</b> hierarchy descendants which also
understand that field they
      * should not install the same files. 


Mime
View raw message