brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From grk...@apache.org
Subject [1/3] brooklyn-server git commit: Added test for entitySpec default usage in YAML parameters
Date Mon, 29 Aug 2016 10:52:09 GMT
Repository: brooklyn-server
Updated Branches:
  refs/heads/master 196ce93a6 -> b70841f72


Added test for entitySpec default usage in YAML parameters


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

Branch: refs/heads/master
Commit: 94ec61dd0d5a8e1e197aa3bf2b7c8947964c3077
Parents: 874fa26
Author: Andrew Donald Kennedy <andrew.kennedy@cloudsoftcorp.com>
Authored: Fri Aug 12 02:53:17 2016 +0100
Committer: Andrew Donald Kennedy <andrew.kennedy@cloudsoftcorp.com>
Committed: Mon Aug 29 11:51:23 2016 +0100

----------------------------------------------------------------------
 .../camp/brooklyn/ConfigParametersYamlTest.java | 51 +++++++++++++++++---
 1 file changed, 43 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/94ec61dd/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 f187b6c..623ff16 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
@@ -20,31 +20,35 @@ package org.apache.brooklyn.camp.brooklyn;
 
 import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
 
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import com.google.api.client.repackaged.com.google.common.base.Joiner;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Iterables;
+
 import org.apache.brooklyn.api.entity.Entity;
+import org.apache.brooklyn.api.entity.EntitySpec;
 import org.apache.brooklyn.api.location.PortRange;
 import org.apache.brooklyn.config.ConfigKey;
 import org.apache.brooklyn.core.config.ConfigKeys;
 import org.apache.brooklyn.core.test.entity.TestEntity;
 import org.apache.brooklyn.entity.software.base.VanillaSoftwareProcess;
+import org.apache.brooklyn.entity.stock.BasicApplication;
 import org.apache.brooklyn.test.Asserts;
 import org.apache.brooklyn.util.collections.MutableList;
 import org.apache.brooklyn.util.core.internal.ssh.ExecCmdAsserts;
 import org.apache.brooklyn.util.core.internal.ssh.RecordingSshTool;
 import org.apache.brooklyn.util.core.internal.ssh.RecordingSshTool.ExecCmd;
 import org.apache.brooklyn.util.time.Duration;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import com.google.api.client.repackaged.com.google.common.base.Joiner;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Iterables;
 
 public class ConfigParametersYamlTest extends AbstractYamlTest {
     @SuppressWarnings("unused")
@@ -398,4 +402,35 @@ public class ConfigParametersYamlTest extends AbstractYamlTest {
             assertEquals(entity.getEntityType().getConfigKey(keyName).getType(), entry.getValue());
         }
     }
+
+    @Test
+    public void testConfigParameterWithEntitySpecAsDefault() throws Exception {
+        addCatalogItems(
+                "brooklyn.catalog:",
+                "  itemType: entity",
+                "  items:",
+                "  - id: entity-with-keys",
+                "    item:",
+                "      type: "+TestEntity.class.getName(),
+                "      brooklyn.parameters:",
+                "      - name: my.param.key",
+                "        type: "+EntitySpec.class.getName(),
+                "        default: ",
+                "          $brooklyn:entitySpec:",
+                "          - type: "+BasicApplication.class.getName());
+
+        String yaml = Joiner.on("\n").join(
+                "services:",
+                "- type: entity-with-keys");
+
+        Entity app = createStartWaitAndLogApplication(yaml);
+        TestEntity entity = (TestEntity) Iterables.getOnlyElement(app.getChildren());
+
+        Object defaultVal = entity.config().get(entity.getEntityType().getConfigKey("my.param.key"));
+        assertTrue(defaultVal instanceof EntitySpec, "defaultVal="+defaultVal);
+        assertEquals(((EntitySpec<?>)defaultVal).getType(), BasicApplication.class,
"defaultVal="+defaultVal);
+
+        Entity child = entity.addChild((EntitySpec<?>)defaultVal);
+        assertTrue(child instanceof BasicApplication, "child="+child);
+    }
 }


Mime
View raw message