Repository: brooklyn-server
Updated Branches:
  refs/heads/master c5fc588c3 -> 8ad5578c1


Adds test for catalog-effector from OSGi bundle

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

Branch: refs/heads/master
Commit: d893d529bccb2cea3b4511a4409a378d2253b8be
Parents: 494ae6f
Author: Aled Sage <aled.s...@gmail.com>
Authored: Thu Jan 19 12:37:42 2017 +0000
Committer: Aled Sage <aled.s...@gmail.com>
Committed: Thu Jan 19 12:37:42 2017 +0000

----------------------------------------------------------------------
 .../CatalogOsgiVersionMoreEntityRebindTest.java | 41 ++++++++++++++++++++
 1 file changed, 41 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d893d529/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogOsgiVersionMoreEntityRebindTest.java
----------------------------------------------------------------------
diff --git 
a/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogOsgiVersionMoreEntityRebindTest.java
 
b/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogOsgiVersionMoreEntityRebindTest.java
index b4af697..cee7a4d 100644
--- 
a/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogOsgiVersionMoreEntityRebindTest.java
+++ 
b/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogOsgiVersionMoreEntityRebindTest.java
@@ -20,6 +20,7 @@ package org.apache.brooklyn.camp.brooklyn.catalog;
 
 import static org.testng.Assert.assertEquals;
 
+import org.apache.brooklyn.api.effector.Effector;
 import org.apache.brooklyn.api.entity.Entity;
 import org.apache.brooklyn.api.location.Location;
 import org.apache.brooklyn.api.location.LocationSpec;
@@ -39,6 +40,7 @@ import org.slf4j.LoggerFactory;
 import org.testng.annotations.Test;
 
 import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.Iterables;
 
 /** Many of the same tests as per {@link OsgiVersionMoreEntityTest} but using 
YAML for catalog and entities, so catalog item ID is set automatically */
@@ -128,4 +130,43 @@ public class CatalogOsgiVersionMoreEntityRebindTest 
extends AbstractYamlRebindTe
         Location newLoc = Iterables.getOnlyElement(newEntity.getLocations());
         assertEquals(newLoc.getClass().getName(), locationType);
     }
+    
+    @Test
+    public void testEffectorInBundleReferencedByStockCatalogItem() throws 
Exception {
+        
TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), 
OsgiTestResources.BROOKLYN_TEST_OSGI_ENTITIES_COM_EXAMPLE_PATH);
+        
+        String effectorType = 
OsgiTestResources.BROOKLYN_TEST_OSGI_ENTITIES_COM_EXAMPLE_EFFECTOR;
+        
+        addCatalogItems(
+                "brooklyn.catalog:",
+                "  id: wrapped-entity",
+                "  version: 1.0",
+                "  item:",
+                "    services:",
+                "    - type: " + TestEntity.class.getName());
+    
+        addCatalogItems(
+                "brooklyn.catalog:",
+                "  id: with-effector-from-library",
+                "  version: 1.0",
+                "  brooklyn.libraries:",
+                "  - classpath:" + 
OsgiTestResources.BROOKLYN_TEST_OSGI_ENTITIES_COM_EXAMPLE_PATH,
+                "  item:",
+                "    services:",
+                "    - type: " + BasicApplication.class.getName(),
+                "      brooklyn.children:",
+                "      - type: wrapped-entity:1.0",
+                "        brooklyn.initializers:",
+                "        - type: " + effectorType);
+
+        Entity app = createAndStartApplication("services: [ { type: 
'with-effector-from-library:1.0' } ]");
+        Entity entity = Iterables.getOnlyElement(app.getChildren());
+        Effector<?> effector = 
entity.getEntityType().getEffectorByName("myEffector").get();
+        entity.invoke(effector, ImmutableMap.<String, Object>of()).get();
+        
+        StartableApplication newApp = rebind();
+        Entity newEntity = Iterables.getOnlyElement(newApp.getChildren());
+        Effector<?> newEffector = 
newEntity.getEntityType().getEffectorByName("myEffector").get();
+        newEntity.invoke(newEffector, ImmutableMap.<String, Object>of()).get();
+    }
 }

Reply via email to