You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by he...@apache.org on 2015/11/11 18:21:43 UTC

[16/21] incubator-brooklyn git commit: Ammended [TestEffector, TestHttpCall, TestSensor] so that they no longer allow children

Ammended [TestEffector,TestHttpCall,TestSensor] so that they no longer allow children

If the entities are found to have children an exception is thrown


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

Branch: refs/heads/master
Commit: d6c455c1454839fbf51329f65887fb3ce4d89d39
Parents: 4cb5330
Author: Mark McKenna <m4...@gmail.com>
Authored: Wed Nov 11 13:12:40 2015 +0000
Committer: Mark McKenna <m4...@gmail.com>
Committed: Wed Nov 11 13:12:40 2015 +0000

----------------------------------------------------------------------
 .../test/framework/TestEffectorImpl.java         | 19 +++----------------
 .../test/framework/TestHttpCallImpl.java         |  3 +++
 .../brooklyn/test/framework/TestSensorImpl.java  | 12 +++---------
 3 files changed, 9 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/d6c455c1/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestEffectorImpl.java
----------------------------------------------------------------------
diff --git a/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestEffectorImpl.java b/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestEffectorImpl.java
index 442797e..f2c0f51 100644
--- a/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestEffectorImpl.java
+++ b/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestEffectorImpl.java
@@ -8,7 +8,6 @@ import org.apache.brooklyn.api.mgmt.Task;
 import org.apache.brooklyn.core.entity.Entities;
 import org.apache.brooklyn.core.entity.lifecycle.Lifecycle;
 import org.apache.brooklyn.core.entity.lifecycle.ServiceStateLogic;
-import org.apache.brooklyn.core.entity.trait.Startable;
 import org.apache.brooklyn.core.mgmt.internal.EffectorUtils;
 import org.apache.brooklyn.util.exceptions.Exceptions;
 import org.apache.brooklyn.util.guava.Maybe;
@@ -30,6 +29,9 @@ public class TestEffectorImpl extends AbstractTest implements TestEffector {
      * {@inheritDoc}
      */
     public void start(Collection<? extends Location> locations) {
+        if (!getChildren().isEmpty()) {
+            throw new RuntimeException(String.format("The entity [%s] cannot have child entities", getClass().getName()));
+        }
         ServiceStateLogic.setExpectedState(this, Lifecycle.STARTING);
         final Entity targetEntity = resolveTarget();
         final String effectorName = getConfig(EFFECTOR_NAME);
@@ -46,14 +48,8 @@ public class TestEffectorImpl extends AbstractTest implements TestEffector {
             } else {
                 effectorResult = Entities.invokeEffector(this, targetEntity, effector.get(), effectorParams);
             }
-
             //Add result of effector to sensor
             sensors().set(EFFECTOR_RESULT, effectorResult.get(timeout));
-
-            //Start Children
-            for (Entity childEntity : getChildren()) {
-                if (childEntity instanceof Startable) ((Startable) childEntity).start(locations);
-            }
             sensors().set(SERVICE_UP, true);
             ServiceStateLogic.setExpectedState(this, Lifecycle.RUNNING);
         } catch (Throwable t) {
@@ -69,15 +65,6 @@ public class TestEffectorImpl extends AbstractTest implements TestEffector {
     public void stop() {
         ServiceStateLogic.setExpectedState(this, Lifecycle.STOPPING);
         sensors().set(SERVICE_UP, false);
-        try {
-            for (Entity child : getChildren()) {
-                if (child instanceof Startable) ((Startable) child).stop();
-            }
-            ServiceStateLogic.setExpectedState(this, Lifecycle.STOPPED);
-        } catch (Exception e) {
-            ServiceStateLogic.setExpectedState(this, Lifecycle.ON_FIRE);
-            throw Exceptions.propagate(e);
-        }
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/d6c455c1/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestHttpCallImpl.java
----------------------------------------------------------------------
diff --git a/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestHttpCallImpl.java b/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestHttpCallImpl.java
index 1b0b3a6..dad5e97 100644
--- a/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestHttpCallImpl.java
+++ b/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestHttpCallImpl.java
@@ -28,6 +28,9 @@ public class TestHttpCallImpl extends AbstractTest implements TestHttpCall {
      * {@inheritDoc}
      */
     public void start(Collection<? extends Location> locations) {
+        if (!getChildren().isEmpty()) {
+            throw new RuntimeException(String.format("The entity [%s] cannot have child entities", getClass().getName()));
+        }
         ServiceStateLogic.setExpectedState(this, Lifecycle.STARTING);
         final String url = getConfig(TARGET_URL);
         final Map assertions = getConfig(ASSERTIONS);

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/d6c455c1/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestSensorImpl.java
----------------------------------------------------------------------
diff --git a/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestSensorImpl.java b/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestSensorImpl.java
index 94151c6..0e1cefc 100644
--- a/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestSensorImpl.java
+++ b/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestSensorImpl.java
@@ -34,6 +34,9 @@ public class TestSensorImpl extends AbstractTest implements TestSensor {
      * {@inheritDoc}
      */
     public void start(Collection<? extends Location> locations) {
+        if (!getChildren().isEmpty()) {
+            throw new RuntimeException(String.format("The entity [%s] cannot have child entities", getClass().getName()));
+        }
         ServiceStateLogic.setExpectedState(this, Lifecycle.STARTING);
         final Entity target = resolveTarget();
         final String sensor = getConfig(SENSOR_NAME);
@@ -78,15 +81,6 @@ public class TestSensorImpl extends AbstractTest implements TestSensor {
     public void stop() {
         ServiceStateLogic.setExpectedState(this, Lifecycle.STOPPING);
         sensors().set(SERVICE_UP, false);
-        try {
-            for (Entity child : getChildren()) {
-                if (child instanceof Startable) ((Startable) child).stop();
-            }
-            ServiceStateLogic.setExpectedState(this, Lifecycle.STOPPED);
-        } catch (Exception e) {
-            ServiceStateLogic.setExpectedState(this, Lifecycle.ON_FIRE);
-            throw Exceptions.propagate(e);
-        }
     }
 
     /**