You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by sv...@apache.org on 2016/07/25 08:20:43 UTC

[1/3] brooklyn-server git commit: Set properties of target entity for use in tests

Repository: brooklyn-server
Updated Branches:
  refs/heads/master 9077ade06 -> 840150c53


Set properties of target entity for use in tests


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

Branch: refs/heads/master
Commit: 9a31d8ac76ea3df9df5233a2a68a1df8aa89a719
Parents: fad2435
Author: Andrew Donald Kennedy <an...@cloudsoftcorp.com>
Authored: Mon Jul 18 13:26:32 2016 +0100
Committer: Andrew Donald Kennedy <an...@cloudsoftcorp.com>
Committed: Thu Jul 21 10:52:12 2016 +0100

----------------------------------------------------------------------
 .../brooklyn/test/framework/TargetableTestComponent.java       | 6 ++++++
 .../brooklyn/test/framework/TargetableTestComponentImpl.java   | 3 +++
 2 files changed, 9 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/9a31d8ac/test-framework/src/main/java/org/apache/brooklyn/test/framework/TargetableTestComponent.java
----------------------------------------------------------------------
diff --git a/test-framework/src/main/java/org/apache/brooklyn/test/framework/TargetableTestComponent.java b/test-framework/src/main/java/org/apache/brooklyn/test/framework/TargetableTestComponent.java
index 7280ef1..70edfbe 100644
--- a/test-framework/src/main/java/org/apache/brooklyn/test/framework/TargetableTestComponent.java
+++ b/test-framework/src/main/java/org/apache/brooklyn/test/framework/TargetableTestComponent.java
@@ -20,10 +20,12 @@ package org.apache.brooklyn.test.framework;
 
 import org.apache.brooklyn.api.entity.Entity;
 import org.apache.brooklyn.api.entity.ImplementedBy;
+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.entity.trait.Startable;
 import org.apache.brooklyn.core.sensor.AttributeSensorAndConfigKey;
