brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject [2/5] brooklyn-server git commit: add similar tests, including one failing, isolating the error
Date Thu, 09 Mar 2017 15:45:57 GMT
add similar tests, including one failing, isolating the error


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

Branch: refs/heads/master
Commit: edaf05441ee46d05e4479a79aee055e6cbfe1237
Parents: d7cbaee
Author: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Authored: Tue Feb 28 12:44:17 2017 +0000
Committer: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Committed: Tue Feb 28 12:44:17 2017 +0000

----------------------------------------------------------------------
 .../camp/brooklyn/ConfigParametersYamlTest.java | 83 ++++++++++++++++++++
 1 file changed, 83 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/edaf0544/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 6e2d899..c26c3e5 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
@@ -23,14 +23,17 @@ import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertNotNull;
 import static org.testng.Assert.assertTrue;
 
+import java.util.Collections;
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.Callable;
 
 import org.apache.brooklyn.api.entity.Entity;
 import org.apache.brooklyn.api.entity.EntitySpec;
 import org.apache.brooklyn.api.entity.ImplementedBy;
 import org.apache.brooklyn.api.internal.AbstractBrooklynObjectSpec;
+import org.apache.brooklyn.api.location.Location;
 import org.apache.brooklyn.api.location.PortRange;
 import org.apache.brooklyn.camp.brooklyn.catalog.SpecParameterUnwrappingTest;
 import org.apache.brooklyn.config.ConfigKey;
@@ -40,6 +43,7 @@ import org.apache.brooklyn.core.config.ConfigPredicates;
 import org.apache.brooklyn.core.config.ConstraintViolationException;
 import org.apache.brooklyn.core.entity.AbstractEntity;
 import org.apache.brooklyn.core.entity.BrooklynConfigKeys;
+import org.apache.brooklyn.core.entity.Entities;
 import org.apache.brooklyn.core.location.PortRanges;
 import org.apache.brooklyn.core.sensor.Sensors;
 import org.apache.brooklyn.core.test.entity.TestEntity;
@@ -792,6 +796,85 @@ public class ConfigParametersYamlTest extends AbstractYamlRebindTest
{
     }
     
     @Test
+    public void testManuallyAddSpec() throws Exception {
+        String yaml = Joiner.on("\n").join(
+                "services:",
+                "- type: "+TestEntity.class.getName());
+
+        Entity app = createStartWaitAndLogApplication(yaml);
+        TestEntity entity1 = (TestEntity) Iterables.getOnlyElement(app.getChildren());
+
+        TestEntity entity2 = entity1.addChild(EntitySpec.create(TestEntity.class));
+        entity2.start(Collections.<Location>emptyList());
+        
+        Entities.dumpInfo(app);
+        
+        LOG.info("E1 keys: "+entity1.getEntityType().getConfigKeys());
+        LOG.info("E2 keys: "+entity2.getEntityType().getConfigKeys());
+        Assert.assertEquals(entity2.getEntityType().getConfigKeys(), entity1.getEntityType().getConfigKeys());
+    }
+    
+    @Test
+    public void testManuallyAddSpecFromCatalog() throws Exception {
+        addCatalogItems(
+            "brooklyn.catalog:",
+            "  itemType: entity",
+            "  items:",
+            "  - id: test-entity",
+            "    item:",
+            "      type: "+TestEntity.class.getName());
+        
+        String yaml = Joiner.on("\n").join(
+                "services:",
+                "- type: test-entity");
+
+        Entity app = createStartWaitAndLogApplication(yaml);
+        TestEntity entity1 = (TestEntity) Iterables.getOnlyElement(app.getChildren());
+
+        TestEntity entity2 = entity1.addChild(EntitySpec.create(TestEntity.class));
+        entity2.start(Collections.<Location>emptyList());
+        
+        Entities.dumpInfo(app);
+        
+        LOG.info("E1 keys: "+entity1.getEntityType().getConfigKeys());
+        LOG.info("E2 keys: "+entity2.getEntityType().getConfigKeys());
+        Assert.assertEquals(entity2.getEntityType().getConfigKeys(), entity1.getEntityType().getConfigKeys());
+    }
+    
+
+    @Test
+    public void testManuallyAddSpecInTaskOfOtherEntity() throws Exception {
+        addCatalogItems(
+            "brooklyn.catalog:",
+            "  itemType: entity",
+            "  items:",
+            "  - id: test-entity",
+            "    item:",
+            "      type: "+TestEntity.class.getName());
+        
+        String yaml = Joiner.on("\n").join(
+                "services:",
+                "- type: test-entity");
+
+        Entity app = createStartWaitAndLogApplication(yaml);
+        final TestEntity entity1 = (TestEntity) Iterables.getOnlyElement(app.getChildren());
+
+        TestEntity entity2 = entity1.getExecutionContext().submit(new Callable<TestEntity>()
{
+            public TestEntity call() {
+                TestEntity entity2 = entity1.addChild(EntitySpec.create(TestEntity.class));
+                entity2.start(Collections.<Location>emptyList());
+                return entity2;
+            } 
+        }).get();
+        
+        Entities.dumpInfo(app);
+        
+        LOG.info("E1 keys: "+entity1.getEntityType().getConfigKeys());
+        LOG.info("E2 keys: "+entity2.getEntityType().getConfigKeys());
+        Assert.assertEquals(entity2.getEntityType().getConfigKeys(), entity1.getEntityType().getConfigKeys());
+    }
+    
+    @Test
     public void testPortSetAsAttributeOnSoftwareProcess() throws Exception {
         addCatalogItems(
                 "brooklyn.catalog:",


Mime
View raw message