You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by al...@apache.org on 2016/11/10 14:22:19 UTC

[1/2] brooklyn-server git commit: Adds ConfigYamlTest.testConfigAtTopLevel

Repository: brooklyn-server
Updated Branches:
  refs/heads/master d6f2c569e -> db21f6a69


Adds ConfigYamlTest.testConfigAtTopLevel


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

Branch: refs/heads/master
Commit: 76a461581aeac1ce627909e039e7a614d31162d7
Parents: fd00978
Author: Aled Sage <al...@gmail.com>
Authored: Tue Nov 8 21:29:18 2016 +0000
Committer: Aled Sage <al...@gmail.com>
Committed: Tue Nov 8 21:30:31 2016 +0000

----------------------------------------------------------------------
 .../brooklyn/camp/brooklyn/ConfigYamlTest.java  | 45 ++++++++++++++++++++
 1 file changed, 45 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/76a46158/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/ConfigYamlTest.java
----------------------------------------------------------------------
diff --git a/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/ConfigYamlTest.java b/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/ConfigYamlTest.java
index 02d7b80..8f9f0e0 100644
--- a/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/ConfigYamlTest.java
+++ b/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/ConfigYamlTest.java
@@ -19,6 +19,7 @@
 package org.apache.brooklyn.camp.brooklyn;
 
 import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNull;
 import static org.testng.Assert.assertTrue;
 
 import java.util.concurrent.Callable;
@@ -26,6 +27,7 @@ import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 
 import org.apache.brooklyn.api.entity.Entity;
+import org.apache.brooklyn.core.config.ConfigKeys;
 import org.apache.brooklyn.core.sensor.Sensors;
 import org.apache.brooklyn.core.test.entity.TestEntity;
 import org.slf4j.Logger;
@@ -63,6 +65,49 @@ public class ConfigYamlTest extends AbstractYamlTest {
     }
 
     @Test
+    public void testConfigInConfigBlock() throws Exception {
+        String yaml = Joiner.on("\n").join(
+                "services:",
+                "- type: org.apache.brooklyn.core.test.entity.TestEntity",
+                "  brooklyn.config:",
+                "    test.confName: myName",
+                "    test.confObject: myObj",
+                "    test.confDynamic: myDynamic");
+
+        final Entity app = createStartWaitAndLogApplication(yaml);
+        TestEntity entity = (TestEntity) Iterables.getOnlyElement(app.getChildren());
+     
+        assertEquals(entity.config().get(TestEntity.CONF_NAME), "myName"); // confName has @SetFromFlag
+        assertEquals(entity.config().get(TestEntity.CONF_OBJECT), "myObj"); // confObject does not have @SetFromFlag
+        assertEquals(entity.config().get(ConfigKeys.newStringConfigKey("test.confDynamic")), "myDynamic"); // not defined on entity
+    }
+
+    @Test
+    public void testConfigAtTopLevel() throws Exception {
+        // This style is discouraged - instead use a "brooklyn.config:" block.
+        // However, it's important we don't break this as blueprints in the wild rely on it!
+        String yaml = Joiner.on("\n").join(
+                "services:",
+                "- type: org.apache.brooklyn.core.test.entity.TestEntity",
+                "  test.confName: myName",
+                "  test.confObject: myObj",
+                "  test.confDynamic: myDynamic");
+
+        final Entity app = createStartWaitAndLogApplication(yaml);
+        TestEntity entity = (TestEntity) Iterables.getOnlyElement(app.getChildren());
+     
+        assertEquals(entity.config().get(TestEntity.CONF_NAME), "myName"); // confName has @SetFromFlag
+        assertEquals(entity.config().get(TestEntity.CONF_OBJECT), "myObj"); // confObject does not have @SetFromFlag
+        
+        // The "dynamic" config key (i.e. not defined on the entity's type) is not picked up to 
+        // be set on the entity if it's not inside the "brooklyn.config" block. This isn't exactly
+        // desired behaviour, but it is what happens! This test is more to demonstrate the behaviour
+        // than to say it is definitely what we want! But like the comment at the start of the 
+        // method says, this style is discouraged so we don't really care.
+        assertNull(entity.config().get(ConfigKeys.newStringConfigKey("test.confDynamic"))); // not defined on entity
+    }
+
+    @Test
     public void testPlainCollections() throws Exception {
         String yaml = Joiner.on("\n").join(
                 "services:",


[2/2] brooklyn-server git commit: This closes #418

Posted by al...@apache.org.
This closes #418


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

Branch: refs/heads/master
Commit: db21f6a69644d81900601925fe21f85865116328
Parents: d6f2c56 76a4615
Author: Aled Sage <al...@gmail.com>
Authored: Thu Nov 10 14:22:06 2016 +0000
Committer: Aled Sage <al...@gmail.com>
Committed: Thu Nov 10 14:22:06 2016 +0000

----------------------------------------------------------------------
 .../brooklyn/camp/brooklyn/ConfigYamlTest.java  | 45 ++++++++++++++++++++
 1 file changed, 45 insertions(+)
----------------------------------------------------------------------