+import org.apache.brooklyn.core.sensor.Sensors;
 import org.apache.brooklyn.util.time.Duration;
 
 /**
@@ -55,6 +57,10 @@ public interface TargetableTestComponent extends Entity, Startable {
             "Time to wait for targetId to exist (defaults to zero, i.e. must exist immediately)",
             Duration.ZERO);
 
+    AttributeSensor<String> TARGET_ENTITY_ID = Sensors.newStringSensor("test.target.entity.id", "Id of the target entity");
+    AttributeSensor<String> TARGET_ENTITY_NAME = Sensors.newStringSensor("test.target.entity.name", "Display name of the target entity");
+    AttributeSensor<String> TARGET_ENTITY_TYPE = Sensors.newStringSensor("test.target.entity.type", "Type of the target entity");
+
     /**
      * Get the target of the test.
      *

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/9a31d8ac/test-framework/src/main/java/org/apache/brooklyn/test/framework/TargetableTestComponentImpl.java
----------------------------------------------------------------------
diff --git a/test-framework/src/main/java/org/apache/brooklyn/test/framework/TargetableTestComponentImpl.java b/test-framework/src/main/java/org/apache/brooklyn/test/framework/TargetableTestComponentImpl.java
index 0d59507..9e279a2 100644
--- a/test-framework/src/main/java/org/apache/brooklyn/test/framework/TargetableTestComponentImpl.java
+++ b/test-framework/src/main/java/org/apache/brooklyn/test/framework/TargetableTestComponentImpl.java
@@ -56,6 +56,9 @@ public abstract class TargetableTestComponentImpl extends AbstractEntity impleme
     public Entity resolveTarget() {
         Entity target = resolveTarget(getExecutionContext(), this);
         sensors().set(TARGET_ENTITY, target);
+        sensors().set(TARGET_ENTITY_ID, target.getId());
+        sensors().set(TARGET_ENTITY_NAME, target.getDisplayName());
+        sensors().set(TARGET_ENTITY_TYPE, target.getEntityType().getName());
         return target;
     }
 


[2/3] brooklyn-server git commit: Set the TARGET sensor with resolved test entity

Posted by sv...@apache.org.
Set the TARGET sensor with resolved test entity


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

Branch: refs/heads/master
Commit: fad2435d4d4f2ca7b6d41bd723e1738dc0b4e13f
Parents: b87c20b
Author: Andrew Donald Kennedy <an...@cloudsoftcorp.com>
Authored: Mon Jul 18 13:28:34 2016 +0100
Committer: Andrew Donald Kennedy <an...@cloudsoftcorp.com>
Committed: Thu Jul 21 10:52:12 2016 +0100

----------------------------------------------------------------------
 .../test/framework/TargetableTestComponent.java     | 16 ++++++++++------
 .../test/framework/TargetableTestComponentImpl.java | 15 ++++++++++-----
 2 files changed, 20 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/fad2435d/test-framework/src/main/java/org/apache/brooklyn/test/framework/TargetableTestComponent.java
----------------------------------------------------------------------
diff --git a/test-framework/src/main/java/org/apache/brooklyn/test/framework/TargetableTestComponent.java b/test-framework/src/main/java/org/apache/brooklyn/test/framework/TargetableTestComponent.java
index 5ea28cb..7280ef1 100644
--- a/test-framework/src/main/java/org/apache/brooklyn/test/framework/TargetableTestComponent.java
+++ b/test-framework/src/main/java/org/apache/brooklyn/test/framework/TargetableTestComponent.java
@@ -27,20 +27,24 @@ import org.apache.brooklyn.core.sensor.AttributeSensorAndConfigKey;
 import org.apache.brooklyn.util.time.Duration;
 
 /**
- * Entity that can target another entity for the purpouse of testing
+ * Entity that can target another entity for the purpose of testing
  */
 @ImplementedBy(value = TargetableTestComponentImpl.class)
 public interface TargetableTestComponent extends Entity, Startable {
 
     /**
-     * The target entity to test (optional, use either this or targetId).
+     * The target entity to test. Optional, use either this or
+     * {@link #TARGET_ID targetId}. If both are set then this
+     * will take precedence.
      */
     AttributeSensorAndConfigKey<Entity, Entity> TARGET_ENTITY = ConfigKeys.newSensorAndConfigKey(Entity.class, "target", "Entity under test");
 
     /**
-     * Id of the target entity to test (optional, use either this or target).
+     * Id of the target entity to test.
+     *
+     * @see {@link #TARGET_ENTITY target}.
      */
-    AttributeSensorAndConfigKey<String, String> TARGET_ID = ConfigKeys.newStringSensorAndConfigKey("targetId", "Id of the entity under test");
+    ConfigKey<String> TARGET_ID = ConfigKeys.newStringConfigKey("targetId", "Id of the entity under test");
 
     /**
      * The duration to wait for an entity with the given targetId to exist, before throwing an exception.
@@ -54,8 +58,8 @@ public interface TargetableTestComponent extends Entity, Startable {
     /**
      * Get the target of the test.
      *
-     * @return The target.
-     * @throws IllegalArgumentException if the target cannot be found.
+     * @return The target entity
+     * @throws {@link IllegalArgumentException} if the target cannot be found
      */
     Entity resolveTarget();
 

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/fad2435d/test-framework/src/main/java/org/apache/brooklyn/test/framework/TargetableTestComponentImpl.java
----------------------------------------------------------------------
diff --git a/test-framework/src/main/java/org/apache/brooklyn/test/framework/TargetableTestComponentImpl.java b/test-framework/src/main/java/org/apache/brooklyn/test/framework/TargetableTestComponentImpl.java
index 4750b4d..0d59507 100644
--- a/test-framework/src/main/java/org/apache/brooklyn/test/framework/TargetableTestComponentImpl.java
+++ b/test-framework/src/main/java/org/apache/brooklyn/test/framework/TargetableTestComponentImpl.java
@@ -44,14 +44,19 @@ public abstract class TargetableTestComponentImpl extends AbstractEntity impleme
     private static final Logger LOG = LoggerFactory.getLogger(TargetableTestComponentImpl.class);
 
     /**
-     * Find the target entity using "target" config key, if entity provided directly in config, or by doing an implicit
-     * lookup using DSL ($brooklyn:component("myNginX")), if id of entity provided as "targetId" config key.
+     * Find the target entity using the {@link #TARGET target} config key value,
+     * or by doing an implicit lookup using the equivalent of the DSL code
+     * {@code $brooklyn:entity("targetId")} if the id of an entity was
+     * provided as the {@link #TARGET_ID targetId} config key value.
      *
-     * @return The target entity.
-     * @throws @RuntimeException if no target can be determined.
+     * @return The target entity
+     * @throws {@link RuntimeException} if no target can be determined
      */
+    @Override
     public Entity resolveTarget() {
-        return resolveTarget(getExecutionContext(), this);
+        Entity target = resolveTarget(getExecutionContext(), this);
+        sensors().set(TARGET_ENTITY, target);
+        return target;
     }
 
     /**


[3/3] brooklyn-server git commit: Closes #261

Posted by sv...@apache.org.
Closes #261

Test target sensor set from targetId


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

Branch: refs/heads/master
Commit: 840150c53c653fe8819632094457a58c5502bcf4
Parents: 9077ade 9a31d8a
Author: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Authored: Mon Jul 25 11:20:29 2016 +0300
Committer: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Committed: Mon Jul 25 11:20:29 2016 +0300

----------------------------------------------------------------------
 .../test/framework/TargetableTestComponent.java | 22 ++++++++++++++------
 .../framework/TargetableTestComponentImpl.java  | 18 +++++++++++-----
 2 files changed, 29 insertions(+), 11 deletions(-)
----------------------------------------------------------------------