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:28 UTC

[01/21] incubator-brooklyn git commit: added timeout to HTTPCall assertions

Repository: incubator-brooklyn
Updated Branches:
  refs/heads/master f0612bd74 -> 78df97a0c


added timeout to HTTPCall assertions


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

Branch: refs/heads/master
Commit: 4d2129a375f793841c45253d7233d772efa5fd44
Parents: d372c19
Author: John McCabe <jo...@johnmccabe.net>
Authored: Mon Nov 9 11:28:17 2015 +0000
Committer: Mark McKenna <m4...@gmail.com>
Committed: Mon Nov 9 20:56:21 2015 +0000

----------------------------------------------------------------------
 .../brooklyn-sandbox-test-framework/README.md   | 15 +--
 .../etc/testhttpcall-examples.yml               | 98 +++++++++++++++++++-
 .../brooklyn/test/framework/TestHttpCall.java   |  7 +-
 .../test/framework/TestHttpCallImpl.java        | 21 +++--
 4 files changed, 124 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d2129a3/sandbox/brooklyn-sandbox-test-framework/README.md
----------------------------------------------------------------------
diff --git a/sandbox/brooklyn-sandbox-test-framework/README.md b/sandbox/brooklyn-sandbox-test-framework/README.md
index 6405af6..a4ca928 100644
--- a/sandbox/brooklyn-sandbox-test-framework/README.md
+++ b/sandbox/brooklyn-sandbox-test-framework/README.md
@@ -71,6 +71,7 @@ Entity that makes a HTTP Request and tests the response
 | --- | ----------- | -------- |
 | url | The URL to test | yes |
 | assert | Assertions to be evaluated | yes |
+| timeout | The duration to wait for assertion result | no |
 
 ##### Assertions
 | Key | Description |
@@ -83,21 +84,23 @@ Entity that makes a HTTP Request and tests the response
   - type: org.apache.brooklyn.test.framework.TestHttpCall
     name: Status Code 200
     url: $brooklyn:component("tomcat").attributeWhenReady("main.uri")
+    timeout: 1m
     assert:
       status: 200
   - type: org.apache.brooklyn.test.framework.TestHttpCall
-    name: Status Code 404
-    url: $brooklyn:formatString("%s/invalidpath/", component("tomcat").attributeWhenReady("main.uri"))
-    assert:
-      status: 404
-  - type: org.apache.brooklyn.test.framework.TestHttpCall
     name: String match
     url: $brooklyn:component("tomcat").attributeWhenReady("main.uri")
+    timeout: 1m
     assert:
       string: Sample Brooklyn Deployed
   - type: org.apache.brooklyn.test.framework.TestHttpCall
+    name: Status Code 404
+    url: $brooklyn:formatString("%s/invalidpath/", component("tomcat").attributeWhenReady("webapp.url"))
+    assert:
+      status: 404
+  - type: org.apache.brooklyn.test.framework.TestHttpCall
     name: Regex match
-    url: $brooklyn:component("tomcat").attributeWhenReady("main.uri")
+    url: $brooklyn:component("tomcat").attributeWhenReady("webapp.url")
     # the regex assert uses java.lang.String under the hood so if the url is expected to returns
     # a multi-line response you should use the embedded dotall flag expression `(?s)` in your regex.
     # See: http://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d2129a3/sandbox/brooklyn-sandbox-test-framework/etc/testhttpcall-examples.yml
----------------------------------------------------------------------
diff --git a/sandbox/brooklyn-sandbox-test-framework/etc/testhttpcall-examples.yml b/sandbox/brooklyn-sandbox-test-framework/etc/testhttpcall-examples.yml
index 0ada000..a418fd8 100644
--- a/sandbox/brooklyn-sandbox-test-framework/etc/testhttpcall-examples.yml
+++ b/sandbox/brooklyn-sandbox-test-framework/etc/testhttpcall-examples.yml
@@ -10,22 +10,112 @@ services:
       war: "http://search.maven.org/remotecontent?filepath=io/brooklyn/example/brooklyn-example-hello-world-sql-webapp/0.6.0/brooklyn-example-hello-world-sql-webapp-0.6.0.war"
   - type: org.apache.brooklyn.test.framework.TestHttpCall
     name: Status Code 200
-    url: $brooklyn:component("tomcat").attributeWhenReady("main.uri")
+    url: $brooklyn:component("tomcat").attributeWhenReady("webapp.url")
     assert:
       status: 200
   - type: org.apache.brooklyn.test.framework.TestHttpCall
     name: Status Code 404
-    url: $brooklyn:formatString("%s/invalidpath/", component("tomcat").attributeWhenReady("main.uri"))
+    url: $brooklyn:formatString("%s/invalidpath/", component("tomcat").attributeWhenReady("webapp.url"))
+    timeout: 10s
     assert:
       status: 404
   - type: org.apache.brooklyn.test.framework.TestHttpCall
     name: String match
-    url: $brooklyn:component("tomcat").attributeWhenReady("main.uri")
+    url: $brooklyn:component("tomcat").attributeWhenReady("webapp.url")
     assert:
       string: Sample Brooklyn Deployed
   - type: org.apache.brooklyn.test.framework.TestHttpCall
     name: Regex match
-    url: $brooklyn:component("tomcat").attributeWhenReady("main.uri")
+    url: $brooklyn:component("tomcat").attributeWhenReady("webapp.url")
+    # the regex assert uses java.lang.String under the hood so if the url is expected to returns
+    # a multi-line response you should use the embedded dotall flag expression `(?s)` in your regex.
+    # See: http://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html
+    assert:
+      regex: "(?s).*illustrate(\\s)*how(\\s)*web(\\s)*applications.*"
+...
+
+---
+name: HTTP Call Test with Effector
+location: localhost
+services:
+- type: org.apache.brooklyn.test.framework.TestCase
+  brooklyn.children:
+  - type: org.apache.brooklyn.entity.webapp.tomcat.TomcatServer
+    id: tomcat
+    brooklyn.config:
+      war: "http://search.maven.org/remotecontent?filepath=io/brooklyn/example/brooklyn-example-hello-world-sql-webapp/0.6.0/brooklyn-example-hello-world-sql-webapp-0.6.0.war"
+  - type: org.apache.brooklyn.test.framework.TestHttpCall
+    name: / Status Code 200
+    url: $brooklyn:component("tomcat").attributeWhenReady("webapp.url")
+    assert:
+      status: 200
+  - type: org.apache.brooklyn.test.framework.TestHttpCall
+    name: /newcontext Status Code 404
+    url: $brooklyn:formatString("%s/newcontext/", component("tomcat").attributeWhenReady("webapp.url"))
+    assert:
+      status: 404
+  - type: org.apache.brooklyn.test.framework.TestEffector
+    name: Deploy WAR in /newcontext
+    target: $brooklyn:component("tomcat")
+    effector: deploy
+    params:
+      url: http://search.maven.org/remotecontent?filepath=io/brooklyn/example/brooklyn-example-hello-world-sql-webapp/0.6.0/brooklyn-example-hello-world-sql-webapp-0.6.0.war
+      targetName: newcontext
+  - type: org.apache.brooklyn.test.framework.TestHttpCall
+    name: /newcontext Status Code 200
+    url: $brooklyn:formatString("%s/newcontext/", component("tomcat").attributeWhenReady("webapp.url"))
+    # Give Tomcat time to make the newly deployed War accessible
+    timeout: 10s
+    assert:
+      status: 200
+...
+
+---
+name: HTTP Call Test with Eventual String and Regex Matches
+location: localhost
+services:
+- type: org.apache.brooklyn.test.framework.TestCase
+  brooklyn.children:
+  - type: org.apache.brooklyn.entity.webapp.tomcat.TomcatServer
+    id: tomcat
+    brooklyn.config:
+      war: "http://search.maven.org/remotecontent?filepath=io/brooklyn/example/brooklyn-example-hello-world-sql-webapp/0.6.0/brooklyn-example-hello-world-sql-webapp-0.6.0.war"
+  - type: org.apache.brooklyn.test.framework.TestEffector
+    name: Deploy WAR in /newcontext
+    target: $brooklyn:component("tomcat")
+    effector: deploy
+    params:
+      url: http://search.maven.org/remotecontent?filepath=io/brooklyn/example/brooklyn-example-hello-world-sql-webapp/0.6.0/brooklyn-example-hello-world-sql-webapp-0.6.0.war
+      targetName: newcontext
+  - type: org.apache.brooklyn.test.framework.TestHttpCall
+    name: Regex match
+    url: $brooklyn:formatString("%s/newcontext/", component("tomcat").attributeWhenReady("webapp.url"))
+    timeout: 10s
+    assert:
+      regex: "(?s).*illustrate(\\s)*how(\\s)*web(\\s)*applications.*"
+  - type: org.apache.brooklyn.test.framework.TestEffector
+    name: Deploy WAR in /newcontext2
+    target: $brooklyn:component("tomcat")
+    effector: deploy
+    params:
+      url: http://search.maven.org/remotecontent?filepath=io/brooklyn/example/brooklyn-example-hello-world-sql-webapp/0.6.0/brooklyn-example-hello-world-sql-webapp-0.6.0.war
+      targetName: newcontext2
+  - type: org.apache.brooklyn.test.framework.TestHttpCall
+    name: String match
+    url: $brooklyn:formatString("%s/newcontext2/", component("tomcat").attributeWhenReady("webapp.url"))
+    timeout: 10s
+    assert:
+      string: Sample Brooklyn Deployed
+    assert:
+      status: 404
+  - type: org.apache.brooklyn.test.framework.TestHttpCall
+    name: String match
+    url: $brooklyn:component("tomcat").attributeWhenReady("webapp.url")
+    assert:
+      string: Sample Brooklyn Deployed
+  - type: org.apache.brooklyn.test.framework.TestHttpCall
+    name: Regex match
+    url: $brooklyn:component("tomcat").attributeWhenReady("webapp.url")
     # the regex assert uses java.lang.String under the hood so if the url is expected to returns
     # a multi-line response you should use the embedded dotall flag expression `(?s)` in your regex.
     # See: http://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d2129a3/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestHttpCall.java
----------------------------------------------------------------------
diff --git a/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestHttpCall.java b/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestHttpCall.java
index 04d551f..5dfa1c8 100644
--- a/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestHttpCall.java
+++ b/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestHttpCall.java
@@ -7,8 +7,10 @@ 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.util.core.flags.SetFromFlag;
+import org.apache.brooklyn.util.time.Duration;
 
 import java.util.Map;
+import java.util.concurrent.TimeUnit;
 
 /**
  * Entity that makes a HTTP Request and tests the respose
@@ -19,10 +21,13 @@ import java.util.Map;
 public interface TestHttpCall extends Entity, Startable {
 
     @SetFromFlag(nullable = false)
-    ConfigKey<String> TARGET_URL = ConfigKeys.newStringConfigKey("url", "Url to test");
+    ConfigKey<String> TARGET_URL = ConfigKeys.newStringConfigKey("url", "URL to test");
 
     @SetFromFlag(nullable = false)
     ConfigKey<Map> ASSERTIONS = ConfigKeys.newConfigKey(Map.class, "assert",
             "Assertions to be evaluated", Maps.newLinkedHashMap());
 
+    ConfigKey<Duration> TIMEOUT = ConfigKeys.newConfigKey(Duration.class, "timeout",
+            "The duration to wait for assertion result", new Duration(1L, TimeUnit.SECONDS));
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4d2129a3/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestHttpCallImpl.java
----------------------------------------------------------------------
diff --git a/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestHttpCallImpl.java b/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestHttpCallImpl.java
index 386f20c..7413066 100644
--- a/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestHttpCallImpl.java
+++ b/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestHttpCallImpl.java
@@ -1,6 +1,7 @@
 package org.apache.brooklyn.test.framework;
 
 import com.google.api.client.util.Objects;
+import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.Lists;
 import org.apache.brooklyn.api.location.Location;
 import org.apache.brooklyn.core.entity.AbstractEntity;
@@ -8,13 +9,16 @@ import org.apache.brooklyn.core.entity.lifecycle.Lifecycle;
 import org.apache.brooklyn.core.entity.lifecycle.ServiceStateLogic;
 import org.apache.brooklyn.util.core.flags.TypeCoercions;
 import org.apache.brooklyn.util.exceptions.Exceptions;
+import org.apache.brooklyn.util.time.Duration;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.util.Collection;
 import java.util.Map;
 
-import static org.apache.brooklyn.util.http.HttpAsserts.*;
+import static org.apache.brooklyn.util.http.HttpAsserts.assertContentEventuallyContainsText;
+import static org.apache.brooklyn.util.http.HttpAsserts.assertContentEventuallyMatches;
+import static org.apache.brooklyn.util.http.HttpAsserts.assertHttpStatusCodeEventuallyEquals;
 
 /**
  * {@inheritDoc}
@@ -30,8 +34,9 @@ public class TestHttpCallImpl extends AbstractEntity implements TestHttpCall {
         ServiceStateLogic.setExpectedState(this, Lifecycle.STARTING);
         final String url = getConfig(TARGET_URL);
         final Map assertions = getConfig(ASSERTIONS);
+        final Duration timeout = getConfig(TIMEOUT);
         try {
-            checkAssertions(url, assertions);
+            checkAssertions(url.toString(), ImmutableMap.of("timeout", timeout), assertions);
             sensors().set(SERVICE_UP, true);
             ServiceStateLogic.setExpectedState(this, Lifecycle.RUNNING);
         } catch (Throwable t) {
@@ -57,23 +62,27 @@ public class TestHttpCallImpl extends AbstractEntity implements TestHttpCall {
      * See the test/resources directory for examples.
      *
      * @param url        The target URL to be tested
+     * @param flags      Passed to {@link org.apache.brooklyn.util.http.HttpAsserts#assertContentEventuallyContainsText(Map, String, String, String...)},
+     *                   {@link org.apache.brooklyn.util.http.HttpAsserts#assertContentEventuallyMatches(Map, String, String)},
+     *                   {@link org.apache.brooklyn.util.http.HttpAsserts#assertHttpStatusCodeEventuallyEquals(Map, String, int)}
+     *
      * @param assertions The map of assertions
      */
-    private void checkAssertions(final String url, final Map<?, ?> assertions) {
+    private void checkAssertions(final String url, final Map<String,?> flags, final Map<?, ?> assertions) {
 
         for (final Map.Entry<?, ?> entry : assertions.entrySet()) {
             if (Objects.equal(entry.getKey(), "regex")) {
                 LOG.info("Testing if url [{}] matches regex [{}]",
                         new Object[]{url, entry.getValue()});
-                assertContentMatches(url, TypeCoercions.coerce(entry.getValue(), String.class));
+                assertContentEventuallyMatches( flags, url, TypeCoercions.coerce(entry.getValue(), String.class));
             } else if (Objects.equal(entry.getKey(), "string")) {
                 LOG.debug("Testing if url [{}] contains string [{}]",
                         new Object[]{url, entry.getValue()});
-                assertContentContainsText(url, TypeCoercions.coerce(entry.getValue(), String.class));
+                assertContentEventuallyContainsText(flags, url, TypeCoercions.coerce(entry.getValue(), String.class));
             } else if (Objects.equal(entry.getKey(), "status")) {
                 LOG.debug("Testing if url [{}] returns status code [{}]",
                         new Object[]{url, entry.getValue()});
-                assertHttpStatusCodeEquals(url, TypeCoercions.coerce(entry.getValue(), Integer.class));
+                assertHttpStatusCodeEventuallyEquals(flags, url, TypeCoercions.coerce(entry.getValue(), Integer.class));
             }
         }
     }


[18/21] incubator-brooklyn git commit: Moved TestEntiy to its own package

Posted by he...@apache.org.
Moved TestEntiy to its own package


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

Branch: refs/heads/master
Commit: 840482faf80501c47605fc33c0ecae17a3ad3031
Parents: a3e253d
Author: Mark McKenna <m4...@gmail.com>
Authored: Wed Nov 11 15:14:46 2015 +0000
Committer: Mark McKenna <m4...@gmail.com>
Committed: Wed Nov 11 15:14:46 2015 +0000

----------------------------------------------------------------------
 .../test/framework/TestEffectorTest.java        |  1 +
 .../brooklyn/test/framework/TestEntity.java     | 55 --------------------
 .../brooklyn/test/framework/TestEntityImpl.java | 39 --------------
 .../test/framework/entity/TestEntity.java       | 55 ++++++++++++++++++++
 .../test/framework/entity/TestEntityImpl.java   | 40 ++++++++++++++
 5 files changed, 96 insertions(+), 94 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/840482fa/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/TestEffectorTest.java
----------------------------------------------------------------------
diff --git a/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/TestEffectorTest.java b/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/TestEffectorTest.java
index b43c76b..65c7aa0 100644
--- a/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/TestEffectorTest.java
+++ b/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/TestEffectorTest.java
@@ -8,6 +8,7 @@ import org.apache.brooklyn.api.mgmt.ManagementContext;
 import org.apache.brooklyn.core.entity.Entities;
 import org.apache.brooklyn.core.test.entity.TestApplication;
 import org.apache.brooklyn.location.localhost.LocalhostMachineProvisioningLocation;
+import org.apache.brooklyn.test.framework.entity.TestEntity;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/840482fa/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/TestEntity.java
----------------------------------------------------------------------
diff --git a/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/TestEntity.java b/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/TestEntity.java
deleted file mode 100644
index 933b227..0000000
--- a/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/TestEntity.java
+++ /dev/null
@@ -1,55 +0,0 @@
-package org.apache.brooklyn.test.framework;
-
-import org.apache.brooklyn.api.entity.Entity;
-import org.apache.brooklyn.api.entity.ImplementedBy;
-import org.apache.brooklyn.core.annotation.Effector;
-import org.apache.brooklyn.core.annotation.EffectorParam;
-import org.apache.brooklyn.core.config.ConfigKeys;
-import org.apache.brooklyn.core.entity.trait.Startable;
-import org.apache.brooklyn.core.sensor.AttributeSensorAndConfigKey;
-
-/**
- * @author m4rkmckenna on 27/10/2015.
- */
-
-@ImplementedBy(TestEntityImpl.class)
-public interface TestEntity extends Entity, Startable {
-
-    AttributeSensorAndConfigKey<Boolean, Boolean> SIMPLE_EFFECTOR_INVOKED = ConfigKeys.newSensorAndConfigKey(Boolean.class, "simple-effector-invoked", "");
-    AttributeSensorAndConfigKey<Boolean, Boolean> COMPLEX_EFFECTOR_INVOKED = ConfigKeys.newSensorAndConfigKey(Boolean.class, "complex-effector-invoked", "");
-    AttributeSensorAndConfigKey<String, String> COMPLEX_EFFECTOR_STRING = ConfigKeys.newSensorAndConfigKey(String.class, "complex-effector-string", "");
-    AttributeSensorAndConfigKey<Boolean, Boolean> COMPLEX_EFFECTOR_BOOLEAN = ConfigKeys.newSensorAndConfigKey(Boolean.class, "complex-effector-boolean", "");
-    AttributeSensorAndConfigKey<Long, Long> COMPLEX_EFFECTOR_LONG = ConfigKeys.newSensorAndConfigKey(Long.class, "complex-effector-long", "");
-
-    @Effector
-    void simpleEffector();
-
-    @Effector
-    TestPojo complexEffector(@EffectorParam(name = "stringValue") final String stringValue,
-                             @EffectorParam(name = "booleanValue") final Boolean booleanValue,
-                             @EffectorParam(name = "longValue") final Long longValue);
-
-    class TestPojo {
-        private final String stringValue;
-        private final Boolean booleanValue;
-        private final Long longValue;
-
-        public TestPojo(final String stringValue, final Boolean booleanValue, final Long longValue) {
-            this.stringValue = stringValue;
-            this.booleanValue = booleanValue;
-            this.longValue = longValue;
-        }
-
-        public String getStringValue() {
-            return stringValue;
-        }
-
-        public Boolean getBooleanValue() {
-            return booleanValue;
-        }
-
-        public Long getLongValue() {
-            return longValue;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/840482fa/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/TestEntityImpl.java
----------------------------------------------------------------------
diff --git a/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/TestEntityImpl.java b/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/TestEntityImpl.java
deleted file mode 100644
index b3386f2..0000000
--- a/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/TestEntityImpl.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package org.apache.brooklyn.test.framework;
-
-import org.apache.brooklyn.api.location.Location;
-import org.apache.brooklyn.core.annotation.EffectorParam;
-import org.apache.brooklyn.core.entity.AbstractEntity;
-
-import java.util.Collection;
-
-/**
- * @author m4rkmckenna on 27/10/2015.
- */
-public class TestEntityImpl extends AbstractEntity implements TestEntity {
-    @Override
-    public void start(final Collection<? extends Location> locations) {
-    }
-
-    @Override
-    public void stop() {
-
-    }
-
-    @Override
-    public void restart() {
-    }
-
-    @Override
-    public void simpleEffector() {
-        sensors().set(SIMPLE_EFFECTOR_INVOKED, Boolean.TRUE);
-    }
-
-    @Override
-    public TestPojo complexEffector(@EffectorParam(name = "stringValue") final String stringValue, @EffectorParam(name = "booleanValue") final Boolean booleanValue, @EffectorParam(name = "longValue") final Long longValue) {
-        sensors().set(COMPLEX_EFFECTOR_INVOKED, Boolean.TRUE);
-        sensors().set(COMPLEX_EFFECTOR_STRING, stringValue);
-        sensors().set(COMPLEX_EFFECTOR_BOOLEAN, booleanValue);
-        sensors().set(COMPLEX_EFFECTOR_LONG, longValue);
-        return new TestPojo(stringValue, booleanValue, longValue);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/840482fa/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/entity/TestEntity.java
----------------------------------------------------------------------
diff --git a/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/entity/TestEntity.java b/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/entity/TestEntity.java
new file mode 100644
index 0000000..a9a6fc0
--- /dev/null
+++ b/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/entity/TestEntity.java
@@ -0,0 +1,55 @@
+package org.apache.brooklyn.test.framework.entity;
+
+import org.apache.brooklyn.api.entity.Entity;
+import org.apache.brooklyn.api.entity.ImplementedBy;
+import org.apache.brooklyn.core.annotation.Effector;
+import org.apache.brooklyn.core.annotation.EffectorParam;
+import org.apache.brooklyn.core.config.ConfigKeys;
+import org.apache.brooklyn.core.entity.trait.Startable;
+import org.apache.brooklyn.core.sensor.AttributeSensorAndConfigKey;
+
+/**
+ * @author m4rkmckenna on 27/10/2015.
+ */
+
+@ImplementedBy(TestEntityImpl.class)
+public interface TestEntity extends Entity, Startable {
+
+    AttributeSensorAndConfigKey<Boolean, Boolean> SIMPLE_EFFECTOR_INVOKED = ConfigKeys.newSensorAndConfigKey(Boolean.class, "simple-effector-invoked", "");
+    AttributeSensorAndConfigKey<Boolean, Boolean> COMPLEX_EFFECTOR_INVOKED = ConfigKeys.newSensorAndConfigKey(Boolean.class, "complex-effector-invoked", "");
+    AttributeSensorAndConfigKey<String, String> COMPLEX_EFFECTOR_STRING = ConfigKeys.newSensorAndConfigKey(String.class, "complex-effector-string", "");
+    AttributeSensorAndConfigKey<Boolean, Boolean> COMPLEX_EFFECTOR_BOOLEAN = ConfigKeys.newSensorAndConfigKey(Boolean.class, "complex-effector-boolean", "");
+    AttributeSensorAndConfigKey<Long, Long> COMPLEX_EFFECTOR_LONG = ConfigKeys.newSensorAndConfigKey(Long.class, "complex-effector-long", "");
+
+    @Effector
+    void simpleEffector();
+
+    @Effector
+    TestPojo complexEffector(@EffectorParam(name = "stringValue") final String stringValue,
+                             @EffectorParam(name = "booleanValue") final Boolean booleanValue,
+                             @EffectorParam(name = "longValue") final Long longValue);
+
+    class TestPojo {
+        private final String stringValue;
+        private final Boolean booleanValue;
+        private final Long longValue;
+
+        public TestPojo(final String stringValue, final Boolean booleanValue, final Long longValue) {
+            this.stringValue = stringValue;
+            this.booleanValue = booleanValue;
+            this.longValue = longValue;
+        }
+
+        public String getStringValue() {
+            return stringValue;
+        }
+
+        public Boolean getBooleanValue() {
+            return booleanValue;
+        }
+
+        public Long getLongValue() {
+            return longValue;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/840482fa/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/entity/TestEntityImpl.java
----------------------------------------------------------------------
diff --git a/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/entity/TestEntityImpl.java b/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/entity/TestEntityImpl.java
new file mode 100644
index 0000000..5c81a7b
--- /dev/null
+++ b/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/entity/TestEntityImpl.java
@@ -0,0 +1,40 @@
+package org.apache.brooklyn.test.framework.entity;
+
+import org.apache.brooklyn.api.location.Location;
+import org.apache.brooklyn.core.annotation.EffectorParam;
+import org.apache.brooklyn.core.entity.AbstractEntity;
+import org.apache.brooklyn.test.framework.entity.TestEntity;
+
+import java.util.Collection;
+
+/**
+ * @author m4rkmckenna on 27/10/2015.
+ */
+public class TestEntityImpl extends AbstractEntity implements TestEntity {
+    @Override
+    public void start(final Collection<? extends Location> locations) {
+    }
+
+    @Override
+    public void stop() {
+
+    }
+
+    @Override
+    public void restart() {
+    }
+
+    @Override
+    public void simpleEffector() {
+        sensors().set(SIMPLE_EFFECTOR_INVOKED, Boolean.TRUE);
+    }
+
+    @Override
+    public TestPojo complexEffector(@EffectorParam(name = "stringValue") final String stringValue, @EffectorParam(name = "booleanValue") final Boolean booleanValue, @EffectorParam(name = "longValue") final Long longValue) {
+        sensors().set(COMPLEX_EFFECTOR_INVOKED, Boolean.TRUE);
+        sensors().set(COMPLEX_EFFECTOR_STRING, stringValue);
+        sensors().set(COMPLEX_EFFECTOR_BOOLEAN, booleanValue);
+        sensors().set(COMPLEX_EFFECTOR_LONG, longValue);
+        return new TestPojo(stringValue, booleanValue, longValue);
+    }
+}


[17/21] incubator-brooklyn git commit: Changed TestHttpCall assertion key word 'string' -> 'bodyContains'

Posted by he...@apache.org.
Changed TestHttpCall assertion key word 'string' -> 'bodyContains'


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

Branch: refs/heads/master
Commit: a3e253d0c25eb3e537e881370d5bc6cd6b9bccdd
Parents: d6c455c
Author: Mark McKenna <m4...@gmail.com>
Authored: Wed Nov 11 14:33:46 2015 +0000
Committer: Mark McKenna <m4...@gmail.com>
Committed: Wed Nov 11 14:33:46 2015 +0000

----------------------------------------------------------------------
 usage/test-framework/README.md                                 | 2 +-
 .../org/apache/brooklyn/test/framework/TestHttpCallImpl.java   | 2 +-
 .../test-framework-examples/testhttpcall-examples.yml          | 6 +++---
 3 files changed, 5 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a3e253d0/usage/test-framework/README.md
----------------------------------------------------------------------
diff --git a/usage/test-framework/README.md b/usage/test-framework/README.md
index a4ca928..65556d8 100644
--- a/usage/test-framework/README.md
+++ b/usage/test-framework/README.md
@@ -92,7 +92,7 @@ Entity that makes a HTTP Request and tests the response
     url: $brooklyn:component("tomcat").attributeWhenReady("main.uri")
     timeout: 1m
     assert:
-      string: Sample Brooklyn Deployed
+      bodyContains: Sample Brooklyn Deployed
   - type: org.apache.brooklyn.test.framework.TestHttpCall
     name: Status Code 404
     url: $brooklyn:formatString("%s/invalidpath/", component("tomcat").attributeWhenReady("webapp.url"))

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a3e253d0/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 dad5e97..9cf46dc 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
@@ -74,7 +74,7 @@ public class TestHttpCallImpl extends AbstractTest implements TestHttpCall {
                 LOG.info("Testing if url [{}] matches regex [{}]",
                         new Object[]{url, entry.getValue()});
                 assertContentEventuallyMatches(flags, url, TypeCoercions.coerce(entry.getValue(), String.class));
-            } else if (Objects.equal(entry.getKey(), "string")) {
+            } else if (Objects.equal(entry.getKey(), "bodyContains")) {
                 LOG.debug("Testing if url [{}] contains string [{}]",
                         new Object[]{url, entry.getValue()});
                 assertContentEventuallyContainsText(flags, url, TypeCoercions.coerce(entry.getValue(), String.class));

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a3e253d0/usage/test-framework/src/test/resources/test-framework-examples/testhttpcall-examples.yml
----------------------------------------------------------------------
diff --git a/usage/test-framework/src/test/resources/test-framework-examples/testhttpcall-examples.yml b/usage/test-framework/src/test/resources/test-framework-examples/testhttpcall-examples.yml
index a418fd8..b439c8a 100644
--- a/usage/test-framework/src/test/resources/test-framework-examples/testhttpcall-examples.yml
+++ b/usage/test-framework/src/test/resources/test-framework-examples/testhttpcall-examples.yml
@@ -23,7 +23,7 @@ services:
     name: String match
     url: $brooklyn:component("tomcat").attributeWhenReady("webapp.url")
     assert:
-      string: Sample Brooklyn Deployed
+      bodyContains: Sample Brooklyn Deployed
   - type: org.apache.brooklyn.test.framework.TestHttpCall
     name: Regex match
     url: $brooklyn:component("tomcat").attributeWhenReady("webapp.url")
@@ -105,14 +105,14 @@ services:
     url: $brooklyn:formatString("%s/newcontext2/", component("tomcat").attributeWhenReady("webapp.url"))
     timeout: 10s
     assert:
-      string: Sample Brooklyn Deployed
+      bodyContains: Sample Brooklyn Deployed
     assert:
       status: 404
   - type: org.apache.brooklyn.test.framework.TestHttpCall
     name: String match
     url: $brooklyn:component("tomcat").attributeWhenReady("webapp.url")
     assert:
-      string: Sample Brooklyn Deployed
+      bodyContains: Sample Brooklyn Deployed
   - type: org.apache.brooklyn.test.framework.TestHttpCall
     name: Regex match
     url: $brooklyn:component("tomcat").attributeWhenReady("webapp.url")


[11/21] incubator-brooklyn git commit: Added README.md to test-framework-examples

Posted by he...@apache.org.
Added README.md to test-framework-examples


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

Branch: refs/heads/master
Commit: 5a3b9628d8dc96efb4d8dcf299435d81ed4940db
Parents: b0405c8
Author: Mark McKenna <m4...@gmail.com>
Authored: Wed Nov 11 11:14:52 2015 +0000
Committer: Mark McKenna <m4...@gmail.com>
Committed: Wed Nov 11 11:14:52 2015 +0000

----------------------------------------------------------------------
 .../src/test/resources/test-framework-examples/README.md    | 9 +++++++++
 1 file changed, 9 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/5a3b9628/usage/test-framework/src/test/resources/test-framework-examples/README.md
----------------------------------------------------------------------
diff --git a/usage/test-framework/src/test/resources/test-framework-examples/README.md b/usage/test-framework/src/test/resources/test-framework-examples/README.md
index e69de29..87fbb1f 100644
--- a/usage/test-framework/src/test/resources/test-framework-examples/README.md
+++ b/usage/test-framework/src/test/resources/test-framework-examples/README.md
@@ -0,0 +1,9 @@
+# Test Framework Examples
+
+| File | Description |
+| ---- | ----------- |
+| [example-catalog.bom](./example-catalog.bom) | A Sample catalog that is to be tested |
+| [example-catalog-test.bom](./example-catalog-test.bom) | Example tests for [example-catalog.bom](./example-catalog.bom) |
+| [nginx-test-examples.yml](./nginx-test-examples.yml) | A number of test fragments for the NGiNX entity |
+| [tomcat-test-examples.yml](./tomcat-test-examples.yml) | A number of test fragments for the TomcatServer entity |
+| [testhttpcall-examples.yml](./testhttpcall-examples.yml) | A number of test fragments showing usage of TestHttp entity |


[04/21] incubator-brooklyn git commit: Updated README with details for TestHtmlCall

Posted by he...@apache.org.
Updated README with details for TestHtmlCall


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

Branch: refs/heads/master
Commit: cfa4b3b5fbad96fdaade2d08085911a6504be7f7
Parents: 0e8c31d
Author: Mark McKenna <m4...@users.noreply.github.com>
Authored: Mon Nov 2 22:15:49 2015 +0000
Committer: Mark McKenna <m4...@gmail.com>
Committed: Mon Nov 9 20:56:21 2015 +0000

----------------------------------------------------------------------
 .../brooklyn-sandbox-test-framework/README.md   | 51 +++++++++++++++++++-
 1 file changed, 50 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/cfa4b3b5/sandbox/brooklyn-sandbox-test-framework/README.md
----------------------------------------------------------------------
diff --git a/sandbox/brooklyn-sandbox-test-framework/README.md b/sandbox/brooklyn-sandbox-test-framework/README.md
index 991ec48..6405af6 100644
--- a/sandbox/brooklyn-sandbox-test-framework/README.md
+++ b/sandbox/brooklyn-sandbox-test-framework/README.md
@@ -21,6 +21,13 @@ Entity that tests a sensor value on another entity eg service.isUp == TRUE
 | assert | Assertions to be evaluated | yes |
 | timeout | The duration to wait on a result | no |
 
+##### Assertions
+| Key | Description |
+| --- | ----------- |
+| equal | Sensor value equals  |
+| regex | Sensor value matches regex |
+| isNull | Sensor value has not been set |
+
 ```
 type: org.apache.brooklyn.test.framework.TestSensor
 target: $brooklyn:component("nginx1")
@@ -54,4 +61,46 @@ effector: deploy
 params:
   url: https://tomcat.apache.org/tomcat-6.0-doc/appdev/sample/sample.war
   targetName: sample1
-```
\ No newline at end of file
+```
+
+## TestHtmlCall
+Entity that makes a HTTP Request and tests the response
+
+#### Configuration
+| Key | Description | Required |
+| --- | ----------- | -------- |
+| url | The URL to test | yes |
+| assert | Assertions to be evaluated | yes |
+
+##### Assertions
+| Key | Description |
+| --- | ----------- |
+| string | HTTP body contains text |
+| regex | HTTP body matches regex |
+| status | HTTP status code equals |
+
+```
+  - type: org.apache.brooklyn.test.framework.TestHttpCall
+    name: Status Code 200
+    url: $brooklyn:component("tomcat").attributeWhenReady("main.uri")
+    assert:
+      status: 200
+  - type: org.apache.brooklyn.test.framework.TestHttpCall
+    name: Status Code 404
+    url: $brooklyn:formatString("%s/invalidpath/", component("tomcat").attributeWhenReady("main.uri"))
+    assert:
+      status: 404
+  - type: org.apache.brooklyn.test.framework.TestHttpCall
+    name: String match
+    url: $brooklyn:component("tomcat").attributeWhenReady("main.uri")
+    assert:
+      string: Sample Brooklyn Deployed
+  - type: org.apache.brooklyn.test.framework.TestHttpCall
+    name: Regex match
+    url: $brooklyn:component("tomcat").attributeWhenReady("main.uri")
+    # the regex assert uses java.lang.String under the hood so if the url is expected to returns
+    # a multi-line response you should use the embedded dotall flag expression `(?s)` in your regex.
+    # See: http://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html
+    assert:
+      regex: "(?s).*illustrate(\\s)*how(\\s)*web(\\s)*applications.*"
+```


[19/21] incubator-brooklyn git commit: Replaced UUID.randomUUID() with Identifiers.makeRandomId(8)

Posted by he...@apache.org.
Replaced UUID.randomUUID() with Identifiers.makeRandomId(8)


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

Branch: refs/heads/master
Commit: 5f044578a6afc1589195f9fe6b0e226f4d9bc6cb
Parents: 840482f
Author: Mark McKenna <m4...@gmail.com>
Authored: Wed Nov 11 15:21:00 2015 +0000
Committer: Mark McKenna <m4...@gmail.com>
Committed: Wed Nov 11 15:21:00 2015 +0000

----------------------------------------------------------------------
 .../brooklyn/test/framework/TestEffectorTest.java   |  5 ++---
 .../brooklyn/test/framework/TestSensorTest.java     | 16 ++++++++--------
 2 files changed, 10 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/5f044578/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/TestEffectorTest.java
----------------------------------------------------------------------
diff --git a/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/TestEffectorTest.java b/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/TestEffectorTest.java
index 65c7aa0..c59ac03 100644
--- a/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/TestEffectorTest.java
+++ b/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/TestEffectorTest.java
@@ -9,12 +9,11 @@ import org.apache.brooklyn.core.entity.Entities;
 import org.apache.brooklyn.core.test.entity.TestApplication;
 import org.apache.brooklyn.location.localhost.LocalhostMachineProvisioningLocation;
 import org.apache.brooklyn.test.framework.entity.TestEntity;
+import org.apache.brooklyn.util.text.Identifiers;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
-import java.util.UUID;
-
 import static org.assertj.core.api.Assertions.assertThat;
 
 /**
@@ -29,7 +28,7 @@ public class TestEffectorTest {
 
     @BeforeMethod
     public void setup() {
-        testId = UUID.randomUUID().toString();
+        testId = Identifiers.makeRandomId(8);
         app = TestApplication.Factory.newManagedInstanceForTests();
         managementContext = app.getManagementContext();
 

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/5f044578/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/TestSensorTest.java
----------------------------------------------------------------------
diff --git a/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/TestSensorTest.java b/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/TestSensorTest.java
index 0b653eb..810768c 100644
--- a/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/TestSensorTest.java
+++ b/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/TestSensorTest.java
@@ -12,12 +12,12 @@ import org.apache.brooklyn.core.test.entity.TestApplication;
 import org.apache.brooklyn.location.localhost.LocalhostMachineProvisioningLocation;
 import org.apache.brooklyn.util.exceptions.Exceptions;
 import org.apache.brooklyn.util.exceptions.PropagatedRuntimeException;
+import org.apache.brooklyn.util.text.Identifiers;
 import org.apache.commons.lang3.builder.ToStringBuilder;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
-import java.util.UUID;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
@@ -37,7 +37,7 @@ public class TestSensorTest {
 
     @BeforeMethod
     public void setup() {
-        testId = UUID.randomUUID().toString();
+        testId = Identifiers.makeRandomId(8);
         app = TestApplication.Factory.newManagedInstanceForTests();
         managementContext = app.getManagementContext();
         loc = managementContext.getLocationManager().createLocation(LocationSpec.create(LocalhostMachineProvisioningLocation.class)
@@ -166,7 +166,7 @@ public class TestSensorTest {
     @Test
     public void testAssertRegex() {
         final long time = System.currentTimeMillis();
-        final String sensorValue = String.format("%s%s%s", UUID.randomUUID().toString(), time, UUID.randomUUID().toString());
+        final String sensorValue = String.format("%s%s%s", Identifiers.makeRandomId(8), time, Identifiers.makeRandomId(8));
 
         //Add Sensor Test for STRING sensor
         app.createAndManageChild(EntitySpec.create(TestSensor.class)
@@ -189,13 +189,13 @@ public class TestSensorTest {
     @Test
     public void testAssertRegexFail() {
         boolean sensorTestFail = false;
-        final String sensorValue = String.format("%s%s%s", UUID.randomUUID().toString(), System.currentTimeMillis(), UUID.randomUUID().toString());
+        final String sensorValue = String.format("%s%s%s", Identifiers.makeRandomId(8), System.currentTimeMillis(), Identifiers.makeRandomId(8));
 
         //Add Sensor Test for STRING sensor
         app.createAndManageChild(EntitySpec.create(TestSensor.class)
                 .configure(TestSensor.TARGET_ENTITY, app)
                 .configure(TestSensor.SENSOR_NAME, STRING_SENSOR.getName())
-                .configure(TestSensor.ASSERTIONS, ImmutableMap.of("regex", String.format(".*%s.*", UUID.randomUUID().toString()))));
+                .configure(TestSensor.ASSERTIONS, ImmutableMap.of("regex", String.format(".*%s.*", Identifiers.makeRandomId(8)))));
 
         //Set STRING sensor
         app.sensors().set(STRING_SENSOR, sensorValue);
@@ -215,13 +215,13 @@ public class TestSensorTest {
     @Test
     public void testAssertRegexOnNullSensor() {
         boolean sensorTestFail = false;
-        final String sensorValue = String.format("%s%s%s", UUID.randomUUID().toString(), System.currentTimeMillis(), UUID.randomUUID().toString());
+        final String sensorValue = String.format("%s%s%s", Identifiers.makeRandomId(8), System.currentTimeMillis(), Identifiers.makeRandomId(8));
 
         //Add Sensor Test for STRING sensor
         app.createAndManageChild(EntitySpec.create(TestSensor.class)
                 .configure(TestSensor.TARGET_ENTITY, app)
                 .configure(TestSensor.SENSOR_NAME, STRING_SENSOR.getName())
-                .configure(TestSensor.ASSERTIONS, ImmutableMap.of("regex", String.format(".*%s.*", UUID.randomUUID().toString()))));
+                .configure(TestSensor.ASSERTIONS, ImmutableMap.of("regex", String.format(".*%s.*", Identifiers.makeRandomId(8)))));
 
         try {
             app.start(ImmutableList.of(loc));
@@ -254,7 +254,7 @@ public class TestSensorTest {
         private final String id;
 
         public TestObject() {
-            id = UUID.randomUUID().toString();
+            id = Identifiers.makeRandomId(8);
         }
 
         public String getId() {


[06/21] incubator-brooklyn git commit: Moved sandbox/brooklyn-sandbox-test-framework to usage/test-framework

Posted by he...@apache.org.
Moved sandbox/brooklyn-sandbox-test-framework to usage/test-framework


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

Branch: refs/heads/master
Commit: 813bba029e92081ab319a20b65fc9facb25e2d93
Parents: 4d2129a
Author: Mark McKenna <m4...@gmail.com>
Authored: Mon Nov 9 21:10:58 2015 +0000
Committer: Mark McKenna <m4...@gmail.com>
Committed: Mon Nov 9 21:10:58 2015 +0000

----------------------------------------------------------------------
 pom.xml                                         |   1 +
 .../brooklyn-sandbox-test-framework/README.md   | 109 --------
 .../etc/exampl-catalog.bom                      |  15 --
 .../etc/example-catalog-test.bom                |  22 --
 .../etc/nginx-test-examples.yml                 |  98 -------
 .../etc/testhttpcall-examples.yml               | 124 ---------
 .../etc/tomcat-test-examples.yml                |  45 ----
 sandbox/brooklyn-sandbox-test-framework/pom.xml |  75 ------
 .../brooklyn/test/framework/AbstractTest.java   |  50 ----
 .../brooklyn/test/framework/BaseTest.java       |  34 ---
 .../test/framework/ParallelTestCase.java        |  13 -
 .../test/framework/ParallelTestCaseImpl.java    | 130 ---------
 .../brooklyn/test/framework/TestCase.java       |  12 -
 .../brooklyn/test/framework/TestCaseImpl.java   |  61 -----
 .../brooklyn/test/framework/TestEffector.java   |  33 ---
 .../test/framework/TestEffectorImpl.java        |  91 -------
 .../brooklyn/test/framework/TestHttpCall.java   |  33 ---
 .../test/framework/TestHttpCallImpl.java        | 107 --------
 .../brooklyn/test/framework/TestSensor.java     |  27 --
 .../brooklyn/test/framework/TestSensorImpl.java | 144 ----------
 .../test/framework/TestEffectorTest.java        | 106 --------
 .../brooklyn/test/framework/TestEntity.java     |  55 ----
 .../brooklyn/test/framework/TestEntityImpl.java |  39 ---
 .../brooklyn/test/framework/TestSensorTest.java | 270 -------------------
 usage/test-framework/README.md                  | 109 ++++++++
 usage/test-framework/etc/exampl-catalog.bom     |  15 ++
 .../test-framework/etc/example-catalog-test.bom |  22 ++
 .../test-framework/etc/nginx-test-examples.yml  |  98 +++++++
 .../etc/testhttpcall-examples.yml               | 124 +++++++++
 .../test-framework/etc/tomcat-test-examples.yml |  45 ++++
 usage/test-framework/pom.xml                    |  75 ++++++
 .../brooklyn/test/framework/AbstractTest.java   |  50 ++++
 .../brooklyn/test/framework/BaseTest.java       |  34 +++
 .../test/framework/ParallelTestCase.java        |  13 +
 .../test/framework/ParallelTestCaseImpl.java    | 130 +++++++++
 .../brooklyn/test/framework/TestCase.java       |  12 +
 .../brooklyn/test/framework/TestCaseImpl.java   |  61 +++++
 .../brooklyn/test/framework/TestEffector.java   |  33 +++
 .../test/framework/TestEffectorImpl.java        |  91 +++++++
 .../brooklyn/test/framework/TestHttpCall.java   |  33 +++
 .../test/framework/TestHttpCallImpl.java        | 107 ++++++++
 .../brooklyn/test/framework/TestSensor.java     |  27 ++
 .../brooklyn/test/framework/TestSensorImpl.java | 144 ++++++++++
 .../test/framework/TestEffectorTest.java        | 106 ++++++++
 .../brooklyn/test/framework/TestEntity.java     |  55 ++++
 .../brooklyn/test/framework/TestEntityImpl.java |  39 +++
 .../brooklyn/test/framework/TestSensorTest.java | 270 +++++++++++++++++++
 47 files changed, 1694 insertions(+), 1693 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/813bba02/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index a414b6a..94101c8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -237,6 +237,7 @@
         <module>usage/rest-api</module>
         <module>usage/rest-client</module>
         <module>usage/rest-server</module>
+        <module>usage/test-framework</module>
         <module>usage/test-support</module>
 
         <module>utils/common</module>

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/813bba02/sandbox/brooklyn-sandbox-test-framework/README.md
----------------------------------------------------------------------
diff --git a/sandbox/brooklyn-sandbox-test-framework/README.md b/sandbox/brooklyn-sandbox-test-framework/README.md
deleted file mode 100644
index a4ca928..0000000
--- a/sandbox/brooklyn-sandbox-test-framework/README.md
+++ /dev/null
@@ -1,109 +0,0 @@
-# Entities
-
-## TestCase
-A logical grouping for tests eg Restart tests
-```
-type: org.apache.brooklyn.test.framework.TestCase
-  name: Stop Test
-  brooklyn.children:
-  - ***
-  - ***
-```
-
-## TestSensor
-Entity that tests a sensor value on another entity eg service.isUp == TRUE
-
-#### Configuration
-| Key | Description | Required |
-| --- | ----------- | -------- |
-| target | The target entity to test | yes (no if *targetId* is supplied) |
-| targetId | The id of the target entity to test | yes (no if *target* is supplied) |
-| assert | Assertions to be evaluated | yes |
-| timeout | The duration to wait on a result | no |
-
-##### Assertions
-| Key | Description |
-| --- | ----------- |
-| equal | Sensor value equals  |
-| regex | Sensor value matches regex |
-| isNull | Sensor value has not been set |
-
-```
-type: org.apache.brooklyn.test.framework.TestSensor
-target: $brooklyn:component("nginx1")
-sensor: service.isUp
-equals: true
-timeout: 5m
-```
-
-## TestEffector
-Entity that invokes an effector on another entity eg restart
-
-#### Configuration
-| Key | Description | Required |
-| --- | ----------- | -------- |
-| target | The target entity to effect | yes (no if *targetId* is supplied) |
-| targetId | The id of the target entity to effect | yes (no if *target* is supplied) |
-| effector | The name of the effector to invoke | yes |
-| params | Parameters to pass to the effector | no |
-| timeout | The duration to wait on a response from an effector | no |
-
-#### Sensors
-| Key | Description |
-| --- | ----------- |
-| result | The result of invoking the effector (null if no result) |
-
-```
-type: org.apache.brooklyn.test.framework.TestEffector
-name: Deploy WAR
-target: $brooklyn:component("tomcat")
-effector: deploy
-params:
-  url: https://tomcat.apache.org/tomcat-6.0-doc/appdev/sample/sample.war
-  targetName: sample1
-```
-
-## TestHtmlCall
-Entity that makes a HTTP Request and tests the response
-
-#### Configuration
-| Key | Description | Required |
-| --- | ----------- | -------- |
-| url | The URL to test | yes |
-| assert | Assertions to be evaluated | yes |
-| timeout | The duration to wait for assertion result | no |
-
-##### Assertions
-| Key | Description |
-| --- | ----------- |
-| string | HTTP body contains text |
-| regex | HTTP body matches regex |
-| status | HTTP status code equals |
-
-```
-  - type: org.apache.brooklyn.test.framework.TestHttpCall
-    name: Status Code 200
-    url: $brooklyn:component("tomcat").attributeWhenReady("main.uri")
-    timeout: 1m
-    assert:
-      status: 200
-  - type: org.apache.brooklyn.test.framework.TestHttpCall
-    name: String match
-    url: $brooklyn:component("tomcat").attributeWhenReady("main.uri")
-    timeout: 1m
-    assert:
-      string: Sample Brooklyn Deployed
-  - type: org.apache.brooklyn.test.framework.TestHttpCall
-    name: Status Code 404
-    url: $brooklyn:formatString("%s/invalidpath/", component("tomcat").attributeWhenReady("webapp.url"))
-    assert:
-      status: 404
-  - type: org.apache.brooklyn.test.framework.TestHttpCall
-    name: Regex match
-    url: $brooklyn:component("tomcat").attributeWhenReady("webapp.url")
-    # the regex assert uses java.lang.String under the hood so if the url is expected to returns
-    # a multi-line response you should use the embedded dotall flag expression `(?s)` in your regex.
-    # See: http://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html
-    assert:
-      regex: "(?s).*illustrate(\\s)*how(\\s)*web(\\s)*applications.*"
-```

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/813bba02/sandbox/brooklyn-sandbox-test-framework/etc/exampl-catalog.bom
----------------------------------------------------------------------
diff --git a/sandbox/brooklyn-sandbox-test-framework/etc/exampl-catalog.bom b/sandbox/brooklyn-sandbox-test-framework/etc/exampl-catalog.bom
deleted file mode 100644
index ab7e54b..0000000
--- a/sandbox/brooklyn-sandbox-test-framework/etc/exampl-catalog.bom
+++ /dev/null
@@ -1,15 +0,0 @@
-brooklyn.catalog:
-  id: simple-tomcat
-  version: 1.0
-  itemType: template
-  iconUrl: http://tomcat.apache.org/images/tomcat.png
-  name: Simple Tomcat
-  license: Apache-2.0
-  item:
-    brooklyn.config:
-      simple.confg: someValue
-    services:
-    - type: org.apache.brooklyn.entity.webapp.tomcat.TomcatServer
-      id: tomcat
-      name: Tomcat
-      war: https://tomcat.apache.org/tomcat-6.0-doc/appdev/sample/sample.war
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/813bba02/sandbox/brooklyn-sandbox-test-framework/etc/example-catalog-test.bom
----------------------------------------------------------------------
diff --git a/sandbox/brooklyn-sandbox-test-framework/etc/example-catalog-test.bom b/sandbox/brooklyn-sandbox-test-framework/etc/example-catalog-test.bom
deleted file mode 100644
index 0605f9d..0000000
--- a/sandbox/brooklyn-sandbox-test-framework/etc/example-catalog-test.bom
+++ /dev/null
@@ -1,22 +0,0 @@
-brooklyn.catalog:
-  id: simple-tomcat-test
-  version: 1.0
-  itemType: template
-  iconUrl: http://tomcat.apache.org/images/tomcat.png
-  name: Simple Tomcat Test
-  license: Apache-2.0
-  item:
-    brooklyn.config:
-      simple.confg: someValue
-    services:
-    - type: org.apache.brooklyn.test.framework.TestCase
-      name: Simple Tomcat Tests
-      brooklyn.children:
-      - type: simple-tomcat
-        id: tomcat
-      - type: org.apache.brooklyn.test.framework.TestSensor
-        target: $brooklyn:component("tomcat")
-        sensor: service.isUp
-        timeout: 10m
-        assert:
-          equals: true
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/813bba02/sandbox/brooklyn-sandbox-test-framework/etc/nginx-test-examples.yml
----------------------------------------------------------------------
diff --git a/sandbox/brooklyn-sandbox-test-framework/etc/nginx-test-examples.yml b/sandbox/brooklyn-sandbox-test-framework/etc/nginx-test-examples.yml
deleted file mode 100644
index f1711ea..0000000
--- a/sandbox/brooklyn-sandbox-test-framework/etc/nginx-test-examples.yml
+++ /dev/null
@@ -1,98 +0,0 @@
----
-# 1. Start an nginx
-# 2. Test it is running
-# 3. Stop it
-# 4. Test it stopped
-# Note there are two alternative forms to look up target - either just provide the 'targetId' to do an implicit DSL lookup,
-# or look it up with explicit DSL and provide it as 'target'.
-name: NGINX Test
-location: localhost
-services:
-- type: org.apache.brooklyn.test.framework.TestCase
-  name: Stop Test
-  brooklyn.children:
-  - type: org.apache.brooklyn.entity.proxy.nginx.NginxController
-    id: nginx1
-  - type: org.apache.brooklyn.test.framework.TestSensor
-    target: $brooklyn:component("nginx1")
-    sensor: service.isUp
-    equals: true
-    timeout: 5m
-  - type: org.apache.brooklyn.test.framework.TestEffector
-    target: $brooklyn:component("nginx1")
-    effector: stop
-  - type: org.apache.brooklyn.test.framework.TestSensor
-    target: $brooklyn:component("nginx1")
-    sensor: service.isUp
-    assert:
-      equals: false
-...
-
----
-name: NGINX Test
-location: localhost
-services:
-- type: org.apache.brooklyn.test.framework.TestCase
-  name: Stop Test
-  targetId: nginx1
-  brooklyn.children:
-  - type: org.apache.brooklyn.entity.proxy.nginx.NginxController
-    id: nginx1
-  - type: org.apache.brooklyn.test.framework.TestSensor
-    sensor: service.isUp
-    equals: true
-    timeout: 5m
-  - type: org.apache.brooklyn.test.framework.TestEffector
-    effector: stop
-  - type: org.apache.brooklyn.test.framework.TestSensor
-    sensor: service.isUp
-    equals: false
-
-
-
----
-name: NGINX Test
-location: localhost
-services:
-- type: org.apache.brooklyn.test.framework.TestCase
-  name: Stop Test
-  brooklyn.children:
-  - type: org.apache.brooklyn.entity.proxy.nginx.NginxController
-    id: nginx1
-  - type: org.apache.brooklyn.test.framework.TestSensor
-    target: $brooklyn:component("nginx1")
-    sensor: service.isUp
-    timeout: 5m
-    assert:
-      equals: true
-  - type: org.apache.brooklyn.test.framework.TestEffector
-    target: $brooklyn:component("nginx1")
-    effector: stop
-  - type: org.apache.brooklyn.test.framework.TestSensor
-    target: $brooklyn:component("nginx1")
-    sensor: service.isUp
-    assert:
-      equals: false
-      regex: .*
-...
-
----
-name: NGINX Test
-location: localhost
-services:
-- type: org.apache.brooklyn.entity.proxy.nginx.NginxController
-  id: nginx1
-- type: org.apache.brooklyn.test.framework.TestSensor
-  target: $brooklyn:component("nginx1")
-  sensor: service.isUp
-  timeout: 5m
-  assert:
-    equals: true
-- type: org.apache.brooklyn.test.framework.TestSensor
-  name: Test Regex
-  target: $brooklyn:component("nginx1")
-  sensor: service.isUp
-  timeout: 5m
-  assert:
-    regex: .*
-...
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/813bba02/sandbox/brooklyn-sandbox-test-framework/etc/testhttpcall-examples.yml
----------------------------------------------------------------------
diff --git a/sandbox/brooklyn-sandbox-test-framework/etc/testhttpcall-examples.yml b/sandbox/brooklyn-sandbox-test-framework/etc/testhttpcall-examples.yml
deleted file mode 100644
index a418fd8..0000000
--- a/sandbox/brooklyn-sandbox-test-framework/etc/testhttpcall-examples.yml
+++ /dev/null
@@ -1,124 +0,0 @@
----
-name: Basic HTTP Call Tests
-location: localhost
-services:
-- type: org.apache.brooklyn.test.framework.TestCase
-  brooklyn.children:
-  - type: org.apache.brooklyn.entity.webapp.tomcat.TomcatServer
-    id: tomcat
-    brooklyn.config:
-      war: "http://search.maven.org/remotecontent?filepath=io/brooklyn/example/brooklyn-example-hello-world-sql-webapp/0.6.0/brooklyn-example-hello-world-sql-webapp-0.6.0.war"
-  - type: org.apache.brooklyn.test.framework.TestHttpCall
-    name: Status Code 200
-    url: $brooklyn:component("tomcat").attributeWhenReady("webapp.url")
-    assert:
-      status: 200
-  - type: org.apache.brooklyn.test.framework.TestHttpCall
-    name: Status Code 404
-    url: $brooklyn:formatString("%s/invalidpath/", component("tomcat").attributeWhenReady("webapp.url"))
-    timeout: 10s
-    assert:
-      status: 404
-  - type: org.apache.brooklyn.test.framework.TestHttpCall
-    name: String match
-    url: $brooklyn:component("tomcat").attributeWhenReady("webapp.url")
-    assert:
-      string: Sample Brooklyn Deployed
-  - type: org.apache.brooklyn.test.framework.TestHttpCall
-    name: Regex match
-    url: $brooklyn:component("tomcat").attributeWhenReady("webapp.url")
-    # the regex assert uses java.lang.String under the hood so if the url is expected to returns
-    # a multi-line response you should use the embedded dotall flag expression `(?s)` in your regex.
-    # See: http://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html
-    assert:
-      regex: "(?s).*illustrate(\\s)*how(\\s)*web(\\s)*applications.*"
-...
-
----
-name: HTTP Call Test with Effector
-location: localhost
-services:
-- type: org.apache.brooklyn.test.framework.TestCase
-  brooklyn.children:
-  - type: org.apache.brooklyn.entity.webapp.tomcat.TomcatServer
-    id: tomcat
-    brooklyn.config:
-      war: "http://search.maven.org/remotecontent?filepath=io/brooklyn/example/brooklyn-example-hello-world-sql-webapp/0.6.0/brooklyn-example-hello-world-sql-webapp-0.6.0.war"
-  - type: org.apache.brooklyn.test.framework.TestHttpCall
-    name: / Status Code 200
-    url: $brooklyn:component("tomcat").attributeWhenReady("webapp.url")
-    assert:
-      status: 200
-  - type: org.apache.brooklyn.test.framework.TestHttpCall
-    name: /newcontext Status Code 404
-    url: $brooklyn:formatString("%s/newcontext/", component("tomcat").attributeWhenReady("webapp.url"))
-    assert:
-      status: 404
-  - type: org.apache.brooklyn.test.framework.TestEffector
-    name: Deploy WAR in /newcontext
-    target: $brooklyn:component("tomcat")
-    effector: deploy
-    params:
-      url: http://search.maven.org/remotecontent?filepath=io/brooklyn/example/brooklyn-example-hello-world-sql-webapp/0.6.0/brooklyn-example-hello-world-sql-webapp-0.6.0.war
-      targetName: newcontext
-  - type: org.apache.brooklyn.test.framework.TestHttpCall
-    name: /newcontext Status Code 200
-    url: $brooklyn:formatString("%s/newcontext/", component("tomcat").attributeWhenReady("webapp.url"))
-    # Give Tomcat time to make the newly deployed War accessible
-    timeout: 10s
-    assert:
-      status: 200
-...
-
----
-name: HTTP Call Test with Eventual String and Regex Matches
-location: localhost
-services:
-- type: org.apache.brooklyn.test.framework.TestCase
-  brooklyn.children:
-  - type: org.apache.brooklyn.entity.webapp.tomcat.TomcatServer
-    id: tomcat
-    brooklyn.config:
-      war: "http://search.maven.org/remotecontent?filepath=io/brooklyn/example/brooklyn-example-hello-world-sql-webapp/0.6.0/brooklyn-example-hello-world-sql-webapp-0.6.0.war"
-  - type: org.apache.brooklyn.test.framework.TestEffector
-    name: Deploy WAR in /newcontext
-    target: $brooklyn:component("tomcat")
-    effector: deploy
-    params:
-      url: http://search.maven.org/remotecontent?filepath=io/brooklyn/example/brooklyn-example-hello-world-sql-webapp/0.6.0/brooklyn-example-hello-world-sql-webapp-0.6.0.war
-      targetName: newcontext
-  - type: org.apache.brooklyn.test.framework.TestHttpCall
-    name: Regex match
-    url: $brooklyn:formatString("%s/newcontext/", component("tomcat").attributeWhenReady("webapp.url"))
-    timeout: 10s
-    assert:
-      regex: "(?s).*illustrate(\\s)*how(\\s)*web(\\s)*applications.*"
-  - type: org.apache.brooklyn.test.framework.TestEffector
-    name: Deploy WAR in /newcontext2
-    target: $brooklyn:component("tomcat")
-    effector: deploy
-    params:
-      url: http://search.maven.org/remotecontent?filepath=io/brooklyn/example/brooklyn-example-hello-world-sql-webapp/0.6.0/brooklyn-example-hello-world-sql-webapp-0.6.0.war
-      targetName: newcontext2
-  - type: org.apache.brooklyn.test.framework.TestHttpCall
-    name: String match
-    url: $brooklyn:formatString("%s/newcontext2/", component("tomcat").attributeWhenReady("webapp.url"))
-    timeout: 10s
-    assert:
-      string: Sample Brooklyn Deployed
-    assert:
-      status: 404
-  - type: org.apache.brooklyn.test.framework.TestHttpCall
-    name: String match
-    url: $brooklyn:component("tomcat").attributeWhenReady("webapp.url")
-    assert:
-      string: Sample Brooklyn Deployed
-  - type: org.apache.brooklyn.test.framework.TestHttpCall
-    name: Regex match
-    url: $brooklyn:component("tomcat").attributeWhenReady("webapp.url")
-    # the regex assert uses java.lang.String under the hood so if the url is expected to returns
-    # a multi-line response you should use the embedded dotall flag expression `(?s)` in your regex.
-    # See: http://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html
-    assert:
-      regex: "(?s).*illustrate(\\s)*how(\\s)*web(\\s)*applications.*"
-...
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/813bba02/sandbox/brooklyn-sandbox-test-framework/etc/tomcat-test-examples.yml
----------------------------------------------------------------------
diff --git a/sandbox/brooklyn-sandbox-test-framework/etc/tomcat-test-examples.yml b/sandbox/brooklyn-sandbox-test-framework/etc/tomcat-test-examples.yml
deleted file mode 100644
index 37d7f4d..0000000
--- a/sandbox/brooklyn-sandbox-test-framework/etc/tomcat-test-examples.yml
+++ /dev/null
@@ -1,45 +0,0 @@
----
-name: Tomcat Multi-War Test
-location: localhost
-services:
-- type: org.apache.brooklyn.entity.webapp.tomcat.TomcatServer
-  id: tomcat
-  name: Tomcat
-  brooklyn.config:
-    wars.by.context:
-      hello1: "http://search.maven.org/remotecontent?filepath=io/brooklyn/example/brooklyn-example-hello-world-sql-webapp/0.6.0/brooklyn-example-hello-world-sql-webapp-0.6.0.war"
-      hello2: "http://search.maven.org/remotecontent?filepath=io/brooklyn/example/brooklyn-example-hello-world-sql-webapp/0.6.0/brooklyn-example-hello-world-sql-webapp-0.6.0.war"
-    start.timeout: 10m
-- type: org.apache.brooklyn.test.framework.TestSensor
-  target: $brooklyn:component("tomcat")
-  sensor: service.isUp
-  assert:
-    equals: true
-  timeout: 10m
-...
-
----
-name: Tomcat Tests
-location: BYON 1
-services:
-  - type: org.apache.brooklyn.test.framework.TestCase
-    name: Effector - Deploy Test
-    brooklyn.children:
-    - type: org.apache.brooklyn.entity.webapp.tomcat.TomcatServer
-      id: tomcat
-      name: Tomcat
-      war: https://tomcat.apache.org/tomcat-6.0-doc/appdev/sample/sample.war
-    - type: org.apache.brooklyn.test.framework.TestEffector
-      name: Deploy Another WAR
-      target: $brooklyn:component("tomcat")
-      effector: deploy
-      params:
-        url: https://tomcat.apache.org/tomcat-6.0-doc/appdev/sample/sample.war
-        targetName: sample1
-#    - type: org.apache.brooklyn.test.framework.TestSensor
-#      target: $brooklyn:component("tomcat")
-#      sensor: webapp.deployedWars
-#      assert:
-#        regex: .*sample1.*
-#      timeout: 1m
-...
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/813bba02/sandbox/brooklyn-sandbox-test-framework/pom.xml
----------------------------------------------------------------------
diff --git a/sandbox/brooklyn-sandbox-test-framework/pom.xml b/sandbox/brooklyn-sandbox-test-framework/pom.xml
deleted file mode 100644
index ba9430f..0000000
--- a/sandbox/brooklyn-sandbox-test-framework/pom.xml
+++ /dev/null
@@ -1,75 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0"
-         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-    <parent>
-        <artifactId>brooklyn</artifactId>
-        <groupId>org.apache.brooklyn</groupId>
-        <version>0.9.0-SNAPSHOT</version>
-        <relativePath>../../pom.xml</relativePath>
-    </parent>
-    <modelVersion>4.0.0</modelVersion>
-
-    <artifactId>brooklyn-sandbox-test-framework</artifactId>
-    <name>Brooklyn Test Framework</name>
-
-    <properties>
-        <assertj.version>3.2.0</assertj.version>
-    </properties>
-
-    <dependencies>
-
-        <dependency>
-            <groupId>org.apache.brooklyn</groupId>
-            <artifactId>brooklyn-core</artifactId>
-            <version>${brooklyn.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.brooklyn</groupId>
-            <artifactId>brooklyn-camp</artifactId>
-            <version>${brooklyn.version}</version>
-        </dependency>
-
-        <!--TEST SCOPE :: START-->
-        <dependency>
-            <groupId>org.testng</groupId>
-            <artifactId>testng</artifactId>
-            <version>${testng.version}</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.brooklyn</groupId>
-            <artifactId>brooklyn-test-support</artifactId>
-            <version>${project.version}</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.brooklyn</groupId>
-            <artifactId>brooklyn-core</artifactId>
-            <version>${brooklyn.version}</version>
-            <scope>test</scope>
-            <classifier>tests</classifier>
-        </dependency>
-        <dependency>
-            <groupId>org.assertj</groupId>
-            <artifactId>assertj-core</artifactId>
-            <version>${assertj.version}</version>
-            <scope>test</scope>
-        </dependency>
-        <!--TEST SCOPE :: END-->
-        
-    </dependencies>
-
-    <build>
-        <plugins>
-            <plugin>
-                <artifactId>maven-compiler-plugin</artifactId>
-                <version>3.3</version>
-                <configuration>
-                    <source>${java.version}</source>
-                    <target>${java.version}</target>
-                </configuration>
-            </plugin>
-        </plugins>
-    </build>
-</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/813bba02/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/AbstractTest.java
----------------------------------------------------------------------
diff --git a/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/AbstractTest.java b/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/AbstractTest.java
deleted file mode 100644
index 2194286..0000000
--- a/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/AbstractTest.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package org.apache.brooklyn.test.framework;
-
-import org.apache.brooklyn.api.entity.Entity;
-import org.apache.brooklyn.api.mgmt.Task;
-import org.apache.brooklyn.camp.brooklyn.spi.dsl.methods.DslComponent;
-import org.apache.brooklyn.core.entity.AbstractEntity;
-import org.apache.brooklyn.util.core.task.Tasks;
-import org.apache.brooklyn.util.exceptions.Exceptions;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.concurrent.ExecutionException;
-
-/**
- * Abstract base class for tests, providing common target lookup.
- */
-public abstract class AbstractTest extends AbstractEntity implements BaseTest {
-
-    private static final Logger LOG = LoggerFactory.getLogger(AbstractTest.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.
-     *
-     * @return The target entity.
-     *
-     * @throws @RuntimeException if no target can be determined.
-     */
-    public Entity resolveTarget() {
-        Entity entity = getConfig(TARGET_ENTITY);
-        if (null == entity) {
-            entity = getTargetById();
-        }
-        return entity;
-    }
-
-    private Entity getTargetById() {
-        String targetId = getConfig(TARGET_ID);
-        final Task<Entity> targetLookup = new DslComponent(targetId).newTask();
-        Entity entity = null;
-        try {
-            entity = Tasks.resolveValue(targetLookup, Entity.class, getExecutionContext(), "Finding entity " + targetId);
-            LOG.debug("Found target by id {}", targetId);
-        } catch (final ExecutionException | InterruptedException e) {
-            LOG.error("Error finding target {}", targetId);
-            Exceptions.propagate(e);
-        }
-        return entity;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/813bba02/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/BaseTest.java
----------------------------------------------------------------------
diff --git a/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/BaseTest.java b/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/BaseTest.java
deleted file mode 100644
index b0f347d..0000000
--- a/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/BaseTest.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package org.apache.brooklyn.test.framework;
-
-import org.apache.brooklyn.api.entity.Entity;
-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.util.core.flags.SetFromFlag;
-
-/**
- *  A base interface for all tests.
- */
-public interface BaseTest extends Entity, Startable {
-
-    /**
-     * The target entity to test (optional, use either this or targetId).
-     */
-    @SetFromFlag(nullable = false)
-    ConfigKey<Entity> TARGET_ENTITY = ConfigKeys.newConfigKey(Entity.class, "target", "Entity under test");
-
-    /**
-     * Id of the target entity to test (optional, use either this or target).
-     */
-    @SetFromFlag(nullable = false)
-    ConfigKey<String> TARGET_ID = ConfigKeys.newStringConfigKey("targetId", "Id of the entity under test");
-
-    /**
-     * Get the target of the test.
-     *
-     * @return The target.
-     *
-     * @throws IllegalArgumentException if the target cannot be found.
-     */
-    Entity resolveTarget();
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/813bba02/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/ParallelTestCase.java
----------------------------------------------------------------------
diff --git a/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/ParallelTestCase.java b/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/ParallelTestCase.java
deleted file mode 100644
index b5dc1ea..0000000
--- a/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/ParallelTestCase.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package org.apache.brooklyn.test.framework;
-
-import org.apache.brooklyn.api.entity.Entity;
-import org.apache.brooklyn.api.entity.ImplementedBy;
-import org.apache.brooklyn.core.entity.trait.Startable;
-
-/**
- * 
- * @author Chris Burke
- */
-@ImplementedBy(value = ParallelTestCaseImpl.class)
-public interface ParallelTestCase extends Entity, Startable {
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/813bba02/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/ParallelTestCaseImpl.java
----------------------------------------------------------------------
diff --git a/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/ParallelTestCaseImpl.java b/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/ParallelTestCaseImpl.java
deleted file mode 100644
index 67e972a..0000000
--- a/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/ParallelTestCaseImpl.java
+++ /dev/null
@@ -1,130 +0,0 @@
-package org.apache.brooklyn.test.framework;
-
-import java.util.Collection;
-import java.util.concurrent.ExecutionException;
-
-import org.apache.brooklyn.api.location.Location;
-import org.apache.brooklyn.api.mgmt.Task;
-import org.apache.brooklyn.api.mgmt.TaskAdaptable;
-import org.apache.brooklyn.core.entity.AbstractEntity;
-import org.apache.brooklyn.core.entity.Attributes;
-import org.apache.brooklyn.core.entity.lifecycle.Lifecycle;
-import org.apache.brooklyn.core.entity.trait.StartableMethods;
-import org.apache.brooklyn.util.core.task.DynamicTasks;
-import org.apache.brooklyn.util.exceptions.Exceptions;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * This implementation will start all child entities in parallel.
- * 
- * @author Chris Burke
- */
-public class ParallelTestCaseImpl extends AbstractEntity implements ParallelTestCase {
-
-    private static final Logger logger = LoggerFactory.getLogger(ParallelTestCaseImpl.class);
-
-    /**
-     * {@inheritDoc}
-     */
-    public void start(Collection<? extends Location> locations) {
-        // Let everyone know we're starting up (so that the GUI shows the correct icon).
-        sensors().set(Attributes.SERVICE_STATE_ACTUAL, Lifecycle.STARTING);
-        try {
-            // Get an unsubmitted task for starting all the children of this entity in parallel,
-            // at the same location as this entity.
-            final TaskAdaptable<?> taskAdaptable = StartableMethods.startingChildren(this);
-            logger.trace("{}, TaskAdaptable: {}", this, taskAdaptable);
-
-            // Submit the task to the ExecutionManager so that they actually get started
-            // and then wait until all the parallel child entities have completed.
-            submitTaskAndWait(taskAdaptable);
-
-            // Let everyone know we've started up successfully (changes the icon in the GUI).
-            logger.debug("Tasks successfully run. Update state of {} to RUNNING.", this);
-            setServiceState(true, Lifecycle.RUNNING);
-        } catch (Throwable t) {
-            logger.debug("Tasks NOT successfully run. Update state of {} to ON_FIRE.", this);
-            setServiceState(false, Lifecycle.ON_FIRE);
-            throw Exceptions.propagate(t);
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public void stop() {
-        // Let everyone know we're stopping (so that the GUI shows the correct icon).
-        sensors().set(Attributes.SERVICE_STATE_ACTUAL, Lifecycle.STOPPING);
-
-        // Get an unsubmitted task for stopping all the children of this entity in parallel.
-        final TaskAdaptable<?> taskAdaptable = StartableMethods.stoppingChildren(this);
-        logger.trace("{}, TaskAdaptable: {}", this, taskAdaptable);
-        try {
-            // Submit the task to the ExecutionManager so that they actually get stopped
-            // and then wait until all the parallel entities have completed.
-            submitTaskAndWait(taskAdaptable);
-            // Let everyone know we've stopped successfully (changes the icon in the GUI).
-            logger.debug("Tasks successfully run. Update state of {} to STOPPED.", this);
-            setServiceState(false, Lifecycle.STOPPED);
-        } catch (Throwable t) {
-            logger.debug("Tasks NOT successfully run. Update state of {} to ON_FIRE.", this);
-            setServiceState(false, Lifecycle.ON_FIRE);
-            throw Exceptions.propagate(t);
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public void restart() {
-        // Let everyone know we're restarting (so that the GUI shows the correct icon).
-        setServiceState(false, Lifecycle.STARTING);
-
-        // Get an unsubmitted task for restarting all the children of this entity in parallel.
-        final TaskAdaptable<?> taskAdaptable = StartableMethods.restartingChildren(this);
-        logger.trace("{}, TaskAdaptable: {}", this, taskAdaptable);
-
-        try {
-            // Submit the task to the ExecutionManager so that they actually get stopped
-            // and then wait until all the parallel entities have completed.
-            submitTaskAndWait(taskAdaptable);
-
-            // Let everyone know we've started up successfully (changes the icon in the GUI).
-            logger.debug("Tasks successfully run. Update state of {} to RUNNING.", this);
-            setServiceState(true, Lifecycle.RUNNING);
-        } catch (Throwable t) {
-            logger.debug("Tasks NOT successfully run. Update state of {} to ON_FIRE.", this);
-            setServiceState(false, Lifecycle.ON_FIRE);
-            throw Exceptions.propagate(t);
-        }
-    }
-
-    /**
-     * Submits the task to the ExecutionManager and then waits until the task has completed.
-     * 
-     * @param taskAdaptable the TaskAdaptable to submit for execution.
-     * @throws ExecutionException if the task threw an exception
-     * @throws InterruptedException if the current thread was interrupted while waiting
-     */
-    private void submitTaskAndWait(final TaskAdaptable<?> taskAdaptable)
-            throws InterruptedException, ExecutionException {
-        logger.debug("{}, Submitting taskAdaptable: {}", this, taskAdaptable);
-        // Submit the task to the ExecutionManager.
-        final Task<?> task = DynamicTasks.submit(taskAdaptable, this);
-
-        // Block until the task has completed.
-        logger.debug("{}, Blocking until task complete.", this);
-        task.blockUntilEnded();
-        logger.debug("{}, Task complete.", this);
-
-        // Get the result of the task. We don't really care about the
-        // actual result but this will throw an exception if the task failed.
-        task.get();
-    }
-
-    private void setServiceState(final boolean serviceUpState, final Lifecycle serviceStateActual) {
-        sensors().set(SERVICE_UP, serviceUpState);
-        sensors().set(Attributes.SERVICE_STATE_ACTUAL, serviceStateActual);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/813bba02/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestCase.java
----------------------------------------------------------------------
diff --git a/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestCase.java b/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestCase.java
deleted file mode 100644
index 6d2ae11..0000000
--- a/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestCase.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package org.apache.brooklyn.test.framework;
-
-import org.apache.brooklyn.api.entity.ImplementedBy;
-
-/**
- * Entity that logically groups other test entities
- *
- * @author m4rkmckenna
- */
-@ImplementedBy(value = TestCaseImpl.class)
-public interface TestCase extends BaseTest {
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/813bba02/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestCaseImpl.java
----------------------------------------------------------------------
diff --git a/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestCaseImpl.java b/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestCaseImpl.java
deleted file mode 100644
index 1b443fb..0000000
--- a/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestCaseImpl.java
+++ /dev/null
@@ -1,61 +0,0 @@
-package org.apache.brooklyn.test.framework;
-
-import com.google.common.collect.Lists;
-import org.apache.brooklyn.api.entity.Entity;
-import org.apache.brooklyn.api.location.Location;
-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.util.exceptions.Exceptions;
-
-import java.util.Collection;
-
-/**
- * {@inheritDoc}
- */
-public class TestCaseImpl extends AbstractTest implements TestCase {
-
-    /**
-     * {@inheritDoc}
-     */
-    public void start(Collection<? extends Location> locations) {
-        ServiceStateLogic.setExpectedState(this, Lifecycle.STARTING);
-        try {
-            for (final Entity childEntity : getChildren()) {
-                if (childEntity instanceof Startable) ((Startable) childEntity).start(locations);
-            }
-            sensors().set(SERVICE_UP, true);
-            ServiceStateLogic.setExpectedState(this, Lifecycle.RUNNING);
-        } catch (Throwable t) {
-            sensors().set(SERVICE_UP, false);
-            ServiceStateLogic.setExpectedState(this, Lifecycle.ON_FIRE);
-            throw Exceptions.propagate(t);
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    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);
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public void restart() {
-        final Collection<Location> locations = Lists.newArrayList(getLocations());
-        stop();
-        start(locations);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/813bba02/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestEffector.java
----------------------------------------------------------------------
diff --git a/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestEffector.java b/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestEffector.java
deleted file mode 100644
index e9ec832..0000000
--- a/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestEffector.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package org.apache.brooklyn.test.framework;
-
-import com.google.common.collect.ImmutableMap;
-import com.google.common.reflect.TypeToken;
-import org.apache.brooklyn.api.entity.ImplementedBy;
-import org.apache.brooklyn.config.ConfigKey;
-import org.apache.brooklyn.core.config.ConfigKeys;
-import org.apache.brooklyn.core.sensor.AttributeSensorAndConfigKey;
-import org.apache.brooklyn.util.core.flags.SetFromFlag;
-import org.apache.brooklyn.util.time.Duration;
-
-import java.util.Map;
-import java.util.concurrent.TimeUnit;
-
-/**
- * Entity that invokes an effector on another entity
- *
- * @author m4rkmckenna
- */
-@ImplementedBy(value = TestEffectorImpl.class)
-public interface TestEffector extends BaseTest {
-
-    @SetFromFlag(nullable = false)
-    ConfigKey<String> EFFECTOR_NAME = ConfigKeys.newConfigKey(String.class, "effector", "The name of the effector to invoke");
-
-    ConfigKey<Map<String, ?>> EFFECTOR_PARAMS = ConfigKeys.newConfigKey(new TypeToken<Map<String, ?>>() {
-    }, "params", "The parameters to pass to the effector", ImmutableMap.<String, Object>of());
-
-    ConfigKey<Duration> TIMEOUT = ConfigKeys.newConfigKey(Duration.class, "timeout", "Time to wait on sensor result", new Duration(5L, TimeUnit.SECONDS));
-
-    AttributeSensorAndConfigKey<Object, Object> EFFECTOR_RESULT = ConfigKeys.newSensorAndConfigKey(Object.class, "result", "The result of invoking the effector");
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/813bba02/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestEffectorImpl.java
----------------------------------------------------------------------
diff --git a/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestEffectorImpl.java b/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestEffectorImpl.java
deleted file mode 100644
index 442797e..0000000
--- a/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestEffectorImpl.java
+++ /dev/null
@@ -1,91 +0,0 @@
-package org.apache.brooklyn.test.framework;
-
-import com.google.common.collect.Lists;
-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.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;
-import org.apache.brooklyn.util.time.Duration;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Collection;
-import java.util.Map;
-
-/**
- *
- */
-public class TestEffectorImpl extends AbstractTest implements TestEffector {
-    private static final Logger LOG = LoggerFactory.getLogger(TestEffectorImpl.class);
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public void start(Collection<? extends Location> locations) {
-        ServiceStateLogic.setExpectedState(this, Lifecycle.STARTING);
-        final Entity targetEntity = resolveTarget();
-        final String effectorName = getConfig(EFFECTOR_NAME);
-        final Map<String, ?> effectorParams = getConfig(EFFECTOR_PARAMS);
-        final Duration timeout = getConfig(TIMEOUT);
-        try {
-            Maybe<Effector<?>> effector = EffectorUtils.findEffectorDeclared(targetEntity, effectorName);
-            if (effector.isAbsentOrNull()) {
-                throw new AssertionError(String.format("No effector with name [%s]", effectorName));
-            }
-            final Task<?> effectorResult;
-            if (effectorParams == null || effectorParams.isEmpty()) {
-                effectorResult = Entities.invokeEffector(this, targetEntity, effector.get());
-            } 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) {
-            sensors().set(SERVICE_UP, false);
-            ServiceStateLogic.setExpectedState(this, Lifecycle.ON_FIRE);
-            throw Exceptions.propagate(t);
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    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);
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public void restart() {
-        final Collection<Location> locations = Lists.newArrayList(getLocations());
-        stop();
-        start(locations);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/813bba02/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestHttpCall.java
----------------------------------------------------------------------
diff --git a/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestHttpCall.java b/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestHttpCall.java
deleted file mode 100644
index 5dfa1c8..0000000
--- a/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestHttpCall.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package org.apache.brooklyn.test.framework;
-
-import com.google.common.collect.Maps;
-import org.apache.brooklyn.api.entity.Entity;
-import org.apache.brooklyn.api.entity.ImplementedBy;
-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.util.core.flags.SetFromFlag;
-import org.apache.brooklyn.util.time.Duration;
-
-import java.util.Map;
-import java.util.concurrent.TimeUnit;
-
-/**
- * Entity that makes a HTTP Request and tests the respose
- *
- * @author johnmccabe
- */
-@ImplementedBy(value = TestHttpCallImpl.class)
-public interface TestHttpCall extends Entity, Startable {
-
-    @SetFromFlag(nullable = false)
-    ConfigKey<String> TARGET_URL = ConfigKeys.newStringConfigKey("url", "URL to test");
-
-    @SetFromFlag(nullable = false)
-    ConfigKey<Map> ASSERTIONS = ConfigKeys.newConfigKey(Map.class, "assert",
-            "Assertions to be evaluated", Maps.newLinkedHashMap());
-
-    ConfigKey<Duration> TIMEOUT = ConfigKeys.newConfigKey(Duration.class, "timeout",
-            "The duration to wait for assertion result", new Duration(1L, TimeUnit.SECONDS));
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/813bba02/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestHttpCallImpl.java
----------------------------------------------------------------------
diff --git a/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestHttpCallImpl.java b/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestHttpCallImpl.java
deleted file mode 100644
index 7413066..0000000
--- a/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestHttpCallImpl.java
+++ /dev/null
@@ -1,107 +0,0 @@
-package org.apache.brooklyn.test.framework;
-
-import com.google.api.client.util.Objects;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Lists;
-import org.apache.brooklyn.api.location.Location;
-import org.apache.brooklyn.core.entity.AbstractEntity;
-import org.apache.brooklyn.core.entity.lifecycle.Lifecycle;
-import org.apache.brooklyn.core.entity.lifecycle.ServiceStateLogic;
-import org.apache.brooklyn.util.core.flags.TypeCoercions;
-import org.apache.brooklyn.util.exceptions.Exceptions;
-import org.apache.brooklyn.util.time.Duration;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Collection;
-import java.util.Map;
-
-import static org.apache.brooklyn.util.http.HttpAsserts.assertContentEventuallyContainsText;
-import static org.apache.brooklyn.util.http.HttpAsserts.assertContentEventuallyMatches;
-import static org.apache.brooklyn.util.http.HttpAsserts.assertHttpStatusCodeEventuallyEquals;
-
-/**
- * {@inheritDoc}
- */
-public class TestHttpCallImpl extends AbstractEntity implements TestHttpCall {
-
-    private static final Logger LOG = LoggerFactory.getLogger(TestHttpCallImpl.class);
-
-    /**
-     * {@inheritDoc}
-     */
-    public void start(Collection<? extends Location> locations) {
-        ServiceStateLogic.setExpectedState(this, Lifecycle.STARTING);
-        final String url = getConfig(TARGET_URL);
-        final Map assertions = getConfig(ASSERTIONS);
-        final Duration timeout = getConfig(TIMEOUT);
-        try {
-            checkAssertions(url.toString(), ImmutableMap.of("timeout", timeout), assertions);
-            sensors().set(SERVICE_UP, true);
-            ServiceStateLogic.setExpectedState(this, Lifecycle.RUNNING);
-        } catch (Throwable t) {
-            LOG.info("Url [{}] test failed", url);
-            sensors().set(SERVICE_UP, false);
-            ServiceStateLogic.setExpectedState(this, Lifecycle.ON_FIRE);
-            throw Exceptions.propagate(t);
-        }
-    }
-
-    /**
-     * Tests HTTP Request reponse matches assertions
-     * <p>
-     * Supported keys in the <code>assertions</code> {@link Map} include:
-     * <ul>
-     * <li>string - simple string match
-     * <li>regex - uses {@link java.lang.String#matches(String)}, if the url returns a multi-line response you should
-     * use the embedded dotall flag expression <code>(?s)</code> in your regex.
-     * <li>status - HTTP status code
-     * </ul>
-     * Wraps the {@link org.apache.brooklyn.util.http.HttpAsserts} immediate assertion methods.
-     * <p>
-     * See the test/resources directory for examples.
-     *
-     * @param url        The target URL to be tested
-     * @param flags      Passed to {@link org.apache.brooklyn.util.http.HttpAsserts#assertContentEventuallyContainsText(Map, String, String, String...)},
-     *                   {@link org.apache.brooklyn.util.http.HttpAsserts#assertContentEventuallyMatches(Map, String, String)},
-     *                   {@link org.apache.brooklyn.util.http.HttpAsserts#assertHttpStatusCodeEventuallyEquals(Map, String, int)}
-     *
-     * @param assertions The map of assertions
-     */
-    private void checkAssertions(final String url, final Map<String,?> flags, final Map<?, ?> assertions) {
-
-        for (final Map.Entry<?, ?> entry : assertions.entrySet()) {
-            if (Objects.equal(entry.getKey(), "regex")) {
-                LOG.info("Testing if url [{}] matches regex [{}]",
-                        new Object[]{url, entry.getValue()});
-                assertContentEventuallyMatches( flags, url, TypeCoercions.coerce(entry.getValue(), String.class));
-            } else if (Objects.equal(entry.getKey(), "string")) {
-                LOG.debug("Testing if url [{}] contains string [{}]",
-                        new Object[]{url, entry.getValue()});
-                assertContentEventuallyContainsText(flags, url, TypeCoercions.coerce(entry.getValue(), String.class));
-            } else if (Objects.equal(entry.getKey(), "status")) {
-                LOG.debug("Testing if url [{}] returns status code [{}]",
-                        new Object[]{url, entry.getValue()});
-                assertHttpStatusCodeEventuallyEquals(flags, url, TypeCoercions.coerce(entry.getValue(), Integer.class));
-            }
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public void stop() {
-        ServiceStateLogic.setExpectedState(this, Lifecycle.STOPPING);
-        sensors().set(SERVICE_UP, false);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public void restart() {
-        final Collection<Location> locations = Lists.newArrayList(getLocations());
-        stop();
-        start(locations);
-    }
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/813bba02/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestSensor.java
----------------------------------------------------------------------
diff --git a/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestSensor.java b/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestSensor.java
deleted file mode 100644
index c6303eb..0000000
--- a/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestSensor.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package org.apache.brooklyn.test.framework;
-
-import com.google.common.collect.Maps;
-import org.apache.brooklyn.api.entity.ImplementedBy;
-import org.apache.brooklyn.config.ConfigKey;
-import org.apache.brooklyn.core.config.ConfigKeys;
-import org.apache.brooklyn.util.core.flags.SetFromFlag;
-import org.apache.brooklyn.util.time.Duration;
-
-import java.util.Map;
-import java.util.concurrent.TimeUnit;
-
-/**
- * Entity that tests a sensor value on another entity
- *
- * @author m4rkmckenna
- */
-@ImplementedBy(value = TestSensorImpl.class)
-public interface TestSensor extends BaseTest {
-
-    @SetFromFlag(nullable = false)
-    ConfigKey<String> SENSOR_NAME = ConfigKeys.newConfigKey(String.class, "sensor", "Sensor to evaluate");
-
-    ConfigKey<Map> ASSERTIONS = ConfigKeys.newConfigKey(Map.class, "assert", "Assertions to be evaluated", Maps.newLinkedHashMap());
-
-    ConfigKey<Duration> TIMEOUT = ConfigKeys.newConfigKey(Duration.class, "timeout", "Time to wait on sensor result", new Duration(1L, TimeUnit.SECONDS));
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/813bba02/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestSensorImpl.java
----------------------------------------------------------------------
diff --git a/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestSensorImpl.java b/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestSensorImpl.java
deleted file mode 100644
index 94151c6..0000000
--- a/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestSensorImpl.java
+++ /dev/null
@@ -1,144 +0,0 @@
-package org.apache.brooklyn.test.framework;
-
-import com.google.api.client.util.Objects;
-import com.google.common.base.Predicate;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Lists;
-import org.apache.brooklyn.api.entity.Entity;
-import org.apache.brooklyn.api.location.Location;
-import org.apache.brooklyn.api.sensor.AttributeSensor;
-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.sensor.Sensors;
-import org.apache.brooklyn.util.core.flags.TypeCoercions;
-import org.apache.brooklyn.util.exceptions.Exceptions;
-import org.apache.brooklyn.util.time.Duration;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Collection;
-import java.util.Map;
-import java.util.regex.Pattern;
-
-import static org.apache.brooklyn.core.entity.EntityAsserts.assertAttributeEventually;
-
-/**
- * {@inheritDoc}
- */
-public class TestSensorImpl extends AbstractTest implements TestSensor {
-
-    private static final Logger LOG = LoggerFactory.getLogger(TestSensorImpl.class);
-
-    /**
-     * {@inheritDoc}
-     */
-    public void start(Collection<? extends Location> locations) {
-        ServiceStateLogic.setExpectedState(this, Lifecycle.STARTING);
-        final Entity target = resolveTarget();
-        final String sensor = getConfig(SENSOR_NAME);
-        final Duration timeout = getConfig(TIMEOUT);
-        final Map assertions = getConfig(ASSERTIONS);
-        try {
-            checkAssertions(target, Sensors.newSensor(Object.class, sensor), ImmutableMap.of("timeout", timeout),
-                    assertions);
-            sensors().set(SERVICE_UP, true);
-            ServiceStateLogic.setExpectedState(this, Lifecycle.RUNNING);
-        } catch (Throwable t) {
-            LOG.info("Sensor [{}] test failed", sensor);
-            sensors().set(SERVICE_UP, false);
-            ServiceStateLogic.setExpectedState(this, Lifecycle.ON_FIRE);
-            throw Exceptions.propagate(t);
-        }
-    }
-
-    /**
-     * Tests sensor values match assertions
-     *
-     * @param target     The {@link Entity} that has the sensor under test
-     * @param sensor     The sensor to test
-     * @param flags      Passed to {@link org.apache.brooklyn.core.entity.EntityAsserts#assertAttributeEventually(Map, Entity, AttributeSensor, Predicate)}
-     * @param assertions The map of assertions
-     */
-    private void checkAssertions(final Entity target, final AttributeSensor<Object> sensor, final Map<?, ?> flags, final Map<?, ?> assertions) {
-        for (final Map.Entry<?, ?> entry : assertions.entrySet()) {
-            if (Objects.equal(entry.getKey(), "equals")) {
-                assertAttributeEventually(flags, target, sensor, isEqualTo(entry.getValue()));
-            } else if (Objects.equal(entry.getKey(), "regex")) {
-                assertAttributeEventually(flags, target, sensor, regexMatches(entry.getValue()));
-            } else if (Objects.equal(entry.getKey(), "isNull")) {
-                assertAttributeEventually(flags, target, sensor, isNull(entry.getValue()));
-            }
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    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);
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public void restart() {
-        final Collection<Location> locations = Lists.newArrayList(getLocations());
-        stop();
-        start(locations);
-    }
-
-    /**
-     * Predicate to check the equality of object
-     *
-     * @param value
-     * @return The created {@link Predicate}
-     */
-    private Predicate<Object> isEqualTo(final Object value) {
-        return new Predicate<Object>() {
-            public boolean apply(final Object input) {
-                return (input != null) && Objects.equal(TypeCoercions.coerce(value, input.getClass()), input);
-            }
-        };
-    }
-
-    /**
-     * Predicate to check if a sensor matches a regex pattern
-     *
-     * @param patternValue
-     * @return
-     */
-    private Predicate<Object> regexMatches(final Object patternValue) {
-        final Pattern pattern = Pattern.compile(TypeCoercions.coerce(patternValue, String.class));
-        return new Predicate<Object>() {
-            public boolean apply(final Object input) {
-                return (input != null) && pattern.matcher(input.toString()).matches();
-            }
-        };
-    }
-
-    /**
-     * Predicate to check if a sensor value is null
-     *
-     * @param isNullValue
-     * @return
-     */
-    private Predicate<Object> isNull(final Object isNullValue) {
-        return new Predicate<Object>() {
-            public boolean apply(final Object input) {
-                return (input == null) == TypeCoercions.coerce(isNullValue, Boolean.class);
-            }
-        };
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/813bba02/sandbox/brooklyn-sandbox-test-framework/src/test/java/org/apache/brooklyn/test/framework/TestEffectorTest.java
----------------------------------------------------------------------
diff --git a/sandbox/brooklyn-sandbox-test-framework/src/test/java/org/apache/brooklyn/test/framework/TestEffectorTest.java b/sandbox/brooklyn-sandbox-test-framework/src/test/java/org/apache/brooklyn/test/framework/TestEffectorTest.java
deleted file mode 100644
index b43c76b..0000000
--- a/sandbox/brooklyn-sandbox-test-framework/src/test/java/org/apache/brooklyn/test/framework/TestEffectorTest.java
+++ /dev/null
@@ -1,106 +0,0 @@
-package org.apache.brooklyn.test.framework;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-import org.apache.brooklyn.api.entity.EntitySpec;
-import org.apache.brooklyn.api.location.LocationSpec;
-import org.apache.brooklyn.api.mgmt.ManagementContext;
-import org.apache.brooklyn.core.entity.Entities;
-import org.apache.brooklyn.core.test.entity.TestApplication;
-import org.apache.brooklyn.location.localhost.LocalhostMachineProvisioningLocation;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import java.util.UUID;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-/**
- * @author m4rkmckenna on 27/10/2015.
- */
-public class TestEffectorTest {
-
-    private TestApplication app;
-    private ManagementContext managementContext;
-    private LocalhostMachineProvisioningLocation loc;
-    private String testId;
-
-    @BeforeMethod
-    public void setup() {
-        testId = UUID.randomUUID().toString();
-        app = TestApplication.Factory.newManagedInstanceForTests();
-        managementContext = app.getManagementContext();
-
-        loc = managementContext.getLocationManager().createLocation(LocationSpec.create(LocalhostMachineProvisioningLocation.class)
-                .configure("name", testId));
-
-    }
-
-
-    @AfterMethod(alwaysRun = true)
-    public void tearDown() throws Exception {
-        if (app != null) Entities.destroyAll(app.getManagementContext());
-    }
-
-
-    @Test
-    public void testSimpleEffector() {
-        final TestCase testCase = app.createAndManageChild(EntitySpec.create(TestCase.class));
-        final TestEntity testEntity = testCase.addChild(EntitySpec.create(TestEntity.class));
-
-
-        final TestEffector testEffector = testCase.addChild(EntitySpec.create(TestEffector.class)
-                .configure(TestEffector.TARGET_ENTITY, testEntity)
-                .configure(TestEffector.EFFECTOR_NAME, "simpleEffector"));
-
-        app.start(ImmutableList.of(app.newSimulatedLocation()));
-
-        assertThat(testEntity.sensors().get(TestEntity.SIMPLE_EFFECTOR_INVOKED)).isNotNull();
-        assertThat(testEntity.sensors().get(TestEntity.SIMPLE_EFFECTOR_INVOKED)).isTrue();
-
-        assertThat(testEffector.sensors().get(TestEffector.EFFECTOR_RESULT)).isNull();
-    }
-
-    @Test
-    public void testComplexffector() {
-        final TestCase testCase = app.createAndManageChild(EntitySpec.create(TestCase.class));
-        final TestEntity testEntity = testCase.addChild(EntitySpec.create(TestEntity.class));
-
-        final long expectedLongValue = System.currentTimeMillis();
-        final boolean expectedBooleanValue = expectedLongValue % 2 == 0;
-
-        final TestEffector testEffector = testCase.addChild(EntitySpec.create(TestEffector.class)
-                .configure(TestEffector.TARGET_ENTITY, testEntity)
-                .configure(TestEffector.EFFECTOR_NAME, "complexEffector")
-                .configure(TestEffector.EFFECTOR_PARAMS, ImmutableMap.of(
-                        "stringValue", testId,
-                        "booleanValue", expectedBooleanValue,
-                        "longValue", expectedLongValue)));
-
-        app.start(ImmutableList.of(app.newSimulatedLocation()));
-
-        assertThat(testEntity.sensors().get(TestEntity.SIMPLE_EFFECTOR_INVOKED)).isNull();
-        assertThat(testEntity.sensors().get(TestEntity.COMPLEX_EFFECTOR_INVOKED)).isNotNull();
-        assertThat(testEntity.sensors().get(TestEntity.COMPLEX_EFFECTOR_INVOKED)).isTrue();
-
-        assertThat(testEntity.sensors().get(TestEntity.COMPLEX_EFFECTOR_STRING)).isNotNull();
-        assertThat(testEntity.sensors().get(TestEntity.COMPLEX_EFFECTOR_STRING)).isEqualTo(testId);
-
-        assertThat(testEntity.sensors().get(TestEntity.COMPLEX_EFFECTOR_BOOLEAN)).isNotNull();
-        assertThat(testEntity.sensors().get(TestEntity.COMPLEX_EFFECTOR_BOOLEAN)).isEqualTo(expectedBooleanValue);
-
-        assertThat(testEntity.sensors().get(TestEntity.COMPLEX_EFFECTOR_LONG)).isNotNull();
-        assertThat(testEntity.sensors().get(TestEntity.COMPLEX_EFFECTOR_LONG)).isEqualTo(expectedLongValue);
-
-        assertThat(testEffector.sensors().get(TestEffector.EFFECTOR_RESULT)).isNotNull();
-        assertThat(testEffector.sensors().get(TestEffector.EFFECTOR_RESULT)).isInstanceOf(TestEntity.TestPojo.class);
-
-        final TestEntity.TestPojo effectorResult = (TestEntity.TestPojo) testEffector.sensors().get(TestEffector.EFFECTOR_RESULT);
-        assertThat(effectorResult.getBooleanValue()).isEqualTo(expectedBooleanValue);
-        assertThat(effectorResult.getStringValue()).isEqualTo(testId);
-        assertThat(effectorResult.getLongValue()).isEqualTo(expectedLongValue);
-
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/813bba02/sandbox/brooklyn-sandbox-test-framework/src/test/java/org/apache/brooklyn/test/framework/TestEntity.java
----------------------------------------------------------------------
diff --git a/sandbox/brooklyn-sandbox-test-framework/src/test/java/org/apache/brooklyn/test/framework/TestEntity.java b/sandbox/brooklyn-sandbox-test-framework/src/test/java/org/apache/brooklyn/test/framework/TestEntity.java
deleted file mode 100644
index 933b227..0000000
--- a/sandbox/brooklyn-sandbox-test-framework/src/test/java/org/apache/brooklyn/test/framework/TestEntity.java
+++ /dev/null
@@ -1,55 +0,0 @@
-package org.apache.brooklyn.test.framework;
-
-import org.apache.brooklyn.api.entity.Entity;
-import org.apache.brooklyn.api.entity.ImplementedBy;
-import org.apache.brooklyn.core.annotation.Effector;
-import org.apache.brooklyn.core.annotation.EffectorParam;
-import org.apache.brooklyn.core.config.ConfigKeys;
-import org.apache.brooklyn.core.entity.trait.Startable;
-import org.apache.brooklyn.core.sensor.AttributeSensorAndConfigKey;
-
-/**
- * @author m4rkmckenna on 27/10/2015.
- */
-
-@ImplementedBy(TestEntityImpl.class)
-public interface TestEntity extends Entity, Startable {
-
-    AttributeSensorAndConfigKey<Boolean, Boolean> SIMPLE_EFFECTOR_INVOKED = ConfigKeys.newSensorAndConfigKey(Boolean.class, "simple-effector-invoked", "");
-    AttributeSensorAndConfigKey<Boolean, Boolean> COMPLEX_EFFECTOR_INVOKED = ConfigKeys.newSensorAndConfigKey(Boolean.class, "complex-effector-invoked", "");
-    AttributeSensorAndConfigKey<String, String> COMPLEX_EFFECTOR_STRING = ConfigKeys.newSensorAndConfigKey(String.class, "complex-effector-string", "");
-    AttributeSensorAndConfigKey<Boolean, Boolean> COMPLEX_EFFECTOR_BOOLEAN = ConfigKeys.newSensorAndConfigKey(Boolean.class, "complex-effector-boolean", "");
-    AttributeSensorAndConfigKey<Long, Long> COMPLEX_EFFECTOR_LONG = ConfigKeys.newSensorAndConfigKey(Long.class, "complex-effector-long", "");
-
-    @Effector
-    void simpleEffector();
-
-    @Effector
-    TestPojo complexEffector(@EffectorParam(name = "stringValue") final String stringValue,
-                             @EffectorParam(name = "booleanValue") final Boolean booleanValue,
-                             @EffectorParam(name = "longValue") final Long longValue);
-
-    class TestPojo {
-        private final String stringValue;
-        private final Boolean booleanValue;
-        private final Long longValue;
-
-        public TestPojo(final String stringValue, final Boolean booleanValue, final Long longValue) {
-            this.stringValue = stringValue;
-            this.booleanValue = booleanValue;
-            this.longValue = longValue;
-        }
-
-        public String getStringValue() {
-            return stringValue;
-        }
-
-        public Boolean getBooleanValue() {
-            return booleanValue;
-        }
-
-        public Long getLongValue() {
-            return longValue;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/813bba02/sandbox/brooklyn-sandbox-test-framework/src/test/java/org/apache/brooklyn/test/framework/TestEntityImpl.java
----------------------------------------------------------------------
diff --git a/sandbox/brooklyn-sandbox-test-framework/src/test/java/org/apache/brooklyn/test/framework/TestEntityImpl.java b/sandbox/brooklyn-sandbox-test-framework/src/test/java/org/apache/brooklyn/test/framework/TestEntityImpl.java
deleted file mode 100644
index b3386f2..0000000
--- a/sandbox/brooklyn-sandbox-test-framework/src/test/java/org/apache/brooklyn/test/framework/TestEntityImpl.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package org.apache.brooklyn.test.framework;
-
-import org.apache.brooklyn.api.location.Location;
-import org.apache.brooklyn.core.annotation.EffectorParam;
-import org.apache.brooklyn.core.entity.AbstractEntity;
-
-import java.util.Collection;
-
-/**
- * @author m4rkmckenna on 27/10/2015.
- */
-public class TestEntityImpl extends AbstractEntity implements TestEntity {
-    @Override
-    public void start(final Collection<? extends Location> locations) {
-    }
-
-    @Override
-    public void stop() {
-
-    }
-
-    @Override
-    public void restart() {
-    }
-
-    @Override
-    public void simpleEffector() {
-        sensors().set(SIMPLE_EFFECTOR_INVOKED, Boolean.TRUE);
-    }
-
-    @Override
-    public TestPojo complexEffector(@EffectorParam(name = "stringValue") final String stringValue, @EffectorParam(name = "booleanValue") final Boolean booleanValue, @EffectorParam(name = "longValue") final Long longValue) {
-        sensors().set(COMPLEX_EFFECTOR_INVOKED, Boolean.TRUE);
-        sensors().set(COMPLEX_EFFECTOR_STRING, stringValue);
-        sensors().set(COMPLEX_EFFECTOR_BOOLEAN, booleanValue);
-        sensors().set(COMPLEX_EFFECTOR_LONG, longValue);
-        return new TestPojo(stringValue, booleanValue, longValue);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/813bba02/sandbox/brooklyn-sandbox-test-framework/src/test/java/org/apache/brooklyn/test/framework/TestSensorTest.java
----------------------------------------------------------------------
diff --git a/sandbox/brooklyn-sandbox-test-framework/src/test/java/org/apache/brooklyn/test/framework/TestSensorTest.java b/sandbox/brooklyn-sandbox-test-framework/src/test/java/org/apache/brooklyn/test/framework/TestSensorTest.java
deleted file mode 100644
index 0b653eb..0000000
--- a/sandbox/brooklyn-sandbox-test-framework/src/test/java/org/apache/brooklyn/test/framework/TestSensorTest.java
+++ /dev/null
@@ -1,270 +0,0 @@
-package org.apache.brooklyn.test.framework;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-import org.apache.brooklyn.api.entity.EntitySpec;
-import org.apache.brooklyn.api.location.LocationSpec;
-import org.apache.brooklyn.api.mgmt.ManagementContext;
-import org.apache.brooklyn.core.config.ConfigKeys;
-import org.apache.brooklyn.core.entity.Entities;
-import org.apache.brooklyn.core.sensor.AttributeSensorAndConfigKey;
-import org.apache.brooklyn.core.test.entity.TestApplication;
-import org.apache.brooklyn.location.localhost.LocalhostMachineProvisioningLocation;
-import org.apache.brooklyn.util.exceptions.Exceptions;
-import org.apache.brooklyn.util.exceptions.PropagatedRuntimeException;
-import org.apache.commons.lang3.builder.ToStringBuilder;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import java.util.UUID;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-/**
- * @author m4rkmckenna on 27/10/2015.
- */
-public class TestSensorTest {
-
-    private static final AttributeSensorAndConfigKey<Boolean, Boolean> BOOLEAN_SENSOR = ConfigKeys.newSensorAndConfigKey(Boolean.class, "boolean-sensor", "Boolean Sensor");
-    private static final AttributeSensorAndConfigKey<String, String> STRING_SENSOR = ConfigKeys.newSensorAndConfigKey(String.class, "string-sensor", "String Sensor");
-    private static final AttributeSensorAndConfigKey<Object, Object> OBJECT_SENSOR = ConfigKeys.newSensorAndConfigKey(Object.class, "object-sensor", "Object Sensor");
-
-    private TestApplication app;
-    private ManagementContext managementContext;
-    private LocalhostMachineProvisioningLocation loc;
-    private String testId;
-
-    @BeforeMethod
-    public void setup() {
-        testId = UUID.randomUUID().toString();
-        app = TestApplication.Factory.newManagedInstanceForTests();
-        managementContext = app.getManagementContext();
-        loc = managementContext.getLocationManager().createLocation(LocationSpec.create(LocalhostMachineProvisioningLocation.class)
-                .configure("name", testId));
-    }
-
-    @AfterMethod(alwaysRun = true)
-    public void tearDown() throws Exception {
-        if (app != null) Entities.destroyAll(app.getManagementContext());
-    }
-
-    @Test
-    public void testAssertEqual() {
-        //Add Sensor Test for BOOLEAN sensor
-        app.createAndManageChild(EntitySpec.create(TestSensor.class)
-                .configure(TestSensor.TARGET_ENTITY, app)
-                .configure(TestSensor.SENSOR_NAME, BOOLEAN_SENSOR.getName())
-                .configure(TestSensor.ASSERTIONS, ImmutableMap.of("equals", true)));
-        //Add Sensor Test for STRING sensor
-        app.createAndManageChild(EntitySpec.create(TestSensor.class)
-                .configure(TestSensor.TARGET_ENTITY, app)
-                .configure(TestSensor.SENSOR_NAME, STRING_SENSOR.getName())
-                .configure(TestSensor.ASSERTIONS, ImmutableMap.of("equals", testId)));
-
-        //Set BOOLEAN Sensor to true
-        app.sensors().set(BOOLEAN_SENSOR, Boolean.TRUE);
-        //Set STRING sensor to random string
-        app.sensors().set(STRING_SENSOR, testId);
-
-
-        app.start(ImmutableList.of(loc));
-
-    }
-
-    @Test
-    public void testAssertEqualFailure() {
-        boolean booleanAssertFailed = false;
-
-        //Add Sensor Test for BOOLEAN sensor
-        app.createAndManageChild(EntitySpec.create(TestSensor.class)
-                .configure(TestSensor.TARGET_ENTITY, app)
-                .configure(TestSensor.SENSOR_NAME, BOOLEAN_SENSOR.getName())
-                .configure(TestSensor.ASSERTIONS, ImmutableMap.of("equals", true)));
-
-        //Set BOOLEAN Sensor to false
-        app.sensors().set(BOOLEAN_SENSOR, Boolean.FALSE);
-
-        try {
-            app.start(ImmutableList.of(loc));
-        } catch (final PropagatedRuntimeException pre) {
-            final AssertionError assertionError = Exceptions.getFirstThrowableOfType(pre, AssertionError.class);
-            assertThat(assertionError).isNotNull();
-            booleanAssertFailed = true;
-        } finally {
-            assertThat(booleanAssertFailed).isTrue();
-        }
-    }
-
-    @Test
-    public void testAssertEqualOnNullSenor() {
-        boolean booleanAssertFailed = false;
-
-        //Add Sensor Test for BOOLEAN sensor
-        app.createAndManageChild(EntitySpec.create(TestSensor.class)
-                .configure(TestSensor.TARGET_ENTITY, app)
-                .configure(TestSensor.SENSOR_NAME, BOOLEAN_SENSOR.getName())
-                .configure(TestSensor.ASSERTIONS, ImmutableMap.of("equals", false)));
-
-        try {
-            app.start(ImmutableList.of(loc));
-        } catch (final PropagatedRuntimeException pre) {
-            final AssertionError assertionError = Exceptions.getFirstThrowableOfType(pre, AssertionError.class);
-            assertThat(assertionError).isNotNull().as("An assertion error should have been thrown");
-            booleanAssertFailed = true;
-        } finally {
-            assertThat(booleanAssertFailed).isTrue().as("Equals assert should have failed as the sensor is NULL");
-        }
-    }
-
-    @Test
-    public void testAssertNull() {
-        //Add Sensor Test for BOOLEAN sensor
-        app.createAndManageChild(EntitySpec.create(TestSensor.class)
-                .configure(TestSensor.TARGET_ENTITY, app)
-                .configure(TestSensor.SENSOR_NAME, BOOLEAN_SENSOR.getName())
-                .configure(TestSensor.ASSERTIONS, ImmutableMap.of("isNull", true)));
-        //Add Sensor Test for STRING sensor
-        app.createAndManageChild(EntitySpec.create(TestSensor.class)
-                .configure(TestSensor.TARGET_ENTITY, app)
-                .configure(TestSensor.SENSOR_NAME, STRING_SENSOR.getName())
-                .configure(TestSensor.ASSERTIONS, ImmutableMap.of("isNull", false)));
-
-        //Set STRING sensor to random string
-        app.sensors().set(STRING_SENSOR, testId);
-
-        app.start(ImmutableList.of(loc));
-
-    }
-
-
-    @Test
-    public void testAssertNullFail() {
-        boolean sensorTestFail = false;
-        //Add Sensor Test for STRING sensor
-        app.createAndManageChild(EntitySpec.create(TestSensor.class)
-                .configure(TestSensor.TARGET_ENTITY, app)
-                .configure(TestSensor.SENSOR_NAME, STRING_SENSOR.getName())
-                .configure(TestSensor.ASSERTIONS, ImmutableMap.of("isNull", true)));
-
-        //Set STRING sensor to random string
-        app.sensors().set(STRING_SENSOR, testId);
-
-
-        try {
-            app.start(ImmutableList.of(loc));
-        } catch (final PropagatedRuntimeException pre) {
-            final AssertionError assertionError = Exceptions.getFirstThrowableOfType(pre, AssertionError.class);
-            assertThat(assertionError).isNotNull().as("An assertion error should have been thrown");
-            sensorTestFail = true;
-        } finally {
-            assertThat(sensorTestFail).isTrue().as("isNull assert should have failed as the sensor has been set");
-        }
-
-    }
-
-    @Test
-    public void testAssertRegex() {
-        final long time = System.currentTimeMillis();
-        final String sensorValue = String.format("%s%s%s", UUID.randomUUID().toString(), time, UUID.randomUUID().toString());
-
-        //Add Sensor Test for STRING sensor
-        app.createAndManageChild(EntitySpec.create(TestSensor.class)
-                .configure(TestSensor.TARGET_ENTITY, app)
-                .configure(TestSensor.SENSOR_NAME, STRING_SENSOR.getName())
-                .configure(TestSensor.ASSERTIONS, ImmutableMap.of("regex", String.format(".*%s.*", time))));
-        app.createAndManageChild(EntitySpec.create(TestSensor.class)
-                .configure(TestSensor.TARGET_ENTITY, app)
-                .configure(TestSensor.SENSOR_NAME, BOOLEAN_SENSOR.getName())
-                .configure(TestSensor.ASSERTIONS, ImmutableMap.of("regex", "true")));
-
-        //Set STRING sensor
-        app.sensors().set(STRING_SENSOR, sensorValue);
-        app.sensors().set(BOOLEAN_SENSOR, true);
-
-
-        app.start(ImmutableList.of(loc));
-    }
-
-    @Test
-    public void testAssertRegexFail() {
-        boolean sensorTestFail = false;
-        final String sensorValue = String.format("%s%s%s", UUID.randomUUID().toString(), System.currentTimeMillis(), UUID.randomUUID().toString());
-
-        //Add Sensor Test for STRING sensor
-        app.createAndManageChild(EntitySpec.create(TestSensor.class)
-                .configure(TestSensor.TARGET_ENTITY, app)
-                .configure(TestSensor.SENSOR_NAME, STRING_SENSOR.getName())
-                .configure(TestSensor.ASSERTIONS, ImmutableMap.of("regex", String.format(".*%s.*", UUID.randomUUID().toString()))));
-
-        //Set STRING sensor
-        app.sensors().set(STRING_SENSOR, sensorValue);
-
-
-        try {
-            app.start(ImmutableList.of(loc));
-        } catch (final PropagatedRuntimeException pre) {
-            final AssertionError assertionError = Exceptions.getFirstThrowableOfType(pre, AssertionError.class);
-            assertThat(assertionError).isNotNull().as("An assertion error should have been thrown");
-            sensorTestFail = true;
-        } finally {
-            assertThat(sensorTestFail).isTrue().as("regex assert should have failed");
-        }
-    }
-
-    @Test
-    public void testAssertRegexOnNullSensor() {
-        boolean sensorTestFail = false;
-        final String sensorValue = String.format("%s%s%s", UUID.randomUUID().toString(), System.currentTimeMillis(), UUID.randomUUID().toString());
-
-        //Add Sensor Test for STRING sensor
-        app.createAndManageChild(EntitySpec.create(TestSensor.class)
-                .configure(TestSensor.TARGET_ENTITY, app)
-                .configure(TestSensor.SENSOR_NAME, STRING_SENSOR.getName())
-                .configure(TestSensor.ASSERTIONS, ImmutableMap.of("regex", String.format(".*%s.*", UUID.randomUUID().toString()))));
-
-        try {
-            app.start(ImmutableList.of(loc));
-        } catch (final PropagatedRuntimeException pre) {
-            final AssertionError assertionError = Exceptions.getFirstThrowableOfType(pre, AssertionError.class);
-            assertThat(assertionError).isNotNull().as("An assertion error should have been thrown");
-            sensorTestFail = true;
-        } finally {
-            assertThat(sensorTestFail).isTrue().as("regex assert should have failed");
-        }
-    }
-
-
-    @Test
-    public void testAssertRegexOnNonStringSensor() {
-        //Add Sensor Test for OBJECT sensor
-        app.createAndManageChild(EntitySpec.create(TestSensor.class)
-                .configure(TestSensor.TARGET_ENTITY, app)
-                .configure(TestSensor.SENSOR_NAME, OBJECT_SENSOR.getName())
-                .configure(TestSensor.ASSERTIONS, ImmutableMap.of("regex", ".*TestObject.*id=.*")));
-
-        app.sensors().set(OBJECT_SENSOR, new TestObject());
-
-        app.start(ImmutableList.of(loc));
-
-    }
-
-
-    class TestObject {
-        private final String id;
-
-        public TestObject() {
-            id = UUID.randomUUID().toString();
-        }
-
-        public String getId() {
-            return id;
-        }
-
-        @Override
-        public String toString() {
-            return ToStringBuilder.reflectionToString(this);
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/813bba02/usage/test-framework/README.md
----------------------------------------------------------------------
diff --git a/usage/test-framework/README.md b/usage/test-framework/README.md
new file mode 100644
index 0000000..a4ca928
--- /dev/null
+++ b/usage/test-framework/README.md
@@ -0,0 +1,109 @@
+# Entities
+
+## TestCase
+A logical grouping for tests eg Restart tests
+```
+type: org.apache.brooklyn.test.framework.TestCase
+  name: Stop Test
+  brooklyn.children:
+  - ***
+  - ***
+```
+
+## TestSensor
+Entity that tests a sensor value on another entity eg service.isUp == TRUE
+
+#### Configuration
+| Key | Description | Required |
+| --- | ----------- | -------- |
+| target | The target entity to test | yes (no if *targetId* is supplied) |
+| targetId | The id of the target entity to test | yes (no if *target* is supplied) |
+| assert | Assertions to be evaluated | yes |
+| timeout | The duration to wait on a result | no |
+
+##### Assertions
+| Key | Description |
+| --- | ----------- |
+| equal | Sensor value equals  |
+| regex | Sensor value matches regex |
+| isNull | Sensor value has not been set |
+
+```
+type: org.apache.brooklyn.test.framework.TestSensor
+target: $brooklyn:component("nginx1")
+sensor: service.isUp
+equals: true
+timeout: 5m
+```
+
+## TestEffector
+Entity that invokes an effector on another entity eg restart
+
+#### Configuration
+| Key | Description | Required |
+| --- | ----------- | -------- |
+| target | The target entity to effect | yes (no if *targetId* is supplied) |
+| targetId | The id of the target entity to effect | yes (no if *target* is supplied) |
+| effector | The name of the effector to invoke | yes |
+| params | Parameters to pass to the effector | no |
+| timeout | The duration to wait on a response from an effector | no |
+
+#### Sensors
+| Key | Description |
+| --- | ----------- |
+| result | The result of invoking the effector (null if no result) |
+
+```
+type: org.apache.brooklyn.test.framework.TestEffector
+name: Deploy WAR
+target: $brooklyn:component("tomcat")
+effector: deploy
+params:
+  url: https://tomcat.apache.org/tomcat-6.0-doc/appdev/sample/sample.war
+  targetName: sample1
+```
+
+## TestHtmlCall
+Entity that makes a HTTP Request and tests the response
+
+#### Configuration
+| Key | Description | Required |
+| --- | ----------- | -------- |
+| url | The URL to test | yes |
+| assert | Assertions to be evaluated | yes |
+| timeout | The duration to wait for assertion result | no |
+
+##### Assertions
+| Key | Description |
+| --- | ----------- |
+| string | HTTP body contains text |
+| regex | HTTP body matches regex |
+| status | HTTP status code equals |
+
+```
+  - type: org.apache.brooklyn.test.framework.TestHttpCall
+    name: Status Code 200
+    url: $brooklyn:component("tomcat").attributeWhenReady("main.uri")
+    timeout: 1m
+    assert:
+      status: 200
+  - type: org.apache.brooklyn.test.framework.TestHttpCall
+    name: String match
+    url: $brooklyn:component("tomcat").attributeWhenReady("main.uri")
+    timeout: 1m
+    assert:
+      string: Sample Brooklyn Deployed
+  - type: org.apache.brooklyn.test.framework.TestHttpCall
+    name: Status Code 404
+    url: $brooklyn:formatString("%s/invalidpath/", component("tomcat").attributeWhenReady("webapp.url"))
+    assert:
+      status: 404
+  - type: org.apache.brooklyn.test.framework.TestHttpCall
+    name: Regex match
+    url: $brooklyn:component("tomcat").attributeWhenReady("webapp.url")
+    # the regex assert uses java.lang.String under the hood so if the url is expected to returns
+    # a multi-line response you should use the embedded dotall flag expression `(?s)` in your regex.
+    # See: http://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html
+    assert:
+      regex: "(?s).*illustrate(\\s)*how(\\s)*web(\\s)*applications.*"
+```



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

Posted by he...@apache.org.
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);
-        }
     }
 
     /**


[20/21] incubator-brooklyn git commit: Removed unused field from TestSensorTest#testAssertRegexOnNullSensor

Posted by he...@apache.org.
Removed unused field from TestSensorTest#testAssertRegexOnNullSensor


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

Branch: refs/heads/master
Commit: 8019fc17197064e8167cc6a5b2335fd2c80fa205
Parents: 5f04457
Author: Mark McKenna <m4...@gmail.com>
Authored: Wed Nov 11 15:36:25 2015 +0000
Committer: Mark McKenna <m4...@gmail.com>
Committed: Wed Nov 11 15:36:25 2015 +0000

----------------------------------------------------------------------
 .../java/org/apache/brooklyn/test/framework/TestSensorTest.java   | 3 ---
 1 file changed, 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/8019fc17/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/TestSensorTest.java
----------------------------------------------------------------------
diff --git a/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/TestSensorTest.java b/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/TestSensorTest.java
index 810768c..2d033e6 100644
--- a/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/TestSensorTest.java
+++ b/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/TestSensorTest.java
@@ -18,7 +18,6 @@ import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
-
 import static org.assertj.core.api.Assertions.assertThat;
 
 /**
@@ -215,8 +214,6 @@ public class TestSensorTest {
     @Test
     public void testAssertRegexOnNullSensor() {
         boolean sensorTestFail = false;
-        final String sensorValue = String.format("%s%s%s", Identifiers.makeRandomId(8), System.currentTimeMillis(), Identifiers.makeRandomId(8));
-
         //Add Sensor Test for STRING sensor
         app.createAndManageChild(EntitySpec.create(TestSensor.class)
                 .configure(TestSensor.TARGET_ENTITY, app)


[15/21] incubator-brooklyn git commit: Moved config keys [assert, timeout] into BaseTest [TestHttpCall, TestEffector] now extend BaseTest

Posted by he...@apache.org.
Moved config keys [assert,timeout] into BaseTest [TestHttpCall,TestEffector] now extend BaseTest


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

Branch: refs/heads/master
Commit: 4cb533078e5954e53104cd7be581f756b2360b80
Parents: a346f5c
Author: Mark McKenna <m4...@gmail.com>
Authored: Wed Nov 11 12:19:23 2015 +0000
Committer: Mark McKenna <m4...@gmail.com>
Committed: Wed Nov 11 12:19:23 2015 +0000

----------------------------------------------------------------------
 .../apache/brooklyn/test/framework/BaseTest.java    | 15 +++++++++++++++
 .../brooklyn/test/framework/TestEffector.java       |  2 --
 .../brooklyn/test/framework/TestHttpCall.java       | 16 +---------------
 .../brooklyn/test/framework/TestHttpCallImpl.java   | 14 +++++---------
 .../apache/brooklyn/test/framework/TestSensor.java  |  3 ---
 5 files changed, 21 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4cb53307/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/BaseTest.java
----------------------------------------------------------------------
diff --git a/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/BaseTest.java b/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/BaseTest.java
index 69eb04d..19dcb63 100644
--- a/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/BaseTest.java
+++ b/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/BaseTest.java
@@ -1,9 +1,14 @@
 package org.apache.brooklyn.test.framework;
 
+import com.google.common.collect.Maps;
 import org.apache.brooklyn.api.entity.Entity;
 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.util.time.Duration;
+
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
 
 /**
  * A base interface for all tests.
@@ -21,6 +26,16 @@ public interface BaseTest extends Entity, Startable {
     ConfigKey<String> TARGET_ID = ConfigKeys.newStringConfigKey("targetId", "Id of the entity under test");
 
     /**
+     * The assertions to be made
+     */
+    ConfigKey<Map> ASSERTIONS = ConfigKeys.newConfigKey(Map.class, "assert", "Assertions to be evaluated", Maps.newHashMap());
+
+    /**
+     * THe duration to wait
+     */
+    ConfigKey<Duration> TIMEOUT = ConfigKeys.newConfigKey(Duration.class, "timeout", "Time to wait on result", new Duration(1L, TimeUnit.SECONDS));
+
+    /**
      * Get the target of the test.
      *
      * @return The target.

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4cb53307/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestEffector.java
----------------------------------------------------------------------
diff --git a/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestEffector.java b/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestEffector.java
index e9ec832..f280137 100644
--- a/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestEffector.java
+++ b/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestEffector.java
@@ -26,8 +26,6 @@ public interface TestEffector extends BaseTest {
     ConfigKey<Map<String, ?>> EFFECTOR_PARAMS = ConfigKeys.newConfigKey(new TypeToken<Map<String, ?>>() {
     }, "params", "The parameters to pass to the effector", ImmutableMap.<String, Object>of());
 
-    ConfigKey<Duration> TIMEOUT = ConfigKeys.newConfigKey(Duration.class, "timeout", "Time to wait on sensor result", new Duration(5L, TimeUnit.SECONDS));
-
     AttributeSensorAndConfigKey<Object, Object> EFFECTOR_RESULT = ConfigKeys.newSensorAndConfigKey(Object.class, "result", "The result of invoking the effector");
 
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4cb53307/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestHttpCall.java
----------------------------------------------------------------------
diff --git a/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestHttpCall.java b/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestHttpCall.java
index 5dfa1c8..b283af8 100644
--- a/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestHttpCall.java
+++ b/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestHttpCall.java
@@ -1,16 +1,9 @@
 package org.apache.brooklyn.test.framework;
 
-import com.google.common.collect.Maps;
-import org.apache.brooklyn.api.entity.Entity;
 import org.apache.brooklyn.api.entity.ImplementedBy;
 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.util.core.flags.SetFromFlag;
-import org.apache.brooklyn.util.time.Duration;
-
-import java.util.Map;
-import java.util.concurrent.TimeUnit;
 
 /**
  * Entity that makes a HTTP Request and tests the respose
@@ -18,16 +11,9 @@ import java.util.concurrent.TimeUnit;
  * @author johnmccabe
  */
 @ImplementedBy(value = TestHttpCallImpl.class)
-public interface TestHttpCall extends Entity, Startable {
+public interface TestHttpCall extends BaseTest {
 
     @SetFromFlag(nullable = false)
     ConfigKey<String> TARGET_URL = ConfigKeys.newStringConfigKey("url", "URL to test");
 
-    @SetFromFlag(nullable = false)
-    ConfigKey<Map> ASSERTIONS = ConfigKeys.newConfigKey(Map.class, "assert",
-            "Assertions to be evaluated", Maps.newLinkedHashMap());
-
-    ConfigKey<Duration> TIMEOUT = ConfigKeys.newConfigKey(Duration.class, "timeout",
-            "The duration to wait for assertion result", new Duration(1L, TimeUnit.SECONDS));
-
 }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4cb53307/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 7413066..1b0b3a6 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
@@ -4,7 +4,6 @@ import com.google.api.client.util.Objects;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.Lists;
 import org.apache.brooklyn.api.location.Location;
-import org.apache.brooklyn.core.entity.AbstractEntity;
 import org.apache.brooklyn.core.entity.lifecycle.Lifecycle;
 import org.apache.brooklyn.core.entity.lifecycle.ServiceStateLogic;
 import org.apache.brooklyn.util.core.flags.TypeCoercions;
@@ -16,14 +15,12 @@ import org.slf4j.LoggerFactory;
 import java.util.Collection;
 import java.util.Map;
 
-import static org.apache.brooklyn.util.http.HttpAsserts.assertContentEventuallyContainsText;
-import static org.apache.brooklyn.util.http.HttpAsserts.assertContentEventuallyMatches;
-import static org.apache.brooklyn.util.http.HttpAsserts.assertHttpStatusCodeEventuallyEquals;
+import static org.apache.brooklyn.util.http.HttpAsserts.*;
 
 /**
  * {@inheritDoc}
  */
-public class TestHttpCallImpl extends AbstractEntity implements TestHttpCall {
+public class TestHttpCallImpl extends AbstractTest implements TestHttpCall {
 
     private static final Logger LOG = LoggerFactory.getLogger(TestHttpCallImpl.class);
 
@@ -36,7 +33,7 @@ public class TestHttpCallImpl extends AbstractEntity implements TestHttpCall {
         final Map assertions = getConfig(ASSERTIONS);
         final Duration timeout = getConfig(TIMEOUT);
         try {
-            checkAssertions(url.toString(), ImmutableMap.of("timeout", timeout), assertions);
+            checkAssertions(url, ImmutableMap.of("timeout", timeout), assertions);
             sensors().set(SERVICE_UP, true);
             ServiceStateLogic.setExpectedState(this, Lifecycle.RUNNING);
         } catch (Throwable t) {
@@ -65,16 +62,15 @@ public class TestHttpCallImpl extends AbstractEntity implements TestHttpCall {
      * @param flags      Passed to {@link org.apache.brooklyn.util.http.HttpAsserts#assertContentEventuallyContainsText(Map, String, String, String...)},
      *                   {@link org.apache.brooklyn.util.http.HttpAsserts#assertContentEventuallyMatches(Map, String, String)},
      *                   {@link org.apache.brooklyn.util.http.HttpAsserts#assertHttpStatusCodeEventuallyEquals(Map, String, int)}
-     *
      * @param assertions The map of assertions
      */
-    private void checkAssertions(final String url, final Map<String,?> flags, final Map<?, ?> assertions) {
+    private void checkAssertions(final String url, final Map<String, ?> flags, final Map<?, ?> assertions) {
 
         for (final Map.Entry<?, ?> entry : assertions.entrySet()) {
             if (Objects.equal(entry.getKey(), "regex")) {
                 LOG.info("Testing if url [{}] matches regex [{}]",
                         new Object[]{url, entry.getValue()});
-                assertContentEventuallyMatches( flags, url, TypeCoercions.coerce(entry.getValue(), String.class));
+                assertContentEventuallyMatches(flags, url, TypeCoercions.coerce(entry.getValue(), String.class));
             } else if (Objects.equal(entry.getKey(), "string")) {
                 LOG.debug("Testing if url [{}] contains string [{}]",
                         new Object[]{url, entry.getValue()});

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4cb53307/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestSensor.java
----------------------------------------------------------------------
diff --git a/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestSensor.java b/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestSensor.java
index c6303eb..e5b46a5 100644
--- a/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestSensor.java
+++ b/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestSensor.java
@@ -21,7 +21,4 @@ public interface TestSensor extends BaseTest {
     @SetFromFlag(nullable = false)
     ConfigKey<String> SENSOR_NAME = ConfigKeys.newConfigKey(String.class, "sensor", "Sensor to evaluate");
 
-    ConfigKey<Map> ASSERTIONS = ConfigKeys.newConfigKey(Map.class, "assert", "Assertions to be evaluated", Maps.newLinkedHashMap());
-
-    ConfigKey<Duration> TIMEOUT = ConfigKeys.newConfigKey(Duration.class, "timeout", "Time to wait on sensor result", new Duration(1L, TimeUnit.SECONDS));
 }


[02/21] incubator-brooklyn git commit: Changes due to comments & changes to PR #994

Posted by he...@apache.org.
Changes due to comments & changes to PR #994

org.apache.brooklyn.util.http.HttpUtils has been renamed to HttpAsserts


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

Branch: refs/heads/master
Commit: d372c194770f2355fca17ca83a938bca202366e1
Parents: cfa4b3b
Author: Mark McKenna <m4...@gmail.com>
Authored: Wed Nov 4 18:34:27 2015 +0000
Committer: Mark McKenna <m4...@gmail.com>
Committed: Mon Nov 9 20:56:21 2015 +0000

----------------------------------------------------------------------
 .../org/apache/brooklyn/test/framework/TestHttpCallImpl.java     | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/d372c194/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestHttpCallImpl.java
----------------------------------------------------------------------
diff --git a/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestHttpCallImpl.java b/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestHttpCallImpl.java
index c0fd608..386f20c 100644
--- a/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestHttpCallImpl.java
+++ b/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestHttpCallImpl.java
@@ -14,7 +14,7 @@ import org.slf4j.LoggerFactory;
 import java.util.Collection;
 import java.util.Map;
 
-import static org.apache.brooklyn.util.http.HttpUtils.*;
+import static org.apache.brooklyn.util.http.HttpAsserts.*;
 
 /**
  * {@inheritDoc}
@@ -52,7 +52,7 @@ public class TestHttpCallImpl extends AbstractEntity implements TestHttpCall {
      * use the embedded dotall flag expression <code>(?s)</code> in your regex.
      * <li>status - HTTP status code
      * </ul>
-     * Wraps the {@link org.apache.brooklyn.util.http.HttpUtils} immediate assertion methods.
+     * Wraps the {@link org.apache.brooklyn.util.http.HttpAsserts} immediate assertion methods.
      * <p>
      * See the test/resources directory for examples.
      *


[07/21] incubator-brooklyn git commit: Rolled assertj version back to 2.2.0 to address test failures in jenkins

Posted by he...@apache.org.
Rolled assertj version back to 2.2.0 to address test failures in jenkins

Assertj version 3.2.0 is for java 1.8 ... as jenkins is running 1.7 version 2.2.0 must be used


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

Branch: refs/heads/master
Commit: eaacdf0a5656d3a6b10c9c7d8fad374382710c0c
Parents: 813bba0
Author: Mark McKenna <m4...@gmail.com>
Authored: Mon Nov 9 21:55:57 2015 +0000
Committer: Mark McKenna <m4...@gmail.com>
Committed: Mon Nov 9 21:57:29 2015 +0000

----------------------------------------------------------------------
 usage/test-framework/pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/eaacdf0a/usage/test-framework/pom.xml
----------------------------------------------------------------------
diff --git a/usage/test-framework/pom.xml b/usage/test-framework/pom.xml
index 5606a8d..2f6c0c2 100644
--- a/usage/test-framework/pom.xml
+++ b/usage/test-framework/pom.xml
@@ -14,7 +14,7 @@
     <name>Brooklyn Test Framework</name>
 
     <properties>
-        <assertj.version>3.2.0</assertj.version>
+        <assertj.version>2.2.0</assertj.version>
     </properties>
 
     <dependencies>


[05/21] incubator-brooklyn git commit: Moved sandbox/brooklyn-sandbox-test-framework to usage/test-framework

Posted by he...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/813bba02/usage/test-framework/etc/exampl-catalog.bom
----------------------------------------------------------------------
diff --git a/usage/test-framework/etc/exampl-catalog.bom b/usage/test-framework/etc/exampl-catalog.bom
new file mode 100644
index 0000000..ab7e54b
--- /dev/null
+++ b/usage/test-framework/etc/exampl-catalog.bom
@@ -0,0 +1,15 @@
+brooklyn.catalog:
+  id: simple-tomcat
+  version: 1.0
+  itemType: template
+  iconUrl: http://tomcat.apache.org/images/tomcat.png
+  name: Simple Tomcat
+  license: Apache-2.0
+  item:
+    brooklyn.config:
+      simple.confg: someValue
+    services:
+    - type: org.apache.brooklyn.entity.webapp.tomcat.TomcatServer
+      id: tomcat
+      name: Tomcat
+      war: https://tomcat.apache.org/tomcat-6.0-doc/appdev/sample/sample.war
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/813bba02/usage/test-framework/etc/example-catalog-test.bom
----------------------------------------------------------------------
diff --git a/usage/test-framework/etc/example-catalog-test.bom b/usage/test-framework/etc/example-catalog-test.bom
new file mode 100644
index 0000000..0605f9d
--- /dev/null
+++ b/usage/test-framework/etc/example-catalog-test.bom
@@ -0,0 +1,22 @@
+brooklyn.catalog:
+  id: simple-tomcat-test
+  version: 1.0
+  itemType: template
+  iconUrl: http://tomcat.apache.org/images/tomcat.png
+  name: Simple Tomcat Test
+  license: Apache-2.0
+  item:
+    brooklyn.config:
+      simple.confg: someValue
+    services:
+    - type: org.apache.brooklyn.test.framework.TestCase
+      name: Simple Tomcat Tests
+      brooklyn.children:
+      - type: simple-tomcat
+        id: tomcat
+      - type: org.apache.brooklyn.test.framework.TestSensor
+        target: $brooklyn:component("tomcat")
+        sensor: service.isUp
+        timeout: 10m
+        assert:
+          equals: true
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/813bba02/usage/test-framework/etc/nginx-test-examples.yml
----------------------------------------------------------------------
diff --git a/usage/test-framework/etc/nginx-test-examples.yml b/usage/test-framework/etc/nginx-test-examples.yml
new file mode 100644
index 0000000..f1711ea
--- /dev/null
+++ b/usage/test-framework/etc/nginx-test-examples.yml
@@ -0,0 +1,98 @@
+---
+# 1. Start an nginx
+# 2. Test it is running
+# 3. Stop it
+# 4. Test it stopped
+# Note there are two alternative forms to look up target - either just provide the 'targetId' to do an implicit DSL lookup,
+# or look it up with explicit DSL and provide it as 'target'.
+name: NGINX Test
+location: localhost
+services:
+- type: org.apache.brooklyn.test.framework.TestCase
+  name: Stop Test
+  brooklyn.children:
+  - type: org.apache.brooklyn.entity.proxy.nginx.NginxController
+    id: nginx1
+  - type: org.apache.brooklyn.test.framework.TestSensor
+    target: $brooklyn:component("nginx1")
+    sensor: service.isUp
+    equals: true
+    timeout: 5m
+  - type: org.apache.brooklyn.test.framework.TestEffector
+    target: $brooklyn:component("nginx1")
+    effector: stop
+  - type: org.apache.brooklyn.test.framework.TestSensor
+    target: $brooklyn:component("nginx1")
+    sensor: service.isUp
+    assert:
+      equals: false
+...
+
+---
+name: NGINX Test
+location: localhost
+services:
+- type: org.apache.brooklyn.test.framework.TestCase
+  name: Stop Test
+  targetId: nginx1
+  brooklyn.children:
+  - type: org.apache.brooklyn.entity.proxy.nginx.NginxController
+    id: nginx1
+  - type: org.apache.brooklyn.test.framework.TestSensor
+    sensor: service.isUp
+    equals: true
+    timeout: 5m
+  - type: org.apache.brooklyn.test.framework.TestEffector
+    effector: stop
+  - type: org.apache.brooklyn.test.framework.TestSensor
+    sensor: service.isUp
+    equals: false
+
+
+
+---
+name: NGINX Test
+location: localhost
+services:
+- type: org.apache.brooklyn.test.framework.TestCase
+  name: Stop Test
+  brooklyn.children:
+  - type: org.apache.brooklyn.entity.proxy.nginx.NginxController
+    id: nginx1
+  - type: org.apache.brooklyn.test.framework.TestSensor
+    target: $brooklyn:component("nginx1")
+    sensor: service.isUp
+    timeout: 5m
+    assert:
+      equals: true
+  - type: org.apache.brooklyn.test.framework.TestEffector
+    target: $brooklyn:component("nginx1")
+    effector: stop
+  - type: org.apache.brooklyn.test.framework.TestSensor
+    target: $brooklyn:component("nginx1")
+    sensor: service.isUp
+    assert:
+      equals: false
+      regex: .*
+...
+
+---
+name: NGINX Test
+location: localhost
+services:
+- type: org.apache.brooklyn.entity.proxy.nginx.NginxController
+  id: nginx1
+- type: org.apache.brooklyn.test.framework.TestSensor
+  target: $brooklyn:component("nginx1")
+  sensor: service.isUp
+  timeout: 5m
+  assert:
+    equals: true
+- type: org.apache.brooklyn.test.framework.TestSensor
+  name: Test Regex
+  target: $brooklyn:component("nginx1")
+  sensor: service.isUp
+  timeout: 5m
+  assert:
+    regex: .*
+...
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/813bba02/usage/test-framework/etc/testhttpcall-examples.yml
----------------------------------------------------------------------
diff --git a/usage/test-framework/etc/testhttpcall-examples.yml b/usage/test-framework/etc/testhttpcall-examples.yml
new file mode 100644
index 0000000..a418fd8
--- /dev/null
+++ b/usage/test-framework/etc/testhttpcall-examples.yml
@@ -0,0 +1,124 @@
+---
+name: Basic HTTP Call Tests
+location: localhost
+services:
+- type: org.apache.brooklyn.test.framework.TestCase
+  brooklyn.children:
+  - type: org.apache.brooklyn.entity.webapp.tomcat.TomcatServer
+    id: tomcat
+    brooklyn.config:
+      war: "http://search.maven.org/remotecontent?filepath=io/brooklyn/example/brooklyn-example-hello-world-sql-webapp/0.6.0/brooklyn-example-hello-world-sql-webapp-0.6.0.war"
+  - type: org.apache.brooklyn.test.framework.TestHttpCall
+    name: Status Code 200
+    url: $brooklyn:component("tomcat").attributeWhenReady("webapp.url")
+    assert:
+      status: 200
+  - type: org.apache.brooklyn.test.framework.TestHttpCall
+    name: Status Code 404
+    url: $brooklyn:formatString("%s/invalidpath/", component("tomcat").attributeWhenReady("webapp.url"))
+    timeout: 10s
+    assert:
+      status: 404
+  - type: org.apache.brooklyn.test.framework.TestHttpCall
+    name: String match
+    url: $brooklyn:component("tomcat").attributeWhenReady("webapp.url")
+    assert:
+      string: Sample Brooklyn Deployed
+  - type: org.apache.brooklyn.test.framework.TestHttpCall
+    name: Regex match
+    url: $brooklyn:component("tomcat").attributeWhenReady("webapp.url")
+    # the regex assert uses java.lang.String under the hood so if the url is expected to returns
+    # a multi-line response you should use the embedded dotall flag expression `(?s)` in your regex.
+    # See: http://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html
+    assert:
+      regex: "(?s).*illustrate(\\s)*how(\\s)*web(\\s)*applications.*"
+...
+
+---
+name: HTTP Call Test with Effector
+location: localhost
+services:
+- type: org.apache.brooklyn.test.framework.TestCase
+  brooklyn.children:
+  - type: org.apache.brooklyn.entity.webapp.tomcat.TomcatServer
+    id: tomcat
+    brooklyn.config:
+      war: "http://search.maven.org/remotecontent?filepath=io/brooklyn/example/brooklyn-example-hello-world-sql-webapp/0.6.0/brooklyn-example-hello-world-sql-webapp-0.6.0.war"
+  - type: org.apache.brooklyn.test.framework.TestHttpCall
+    name: / Status Code 200
+    url: $brooklyn:component("tomcat").attributeWhenReady("webapp.url")
+    assert:
+      status: 200
+  - type: org.apache.brooklyn.test.framework.TestHttpCall
+    name: /newcontext Status Code 404
+    url: $brooklyn:formatString("%s/newcontext/", component("tomcat").attributeWhenReady("webapp.url"))
+    assert:
+      status: 404
+  - type: org.apache.brooklyn.test.framework.TestEffector
+    name: Deploy WAR in /newcontext
+    target: $brooklyn:component("tomcat")
+    effector: deploy
+    params:
+      url: http://search.maven.org/remotecontent?filepath=io/brooklyn/example/brooklyn-example-hello-world-sql-webapp/0.6.0/brooklyn-example-hello-world-sql-webapp-0.6.0.war
+      targetName: newcontext
+  - type: org.apache.brooklyn.test.framework.TestHttpCall
+    name: /newcontext Status Code 200
+    url: $brooklyn:formatString("%s/newcontext/", component("tomcat").attributeWhenReady("webapp.url"))
+    # Give Tomcat time to make the newly deployed War accessible
+    timeout: 10s
+    assert:
+      status: 200
+...
+
+---
+name: HTTP Call Test with Eventual String and Regex Matches
+location: localhost
+services:
+- type: org.apache.brooklyn.test.framework.TestCase
+  brooklyn.children:
+  - type: org.apache.brooklyn.entity.webapp.tomcat.TomcatServer
+    id: tomcat
+    brooklyn.config:
+      war: "http://search.maven.org/remotecontent?filepath=io/brooklyn/example/brooklyn-example-hello-world-sql-webapp/0.6.0/brooklyn-example-hello-world-sql-webapp-0.6.0.war"
+  - type: org.apache.brooklyn.test.framework.TestEffector
+    name: Deploy WAR in /newcontext
+    target: $brooklyn:component("tomcat")
+    effector: deploy
+    params:
+      url: http://search.maven.org/remotecontent?filepath=io/brooklyn/example/brooklyn-example-hello-world-sql-webapp/0.6.0/brooklyn-example-hello-world-sql-webapp-0.6.0.war
+      targetName: newcontext
+  - type: org.apache.brooklyn.test.framework.TestHttpCall
+    name: Regex match
+    url: $brooklyn:formatString("%s/newcontext/", component("tomcat").attributeWhenReady("webapp.url"))
+    timeout: 10s
+    assert:
+      regex: "(?s).*illustrate(\\s)*how(\\s)*web(\\s)*applications.*"
+  - type: org.apache.brooklyn.test.framework.TestEffector
+    name: Deploy WAR in /newcontext2
+    target: $brooklyn:component("tomcat")
+    effector: deploy
+    params:
+      url: http://search.maven.org/remotecontent?filepath=io/brooklyn/example/brooklyn-example-hello-world-sql-webapp/0.6.0/brooklyn-example-hello-world-sql-webapp-0.6.0.war
+      targetName: newcontext2
+  - type: org.apache.brooklyn.test.framework.TestHttpCall
+    name: String match
+    url: $brooklyn:formatString("%s/newcontext2/", component("tomcat").attributeWhenReady("webapp.url"))
+    timeout: 10s
+    assert:
+      string: Sample Brooklyn Deployed
+    assert:
+      status: 404
+  - type: org.apache.brooklyn.test.framework.TestHttpCall
+    name: String match
+    url: $brooklyn:component("tomcat").attributeWhenReady("webapp.url")
+    assert:
+      string: Sample Brooklyn Deployed
+  - type: org.apache.brooklyn.test.framework.TestHttpCall
+    name: Regex match
+    url: $brooklyn:component("tomcat").attributeWhenReady("webapp.url")
+    # the regex assert uses java.lang.String under the hood so if the url is expected to returns
+    # a multi-line response you should use the embedded dotall flag expression `(?s)` in your regex.
+    # See: http://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html
+    assert:
+      regex: "(?s).*illustrate(\\s)*how(\\s)*web(\\s)*applications.*"
+...
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/813bba02/usage/test-framework/etc/tomcat-test-examples.yml
----------------------------------------------------------------------
diff --git a/usage/test-framework/etc/tomcat-test-examples.yml b/usage/test-framework/etc/tomcat-test-examples.yml
new file mode 100644
index 0000000..37d7f4d
--- /dev/null
+++ b/usage/test-framework/etc/tomcat-test-examples.yml
@@ -0,0 +1,45 @@
+---
+name: Tomcat Multi-War Test
+location: localhost
+services:
+- type: org.apache.brooklyn.entity.webapp.tomcat.TomcatServer
+  id: tomcat
+  name: Tomcat
+  brooklyn.config:
+    wars.by.context:
+      hello1: "http://search.maven.org/remotecontent?filepath=io/brooklyn/example/brooklyn-example-hello-world-sql-webapp/0.6.0/brooklyn-example-hello-world-sql-webapp-0.6.0.war"
+      hello2: "http://search.maven.org/remotecontent?filepath=io/brooklyn/example/brooklyn-example-hello-world-sql-webapp/0.6.0/brooklyn-example-hello-world-sql-webapp-0.6.0.war"
+    start.timeout: 10m
+- type: org.apache.brooklyn.test.framework.TestSensor
+  target: $brooklyn:component("tomcat")
+  sensor: service.isUp
+  assert:
+    equals: true
+  timeout: 10m
+...
+
+---
+name: Tomcat Tests
+location: BYON 1
+services:
+  - type: org.apache.brooklyn.test.framework.TestCase
+    name: Effector - Deploy Test
+    brooklyn.children:
+    - type: org.apache.brooklyn.entity.webapp.tomcat.TomcatServer
+      id: tomcat
+      name: Tomcat
+      war: https://tomcat.apache.org/tomcat-6.0-doc/appdev/sample/sample.war
+    - type: org.apache.brooklyn.test.framework.TestEffector
+      name: Deploy Another WAR
+      target: $brooklyn:component("tomcat")
+      effector: deploy
+      params:
+        url: https://tomcat.apache.org/tomcat-6.0-doc/appdev/sample/sample.war
+        targetName: sample1
+#    - type: org.apache.brooklyn.test.framework.TestSensor
+#      target: $brooklyn:component("tomcat")
+#      sensor: webapp.deployedWars
+#      assert:
+#        regex: .*sample1.*
+#      timeout: 1m
+...
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/813bba02/usage/test-framework/pom.xml
----------------------------------------------------------------------
diff --git a/usage/test-framework/pom.xml b/usage/test-framework/pom.xml
new file mode 100644
index 0000000..5606a8d
--- /dev/null
+++ b/usage/test-framework/pom.xml
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>brooklyn</artifactId>
+        <groupId>org.apache.brooklyn</groupId>
+        <version>0.9.0-SNAPSHOT</version>
+        <relativePath>../../pom.xml</relativePath>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>test-framework</artifactId>
+    <name>Brooklyn Test Framework</name>
+
+    <properties>
+        <assertj.version>3.2.0</assertj.version>
+    </properties>
+
+    <dependencies>
+
+        <dependency>
+            <groupId>org.apache.brooklyn</groupId>
+            <artifactId>brooklyn-core</artifactId>
+            <version>${brooklyn.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.brooklyn</groupId>
+            <artifactId>brooklyn-camp</artifactId>
+            <version>${brooklyn.version}</version>
+        </dependency>
+
+        <!--TEST SCOPE :: START-->
+        <dependency>
+            <groupId>org.testng</groupId>
+            <artifactId>testng</artifactId>
+            <version>${testng.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.brooklyn</groupId>
+            <artifactId>brooklyn-test-support</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.brooklyn</groupId>
+            <artifactId>brooklyn-core</artifactId>
+            <version>${brooklyn.version}</version>
+            <scope>test</scope>
+            <classifier>tests</classifier>
+        </dependency>
+        <dependency>
+            <groupId>org.assertj</groupId>
+            <artifactId>assertj-core</artifactId>
+            <version>${assertj.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <!--TEST SCOPE :: END-->
+        
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>3.3</version>
+                <configuration>
+                    <source>${java.version}</source>
+                    <target>${java.version}</target>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/813bba02/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/AbstractTest.java
----------------------------------------------------------------------
diff --git a/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/AbstractTest.java b/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/AbstractTest.java
new file mode 100644
index 0000000..2194286
--- /dev/null
+++ b/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/AbstractTest.java
@@ -0,0 +1,50 @@
+package org.apache.brooklyn.test.framework;
+
+import org.apache.brooklyn.api.entity.Entity;
+import org.apache.brooklyn.api.mgmt.Task;
+import org.apache.brooklyn.camp.brooklyn.spi.dsl.methods.DslComponent;
+import org.apache.brooklyn.core.entity.AbstractEntity;
+import org.apache.brooklyn.util.core.task.Tasks;
+import org.apache.brooklyn.util.exceptions.Exceptions;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.concurrent.ExecutionException;
+
+/**
+ * Abstract base class for tests, providing common target lookup.
+ */
+public abstract class AbstractTest extends AbstractEntity implements BaseTest {
+
+    private static final Logger LOG = LoggerFactory.getLogger(AbstractTest.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.
+     *
+     * @return The target entity.
+     *
+     * @throws @RuntimeException if no target can be determined.
+     */
+    public Entity resolveTarget() {
+        Entity entity = getConfig(TARGET_ENTITY);
+        if (null == entity) {
+            entity = getTargetById();
+        }
+        return entity;
+    }
+
+    private Entity getTargetById() {
+        String targetId = getConfig(TARGET_ID);
+        final Task<Entity> targetLookup = new DslComponent(targetId).newTask();
+        Entity entity = null;
+        try {
+            entity = Tasks.resolveValue(targetLookup, Entity.class, getExecutionContext(), "Finding entity " + targetId);
+            LOG.debug("Found target by id {}", targetId);
+        } catch (final ExecutionException | InterruptedException e) {
+            LOG.error("Error finding target {}", targetId);
+            Exceptions.propagate(e);
+        }
+        return entity;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/813bba02/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/BaseTest.java
----------------------------------------------------------------------
diff --git a/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/BaseTest.java b/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/BaseTest.java
new file mode 100644
index 0000000..b0f347d
--- /dev/null
+++ b/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/BaseTest.java
@@ -0,0 +1,34 @@
+package org.apache.brooklyn.test.framework;
+
+import org.apache.brooklyn.api.entity.Entity;
+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.util.core.flags.SetFromFlag;
+
+/**
+ *  A base interface for all tests.
+ */
+public interface BaseTest extends Entity, Startable {
+
+    /**
+     * The target entity to test (optional, use either this or targetId).
+     */
+    @SetFromFlag(nullable = false)
+    ConfigKey<Entity> TARGET_ENTITY = ConfigKeys.newConfigKey(Entity.class, "target", "Entity under test");
+
+    /**
+     * Id of the target entity to test (optional, use either this or target).
+     */
+    @SetFromFlag(nullable = false)
+    ConfigKey<String> TARGET_ID = ConfigKeys.newStringConfigKey("targetId", "Id of the entity under test");
+
+    /**
+     * Get the target of the test.
+     *
+     * @return The target.
+     *
+     * @throws IllegalArgumentException if the target cannot be found.
+     */
+    Entity resolveTarget();
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/813bba02/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/ParallelTestCase.java
----------------------------------------------------------------------
diff --git a/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/ParallelTestCase.java b/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/ParallelTestCase.java
new file mode 100644
index 0000000..b5dc1ea
--- /dev/null
+++ b/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/ParallelTestCase.java
@@ -0,0 +1,13 @@
+package org.apache.brooklyn.test.framework;
+
+import org.apache.brooklyn.api.entity.Entity;
+import org.apache.brooklyn.api.entity.ImplementedBy;
+import org.apache.brooklyn.core.entity.trait.Startable;
+
+/**
+ * 
+ * @author Chris Burke
+ */
+@ImplementedBy(value = ParallelTestCaseImpl.class)
+public interface ParallelTestCase extends Entity, Startable {
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/813bba02/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/ParallelTestCaseImpl.java
----------------------------------------------------------------------
diff --git a/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/ParallelTestCaseImpl.java b/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/ParallelTestCaseImpl.java
new file mode 100644
index 0000000..67e972a
--- /dev/null
+++ b/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/ParallelTestCaseImpl.java
@@ -0,0 +1,130 @@
+package org.apache.brooklyn.test.framework;
+
+import java.util.Collection;
+import java.util.concurrent.ExecutionException;
+
+import org.apache.brooklyn.api.location.Location;
+import org.apache.brooklyn.api.mgmt.Task;
+import org.apache.brooklyn.api.mgmt.TaskAdaptable;
+import org.apache.brooklyn.core.entity.AbstractEntity;
+import org.apache.brooklyn.core.entity.Attributes;
+import org.apache.brooklyn.core.entity.lifecycle.Lifecycle;
+import org.apache.brooklyn.core.entity.trait.StartableMethods;
+import org.apache.brooklyn.util.core.task.DynamicTasks;
+import org.apache.brooklyn.util.exceptions.Exceptions;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This implementation will start all child entities in parallel.
+ * 
+ * @author Chris Burke
+ */
+public class ParallelTestCaseImpl extends AbstractEntity implements ParallelTestCase {
+
+    private static final Logger logger = LoggerFactory.getLogger(ParallelTestCaseImpl.class);
+
+    /**
+     * {@inheritDoc}
+     */
+    public void start(Collection<? extends Location> locations) {
+        // Let everyone know we're starting up (so that the GUI shows the correct icon).
+        sensors().set(Attributes.SERVICE_STATE_ACTUAL, Lifecycle.STARTING);
+        try {
+            // Get an unsubmitted task for starting all the children of this entity in parallel,
+            // at the same location as this entity.
+            final TaskAdaptable<?> taskAdaptable = StartableMethods.startingChildren(this);
+            logger.trace("{}, TaskAdaptable: {}", this, taskAdaptable);
+
+            // Submit the task to the ExecutionManager so that they actually get started
+            // and then wait until all the parallel child entities have completed.
+            submitTaskAndWait(taskAdaptable);
+
+            // Let everyone know we've started up successfully (changes the icon in the GUI).
+            logger.debug("Tasks successfully run. Update state of {} to RUNNING.", this);
+            setServiceState(true, Lifecycle.RUNNING);
+        } catch (Throwable t) {
+            logger.debug("Tasks NOT successfully run. Update state of {} to ON_FIRE.", this);
+            setServiceState(false, Lifecycle.ON_FIRE);
+            throw Exceptions.propagate(t);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void stop() {
+        // Let everyone know we're stopping (so that the GUI shows the correct icon).
+        sensors().set(Attributes.SERVICE_STATE_ACTUAL, Lifecycle.STOPPING);
+
+        // Get an unsubmitted task for stopping all the children of this entity in parallel.
+        final TaskAdaptable<?> taskAdaptable = StartableMethods.stoppingChildren(this);
+        logger.trace("{}, TaskAdaptable: {}", this, taskAdaptable);
+        try {
+            // Submit the task to the ExecutionManager so that they actually get stopped
+            // and then wait until all the parallel entities have completed.
+            submitTaskAndWait(taskAdaptable);
+            // Let everyone know we've stopped successfully (changes the icon in the GUI).
+            logger.debug("Tasks successfully run. Update state of {} to STOPPED.", this);
+            setServiceState(false, Lifecycle.STOPPED);
+        } catch (Throwable t) {
+            logger.debug("Tasks NOT successfully run. Update state of {} to ON_FIRE.", this);
+            setServiceState(false, Lifecycle.ON_FIRE);
+            throw Exceptions.propagate(t);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void restart() {
+        // Let everyone know we're restarting (so that the GUI shows the correct icon).
+        setServiceState(false, Lifecycle.STARTING);
+
+        // Get an unsubmitted task for restarting all the children of this entity in parallel.
+        final TaskAdaptable<?> taskAdaptable = StartableMethods.restartingChildren(this);
+        logger.trace("{}, TaskAdaptable: {}", this, taskAdaptable);
+
+        try {
+            // Submit the task to the ExecutionManager so that they actually get stopped
+            // and then wait until all the parallel entities have completed.
+            submitTaskAndWait(taskAdaptable);
+
+            // Let everyone know we've started up successfully (changes the icon in the GUI).
+            logger.debug("Tasks successfully run. Update state of {} to RUNNING.", this);
+            setServiceState(true, Lifecycle.RUNNING);
+        } catch (Throwable t) {
+            logger.debug("Tasks NOT successfully run. Update state of {} to ON_FIRE.", this);
+            setServiceState(false, Lifecycle.ON_FIRE);
+            throw Exceptions.propagate(t);
+        }
+    }
+
+    /**
+     * Submits the task to the ExecutionManager and then waits until the task has completed.
+     * 
+     * @param taskAdaptable the TaskAdaptable to submit for execution.
+     * @throws ExecutionException if the task threw an exception
+     * @throws InterruptedException if the current thread was interrupted while waiting
+     */
+    private void submitTaskAndWait(final TaskAdaptable<?> taskAdaptable)
+            throws InterruptedException, ExecutionException {
+        logger.debug("{}, Submitting taskAdaptable: {}", this, taskAdaptable);
+        // Submit the task to the ExecutionManager.
+        final Task<?> task = DynamicTasks.submit(taskAdaptable, this);
+
+        // Block until the task has completed.
+        logger.debug("{}, Blocking until task complete.", this);
+        task.blockUntilEnded();
+        logger.debug("{}, Task complete.", this);
+
+        // Get the result of the task. We don't really care about the
+        // actual result but this will throw an exception if the task failed.
+        task.get();
+    }
+
+    private void setServiceState(final boolean serviceUpState, final Lifecycle serviceStateActual) {
+        sensors().set(SERVICE_UP, serviceUpState);
+        sensors().set(Attributes.SERVICE_STATE_ACTUAL, serviceStateActual);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/813bba02/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestCase.java
----------------------------------------------------------------------
diff --git a/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestCase.java b/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestCase.java
new file mode 100644
index 0000000..6d2ae11
--- /dev/null
+++ b/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestCase.java
@@ -0,0 +1,12 @@
+package org.apache.brooklyn.test.framework;
+
+import org.apache.brooklyn.api.entity.ImplementedBy;
+
+/**
+ * Entity that logically groups other test entities
+ *
+ * @author m4rkmckenna
+ */
+@ImplementedBy(value = TestCaseImpl.class)
+public interface TestCase extends BaseTest {
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/813bba02/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestCaseImpl.java
----------------------------------------------------------------------
diff --git a/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestCaseImpl.java b/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestCaseImpl.java
new file mode 100644
index 0000000..1b443fb
--- /dev/null
+++ b/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestCaseImpl.java
@@ -0,0 +1,61 @@
+package org.apache.brooklyn.test.framework;
+
+import com.google.common.collect.Lists;
+import org.apache.brooklyn.api.entity.Entity;
+import org.apache.brooklyn.api.location.Location;
+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.util.exceptions.Exceptions;
+
+import java.util.Collection;
+
+/**
+ * {@inheritDoc}
+ */
+public class TestCaseImpl extends AbstractTest implements TestCase {
+
+    /**
+     * {@inheritDoc}
+     */
+    public void start(Collection<? extends Location> locations) {
+        ServiceStateLogic.setExpectedState(this, Lifecycle.STARTING);
+        try {
+            for (final Entity childEntity : getChildren()) {
+                if (childEntity instanceof Startable) ((Startable) childEntity).start(locations);
+            }
+            sensors().set(SERVICE_UP, true);
+            ServiceStateLogic.setExpectedState(this, Lifecycle.RUNNING);
+        } catch (Throwable t) {
+            sensors().set(SERVICE_UP, false);
+            ServiceStateLogic.setExpectedState(this, Lifecycle.ON_FIRE);
+            throw Exceptions.propagate(t);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    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);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void restart() {
+        final Collection<Location> locations = Lists.newArrayList(getLocations());
+        stop();
+        start(locations);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/813bba02/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestEffector.java
----------------------------------------------------------------------
diff --git a/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestEffector.java b/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestEffector.java
new file mode 100644
index 0000000..e9ec832
--- /dev/null
+++ b/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestEffector.java
@@ -0,0 +1,33 @@
+package org.apache.brooklyn.test.framework;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.reflect.TypeToken;
+import org.apache.brooklyn.api.entity.ImplementedBy;
+import org.apache.brooklyn.config.ConfigKey;
+import org.apache.brooklyn.core.config.ConfigKeys;
+import org.apache.brooklyn.core.sensor.AttributeSensorAndConfigKey;
+import org.apache.brooklyn.util.core.flags.SetFromFlag;
+import org.apache.brooklyn.util.time.Duration;
+
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Entity that invokes an effector on another entity
+ *
+ * @author m4rkmckenna
+ */
+@ImplementedBy(value = TestEffectorImpl.class)
+public interface TestEffector extends BaseTest {
+
+    @SetFromFlag(nullable = false)
+    ConfigKey<String> EFFECTOR_NAME = ConfigKeys.newConfigKey(String.class, "effector", "The name of the effector to invoke");
+
+    ConfigKey<Map<String, ?>> EFFECTOR_PARAMS = ConfigKeys.newConfigKey(new TypeToken<Map<String, ?>>() {
+    }, "params", "The parameters to pass to the effector", ImmutableMap.<String, Object>of());
+
+    ConfigKey<Duration> TIMEOUT = ConfigKeys.newConfigKey(Duration.class, "timeout", "Time to wait on sensor result", new Duration(5L, TimeUnit.SECONDS));
+
+    AttributeSensorAndConfigKey<Object, Object> EFFECTOR_RESULT = ConfigKeys.newSensorAndConfigKey(Object.class, "result", "The result of invoking the effector");
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/813bba02/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
new file mode 100644
index 0000000..442797e
--- /dev/null
+++ b/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestEffectorImpl.java
@@ -0,0 +1,91 @@
+package org.apache.brooklyn.test.framework;
+
+import com.google.common.collect.Lists;
+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.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;
+import org.apache.brooklyn.util.time.Duration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Collection;
+import java.util.Map;
+
+/**
+ *
+ */
+public class TestEffectorImpl extends AbstractTest implements TestEffector {
+    private static final Logger LOG = LoggerFactory.getLogger(TestEffectorImpl.class);
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void start(Collection<? extends Location> locations) {
+        ServiceStateLogic.setExpectedState(this, Lifecycle.STARTING);
+        final Entity targetEntity = resolveTarget();
+        final String effectorName = getConfig(EFFECTOR_NAME);
+        final Map<String, ?> effectorParams = getConfig(EFFECTOR_PARAMS);
+        final Duration timeout = getConfig(TIMEOUT);
+        try {
+            Maybe<Effector<?>> effector = EffectorUtils.findEffectorDeclared(targetEntity, effectorName);
+            if (effector.isAbsentOrNull()) {
+                throw new AssertionError(String.format("No effector with name [%s]", effectorName));
+            }
+            final Task<?> effectorResult;
+            if (effectorParams == null || effectorParams.isEmpty()) {
+                effectorResult = Entities.invokeEffector(this, targetEntity, effector.get());
+            } 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) {
+            sensors().set(SERVICE_UP, false);
+            ServiceStateLogic.setExpectedState(this, Lifecycle.ON_FIRE);
+            throw Exceptions.propagate(t);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    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);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void restart() {
+        final Collection<Location> locations = Lists.newArrayList(getLocations());
+        stop();
+        start(locations);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/813bba02/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestHttpCall.java
----------------------------------------------------------------------
diff --git a/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestHttpCall.java b/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestHttpCall.java
new file mode 100644
index 0000000..5dfa1c8
--- /dev/null
+++ b/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestHttpCall.java
@@ -0,0 +1,33 @@
+package org.apache.brooklyn.test.framework;
+
+import com.google.common.collect.Maps;
+import org.apache.brooklyn.api.entity.Entity;
+import org.apache.brooklyn.api.entity.ImplementedBy;
+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.util.core.flags.SetFromFlag;
+import org.apache.brooklyn.util.time.Duration;
+
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Entity that makes a HTTP Request and tests the respose
+ *
+ * @author johnmccabe
+ */
+@ImplementedBy(value = TestHttpCallImpl.class)
+public interface TestHttpCall extends Entity, Startable {
+
+    @SetFromFlag(nullable = false)
+    ConfigKey<String> TARGET_URL = ConfigKeys.newStringConfigKey("url", "URL to test");
+
+    @SetFromFlag(nullable = false)
+    ConfigKey<Map> ASSERTIONS = ConfigKeys.newConfigKey(Map.class, "assert",
+            "Assertions to be evaluated", Maps.newLinkedHashMap());
+
+    ConfigKey<Duration> TIMEOUT = ConfigKeys.newConfigKey(Duration.class, "timeout",
+            "The duration to wait for assertion result", new Duration(1L, TimeUnit.SECONDS));
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/813bba02/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
new file mode 100644
index 0000000..7413066
--- /dev/null
+++ b/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestHttpCallImpl.java
@@ -0,0 +1,107 @@
+package org.apache.brooklyn.test.framework;
+
+import com.google.api.client.util.Objects;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Lists;
+import org.apache.brooklyn.api.location.Location;
+import org.apache.brooklyn.core.entity.AbstractEntity;
+import org.apache.brooklyn.core.entity.lifecycle.Lifecycle;
+import org.apache.brooklyn.core.entity.lifecycle.ServiceStateLogic;
+import org.apache.brooklyn.util.core.flags.TypeCoercions;
+import org.apache.brooklyn.util.exceptions.Exceptions;
+import org.apache.brooklyn.util.time.Duration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Collection;
+import java.util.Map;
+
+import static org.apache.brooklyn.util.http.HttpAsserts.assertContentEventuallyContainsText;
+import static org.apache.brooklyn.util.http.HttpAsserts.assertContentEventuallyMatches;
+import static org.apache.brooklyn.util.http.HttpAsserts.assertHttpStatusCodeEventuallyEquals;
+
+/**
+ * {@inheritDoc}
+ */
+public class TestHttpCallImpl extends AbstractEntity implements TestHttpCall {
+
+    private static final Logger LOG = LoggerFactory.getLogger(TestHttpCallImpl.class);
+
+    /**
+     * {@inheritDoc}
+     */
+    public void start(Collection<? extends Location> locations) {
+        ServiceStateLogic.setExpectedState(this, Lifecycle.STARTING);
+        final String url = getConfig(TARGET_URL);
+        final Map assertions = getConfig(ASSERTIONS);
+        final Duration timeout = getConfig(TIMEOUT);
+        try {
+            checkAssertions(url.toString(), ImmutableMap.of("timeout", timeout), assertions);
+            sensors().set(SERVICE_UP, true);
+            ServiceStateLogic.setExpectedState(this, Lifecycle.RUNNING);
+        } catch (Throwable t) {
+            LOG.info("Url [{}] test failed", url);
+            sensors().set(SERVICE_UP, false);
+            ServiceStateLogic.setExpectedState(this, Lifecycle.ON_FIRE);
+            throw Exceptions.propagate(t);
+        }
+    }
+
+    /**
+     * Tests HTTP Request reponse matches assertions
+     * <p>
+     * Supported keys in the <code>assertions</code> {@link Map} include:
+     * <ul>
+     * <li>string - simple string match
+     * <li>regex - uses {@link java.lang.String#matches(String)}, if the url returns a multi-line response you should
+     * use the embedded dotall flag expression <code>(?s)</code> in your regex.
+     * <li>status - HTTP status code
+     * </ul>
+     * Wraps the {@link org.apache.brooklyn.util.http.HttpAsserts} immediate assertion methods.
+     * <p>
+     * See the test/resources directory for examples.
+     *
+     * @param url        The target URL to be tested
+     * @param flags      Passed to {@link org.apache.brooklyn.util.http.HttpAsserts#assertContentEventuallyContainsText(Map, String, String, String...)},
+     *                   {@link org.apache.brooklyn.util.http.HttpAsserts#assertContentEventuallyMatches(Map, String, String)},
+     *                   {@link org.apache.brooklyn.util.http.HttpAsserts#assertHttpStatusCodeEventuallyEquals(Map, String, int)}
+     *
+     * @param assertions The map of assertions
+     */
+    private void checkAssertions(final String url, final Map<String,?> flags, final Map<?, ?> assertions) {
+
+        for (final Map.Entry<?, ?> entry : assertions.entrySet()) {
+            if (Objects.equal(entry.getKey(), "regex")) {
+                LOG.info("Testing if url [{}] matches regex [{}]",
+                        new Object[]{url, entry.getValue()});
+                assertContentEventuallyMatches( flags, url, TypeCoercions.coerce(entry.getValue(), String.class));
+            } else if (Objects.equal(entry.getKey(), "string")) {
+                LOG.debug("Testing if url [{}] contains string [{}]",
+                        new Object[]{url, entry.getValue()});
+                assertContentEventuallyContainsText(flags, url, TypeCoercions.coerce(entry.getValue(), String.class));
+            } else if (Objects.equal(entry.getKey(), "status")) {
+                LOG.debug("Testing if url [{}] returns status code [{}]",
+                        new Object[]{url, entry.getValue()});
+                assertHttpStatusCodeEventuallyEquals(flags, url, TypeCoercions.coerce(entry.getValue(), Integer.class));
+            }
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void stop() {
+        ServiceStateLogic.setExpectedState(this, Lifecycle.STOPPING);
+        sensors().set(SERVICE_UP, false);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void restart() {
+        final Collection<Location> locations = Lists.newArrayList(getLocations());
+        stop();
+        start(locations);
+    }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/813bba02/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestSensor.java
----------------------------------------------------------------------
diff --git a/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestSensor.java b/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestSensor.java
new file mode 100644
index 0000000..c6303eb
--- /dev/null
+++ b/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestSensor.java
@@ -0,0 +1,27 @@
+package org.apache.brooklyn.test.framework;
+
+import com.google.common.collect.Maps;
+import org.apache.brooklyn.api.entity.ImplementedBy;
+import org.apache.brooklyn.config.ConfigKey;
+import org.apache.brooklyn.core.config.ConfigKeys;
+import org.apache.brooklyn.util.core.flags.SetFromFlag;
+import org.apache.brooklyn.util.time.Duration;
+
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Entity that tests a sensor value on another entity
+ *
+ * @author m4rkmckenna
+ */
+@ImplementedBy(value = TestSensorImpl.class)
+public interface TestSensor extends BaseTest {
+
+    @SetFromFlag(nullable = false)
+    ConfigKey<String> SENSOR_NAME = ConfigKeys.newConfigKey(String.class, "sensor", "Sensor to evaluate");
+
+    ConfigKey<Map> ASSERTIONS = ConfigKeys.newConfigKey(Map.class, "assert", "Assertions to be evaluated", Maps.newLinkedHashMap());
+
+    ConfigKey<Duration> TIMEOUT = ConfigKeys.newConfigKey(Duration.class, "timeout", "Time to wait on sensor result", new Duration(1L, TimeUnit.SECONDS));
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/813bba02/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
new file mode 100644
index 0000000..94151c6
--- /dev/null
+++ b/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/TestSensorImpl.java
@@ -0,0 +1,144 @@
+package org.apache.brooklyn.test.framework;
+
+import com.google.api.client.util.Objects;
+import com.google.common.base.Predicate;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Lists;
+import org.apache.brooklyn.api.entity.Entity;
+import org.apache.brooklyn.api.location.Location;
+import org.apache.brooklyn.api.sensor.AttributeSensor;
+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.sensor.Sensors;
+import org.apache.brooklyn.util.core.flags.TypeCoercions;
+import org.apache.brooklyn.util.exceptions.Exceptions;
+import org.apache.brooklyn.util.time.Duration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.regex.Pattern;
+
+import static org.apache.brooklyn.core.entity.EntityAsserts.assertAttributeEventually;
+
+/**
+ * {@inheritDoc}
+ */
+public class TestSensorImpl extends AbstractTest implements TestSensor {
+
+    private static final Logger LOG = LoggerFactory.getLogger(TestSensorImpl.class);
+
+    /**
+     * {@inheritDoc}
+     */
+    public void start(Collection<? extends Location> locations) {
+        ServiceStateLogic.setExpectedState(this, Lifecycle.STARTING);
+        final Entity target = resolveTarget();
+        final String sensor = getConfig(SENSOR_NAME);
+        final Duration timeout = getConfig(TIMEOUT);
+        final Map assertions = getConfig(ASSERTIONS);
+        try {
+            checkAssertions(target, Sensors.newSensor(Object.class, sensor), ImmutableMap.of("timeout", timeout),
+                    assertions);
+            sensors().set(SERVICE_UP, true);
+            ServiceStateLogic.setExpectedState(this, Lifecycle.RUNNING);
+        } catch (Throwable t) {
+            LOG.info("Sensor [{}] test failed", sensor);
+            sensors().set(SERVICE_UP, false);
+            ServiceStateLogic.setExpectedState(this, Lifecycle.ON_FIRE);
+            throw Exceptions.propagate(t);
+        }
+    }
+
+    /**
+     * Tests sensor values match assertions
+     *
+     * @param target     The {@link Entity} that has the sensor under test
+     * @param sensor     The sensor to test
+     * @param flags      Passed to {@link org.apache.brooklyn.core.entity.EntityAsserts#assertAttributeEventually(Map, Entity, AttributeSensor, Predicate)}
+     * @param assertions The map of assertions
+     */
+    private void checkAssertions(final Entity target, final AttributeSensor<Object> sensor, final Map<?, ?> flags, final Map<?, ?> assertions) {
+        for (final Map.Entry<?, ?> entry : assertions.entrySet()) {
+            if (Objects.equal(entry.getKey(), "equals")) {
+                assertAttributeEventually(flags, target, sensor, isEqualTo(entry.getValue()));
+            } else if (Objects.equal(entry.getKey(), "regex")) {
+                assertAttributeEventually(flags, target, sensor, regexMatches(entry.getValue()));
+            } else if (Objects.equal(entry.getKey(), "isNull")) {
+                assertAttributeEventually(flags, target, sensor, isNull(entry.getValue()));
+            }
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    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);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void restart() {
+        final Collection<Location> locations = Lists.newArrayList(getLocations());
+        stop();
+        start(locations);
+    }
+
+    /**
+     * Predicate to check the equality of object
+     *
+     * @param value
+     * @return The created {@link Predicate}
+     */
+    private Predicate<Object> isEqualTo(final Object value) {
+        return new Predicate<Object>() {
+            public boolean apply(final Object input) {
+                return (input != null) && Objects.equal(TypeCoercions.coerce(value, input.getClass()), input);
+            }
+        };
+    }
+
+    /**
+     * Predicate to check if a sensor matches a regex pattern
+     *
+     * @param patternValue
+     * @return
+     */
+    private Predicate<Object> regexMatches(final Object patternValue) {
+        final Pattern pattern = Pattern.compile(TypeCoercions.coerce(patternValue, String.class));
+        return new Predicate<Object>() {
+            public boolean apply(final Object input) {
+                return (input != null) && pattern.matcher(input.toString()).matches();
+            }
+        };
+    }
+
+    /**
+     * Predicate to check if a sensor value is null
+     *
+     * @param isNullValue
+     * @return
+     */
+    private Predicate<Object> isNull(final Object isNullValue) {
+        return new Predicate<Object>() {
+            public boolean apply(final Object input) {
+                return (input == null) == TypeCoercions.coerce(isNullValue, Boolean.class);
+            }
+        };
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/813bba02/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/TestEffectorTest.java
----------------------------------------------------------------------
diff --git a/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/TestEffectorTest.java b/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/TestEffectorTest.java
new file mode 100644
index 0000000..b43c76b
--- /dev/null
+++ b/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/TestEffectorTest.java
@@ -0,0 +1,106 @@
+package org.apache.brooklyn.test.framework;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import org.apache.brooklyn.api.entity.EntitySpec;
+import org.apache.brooklyn.api.location.LocationSpec;
+import org.apache.brooklyn.api.mgmt.ManagementContext;
+import org.apache.brooklyn.core.entity.Entities;
+import org.apache.brooklyn.core.test.entity.TestApplication;
+import org.apache.brooklyn.location.localhost.LocalhostMachineProvisioningLocation;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import java.util.UUID;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * @author m4rkmckenna on 27/10/2015.
+ */
+public class TestEffectorTest {
+
+    private TestApplication app;
+    private ManagementContext managementContext;
+    private LocalhostMachineProvisioningLocation loc;
+    private String testId;
+
+    @BeforeMethod
+    public void setup() {
+        testId = UUID.randomUUID().toString();
+        app = TestApplication.Factory.newManagedInstanceForTests();
+        managementContext = app.getManagementContext();
+
+        loc = managementContext.getLocationManager().createLocation(LocationSpec.create(LocalhostMachineProvisioningLocation.class)
+                .configure("name", testId));
+
+    }
+
+
+    @AfterMethod(alwaysRun = true)
+    public void tearDown() throws Exception {
+        if (app != null) Entities.destroyAll(app.getManagementContext());
+    }
+
+
+    @Test
+    public void testSimpleEffector() {
+        final TestCase testCase = app.createAndManageChild(EntitySpec.create(TestCase.class));
+        final TestEntity testEntity = testCase.addChild(EntitySpec.create(TestEntity.class));
+
+
+        final TestEffector testEffector = testCase.addChild(EntitySpec.create(TestEffector.class)
+                .configure(TestEffector.TARGET_ENTITY, testEntity)
+                .configure(TestEffector.EFFECTOR_NAME, "simpleEffector"));
+
+        app.start(ImmutableList.of(app.newSimulatedLocation()));
+
+        assertThat(testEntity.sensors().get(TestEntity.SIMPLE_EFFECTOR_INVOKED)).isNotNull();
+        assertThat(testEntity.sensors().get(TestEntity.SIMPLE_EFFECTOR_INVOKED)).isTrue();
+
+        assertThat(testEffector.sensors().get(TestEffector.EFFECTOR_RESULT)).isNull();
+    }
+
+    @Test
+    public void testComplexffector() {
+        final TestCase testCase = app.createAndManageChild(EntitySpec.create(TestCase.class));
+        final TestEntity testEntity = testCase.addChild(EntitySpec.create(TestEntity.class));
+
+        final long expectedLongValue = System.currentTimeMillis();
+        final boolean expectedBooleanValue = expectedLongValue % 2 == 0;
+
+        final TestEffector testEffector = testCase.addChild(EntitySpec.create(TestEffector.class)
+                .configure(TestEffector.TARGET_ENTITY, testEntity)
+                .configure(TestEffector.EFFECTOR_NAME, "complexEffector")
+                .configure(TestEffector.EFFECTOR_PARAMS, ImmutableMap.of(
+                        "stringValue", testId,
+                        "booleanValue", expectedBooleanValue,
+                        "longValue", expectedLongValue)));
+
+        app.start(ImmutableList.of(app.newSimulatedLocation()));
+
+        assertThat(testEntity.sensors().get(TestEntity.SIMPLE_EFFECTOR_INVOKED)).isNull();
+        assertThat(testEntity.sensors().get(TestEntity.COMPLEX_EFFECTOR_INVOKED)).isNotNull();
+        assertThat(testEntity.sensors().get(TestEntity.COMPLEX_EFFECTOR_INVOKED)).isTrue();
+
+        assertThat(testEntity.sensors().get(TestEntity.COMPLEX_EFFECTOR_STRING)).isNotNull();
+        assertThat(testEntity.sensors().get(TestEntity.COMPLEX_EFFECTOR_STRING)).isEqualTo(testId);
+
+        assertThat(testEntity.sensors().get(TestEntity.COMPLEX_EFFECTOR_BOOLEAN)).isNotNull();
+        assertThat(testEntity.sensors().get(TestEntity.COMPLEX_EFFECTOR_BOOLEAN)).isEqualTo(expectedBooleanValue);
+
+        assertThat(testEntity.sensors().get(TestEntity.COMPLEX_EFFECTOR_LONG)).isNotNull();
+        assertThat(testEntity.sensors().get(TestEntity.COMPLEX_EFFECTOR_LONG)).isEqualTo(expectedLongValue);
+
+        assertThat(testEffector.sensors().get(TestEffector.EFFECTOR_RESULT)).isNotNull();
+        assertThat(testEffector.sensors().get(TestEffector.EFFECTOR_RESULT)).isInstanceOf(TestEntity.TestPojo.class);
+
+        final TestEntity.TestPojo effectorResult = (TestEntity.TestPojo) testEffector.sensors().get(TestEffector.EFFECTOR_RESULT);
+        assertThat(effectorResult.getBooleanValue()).isEqualTo(expectedBooleanValue);
+        assertThat(effectorResult.getStringValue()).isEqualTo(testId);
+        assertThat(effectorResult.getLongValue()).isEqualTo(expectedLongValue);
+
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/813bba02/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/TestEntity.java
----------------------------------------------------------------------
diff --git a/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/TestEntity.java b/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/TestEntity.java
new file mode 100644
index 0000000..933b227
--- /dev/null
+++ b/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/TestEntity.java
@@ -0,0 +1,55 @@
+package org.apache.brooklyn.test.framework;
+
+import org.apache.brooklyn.api.entity.Entity;
+import org.apache.brooklyn.api.entity.ImplementedBy;
+import org.apache.brooklyn.core.annotation.Effector;
+import org.apache.brooklyn.core.annotation.EffectorParam;
+import org.apache.brooklyn.core.config.ConfigKeys;
+import org.apache.brooklyn.core.entity.trait.Startable;
+import org.apache.brooklyn.core.sensor.AttributeSensorAndConfigKey;
+
+/**
+ * @author m4rkmckenna on 27/10/2015.
+ */
+
+@ImplementedBy(TestEntityImpl.class)
+public interface TestEntity extends Entity, Startable {
+
+    AttributeSensorAndConfigKey<Boolean, Boolean> SIMPLE_EFFECTOR_INVOKED = ConfigKeys.newSensorAndConfigKey(Boolean.class, "simple-effector-invoked", "");
+    AttributeSensorAndConfigKey<Boolean, Boolean> COMPLEX_EFFECTOR_INVOKED = ConfigKeys.newSensorAndConfigKey(Boolean.class, "complex-effector-invoked", "");
+    AttributeSensorAndConfigKey<String, String> COMPLEX_EFFECTOR_STRING = ConfigKeys.newSensorAndConfigKey(String.class, "complex-effector-string", "");
+    AttributeSensorAndConfigKey<Boolean, Boolean> COMPLEX_EFFECTOR_BOOLEAN = ConfigKeys.newSensorAndConfigKey(Boolean.class, "complex-effector-boolean", "");
+    AttributeSensorAndConfigKey<Long, Long> COMPLEX_EFFECTOR_LONG = ConfigKeys.newSensorAndConfigKey(Long.class, "complex-effector-long", "");
+
+    @Effector
+    void simpleEffector();
+
+    @Effector
+    TestPojo complexEffector(@EffectorParam(name = "stringValue") final String stringValue,
+                             @EffectorParam(name = "booleanValue") final Boolean booleanValue,
+                             @EffectorParam(name = "longValue") final Long longValue);
+
+    class TestPojo {
+        private final String stringValue;
+        private final Boolean booleanValue;
+        private final Long longValue;
+
+        public TestPojo(final String stringValue, final Boolean booleanValue, final Long longValue) {
+            this.stringValue = stringValue;
+            this.booleanValue = booleanValue;
+            this.longValue = longValue;
+        }
+
+        public String getStringValue() {
+            return stringValue;
+        }
+
+        public Boolean getBooleanValue() {
+            return booleanValue;
+        }
+
+        public Long getLongValue() {
+            return longValue;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/813bba02/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/TestEntityImpl.java
----------------------------------------------------------------------
diff --git a/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/TestEntityImpl.java b/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/TestEntityImpl.java
new file mode 100644
index 0000000..b3386f2
--- /dev/null
+++ b/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/TestEntityImpl.java
@@ -0,0 +1,39 @@
+package org.apache.brooklyn.test.framework;
+
+import org.apache.brooklyn.api.location.Location;
+import org.apache.brooklyn.core.annotation.EffectorParam;
+import org.apache.brooklyn.core.entity.AbstractEntity;
+
+import java.util.Collection;
+
+/**
+ * @author m4rkmckenna on 27/10/2015.
+ */
+public class TestEntityImpl extends AbstractEntity implements TestEntity {
+    @Override
+    public void start(final Collection<? extends Location> locations) {
+    }
+
+    @Override
+    public void stop() {
+
+    }
+
+    @Override
+    public void restart() {
+    }
+
+    @Override
+    public void simpleEffector() {
+        sensors().set(SIMPLE_EFFECTOR_INVOKED, Boolean.TRUE);
+    }
+
+    @Override
+    public TestPojo complexEffector(@EffectorParam(name = "stringValue") final String stringValue, @EffectorParam(name = "booleanValue") final Boolean booleanValue, @EffectorParam(name = "longValue") final Long longValue) {
+        sensors().set(COMPLEX_EFFECTOR_INVOKED, Boolean.TRUE);
+        sensors().set(COMPLEX_EFFECTOR_STRING, stringValue);
+        sensors().set(COMPLEX_EFFECTOR_BOOLEAN, booleanValue);
+        sensors().set(COMPLEX_EFFECTOR_LONG, longValue);
+        return new TestPojo(stringValue, booleanValue, longValue);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/813bba02/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/TestSensorTest.java
----------------------------------------------------------------------
diff --git a/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/TestSensorTest.java b/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/TestSensorTest.java
new file mode 100644
index 0000000..0b653eb
--- /dev/null
+++ b/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/TestSensorTest.java
@@ -0,0 +1,270 @@
+package org.apache.brooklyn.test.framework;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import org.apache.brooklyn.api.entity.EntitySpec;
+import org.apache.brooklyn.api.location.LocationSpec;
+import org.apache.brooklyn.api.mgmt.ManagementContext;
+import org.apache.brooklyn.core.config.ConfigKeys;
+import org.apache.brooklyn.core.entity.Entities;
+import org.apache.brooklyn.core.sensor.AttributeSensorAndConfigKey;
+import org.apache.brooklyn.core.test.entity.TestApplication;
+import org.apache.brooklyn.location.localhost.LocalhostMachineProvisioningLocation;
+import org.apache.brooklyn.util.exceptions.Exceptions;
+import org.apache.brooklyn.util.exceptions.PropagatedRuntimeException;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import java.util.UUID;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * @author m4rkmckenna on 27/10/2015.
+ */
+public class TestSensorTest {
+
+    private static final AttributeSensorAndConfigKey<Boolean, Boolean> BOOLEAN_SENSOR = ConfigKeys.newSensorAndConfigKey(Boolean.class, "boolean-sensor", "Boolean Sensor");
+    private static final AttributeSensorAndConfigKey<String, String> STRING_SENSOR = ConfigKeys.newSensorAndConfigKey(String.class, "string-sensor", "String Sensor");
+    private static final AttributeSensorAndConfigKey<Object, Object> OBJECT_SENSOR = ConfigKeys.newSensorAndConfigKey(Object.class, "object-sensor", "Object Sensor");
+
+    private TestApplication app;
+    private ManagementContext managementContext;
+    private LocalhostMachineProvisioningLocation loc;
+    private String testId;
+
+    @BeforeMethod
+    public void setup() {
+        testId = UUID.randomUUID().toString();
+        app = TestApplication.Factory.newManagedInstanceForTests();
+        managementContext = app.getManagementContext();
+        loc = managementContext.getLocationManager().createLocation(LocationSpec.create(LocalhostMachineProvisioningLocation.class)
+                .configure("name", testId));
+    }
+
+    @AfterMethod(alwaysRun = true)
+    public void tearDown() throws Exception {
+        if (app != null) Entities.destroyAll(app.getManagementContext());
+    }
+
+    @Test
+    public void testAssertEqual() {
+        //Add Sensor Test for BOOLEAN sensor
+        app.createAndManageChild(EntitySpec.create(TestSensor.class)
+                .configure(TestSensor.TARGET_ENTITY, app)
+                .configure(TestSensor.SENSOR_NAME, BOOLEAN_SENSOR.getName())
+                .configure(TestSensor.ASSERTIONS, ImmutableMap.of("equals", true)));
+        //Add Sensor Test for STRING sensor
+        app.createAndManageChild(EntitySpec.create(TestSensor.class)
+                .configure(TestSensor.TARGET_ENTITY, app)
+                .configure(TestSensor.SENSOR_NAME, STRING_SENSOR.getName())
+                .configure(TestSensor.ASSERTIONS, ImmutableMap.of("equals", testId)));
+
+        //Set BOOLEAN Sensor to true
+        app.sensors().set(BOOLEAN_SENSOR, Boolean.TRUE);
+        //Set STRING sensor to random string
+        app.sensors().set(STRING_SENSOR, testId);
+
+
+        app.start(ImmutableList.of(loc));
+
+    }
+
+    @Test
+    public void testAssertEqualFailure() {
+        boolean booleanAssertFailed = false;
+
+        //Add Sensor Test for BOOLEAN sensor
+        app.createAndManageChild(EntitySpec.create(TestSensor.class)
+                .configure(TestSensor.TARGET_ENTITY, app)
+                .configure(TestSensor.SENSOR_NAME, BOOLEAN_SENSOR.getName())
+                .configure(TestSensor.ASSERTIONS, ImmutableMap.of("equals", true)));
+
+        //Set BOOLEAN Sensor to false
+        app.sensors().set(BOOLEAN_SENSOR, Boolean.FALSE);
+
+        try {
+            app.start(ImmutableList.of(loc));
+        } catch (final PropagatedRuntimeException pre) {
+            final AssertionError assertionError = Exceptions.getFirstThrowableOfType(pre, AssertionError.class);
+            assertThat(assertionError).isNotNull();
+            booleanAssertFailed = true;
+        } finally {
+            assertThat(booleanAssertFailed).isTrue();
+        }
+    }
+
+    @Test
+    public void testAssertEqualOnNullSenor() {
+        boolean booleanAssertFailed = false;
+
+        //Add Sensor Test for BOOLEAN sensor
+        app.createAndManageChild(EntitySpec.create(TestSensor.class)
+                .configure(TestSensor.TARGET_ENTITY, app)
+                .configure(TestSensor.SENSOR_NAME, BOOLEAN_SENSOR.getName())
+                .configure(TestSensor.ASSERTIONS, ImmutableMap.of("equals", false)));
+
+        try {
+            app.start(ImmutableList.of(loc));
+        } catch (final PropagatedRuntimeException pre) {
+            final AssertionError assertionError = Exceptions.getFirstThrowableOfType(pre, AssertionError.class);
+            assertThat(assertionError).isNotNull().as("An assertion error should have been thrown");
+            booleanAssertFailed = true;
+        } finally {
+            assertThat(booleanAssertFailed).isTrue().as("Equals assert should have failed as the sensor is NULL");
+        }
+    }
+
+    @Test
+    public void testAssertNull() {
+        //Add Sensor Test for BOOLEAN sensor
+        app.createAndManageChild(EntitySpec.create(TestSensor.class)
+                .configure(TestSensor.TARGET_ENTITY, app)
+                .configure(TestSensor.SENSOR_NAME, BOOLEAN_SENSOR.getName())
+                .configure(TestSensor.ASSERTIONS, ImmutableMap.of("isNull", true)));
+        //Add Sensor Test for STRING sensor
+        app.createAndManageChild(EntitySpec.create(TestSensor.class)
+                .configure(TestSensor.TARGET_ENTITY, app)
+                .configure(TestSensor.SENSOR_NAME, STRING_SENSOR.getName())
+                .configure(TestSensor.ASSERTIONS, ImmutableMap.of("isNull", false)));
+
+        //Set STRING sensor to random string
+        app.sensors().set(STRING_SENSOR, testId);
+
+        app.start(ImmutableList.of(loc));
+
+    }
+
+
+    @Test
+    public void testAssertNullFail() {
+        boolean sensorTestFail = false;
+        //Add Sensor Test for STRING sensor
+        app.createAndManageChild(EntitySpec.create(TestSensor.class)
+                .configure(TestSensor.TARGET_ENTITY, app)
+                .configure(TestSensor.SENSOR_NAME, STRING_SENSOR.getName())
+                .configure(TestSensor.ASSERTIONS, ImmutableMap.of("isNull", true)));
+
+        //Set STRING sensor to random string
+        app.sensors().set(STRING_SENSOR, testId);
+
+
+        try {
+            app.start(ImmutableList.of(loc));
+        } catch (final PropagatedRuntimeException pre) {
+            final AssertionError assertionError = Exceptions.getFirstThrowableOfType(pre, AssertionError.class);
+            assertThat(assertionError).isNotNull().as("An assertion error should have been thrown");
+            sensorTestFail = true;
+        } finally {
+            assertThat(sensorTestFail).isTrue().as("isNull assert should have failed as the sensor has been set");
+        }
+
+    }
+
+    @Test
+    public void testAssertRegex() {
+        final long time = System.currentTimeMillis();
+        final String sensorValue = String.format("%s%s%s", UUID.randomUUID().toString(), time, UUID.randomUUID().toString());
+
+        //Add Sensor Test for STRING sensor
+        app.createAndManageChild(EntitySpec.create(TestSensor.class)
+                .configure(TestSensor.TARGET_ENTITY, app)
+                .configure(TestSensor.SENSOR_NAME, STRING_SENSOR.getName())
+                .configure(TestSensor.ASSERTIONS, ImmutableMap.of("regex", String.format(".*%s.*", time))));
+        app.createAndManageChild(EntitySpec.create(TestSensor.class)
+                .configure(TestSensor.TARGET_ENTITY, app)
+                .configure(TestSensor.SENSOR_NAME, BOOLEAN_SENSOR.getName())
+                .configure(TestSensor.ASSERTIONS, ImmutableMap.of("regex", "true")));
+
+        //Set STRING sensor
+        app.sensors().set(STRING_SENSOR, sensorValue);
+        app.sensors().set(BOOLEAN_SENSOR, true);
+
+
+        app.start(ImmutableList.of(loc));
+    }
+
+    @Test
+    public void testAssertRegexFail() {
+        boolean sensorTestFail = false;
+        final String sensorValue = String.format("%s%s%s", UUID.randomUUID().toString(), System.currentTimeMillis(), UUID.randomUUID().toString());
+
+        //Add Sensor Test for STRING sensor
+        app.createAndManageChild(EntitySpec.create(TestSensor.class)
+                .configure(TestSensor.TARGET_ENTITY, app)
+                .configure(TestSensor.SENSOR_NAME, STRING_SENSOR.getName())
+                .configure(TestSensor.ASSERTIONS, ImmutableMap.of("regex", String.format(".*%s.*", UUID.randomUUID().toString()))));
+
+        //Set STRING sensor
+        app.sensors().set(STRING_SENSOR, sensorValue);
+
+
+        try {
+            app.start(ImmutableList.of(loc));
+        } catch (final PropagatedRuntimeException pre) {
+            final AssertionError assertionError = Exceptions.getFirstThrowableOfType(pre, AssertionError.class);
+            assertThat(assertionError).isNotNull().as("An assertion error should have been thrown");
+            sensorTestFail = true;
+        } finally {
+            assertThat(sensorTestFail).isTrue().as("regex assert should have failed");
+        }
+    }
+
+    @Test
+    public void testAssertRegexOnNullSensor() {
+        boolean sensorTestFail = false;
+        final String sensorValue = String.format("%s%s%s", UUID.randomUUID().toString(), System.currentTimeMillis(), UUID.randomUUID().toString());
+
+        //Add Sensor Test for STRING sensor
+        app.createAndManageChild(EntitySpec.create(TestSensor.class)
+                .configure(TestSensor.TARGET_ENTITY, app)
+                .configure(TestSensor.SENSOR_NAME, STRING_SENSOR.getName())
+                .configure(TestSensor.ASSERTIONS, ImmutableMap.of("regex", String.format(".*%s.*", UUID.randomUUID().toString()))));
+
+        try {
+            app.start(ImmutableList.of(loc));
+        } catch (final PropagatedRuntimeException pre) {
+            final AssertionError assertionError = Exceptions.getFirstThrowableOfType(pre, AssertionError.class);
+            assertThat(assertionError).isNotNull().as("An assertion error should have been thrown");
+            sensorTestFail = true;
+        } finally {
+            assertThat(sensorTestFail).isTrue().as("regex assert should have failed");
+        }
+    }
+
+
+    @Test
+    public void testAssertRegexOnNonStringSensor() {
+        //Add Sensor Test for OBJECT sensor
+        app.createAndManageChild(EntitySpec.create(TestSensor.class)
+                .configure(TestSensor.TARGET_ENTITY, app)
+                .configure(TestSensor.SENSOR_NAME, OBJECT_SENSOR.getName())
+                .configure(TestSensor.ASSERTIONS, ImmutableMap.of("regex", ".*TestObject.*id=.*")));
+
+        app.sensors().set(OBJECT_SENSOR, new TestObject());
+
+        app.start(ImmutableList.of(loc));
+
+    }
+
+
+    class TestObject {
+        private final String id;
+
+        public TestObject() {
+            id = UUID.randomUUID().toString();
+        }
+
+        public String getId() {
+            return id;
+        }
+
+        @Override
+        public String toString() {
+            return ToStringBuilder.reflectionToString(this);
+        }
+    }
+
+}


[14/21] incubator-brooklyn git commit: Changed test-framework artifact ID to brooklyn-test-framework

Posted by he...@apache.org.
Changed test-framework artifact ID to brooklyn-test-framework


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

Branch: refs/heads/master
Commit: a346f5c96558144667d217777de8e912aac753f4
Parents: adbf0ef
Author: Mark McKenna <m4...@gmail.com>
Authored: Wed Nov 11 12:12:41 2015 +0000
Committer: Mark McKenna <m4...@gmail.com>
Committed: Wed Nov 11 12:12:41 2015 +0000

----------------------------------------------------------------------
 usage/test-framework/pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a346f5c9/usage/test-framework/pom.xml
----------------------------------------------------------------------
diff --git a/usage/test-framework/pom.xml b/usage/test-framework/pom.xml
index 1eaf3e1..0430787 100644
--- a/usage/test-framework/pom.xml
+++ b/usage/test-framework/pom.xml
@@ -10,7 +10,7 @@
     </parent>
     <modelVersion>4.0.0</modelVersion>
 
-    <artifactId>test-framework</artifactId>
+    <artifactId>brooklyn-test-framework</artifactId>
     <name>Brooklyn Test Framework</name>
 
     <dependencies>


[09/21] incubator-brooklyn git commit: Fixed typo in file name exampl-catalog.bom -> example-catalog.bom

Posted by he...@apache.org.
Fixed typo in file name exampl-catalog.bom -> example-catalog.bom


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

Branch: refs/heads/master
Commit: 01f19e73c1a8487350521db235c5904327384363
Parents: 761e81f
Author: Mark McKenna <m4...@gmail.com>
Authored: Wed Nov 11 10:51:49 2015 +0000
Committer: Mark McKenna <m4...@gmail.com>
Committed: Wed Nov 11 10:51:49 2015 +0000

----------------------------------------------------------------------
 usage/test-framework/etc/exampl-catalog.bom  | 15 ---------------
 usage/test-framework/etc/example-catalog.bom | 15 +++++++++++++++
 2 files changed, 15 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/01f19e73/usage/test-framework/etc/exampl-catalog.bom
----------------------------------------------------------------------
diff --git a/usage/test-framework/etc/exampl-catalog.bom b/usage/test-framework/etc/exampl-catalog.bom
deleted file mode 100644
index ab7e54b..0000000
--- a/usage/test-framework/etc/exampl-catalog.bom
+++ /dev/null
@@ -1,15 +0,0 @@
-brooklyn.catalog:
-  id: simple-tomcat
-  version: 1.0
-  itemType: template
-  iconUrl: http://tomcat.apache.org/images/tomcat.png
-  name: Simple Tomcat
-  license: Apache-2.0
-  item:
-    brooklyn.config:
-      simple.confg: someValue
-    services:
-    - type: org.apache.brooklyn.entity.webapp.tomcat.TomcatServer
-      id: tomcat
-      name: Tomcat
-      war: https://tomcat.apache.org/tomcat-6.0-doc/appdev/sample/sample.war
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/01f19e73/usage/test-framework/etc/example-catalog.bom
----------------------------------------------------------------------
diff --git a/usage/test-framework/etc/example-catalog.bom b/usage/test-framework/etc/example-catalog.bom
new file mode 100644
index 0000000..ab7e54b
--- /dev/null
+++ b/usage/test-framework/etc/example-catalog.bom
@@ -0,0 +1,15 @@
+brooklyn.catalog:
+  id: simple-tomcat
+  version: 1.0
+  itemType: template
+  iconUrl: http://tomcat.apache.org/images/tomcat.png
+  name: Simple Tomcat
+  license: Apache-2.0
+  item:
+    brooklyn.config:
+      simple.confg: someValue
+    services:
+    - type: org.apache.brooklyn.entity.webapp.tomcat.TomcatServer
+      id: tomcat
+      name: Tomcat
+      war: https://tomcat.apache.org/tomcat-6.0-doc/appdev/sample/sample.war
\ No newline at end of file


[13/21] incubator-brooklyn git commit: Moved class javadoc to interface

Posted by he...@apache.org.
Moved class javadoc to interface


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

Branch: refs/heads/master
Commit: adbf0ef12e93f55d455b59e096fb81a6389602e0
Parents: 4ce5c1c
Author: Mark McKenna <m4...@gmail.com>
Authored: Wed Nov 11 11:32:38 2015 +0000
Committer: Mark McKenna <m4...@gmail.com>
Committed: Wed Nov 11 11:32:38 2015 +0000

----------------------------------------------------------------------
 .../brooklyn/test/framework/ParallelTestCase.java    |  3 ++-
 .../test/framework/ParallelTestCaseImpl.java         | 15 +++++----------
 2 files changed, 7 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/adbf0ef1/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/ParallelTestCase.java
----------------------------------------------------------------------
diff --git a/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/ParallelTestCase.java b/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/ParallelTestCase.java
index b5dc1ea..47de3b6 100644
--- a/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/ParallelTestCase.java
+++ b/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/ParallelTestCase.java
@@ -5,7 +5,8 @@ import org.apache.brooklyn.api.entity.ImplementedBy;
 import org.apache.brooklyn.core.entity.trait.Startable;
 
 /**
- * 
+ * This implementation will start all child entities in parallel.
+ *
  * @author Chris Burke
  */
 @ImplementedBy(value = ParallelTestCaseImpl.class)

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/adbf0ef1/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/ParallelTestCaseImpl.java
----------------------------------------------------------------------
diff --git a/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/ParallelTestCaseImpl.java b/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/ParallelTestCaseImpl.java
index 67e972a..2a00a63 100644
--- a/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/ParallelTestCaseImpl.java
+++ b/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/ParallelTestCaseImpl.java
@@ -1,8 +1,5 @@
 package org.apache.brooklyn.test.framework;
 
-import java.util.Collection;
-import java.util.concurrent.ExecutionException;
-
 import org.apache.brooklyn.api.location.Location;
 import org.apache.brooklyn.api.mgmt.Task;
 import org.apache.brooklyn.api.mgmt.TaskAdaptable;
@@ -15,11 +12,9 @@ import org.apache.brooklyn.util.exceptions.Exceptions;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-/**
- * This implementation will start all child entities in parallel.
- * 
- * @author Chris Burke
- */
+import java.util.Collection;
+import java.util.concurrent.ExecutionException;
+
 public class ParallelTestCaseImpl extends AbstractEntity implements ParallelTestCase {
 
     private static final Logger logger = LoggerFactory.getLogger(ParallelTestCaseImpl.class);
@@ -102,9 +97,9 @@ public class ParallelTestCaseImpl extends AbstractEntity implements ParallelTest
 
     /**
      * Submits the task to the ExecutionManager and then waits until the task has completed.
-     * 
+     *
      * @param taskAdaptable the TaskAdaptable to submit for execution.
-     * @throws ExecutionException if the task threw an exception
+     * @throws ExecutionException   if the task threw an exception
      * @throws InterruptedException if the current thread was interrupted while waiting
      */
     private void submitTaskAndWait(final TaskAdaptable<?> taskAdaptable)


[21/21] incubator-brooklyn git commit: This closes #999

Posted by he...@apache.org.
This closes #999


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

Branch: refs/heads/master
Commit: 78df97a0c8fffb81cf25a6588b128743ca44620c
Parents: f0612bd 8019fc1
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Authored: Wed Nov 11 17:21:16 2015 +0000
Committer: Alex Heneveld <al...@cloudsoftcorp.com>
Committed: Wed Nov 11 17:21:16 2015 +0000

----------------------------------------------------------------------
 pom.xml                                         |   2 +
 usage/test-framework/README.md                  | 109 ++++++++
 usage/test-framework/pom.xml                    |  71 +++++
 .../brooklyn/test/framework/AbstractTest.java   |  50 ++++
 .../brooklyn/test/framework/BaseTest.java       |  45 ++++
 .../test/framework/ParallelTestCase.java        |  14 +
 .../test/framework/ParallelTestCaseImpl.java    | 125 +++++++++
 .../brooklyn/test/framework/TestCase.java       |  12 +
 .../brooklyn/test/framework/TestCaseImpl.java   |  61 +++++
 .../brooklyn/test/framework/TestEffector.java   |  31 +++
 .../test/framework/TestEffectorImpl.java        |  78 ++++++
 .../brooklyn/test/framework/TestHttpCall.java   |  19 ++
 .../test/framework/TestHttpCallImpl.java        | 106 ++++++++
 .../brooklyn/test/framework/TestSensor.java     |  24 ++
 .../brooklyn/test/framework/TestSensorImpl.java | 138 ++++++++++
 .../test/framework/TestEffectorTest.java        | 106 ++++++++
 .../brooklyn/test/framework/TestSensorTest.java | 267 +++++++++++++++++++
 .../test/framework/entity/TestEntity.java       |  55 ++++
 .../test/framework/entity/TestEntityImpl.java   |  40 +++
 .../resources/test-framework-examples/README.md |   9 +
 .../example-catalog-test.bom                    |  22 ++
 .../test-framework-examples/example-catalog.bom |  15 ++
 .../nginx-test-examples.yml                     |  98 +++++++
 .../testhttpcall-examples.yml                   | 124 +++++++++
 .../tomcat-test-examples.yml                    |  45 ++++
 25 files changed, 1666 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/78df97a0/pom.xml
----------------------------------------------------------------------


[12/21] incubator-brooklyn git commit: Removed incorrect nullable=false annotations from 'target' & 'targetId'

Posted by he...@apache.org.
Removed incorrect nullable=false annotations from 'target' & 'targetId'

Both config keys may be null ... just not at the same time


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

Branch: refs/heads/master
Commit: 4ce5c1cab75d583074755babd5576dbb9440d132
Parents: 5a3b962
Author: Mark McKenna <m4...@gmail.com>
Authored: Wed Nov 11 11:18:27 2015 +0000
Committer: Mark McKenna <m4...@gmail.com>
Committed: Wed Nov 11 11:18:27 2015 +0000

----------------------------------------------------------------------
 .../main/java/org/apache/brooklyn/test/framework/BaseTest.java | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4ce5c1ca/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/BaseTest.java
----------------------------------------------------------------------
diff --git a/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/BaseTest.java b/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/BaseTest.java
index b0f347d..69eb04d 100644
--- a/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/BaseTest.java
+++ b/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/BaseTest.java
@@ -4,30 +4,26 @@ import org.apache.brooklyn.api.entity.Entity;
 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.util.core.flags.SetFromFlag;
 
 /**
- *  A base interface for all tests.
+ * A base interface for all tests.
  */
 public interface BaseTest extends Entity, Startable {
 
     /**
      * The target entity to test (optional, use either this or targetId).
      */
-    @SetFromFlag(nullable = false)
     ConfigKey<Entity> TARGET_ENTITY = ConfigKeys.newConfigKey(Entity.class, "target", "Entity under test");
 
     /**
      * Id of the target entity to test (optional, use either this or target).
      */
-    @SetFromFlag(nullable = false)
     ConfigKey<String> TARGET_ID = ConfigKeys.newStringConfigKey("targetId", "Id of the entity under test");
 
     /**
      * Get the target of the test.
      *
      * @return The target.
-     *
      * @throws IllegalArgumentException if the target cannot be found.
      */
     Entity resolveTarget();


[08/21] incubator-brooklyn git commit: Moved assertj.version property to parent pom and added comment about version choice

Posted by he...@apache.org.
Moved assertj.version property to parent pom and added comment about version choice


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

Branch: refs/heads/master
Commit: 761e81f4e573ad4010ff0b7be47968d35260963e
Parents: eaacdf0
Author: Mark McKenna <m4...@gmail.com>
Authored: Wed Nov 11 10:44:21 2015 +0000
Committer: Mark McKenna <m4...@gmail.com>
Committed: Wed Nov 11 10:44:21 2015 +0000

----------------------------------------------------------------------
 pom.xml                      | 1 +
 usage/test-framework/pom.xml | 4 ----
 2 files changed, 1 insertion(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/761e81f4/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 94101c8..67353b6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -80,6 +80,7 @@
         <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
 
         <!-- Testing -->
+        <assertj.version>2.2.0</assertj.version> <!-- v 2.2.0 is being used as v 3.20 introduces Java8 dependencies-->
         <cobertura.plugin.version>2.7</cobertura.plugin.version>
         <surefire.version>2.18.1</surefire.version>
         <plantuml.version>6121</plantuml.version>

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/761e81f4/usage/test-framework/pom.xml
----------------------------------------------------------------------
diff --git a/usage/test-framework/pom.xml b/usage/test-framework/pom.xml
index 2f6c0c2..1eaf3e1 100644
--- a/usage/test-framework/pom.xml
+++ b/usage/test-framework/pom.xml
@@ -13,10 +13,6 @@
     <artifactId>test-framework</artifactId>
     <name>Brooklyn Test Framework</name>
 
-    <properties>
-        <assertj.version>2.2.0</assertj.version>
-    </properties>
-
     <dependencies>
 
         <dependency>


[03/21] incubator-brooklyn git commit: Implementation of proposed Test Entities to allow testing directly from blueprints

Posted by he...@apache.org.
Implementation of proposed Test Entities to allow testing directly from blueprints

Proposal :: http://mail-archives.apache.org/mod_mbox/incubator-brooklyn-dev/201510.mbox/%3CE185CA37-E693-4733-8DE1-208872BC1978%40cloudsoftcorp.com%3E


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

Branch: refs/heads/master
Commit: 0e8c31dfaf5d2a3a1c2e90102b739d46142d91fe
Parents: 6c4b517
Author: Mark McKenna <m4...@gmail.com>
Authored: Mon Nov 2 17:17:07 2015 +0000
Committer: Mark McKenna <m4...@gmail.com>
Committed: Mon Nov 9 20:56:21 2015 +0000

----------------------------------------------------------------------
 .../brooklyn-sandbox-test-framework/README.md   |  57 ++++
 .../etc/exampl-catalog.bom                      |  15 ++
 .../etc/example-catalog-test.bom                |  22 ++
 .../etc/nginx-test-examples.yml                 |  98 +++++++
 .../etc/testhttpcall-examples.yml               |  34 +++
 .../etc/tomcat-test-examples.yml                |  45 ++++
 sandbox/brooklyn-sandbox-test-framework/pom.xml |  75 ++++++
 .../brooklyn/test/framework/AbstractTest.java   |  50 ++++
 .../brooklyn/test/framework/BaseTest.java       |  34 +++
 .../test/framework/ParallelTestCase.java        |  13 +
 .../test/framework/ParallelTestCaseImpl.java    | 130 +++++++++
 .../brooklyn/test/framework/TestCase.java       |  12 +
 .../brooklyn/test/framework/TestCaseImpl.java   |  61 +++++
 .../brooklyn/test/framework/TestEffector.java   |  33 +++
 .../test/framework/TestEffectorImpl.java        |  91 +++++++
 .../brooklyn/test/framework/TestHttpCall.java   |  28 ++
 .../test/framework/TestHttpCallImpl.java        |  98 +++++++
 .../brooklyn/test/framework/TestSensor.java     |  27 ++
 .../brooklyn/test/framework/TestSensorImpl.java | 144 ++++++++++
 .../test/framework/TestEffectorTest.java        | 106 ++++++++
 .../brooklyn/test/framework/TestEntity.java     |  55 ++++
 .../brooklyn/test/framework/TestEntityImpl.java |  39 +++
 .../brooklyn/test/framework/TestSensorTest.java | 270 +++++++++++++++++++
 23 files changed, 1537 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0e8c31df/sandbox/brooklyn-sandbox-test-framework/README.md
----------------------------------------------------------------------
diff --git a/sandbox/brooklyn-sandbox-test-framework/README.md b/sandbox/brooklyn-sandbox-test-framework/README.md
new file mode 100644
index 0000000..991ec48
--- /dev/null
+++ b/sandbox/brooklyn-sandbox-test-framework/README.md
@@ -0,0 +1,57 @@
+# Entities
+
+## TestCase
+A logical grouping for tests eg Restart tests
+```
+type: org.apache.brooklyn.test.framework.TestCase
+  name: Stop Test
+  brooklyn.children:
+  - ***
+  - ***
+```
+
+## TestSensor
+Entity that tests a sensor value on another entity eg service.isUp == TRUE
+
+#### Configuration
+| Key | Description | Required |
+| --- | ----------- | -------- |
+| target | The target entity to test | yes (no if *targetId* is supplied) |
+| targetId | The id of the target entity to test | yes (no if *target* is supplied) |
+| assert | Assertions to be evaluated | yes |
+| timeout | The duration to wait on a result | no |
+
+```
+type: org.apache.brooklyn.test.framework.TestSensor
+target: $brooklyn:component("nginx1")
+sensor: service.isUp
+equals: true
+timeout: 5m
+```
+
+## TestEffector
+Entity that invokes an effector on another entity eg restart
+
+#### Configuration
+| Key | Description | Required |
+| --- | ----------- | -------- |
+| target | The target entity to effect | yes (no if *targetId* is supplied) |
+| targetId | The id of the target entity to effect | yes (no if *target* is supplied) |
+| effector | The name of the effector to invoke | yes |
+| params | Parameters to pass to the effector | no |
+| timeout | The duration to wait on a response from an effector | no |
+
+#### Sensors
+| Key | Description |
+| --- | ----------- |
+| result | The result of invoking the effector (null if no result) |
+
+```
+type: org.apache.brooklyn.test.framework.TestEffector
+name: Deploy WAR
+target: $brooklyn:component("tomcat")
+effector: deploy
+params:
+  url: https://tomcat.apache.org/tomcat-6.0-doc/appdev/sample/sample.war
+  targetName: sample1
+```
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0e8c31df/sandbox/brooklyn-sandbox-test-framework/etc/exampl-catalog.bom
----------------------------------------------------------------------
diff --git a/sandbox/brooklyn-sandbox-test-framework/etc/exampl-catalog.bom b/sandbox/brooklyn-sandbox-test-framework/etc/exampl-catalog.bom
new file mode 100644
index 0000000..ab7e54b
--- /dev/null
+++ b/sandbox/brooklyn-sandbox-test-framework/etc/exampl-catalog.bom
@@ -0,0 +1,15 @@
+brooklyn.catalog:
+  id: simple-tomcat
+  version: 1.0
+  itemType: template
+  iconUrl: http://tomcat.apache.org/images/tomcat.png
+  name: Simple Tomcat
+  license: Apache-2.0
+  item:
+    brooklyn.config:
+      simple.confg: someValue
+    services:
+    - type: org.apache.brooklyn.entity.webapp.tomcat.TomcatServer
+      id: tomcat
+      name: Tomcat
+      war: https://tomcat.apache.org/tomcat-6.0-doc/appdev/sample/sample.war
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0e8c31df/sandbox/brooklyn-sandbox-test-framework/etc/example-catalog-test.bom
----------------------------------------------------------------------
diff --git a/sandbox/brooklyn-sandbox-test-framework/etc/example-catalog-test.bom b/sandbox/brooklyn-sandbox-test-framework/etc/example-catalog-test.bom
new file mode 100644
index 0000000..0605f9d
--- /dev/null
+++ b/sandbox/brooklyn-sandbox-test-framework/etc/example-catalog-test.bom
@@ -0,0 +1,22 @@
+brooklyn.catalog:
+  id: simple-tomcat-test
+  version: 1.0
+  itemType: template
+  iconUrl: http://tomcat.apache.org/images/tomcat.png
+  name: Simple Tomcat Test
+  license: Apache-2.0
+  item:
+    brooklyn.config:
+      simple.confg: someValue
+    services:
+    - type: org.apache.brooklyn.test.framework.TestCase
+      name: Simple Tomcat Tests
+      brooklyn.children:
+      - type: simple-tomcat
+        id: tomcat
+      - type: org.apache.brooklyn.test.framework.TestSensor
+        target: $brooklyn:component("tomcat")
+        sensor: service.isUp
+        timeout: 10m
+        assert:
+          equals: true
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0e8c31df/sandbox/brooklyn-sandbox-test-framework/etc/nginx-test-examples.yml
----------------------------------------------------------------------
diff --git a/sandbox/brooklyn-sandbox-test-framework/etc/nginx-test-examples.yml b/sandbox/brooklyn-sandbox-test-framework/etc/nginx-test-examples.yml
new file mode 100644
index 0000000..f1711ea
--- /dev/null
+++ b/sandbox/brooklyn-sandbox-test-framework/etc/nginx-test-examples.yml
@@ -0,0 +1,98 @@
+---
+# 1. Start an nginx
+# 2. Test it is running
+# 3. Stop it
+# 4. Test it stopped
+# Note there are two alternative forms to look up target - either just provide the 'targetId' to do an implicit DSL lookup,
+# or look it up with explicit DSL and provide it as 'target'.
+name: NGINX Test
+location: localhost
+services:
+- type: org.apache.brooklyn.test.framework.TestCase
+  name: Stop Test
+  brooklyn.children:
+  - type: org.apache.brooklyn.entity.proxy.nginx.NginxController
+    id: nginx1
+  - type: org.apache.brooklyn.test.framework.TestSensor
+    target: $brooklyn:component("nginx1")
+    sensor: service.isUp
+    equals: true
+    timeout: 5m
+  - type: org.apache.brooklyn.test.framework.TestEffector
+    target: $brooklyn:component("nginx1")
+    effector: stop
+  - type: org.apache.brooklyn.test.framework.TestSensor
+    target: $brooklyn:component("nginx1")
+    sensor: service.isUp
+    assert:
+      equals: false
+...
+
+---
+name: NGINX Test
+location: localhost
+services:
+- type: org.apache.brooklyn.test.framework.TestCase
+  name: Stop Test
+  targetId: nginx1
+  brooklyn.children:
+  - type: org.apache.brooklyn.entity.proxy.nginx.NginxController
+    id: nginx1
+  - type: org.apache.brooklyn.test.framework.TestSensor
+    sensor: service.isUp
+    equals: true
+    timeout: 5m
+  - type: org.apache.brooklyn.test.framework.TestEffector
+    effector: stop
+  - type: org.apache.brooklyn.test.framework.TestSensor
+    sensor: service.isUp
+    equals: false
+
+
+
+---
+name: NGINX Test
+location: localhost
+services:
+- type: org.apache.brooklyn.test.framework.TestCase
+  name: Stop Test
+  brooklyn.children:
+  - type: org.apache.brooklyn.entity.proxy.nginx.NginxController
+    id: nginx1
+  - type: org.apache.brooklyn.test.framework.TestSensor
+    target: $brooklyn:component("nginx1")
+    sensor: service.isUp
+    timeout: 5m
+    assert:
+      equals: true
+  - type: org.apache.brooklyn.test.framework.TestEffector
+    target: $brooklyn:component("nginx1")
+    effector: stop
+  - type: org.apache.brooklyn.test.framework.TestSensor
+    target: $brooklyn:component("nginx1")
+    sensor: service.isUp
+    assert:
+      equals: false
+      regex: .*
+...
+
+---
+name: NGINX Test
+location: localhost
+services:
+- type: org.apache.brooklyn.entity.proxy.nginx.NginxController
+  id: nginx1
+- type: org.apache.brooklyn.test.framework.TestSensor
+  target: $brooklyn:component("nginx1")
+  sensor: service.isUp
+  timeout: 5m
+  assert:
+    equals: true
+- type: org.apache.brooklyn.test.framework.TestSensor
+  name: Test Regex
+  target: $brooklyn:component("nginx1")
+  sensor: service.isUp
+  timeout: 5m
+  assert:
+    regex: .*
+...
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0e8c31df/sandbox/brooklyn-sandbox-test-framework/etc/testhttpcall-examples.yml
----------------------------------------------------------------------
diff --git a/sandbox/brooklyn-sandbox-test-framework/etc/testhttpcall-examples.yml b/sandbox/brooklyn-sandbox-test-framework/etc/testhttpcall-examples.yml
new file mode 100644
index 0000000..0ada000
--- /dev/null
+++ b/sandbox/brooklyn-sandbox-test-framework/etc/testhttpcall-examples.yml
@@ -0,0 +1,34 @@
+---
+name: Basic HTTP Call Tests
+location: localhost
+services:
+- type: org.apache.brooklyn.test.framework.TestCase
+  brooklyn.children:
+  - type: org.apache.brooklyn.entity.webapp.tomcat.TomcatServer
+    id: tomcat
+    brooklyn.config:
+      war: "http://search.maven.org/remotecontent?filepath=io/brooklyn/example/brooklyn-example-hello-world-sql-webapp/0.6.0/brooklyn-example-hello-world-sql-webapp-0.6.0.war"
+  - type: org.apache.brooklyn.test.framework.TestHttpCall
+    name: Status Code 200
+    url: $brooklyn:component("tomcat").attributeWhenReady("main.uri")
+    assert:
+      status: 200
+  - type: org.apache.brooklyn.test.framework.TestHttpCall
+    name: Status Code 404
+    url: $brooklyn:formatString("%s/invalidpath/", component("tomcat").attributeWhenReady("main.uri"))
+    assert:
+      status: 404
+  - type: org.apache.brooklyn.test.framework.TestHttpCall
+    name: String match
+    url: $brooklyn:component("tomcat").attributeWhenReady("main.uri")
+    assert:
+      string: Sample Brooklyn Deployed
+  - type: org.apache.brooklyn.test.framework.TestHttpCall
+    name: Regex match
+    url: $brooklyn:component("tomcat").attributeWhenReady("main.uri")
+    # the regex assert uses java.lang.String under the hood so if the url is expected to returns
+    # a multi-line response you should use the embedded dotall flag expression `(?s)` in your regex.
+    # See: http://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html
+    assert:
+      regex: "(?s).*illustrate(\\s)*how(\\s)*web(\\s)*applications.*"
+...
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0e8c31df/sandbox/brooklyn-sandbox-test-framework/etc/tomcat-test-examples.yml
----------------------------------------------------------------------
diff --git a/sandbox/brooklyn-sandbox-test-framework/etc/tomcat-test-examples.yml b/sandbox/brooklyn-sandbox-test-framework/etc/tomcat-test-examples.yml
new file mode 100644
index 0000000..37d7f4d
--- /dev/null
+++ b/sandbox/brooklyn-sandbox-test-framework/etc/tomcat-test-examples.yml
@@ -0,0 +1,45 @@
+---
+name: Tomcat Multi-War Test
+location: localhost
+services:
+- type: org.apache.brooklyn.entity.webapp.tomcat.TomcatServer
+  id: tomcat
+  name: Tomcat
+  brooklyn.config:
+    wars.by.context:
+      hello1: "http://search.maven.org/remotecontent?filepath=io/brooklyn/example/brooklyn-example-hello-world-sql-webapp/0.6.0/brooklyn-example-hello-world-sql-webapp-0.6.0.war"
+      hello2: "http://search.maven.org/remotecontent?filepath=io/brooklyn/example/brooklyn-example-hello-world-sql-webapp/0.6.0/brooklyn-example-hello-world-sql-webapp-0.6.0.war"
+    start.timeout: 10m
+- type: org.apache.brooklyn.test.framework.TestSensor
+  target: $brooklyn:component("tomcat")
+  sensor: service.isUp
+  assert:
+    equals: true
+  timeout: 10m
+...
+
+---
+name: Tomcat Tests
+location: BYON 1
+services:
+  - type: org.apache.brooklyn.test.framework.TestCase
+    name: Effector - Deploy Test
+    brooklyn.children:
+    - type: org.apache.brooklyn.entity.webapp.tomcat.TomcatServer
+      id: tomcat
+      name: Tomcat
+      war: https://tomcat.apache.org/tomcat-6.0-doc/appdev/sample/sample.war
+    - type: org.apache.brooklyn.test.framework.TestEffector
+      name: Deploy Another WAR
+      target: $brooklyn:component("tomcat")
+      effector: deploy
+      params:
+        url: https://tomcat.apache.org/tomcat-6.0-doc/appdev/sample/sample.war
+        targetName: sample1
+#    - type: org.apache.brooklyn.test.framework.TestSensor
+#      target: $brooklyn:component("tomcat")
+#      sensor: webapp.deployedWars
+#      assert:
+#        regex: .*sample1.*
+#      timeout: 1m
+...
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0e8c31df/sandbox/brooklyn-sandbox-test-framework/pom.xml
----------------------------------------------------------------------
diff --git a/sandbox/brooklyn-sandbox-test-framework/pom.xml b/sandbox/brooklyn-sandbox-test-framework/pom.xml
new file mode 100644
index 0000000..ba9430f
--- /dev/null
+++ b/sandbox/brooklyn-sandbox-test-framework/pom.xml
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>brooklyn</artifactId>
+        <groupId>org.apache.brooklyn</groupId>
+        <version>0.9.0-SNAPSHOT</version>
+        <relativePath>../../pom.xml</relativePath>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>brooklyn-sandbox-test-framework</artifactId>
+    <name>Brooklyn Test Framework</name>
+
+    <properties>
+        <assertj.version>3.2.0</assertj.version>
+    </properties>
+
+    <dependencies>
+
+        <dependency>
+            <groupId>org.apache.brooklyn</groupId>
+            <artifactId>brooklyn-core</artifactId>
+            <version>${brooklyn.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.brooklyn</groupId>
+            <artifactId>brooklyn-camp</artifactId>
+            <version>${brooklyn.version}</version>
+        </dependency>
+
+        <!--TEST SCOPE :: START-->
+        <dependency>
+            <groupId>org.testng</groupId>
+            <artifactId>testng</artifactId>
+            <version>${testng.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.brooklyn</groupId>
+            <artifactId>brooklyn-test-support</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.brooklyn</groupId>
+            <artifactId>brooklyn-core</artifactId>
+            <version>${brooklyn.version}</version>
+            <scope>test</scope>
+            <classifier>tests</classifier>
+        </dependency>
+        <dependency>
+            <groupId>org.assertj</groupId>
+            <artifactId>assertj-core</artifactId>
+            <version>${assertj.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <!--TEST SCOPE :: END-->
+        
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>3.3</version>
+                <configuration>
+                    <source>${java.version}</source>
+                    <target>${java.version}</target>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0e8c31df/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/AbstractTest.java
----------------------------------------------------------------------
diff --git a/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/AbstractTest.java b/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/AbstractTest.java
new file mode 100644
index 0000000..2194286
--- /dev/null
+++ b/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/AbstractTest.java
@@ -0,0 +1,50 @@
+package org.apache.brooklyn.test.framework;
+
+import org.apache.brooklyn.api.entity.Entity;
+import org.apache.brooklyn.api.mgmt.Task;
+import org.apache.brooklyn.camp.brooklyn.spi.dsl.methods.DslComponent;
+import org.apache.brooklyn.core.entity.AbstractEntity;
+import org.apache.brooklyn.util.core.task.Tasks;
+import org.apache.brooklyn.util.exceptions.Exceptions;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.concurrent.ExecutionException;
+
+/**
+ * Abstract base class for tests, providing common target lookup.
+ */
+public abstract class AbstractTest extends AbstractEntity implements BaseTest {
+
+    private static final Logger LOG = LoggerFactory.getLogger(AbstractTest.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.
+     *
+     * @return The target entity.
+     *
+     * @throws @RuntimeException if no target can be determined.
+     */
+    public Entity resolveTarget() {
+        Entity entity = getConfig(TARGET_ENTITY);
+        if (null == entity) {
+            entity = getTargetById();
+        }
+        return entity;
+    }
+
+    private Entity getTargetById() {
+        String targetId = getConfig(TARGET_ID);
+        final Task<Entity> targetLookup = new DslComponent(targetId).newTask();
+        Entity entity = null;
+        try {
+            entity = Tasks.resolveValue(targetLookup, Entity.class, getExecutionContext(), "Finding entity " + targetId);
+            LOG.debug("Found target by id {}", targetId);
+        } catch (final ExecutionException | InterruptedException e) {
+            LOG.error("Error finding target {}", targetId);
+            Exceptions.propagate(e);
+        }
+        return entity;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0e8c31df/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/BaseTest.java
----------------------------------------------------------------------
diff --git a/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/BaseTest.java b/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/BaseTest.java
new file mode 100644
index 0000000..b0f347d
--- /dev/null
+++ b/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/BaseTest.java
@@ -0,0 +1,34 @@
+package org.apache.brooklyn.test.framework;
+
+import org.apache.brooklyn.api.entity.Entity;
+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.util.core.flags.SetFromFlag;
+
+/**
+ *  A base interface for all tests.
+ */
+public interface BaseTest extends Entity, Startable {
+
+    /**
+     * The target entity to test (optional, use either this or targetId).
+     */
+    @SetFromFlag(nullable = false)
+    ConfigKey<Entity> TARGET_ENTITY = ConfigKeys.newConfigKey(Entity.class, "target", "Entity under test");
+
+    /**
+     * Id of the target entity to test (optional, use either this or target).
+     */
+    @SetFromFlag(nullable = false)
+    ConfigKey<String> TARGET_ID = ConfigKeys.newStringConfigKey("targetId", "Id of the entity under test");
+
+    /**
+     * Get the target of the test.
+     *
+     * @return The target.
+     *
+     * @throws IllegalArgumentException if the target cannot be found.
+     */
+    Entity resolveTarget();
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0e8c31df/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/ParallelTestCase.java
----------------------------------------------------------------------
diff --git a/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/ParallelTestCase.java b/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/ParallelTestCase.java
new file mode 100644
index 0000000..b5dc1ea
--- /dev/null
+++ b/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/ParallelTestCase.java
@@ -0,0 +1,13 @@
+package org.apache.brooklyn.test.framework;
+
+import org.apache.brooklyn.api.entity.Entity;
+import org.apache.brooklyn.api.entity.ImplementedBy;
+import org.apache.brooklyn.core.entity.trait.Startable;
+
+/**
+ * 
+ * @author Chris Burke
+ */
+@ImplementedBy(value = ParallelTestCaseImpl.class)
+public interface ParallelTestCase extends Entity, Startable {
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0e8c31df/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/ParallelTestCaseImpl.java
----------------------------------------------------------------------
diff --git a/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/ParallelTestCaseImpl.java b/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/ParallelTestCaseImpl.java
new file mode 100644
index 0000000..67e972a
--- /dev/null
+++ b/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/ParallelTestCaseImpl.java
@@ -0,0 +1,130 @@
+package org.apache.brooklyn.test.framework;
+
+import java.util.Collection;
+import java.util.concurrent.ExecutionException;
+
+import org.apache.brooklyn.api.location.Location;
+import org.apache.brooklyn.api.mgmt.Task;
+import org.apache.brooklyn.api.mgmt.TaskAdaptable;
+import org.apache.brooklyn.core.entity.AbstractEntity;
+import org.apache.brooklyn.core.entity.Attributes;
+import org.apache.brooklyn.core.entity.lifecycle.Lifecycle;
+import org.apache.brooklyn.core.entity.trait.StartableMethods;
+import org.apache.brooklyn.util.core.task.DynamicTasks;
+import org.apache.brooklyn.util.exceptions.Exceptions;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This implementation will start all child entities in parallel.
+ * 
+ * @author Chris Burke
+ */
+public class ParallelTestCaseImpl extends AbstractEntity implements ParallelTestCase {
+
+    private static final Logger logger = LoggerFactory.getLogger(ParallelTestCaseImpl.class);
+
+    /**
+     * {@inheritDoc}
+     */
+    public void start(Collection<? extends Location> locations) {
+        // Let everyone know we're starting up (so that the GUI shows the correct icon).
+        sensors().set(Attributes.SERVICE_STATE_ACTUAL, Lifecycle.STARTING);
+        try {
+            // Get an unsubmitted task for starting all the children of this entity in parallel,
+            // at the same location as this entity.
+            final TaskAdaptable<?> taskAdaptable = StartableMethods.startingChildren(this);
+            logger.trace("{}, TaskAdaptable: {}", this, taskAdaptable);
+
+            // Submit the task to the ExecutionManager so that they actually get started
+            // and then wait until all the parallel child entities have completed.
+            submitTaskAndWait(taskAdaptable);
+
+            // Let everyone know we've started up successfully (changes the icon in the GUI).
+            logger.debug("Tasks successfully run. Update state of {} to RUNNING.", this);
+            setServiceState(true, Lifecycle.RUNNING);
+        } catch (Throwable t) {
+            logger.debug("Tasks NOT successfully run. Update state of {} to ON_FIRE.", this);
+            setServiceState(false, Lifecycle.ON_FIRE);
+            throw Exceptions.propagate(t);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void stop() {
+        // Let everyone know we're stopping (so that the GUI shows the correct icon).
+        sensors().set(Attributes.SERVICE_STATE_ACTUAL, Lifecycle.STOPPING);
+
+        // Get an unsubmitted task for stopping all the children of this entity in parallel.
+        final TaskAdaptable<?> taskAdaptable = StartableMethods.stoppingChildren(this);
+        logger.trace("{}, TaskAdaptable: {}", this, taskAdaptable);
+        try {
+            // Submit the task to the ExecutionManager so that they actually get stopped
+            // and then wait until all the parallel entities have completed.
+            submitTaskAndWait(taskAdaptable);
+            // Let everyone know we've stopped successfully (changes the icon in the GUI).
+            logger.debug("Tasks successfully run. Update state of {} to STOPPED.", this);
+            setServiceState(false, Lifecycle.STOPPED);
+        } catch (Throwable t) {
+            logger.debug("Tasks NOT successfully run. Update state of {} to ON_FIRE.", this);
+            setServiceState(false, Lifecycle.ON_FIRE);
+            throw Exceptions.propagate(t);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void restart() {
+        // Let everyone know we're restarting (so that the GUI shows the correct icon).
+        setServiceState(false, Lifecycle.STARTING);
+
+        // Get an unsubmitted task for restarting all the children of this entity in parallel.
+        final TaskAdaptable<?> taskAdaptable = StartableMethods.restartingChildren(this);
+        logger.trace("{}, TaskAdaptable: {}", this, taskAdaptable);
+
+        try {
+            // Submit the task to the ExecutionManager so that they actually get stopped
+            // and then wait until all the parallel entities have completed.
+            submitTaskAndWait(taskAdaptable);
+
+            // Let everyone know we've started up successfully (changes the icon in the GUI).
+            logger.debug("Tasks successfully run. Update state of {} to RUNNING.", this);
+            setServiceState(true, Lifecycle.RUNNING);
+        } catch (Throwable t) {
+            logger.debug("Tasks NOT successfully run. Update state of {} to ON_FIRE.", this);
+            setServiceState(false, Lifecycle.ON_FIRE);
+            throw Exceptions.propagate(t);
+        }
+    }
+
+    /**
+     * Submits the task to the ExecutionManager and then waits until the task has completed.
+     * 
+     * @param taskAdaptable the TaskAdaptable to submit for execution.
+     * @throws ExecutionException if the task threw an exception
+     * @throws InterruptedException if the current thread was interrupted while waiting
+     */
+    private void submitTaskAndWait(final TaskAdaptable<?> taskAdaptable)
+            throws InterruptedException, ExecutionException {
+        logger.debug("{}, Submitting taskAdaptable: {}", this, taskAdaptable);
+        // Submit the task to the ExecutionManager.
+        final Task<?> task = DynamicTasks.submit(taskAdaptable, this);
+
+        // Block until the task has completed.
+        logger.debug("{}, Blocking until task complete.", this);
+        task.blockUntilEnded();
+        logger.debug("{}, Task complete.", this);
+
+        // Get the result of the task. We don't really care about the
+        // actual result but this will throw an exception if the task failed.
+        task.get();
+    }
+
+    private void setServiceState(final boolean serviceUpState, final Lifecycle serviceStateActual) {
+        sensors().set(SERVICE_UP, serviceUpState);
+        sensors().set(Attributes.SERVICE_STATE_ACTUAL, serviceStateActual);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0e8c31df/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestCase.java
----------------------------------------------------------------------
diff --git a/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestCase.java b/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestCase.java
new file mode 100644
index 0000000..6d2ae11
--- /dev/null
+++ b/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestCase.java
@@ -0,0 +1,12 @@
+package org.apache.brooklyn.test.framework;
+
+import org.apache.brooklyn.api.entity.ImplementedBy;
+
+/**
+ * Entity that logically groups other test entities
+ *
+ * @author m4rkmckenna
+ */
+@ImplementedBy(value = TestCaseImpl.class)
+public interface TestCase extends BaseTest {
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0e8c31df/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestCaseImpl.java
----------------------------------------------------------------------
diff --git a/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestCaseImpl.java b/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestCaseImpl.java
new file mode 100644
index 0000000..1b443fb
--- /dev/null
+++ b/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestCaseImpl.java
@@ -0,0 +1,61 @@
+package org.apache.brooklyn.test.framework;
+
+import com.google.common.collect.Lists;
+import org.apache.brooklyn.api.entity.Entity;
+import org.apache.brooklyn.api.location.Location;
+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.util.exceptions.Exceptions;
+
+import java.util.Collection;
+
+/**
+ * {@inheritDoc}
+ */
+public class TestCaseImpl extends AbstractTest implements TestCase {
+
+    /**
+     * {@inheritDoc}
+     */
+    public void start(Collection<? extends Location> locations) {
+        ServiceStateLogic.setExpectedState(this, Lifecycle.STARTING);
+        try {
+            for (final Entity childEntity : getChildren()) {
+                if (childEntity instanceof Startable) ((Startable) childEntity).start(locations);
+            }
+            sensors().set(SERVICE_UP, true);
+            ServiceStateLogic.setExpectedState(this, Lifecycle.RUNNING);
+        } catch (Throwable t) {
+            sensors().set(SERVICE_UP, false);
+            ServiceStateLogic.setExpectedState(this, Lifecycle.ON_FIRE);
+            throw Exceptions.propagate(t);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    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);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void restart() {
+        final Collection<Location> locations = Lists.newArrayList(getLocations());
+        stop();
+        start(locations);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0e8c31df/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestEffector.java
----------------------------------------------------------------------
diff --git a/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestEffector.java b/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestEffector.java
new file mode 100644
index 0000000..e9ec832
--- /dev/null
+++ b/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestEffector.java
@@ -0,0 +1,33 @@
+package org.apache.brooklyn.test.framework;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.reflect.TypeToken;
+import org.apache.brooklyn.api.entity.ImplementedBy;
+import org.apache.brooklyn.config.ConfigKey;
+import org.apache.brooklyn.core.config.ConfigKeys;
+import org.apache.brooklyn.core.sensor.AttributeSensorAndConfigKey;
+import org.apache.brooklyn.util.core.flags.SetFromFlag;
+import org.apache.brooklyn.util.time.Duration;
+
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Entity that invokes an effector on another entity
+ *
+ * @author m4rkmckenna
+ */
+@ImplementedBy(value = TestEffectorImpl.class)
+public interface TestEffector extends BaseTest {
+
+    @SetFromFlag(nullable = false)
+    ConfigKey<String> EFFECTOR_NAME = ConfigKeys.newConfigKey(String.class, "effector", "The name of the effector to invoke");
+
+    ConfigKey<Map<String, ?>> EFFECTOR_PARAMS = ConfigKeys.newConfigKey(new TypeToken<Map<String, ?>>() {
+    }, "params", "The parameters to pass to the effector", ImmutableMap.<String, Object>of());
+
+    ConfigKey<Duration> TIMEOUT = ConfigKeys.newConfigKey(Duration.class, "timeout", "Time to wait on sensor result", new Duration(5L, TimeUnit.SECONDS));
+
+    AttributeSensorAndConfigKey<Object, Object> EFFECTOR_RESULT = ConfigKeys.newSensorAndConfigKey(Object.class, "result", "The result of invoking the effector");
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0e8c31df/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestEffectorImpl.java
----------------------------------------------------------------------
diff --git a/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestEffectorImpl.java b/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestEffectorImpl.java
new file mode 100644
index 0000000..442797e
--- /dev/null
+++ b/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestEffectorImpl.java
@@ -0,0 +1,91 @@
+package org.apache.brooklyn.test.framework;
+
+import com.google.common.collect.Lists;
+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.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;
+import org.apache.brooklyn.util.time.Duration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Collection;
+import java.util.Map;
+
+/**
+ *
+ */
+public class TestEffectorImpl extends AbstractTest implements TestEffector {
+    private static final Logger LOG = LoggerFactory.getLogger(TestEffectorImpl.class);
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void start(Collection<? extends Location> locations) {
+        ServiceStateLogic.setExpectedState(this, Lifecycle.STARTING);
+        final Entity targetEntity = resolveTarget();
+        final String effectorName = getConfig(EFFECTOR_NAME);
+        final Map<String, ?> effectorParams = getConfig(EFFECTOR_PARAMS);
+        final Duration timeout = getConfig(TIMEOUT);
+        try {
+            Maybe<Effector<?>> effector = EffectorUtils.findEffectorDeclared(targetEntity, effectorName);
+            if (effector.isAbsentOrNull()) {
+                throw new AssertionError(String.format("No effector with name [%s]", effectorName));
+            }
+            final Task<?> effectorResult;
+            if (effectorParams == null || effectorParams.isEmpty()) {
+                effectorResult = Entities.invokeEffector(this, targetEntity, effector.get());
+            } 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) {
+            sensors().set(SERVICE_UP, false);
+            ServiceStateLogic.setExpectedState(this, Lifecycle.ON_FIRE);
+            throw Exceptions.propagate(t);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    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);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void restart() {
+        final Collection<Location> locations = Lists.newArrayList(getLocations());
+        stop();
+        start(locations);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0e8c31df/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestHttpCall.java
----------------------------------------------------------------------
diff --git a/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestHttpCall.java b/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestHttpCall.java
new file mode 100644
index 0000000..04d551f
--- /dev/null
+++ b/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestHttpCall.java
@@ -0,0 +1,28 @@
+package org.apache.brooklyn.test.framework;
+
+import com.google.common.collect.Maps;
+import org.apache.brooklyn.api.entity.Entity;
+import org.apache.brooklyn.api.entity.ImplementedBy;
+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.util.core.flags.SetFromFlag;
+
+import java.util.Map;
+
+/**
+ * Entity that makes a HTTP Request and tests the respose
+ *
+ * @author johnmccabe
+ */
+@ImplementedBy(value = TestHttpCallImpl.class)
+public interface TestHttpCall extends Entity, Startable {
+
+    @SetFromFlag(nullable = false)
+    ConfigKey<String> TARGET_URL = ConfigKeys.newStringConfigKey("url", "Url to test");
+
+    @SetFromFlag(nullable = false)
+    ConfigKey<Map> ASSERTIONS = ConfigKeys.newConfigKey(Map.class, "assert",
+            "Assertions to be evaluated", Maps.newLinkedHashMap());
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0e8c31df/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestHttpCallImpl.java
----------------------------------------------------------------------
diff --git a/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestHttpCallImpl.java b/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestHttpCallImpl.java
new file mode 100644
index 0000000..c0fd608
--- /dev/null
+++ b/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestHttpCallImpl.java
@@ -0,0 +1,98 @@
+package org.apache.brooklyn.test.framework;
+
+import com.google.api.client.util.Objects;
+import com.google.common.collect.Lists;
+import org.apache.brooklyn.api.location.Location;
+import org.apache.brooklyn.core.entity.AbstractEntity;
+import org.apache.brooklyn.core.entity.lifecycle.Lifecycle;
+import org.apache.brooklyn.core.entity.lifecycle.ServiceStateLogic;
+import org.apache.brooklyn.util.core.flags.TypeCoercions;
+import org.apache.brooklyn.util.exceptions.Exceptions;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Collection;
+import java.util.Map;
+
+import static org.apache.brooklyn.util.http.HttpUtils.*;
+
+/**
+ * {@inheritDoc}
+ */
+public class TestHttpCallImpl extends AbstractEntity implements TestHttpCall {
+
+    private static final Logger LOG = LoggerFactory.getLogger(TestHttpCallImpl.class);
+
+    /**
+     * {@inheritDoc}
+     */
+    public void start(Collection<? extends Location> locations) {
+        ServiceStateLogic.setExpectedState(this, Lifecycle.STARTING);
+        final String url = getConfig(TARGET_URL);
+        final Map assertions = getConfig(ASSERTIONS);
+        try {
+            checkAssertions(url, assertions);
+            sensors().set(SERVICE_UP, true);
+            ServiceStateLogic.setExpectedState(this, Lifecycle.RUNNING);
+        } catch (Throwable t) {
+            LOG.info("Url [{}] test failed", url);
+            sensors().set(SERVICE_UP, false);
+            ServiceStateLogic.setExpectedState(this, Lifecycle.ON_FIRE);
+            throw Exceptions.propagate(t);
+        }
+    }
+
+    /**
+     * Tests HTTP Request reponse matches assertions
+     * <p>
+     * Supported keys in the <code>assertions</code> {@link Map} include:
+     * <ul>
+     * <li>string - simple string match
+     * <li>regex - uses {@link java.lang.String#matches(String)}, if the url returns a multi-line response you should
+     * use the embedded dotall flag expression <code>(?s)</code> in your regex.
+     * <li>status - HTTP status code
+     * </ul>
+     * Wraps the {@link org.apache.brooklyn.util.http.HttpUtils} immediate assertion methods.
+     * <p>
+     * See the test/resources directory for examples.
+     *
+     * @param url        The target URL to be tested
+     * @param assertions The map of assertions
+     */
+    private void checkAssertions(final String url, final Map<?, ?> assertions) {
+
+        for (final Map.Entry<?, ?> entry : assertions.entrySet()) {
+            if (Objects.equal(entry.getKey(), "regex")) {
+                LOG.info("Testing if url [{}] matches regex [{}]",
+                        new Object[]{url, entry.getValue()});
+                assertContentMatches(url, TypeCoercions.coerce(entry.getValue(), String.class));
+            } else if (Objects.equal(entry.getKey(), "string")) {
+                LOG.debug("Testing if url [{}] contains string [{}]",
+                        new Object[]{url, entry.getValue()});
+                assertContentContainsText(url, TypeCoercions.coerce(entry.getValue(), String.class));
+            } else if (Objects.equal(entry.getKey(), "status")) {
+                LOG.debug("Testing if url [{}] returns status code [{}]",
+                        new Object[]{url, entry.getValue()});
+                assertHttpStatusCodeEquals(url, TypeCoercions.coerce(entry.getValue(), Integer.class));
+            }
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void stop() {
+        ServiceStateLogic.setExpectedState(this, Lifecycle.STOPPING);
+        sensors().set(SERVICE_UP, false);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void restart() {
+        final Collection<Location> locations = Lists.newArrayList(getLocations());
+        stop();
+        start(locations);
+    }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0e8c31df/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestSensor.java
----------------------------------------------------------------------
diff --git a/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestSensor.java b/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestSensor.java
new file mode 100644
index 0000000..c6303eb
--- /dev/null
+++ b/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestSensor.java
@@ -0,0 +1,27 @@
+package org.apache.brooklyn.test.framework;
+
+import com.google.common.collect.Maps;
+import org.apache.brooklyn.api.entity.ImplementedBy;
+import org.apache.brooklyn.config.ConfigKey;
+import org.apache.brooklyn.core.config.ConfigKeys;
+import org.apache.brooklyn.util.core.flags.SetFromFlag;
+import org.apache.brooklyn.util.time.Duration;
+
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Entity that tests a sensor value on another entity
+ *
+ * @author m4rkmckenna
+ */
+@ImplementedBy(value = TestSensorImpl.class)
+public interface TestSensor extends BaseTest {
+
+    @SetFromFlag(nullable = false)
+    ConfigKey<String> SENSOR_NAME = ConfigKeys.newConfigKey(String.class, "sensor", "Sensor to evaluate");
+
+    ConfigKey<Map> ASSERTIONS = ConfigKeys.newConfigKey(Map.class, "assert", "Assertions to be evaluated", Maps.newLinkedHashMap());
+
+    ConfigKey<Duration> TIMEOUT = ConfigKeys.newConfigKey(Duration.class, "timeout", "Time to wait on sensor result", new Duration(1L, TimeUnit.SECONDS));
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0e8c31df/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestSensorImpl.java
----------------------------------------------------------------------
diff --git a/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestSensorImpl.java b/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestSensorImpl.java
new file mode 100644
index 0000000..94151c6
--- /dev/null
+++ b/sandbox/brooklyn-sandbox-test-framework/src/main/java/org/apache/brooklyn/test/framework/TestSensorImpl.java
@@ -0,0 +1,144 @@
+package org.apache.brooklyn.test.framework;
+
+import com.google.api.client.util.Objects;
+import com.google.common.base.Predicate;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Lists;
+import org.apache.brooklyn.api.entity.Entity;
+import org.apache.brooklyn.api.location.Location;
+import org.apache.brooklyn.api.sensor.AttributeSensor;
+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.sensor.Sensors;
+import org.apache.brooklyn.util.core.flags.TypeCoercions;
+import org.apache.brooklyn.util.exceptions.Exceptions;
+import org.apache.brooklyn.util.time.Duration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.regex.Pattern;
+
+import static org.apache.brooklyn.core.entity.EntityAsserts.assertAttributeEventually;
+
+/**
+ * {@inheritDoc}
+ */
+public class TestSensorImpl extends AbstractTest implements TestSensor {
+
+    private static final Logger LOG = LoggerFactory.getLogger(TestSensorImpl.class);
+
+    /**
+     * {@inheritDoc}
+     */
+    public void start(Collection<? extends Location> locations) {
+        ServiceStateLogic.setExpectedState(this, Lifecycle.STARTING);
+        final Entity target = resolveTarget();
+        final String sensor = getConfig(SENSOR_NAME);
+        final Duration timeout = getConfig(TIMEOUT);
+        final Map assertions = getConfig(ASSERTIONS);
+        try {
+            checkAssertions(target, Sensors.newSensor(Object.class, sensor), ImmutableMap.of("timeout", timeout),
+                    assertions);
+            sensors().set(SERVICE_UP, true);
+            ServiceStateLogic.setExpectedState(this, Lifecycle.RUNNING);
+        } catch (Throwable t) {
+            LOG.info("Sensor [{}] test failed", sensor);
+            sensors().set(SERVICE_UP, false);
+            ServiceStateLogic.setExpectedState(this, Lifecycle.ON_FIRE);
+            throw Exceptions.propagate(t);
+        }
+    }
+
+    /**
+     * Tests sensor values match assertions
+     *
+     * @param target     The {@link Entity} that has the sensor under test
+     * @param sensor     The sensor to test
+     * @param flags      Passed to {@link org.apache.brooklyn.core.entity.EntityAsserts#assertAttributeEventually(Map, Entity, AttributeSensor, Predicate)}
+     * @param assertions The map of assertions
+     */
+    private void checkAssertions(final Entity target, final AttributeSensor<Object> sensor, final Map<?, ?> flags, final Map<?, ?> assertions) {
+        for (final Map.Entry<?, ?> entry : assertions.entrySet()) {
+            if (Objects.equal(entry.getKey(), "equals")) {
+                assertAttributeEventually(flags, target, sensor, isEqualTo(entry.getValue()));
+            } else if (Objects.equal(entry.getKey(), "regex")) {
+                assertAttributeEventually(flags, target, sensor, regexMatches(entry.getValue()));
+            } else if (Objects.equal(entry.getKey(), "isNull")) {
+                assertAttributeEventually(flags, target, sensor, isNull(entry.getValue()));
+            }
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    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);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void restart() {
+        final Collection<Location> locations = Lists.newArrayList(getLocations());
+        stop();
+        start(locations);
+    }
+
+    /**
+     * Predicate to check the equality of object
+     *
+     * @param value
+     * @return The created {@link Predicate}
+     */
+    private Predicate<Object> isEqualTo(final Object value) {
+        return new Predicate<Object>() {
+            public boolean apply(final Object input) {
+                return (input != null) && Objects.equal(TypeCoercions.coerce(value, input.getClass()), input);
+            }
+        };
+    }
+
+    /**
+     * Predicate to check if a sensor matches a regex pattern
+     *
+     * @param patternValue
+     * @return
+     */
+    private Predicate<Object> regexMatches(final Object patternValue) {
+        final Pattern pattern = Pattern.compile(TypeCoercions.coerce(patternValue, String.class));
+        return new Predicate<Object>() {
+            public boolean apply(final Object input) {
+                return (input != null) && pattern.matcher(input.toString()).matches();
+            }
+        };
+    }
+
+    /**
+     * Predicate to check if a sensor value is null
+     *
+     * @param isNullValue
+     * @return
+     */
+    private Predicate<Object> isNull(final Object isNullValue) {
+        return new Predicate<Object>() {
+            public boolean apply(final Object input) {
+                return (input == null) == TypeCoercions.coerce(isNullValue, Boolean.class);
+            }
+        };
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0e8c31df/sandbox/brooklyn-sandbox-test-framework/src/test/java/org/apache/brooklyn/test/framework/TestEffectorTest.java
----------------------------------------------------------------------
diff --git a/sandbox/brooklyn-sandbox-test-framework/src/test/java/org/apache/brooklyn/test/framework/TestEffectorTest.java b/sandbox/brooklyn-sandbox-test-framework/src/test/java/org/apache/brooklyn/test/framework/TestEffectorTest.java
new file mode 100644
index 0000000..b43c76b
--- /dev/null
+++ b/sandbox/brooklyn-sandbox-test-framework/src/test/java/org/apache/brooklyn/test/framework/TestEffectorTest.java
@@ -0,0 +1,106 @@
+package org.apache.brooklyn.test.framework;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import org.apache.brooklyn.api.entity.EntitySpec;
+import org.apache.brooklyn.api.location.LocationSpec;
+import org.apache.brooklyn.api.mgmt.ManagementContext;
+import org.apache.brooklyn.core.entity.Entities;
+import org.apache.brooklyn.core.test.entity.TestApplication;
+import org.apache.brooklyn.location.localhost.LocalhostMachineProvisioningLocation;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import java.util.UUID;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * @author m4rkmckenna on 27/10/2015.
+ */
+public class TestEffectorTest {
+
+    private TestApplication app;
+    private ManagementContext managementContext;
+    private LocalhostMachineProvisioningLocation loc;
+    private String testId;
+
+    @BeforeMethod
+    public void setup() {
+        testId = UUID.randomUUID().toString();
+        app = TestApplication.Factory.newManagedInstanceForTests();
+        managementContext = app.getManagementContext();
+
+        loc = managementContext.getLocationManager().createLocation(LocationSpec.create(LocalhostMachineProvisioningLocation.class)
+                .configure("name", testId));
+
+    }
+
+
+    @AfterMethod(alwaysRun = true)
+    public void tearDown() throws Exception {
+        if (app != null) Entities.destroyAll(app.getManagementContext());
+    }
+
+
+    @Test
+    public void testSimpleEffector() {
+        final TestCase testCase = app.createAndManageChild(EntitySpec.create(TestCase.class));
+        final TestEntity testEntity = testCase.addChild(EntitySpec.create(TestEntity.class));
+
+
+        final TestEffector testEffector = testCase.addChild(EntitySpec.create(TestEffector.class)
+                .configure(TestEffector.TARGET_ENTITY, testEntity)
+                .configure(TestEffector.EFFECTOR_NAME, "simpleEffector"));
+
+        app.start(ImmutableList.of(app.newSimulatedLocation()));
+
+        assertThat(testEntity.sensors().get(TestEntity.SIMPLE_EFFECTOR_INVOKED)).isNotNull();
+        assertThat(testEntity.sensors().get(TestEntity.SIMPLE_EFFECTOR_INVOKED)).isTrue();
+
+        assertThat(testEffector.sensors().get(TestEffector.EFFECTOR_RESULT)).isNull();
+    }
+
+    @Test
+    public void testComplexffector() {
+        final TestCase testCase = app.createAndManageChild(EntitySpec.create(TestCase.class));
+        final TestEntity testEntity = testCase.addChild(EntitySpec.create(TestEntity.class));
+
+        final long expectedLongValue = System.currentTimeMillis();
+        final boolean expectedBooleanValue = expectedLongValue % 2 == 0;
+
+        final TestEffector testEffector = testCase.addChild(EntitySpec.create(TestEffector.class)
+                .configure(TestEffector.TARGET_ENTITY, testEntity)
+                .configure(TestEffector.EFFECTOR_NAME, "complexEffector")
+                .configure(TestEffector.EFFECTOR_PARAMS, ImmutableMap.of(
+                        "stringValue", testId,
+                        "booleanValue", expectedBooleanValue,
+                        "longValue", expectedLongValue)));
+
+        app.start(ImmutableList.of(app.newSimulatedLocation()));
+
+        assertThat(testEntity.sensors().get(TestEntity.SIMPLE_EFFECTOR_INVOKED)).isNull();
+        assertThat(testEntity.sensors().get(TestEntity.COMPLEX_EFFECTOR_INVOKED)).isNotNull();
+        assertThat(testEntity.sensors().get(TestEntity.COMPLEX_EFFECTOR_INVOKED)).isTrue();
+
+        assertThat(testEntity.sensors().get(TestEntity.COMPLEX_EFFECTOR_STRING)).isNotNull();
+        assertThat(testEntity.sensors().get(TestEntity.COMPLEX_EFFECTOR_STRING)).isEqualTo(testId);
+
+        assertThat(testEntity.sensors().get(TestEntity.COMPLEX_EFFECTOR_BOOLEAN)).isNotNull();
+        assertThat(testEntity.sensors().get(TestEntity.COMPLEX_EFFECTOR_BOOLEAN)).isEqualTo(expectedBooleanValue);
+
+        assertThat(testEntity.sensors().get(TestEntity.COMPLEX_EFFECTOR_LONG)).isNotNull();
+        assertThat(testEntity.sensors().get(TestEntity.COMPLEX_EFFECTOR_LONG)).isEqualTo(expectedLongValue);
+
+        assertThat(testEffector.sensors().get(TestEffector.EFFECTOR_RESULT)).isNotNull();
+        assertThat(testEffector.sensors().get(TestEffector.EFFECTOR_RESULT)).isInstanceOf(TestEntity.TestPojo.class);
+
+        final TestEntity.TestPojo effectorResult = (TestEntity.TestPojo) testEffector.sensors().get(TestEffector.EFFECTOR_RESULT);
+        assertThat(effectorResult.getBooleanValue()).isEqualTo(expectedBooleanValue);
+        assertThat(effectorResult.getStringValue()).isEqualTo(testId);
+        assertThat(effectorResult.getLongValue()).isEqualTo(expectedLongValue);
+
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0e8c31df/sandbox/brooklyn-sandbox-test-framework/src/test/java/org/apache/brooklyn/test/framework/TestEntity.java
----------------------------------------------------------------------
diff --git a/sandbox/brooklyn-sandbox-test-framework/src/test/java/org/apache/brooklyn/test/framework/TestEntity.java b/sandbox/brooklyn-sandbox-test-framework/src/test/java/org/apache/brooklyn/test/framework/TestEntity.java
new file mode 100644
index 0000000..933b227
--- /dev/null
+++ b/sandbox/brooklyn-sandbox-test-framework/src/test/java/org/apache/brooklyn/test/framework/TestEntity.java
@@ -0,0 +1,55 @@
+package org.apache.brooklyn.test.framework;
+
+import org.apache.brooklyn.api.entity.Entity;
+import org.apache.brooklyn.api.entity.ImplementedBy;
+import org.apache.brooklyn.core.annotation.Effector;
+import org.apache.brooklyn.core.annotation.EffectorParam;
+import org.apache.brooklyn.core.config.ConfigKeys;
+import org.apache.brooklyn.core.entity.trait.Startable;
+import org.apache.brooklyn.core.sensor.AttributeSensorAndConfigKey;
+
+/**
+ * @author m4rkmckenna on 27/10/2015.
+ */
+
+@ImplementedBy(TestEntityImpl.class)
+public interface TestEntity extends Entity, Startable {
+
+    AttributeSensorAndConfigKey<Boolean, Boolean> SIMPLE_EFFECTOR_INVOKED = ConfigKeys.newSensorAndConfigKey(Boolean.class, "simple-effector-invoked", "");
+    AttributeSensorAndConfigKey<Boolean, Boolean> COMPLEX_EFFECTOR_INVOKED = ConfigKeys.newSensorAndConfigKey(Boolean.class, "complex-effector-invoked", "");
+    AttributeSensorAndConfigKey<String, String> COMPLEX_EFFECTOR_STRING = ConfigKeys.newSensorAndConfigKey(String.class, "complex-effector-string", "");
+    AttributeSensorAndConfigKey<Boolean, Boolean> COMPLEX_EFFECTOR_BOOLEAN = ConfigKeys.newSensorAndConfigKey(Boolean.class, "complex-effector-boolean", "");
+    AttributeSensorAndConfigKey<Long, Long> COMPLEX_EFFECTOR_LONG = ConfigKeys.newSensorAndConfigKey(Long.class, "complex-effector-long", "");
+
+    @Effector
+    void simpleEffector();
+
+    @Effector
+    TestPojo complexEffector(@EffectorParam(name = "stringValue") final String stringValue,
+                             @EffectorParam(name = "booleanValue") final Boolean booleanValue,
+                             @EffectorParam(name = "longValue") final Long longValue);
+
+    class TestPojo {
+        private final String stringValue;
+        private final Boolean booleanValue;
+        private final Long longValue;
+
+        public TestPojo(final String stringValue, final Boolean booleanValue, final Long longValue) {
+            this.stringValue = stringValue;
+            this.booleanValue = booleanValue;
+            this.longValue = longValue;
+        }
+
+        public String getStringValue() {
+            return stringValue;
+        }
+
+        public Boolean getBooleanValue() {
+            return booleanValue;
+        }
+
+        public Long getLongValue() {
+            return longValue;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0e8c31df/sandbox/brooklyn-sandbox-test-framework/src/test/java/org/apache/brooklyn/test/framework/TestEntityImpl.java
----------------------------------------------------------------------
diff --git a/sandbox/brooklyn-sandbox-test-framework/src/test/java/org/apache/brooklyn/test/framework/TestEntityImpl.java b/sandbox/brooklyn-sandbox-test-framework/src/test/java/org/apache/brooklyn/test/framework/TestEntityImpl.java
new file mode 100644
index 0000000..b3386f2
--- /dev/null
+++ b/sandbox/brooklyn-sandbox-test-framework/src/test/java/org/apache/brooklyn/test/framework/TestEntityImpl.java
@@ -0,0 +1,39 @@
+package org.apache.brooklyn.test.framework;
+
+import org.apache.brooklyn.api.location.Location;
+import org.apache.brooklyn.core.annotation.EffectorParam;
+import org.apache.brooklyn.core.entity.AbstractEntity;
+
+import java.util.Collection;
+
+/**
+ * @author m4rkmckenna on 27/10/2015.
+ */
+public class TestEntityImpl extends AbstractEntity implements TestEntity {
+    @Override
+    public void start(final Collection<? extends Location> locations) {
+    }
+
+    @Override
+    public void stop() {
+
+    }
+
+    @Override
+    public void restart() {
+    }
+
+    @Override
+    public void simpleEffector() {
+        sensors().set(SIMPLE_EFFECTOR_INVOKED, Boolean.TRUE);
+    }
+
+    @Override
+    public TestPojo complexEffector(@EffectorParam(name = "stringValue") final String stringValue, @EffectorParam(name = "booleanValue") final Boolean booleanValue, @EffectorParam(name = "longValue") final Long longValue) {
+        sensors().set(COMPLEX_EFFECTOR_INVOKED, Boolean.TRUE);
+        sensors().set(COMPLEX_EFFECTOR_STRING, stringValue);
+        sensors().set(COMPLEX_EFFECTOR_BOOLEAN, booleanValue);
+        sensors().set(COMPLEX_EFFECTOR_LONG, longValue);
+        return new TestPojo(stringValue, booleanValue, longValue);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0e8c31df/sandbox/brooklyn-sandbox-test-framework/src/test/java/org/apache/brooklyn/test/framework/TestSensorTest.java
----------------------------------------------------------------------
diff --git a/sandbox/brooklyn-sandbox-test-framework/src/test/java/org/apache/brooklyn/test/framework/TestSensorTest.java b/sandbox/brooklyn-sandbox-test-framework/src/test/java/org/apache/brooklyn/test/framework/TestSensorTest.java
new file mode 100644
index 0000000..0b653eb
--- /dev/null
+++ b/sandbox/brooklyn-sandbox-test-framework/src/test/java/org/apache/brooklyn/test/framework/TestSensorTest.java
@@ -0,0 +1,270 @@
+package org.apache.brooklyn.test.framework;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import org.apache.brooklyn.api.entity.EntitySpec;
+import org.apache.brooklyn.api.location.LocationSpec;
+import org.apache.brooklyn.api.mgmt.ManagementContext;
+import org.apache.brooklyn.core.config.ConfigKeys;
+import org.apache.brooklyn.core.entity.Entities;
+import org.apache.brooklyn.core.sensor.AttributeSensorAndConfigKey;
+import org.apache.brooklyn.core.test.entity.TestApplication;
+import org.apache.brooklyn.location.localhost.LocalhostMachineProvisioningLocation;
+import org.apache.brooklyn.util.exceptions.Exceptions;
+import org.apache.brooklyn.util.exceptions.PropagatedRuntimeException;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import java.util.UUID;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * @author m4rkmckenna on 27/10/2015.
+ */
+public class TestSensorTest {
+
+    private static final AttributeSensorAndConfigKey<Boolean, Boolean> BOOLEAN_SENSOR = ConfigKeys.newSensorAndConfigKey(Boolean.class, "boolean-sensor", "Boolean Sensor");
+    private static final AttributeSensorAndConfigKey<String, String> STRING_SENSOR = ConfigKeys.newSensorAndConfigKey(String.class, "string-sensor", "String Sensor");
+    private static final AttributeSensorAndConfigKey<Object, Object> OBJECT_SENSOR = ConfigKeys.newSensorAndConfigKey(Object.class, "object-sensor", "Object Sensor");
+
+    private TestApplication app;
+    private ManagementContext managementContext;
+    private LocalhostMachineProvisioningLocation loc;
+    private String testId;
+
+    @BeforeMethod
+    public void setup() {
+        testId = UUID.randomUUID().toString();
+        app = TestApplication.Factory.newManagedInstanceForTests();
+        managementContext = app.getManagementContext();
+        loc = managementContext.getLocationManager().createLocation(LocationSpec.create(LocalhostMachineProvisioningLocation.class)
+                .configure("name", testId));
+    }
+
+    @AfterMethod(alwaysRun = true)
+    public void tearDown() throws Exception {
+        if (app != null) Entities.destroyAll(app.getManagementContext());
+    }
+
+    @Test
+    public void testAssertEqual() {
+        //Add Sensor Test for BOOLEAN sensor
+        app.createAndManageChild(EntitySpec.create(TestSensor.class)
+                .configure(TestSensor.TARGET_ENTITY, app)
+                .configure(TestSensor.SENSOR_NAME, BOOLEAN_SENSOR.getName())
+                .configure(TestSensor.ASSERTIONS, ImmutableMap.of("equals", true)));
+        //Add Sensor Test for STRING sensor
+        app.createAndManageChild(EntitySpec.create(TestSensor.class)
+                .configure(TestSensor.TARGET_ENTITY, app)
+                .configure(TestSensor.SENSOR_NAME, STRING_SENSOR.getName())
+                .configure(TestSensor.ASSERTIONS, ImmutableMap.of("equals", testId)));
+
+        //Set BOOLEAN Sensor to true
+        app.sensors().set(BOOLEAN_SENSOR, Boolean.TRUE);
+        //Set STRING sensor to random string
+        app.sensors().set(STRING_SENSOR, testId);
+
+
+        app.start(ImmutableList.of(loc));
+
+    }
+
+    @Test
+    public void testAssertEqualFailure() {
+        boolean booleanAssertFailed = false;
+
+        //Add Sensor Test for BOOLEAN sensor
+        app.createAndManageChild(EntitySpec.create(TestSensor.class)
+                .configure(TestSensor.TARGET_ENTITY, app)
+                .configure(TestSensor.SENSOR_NAME, BOOLEAN_SENSOR.getName())
+                .configure(TestSensor.ASSERTIONS, ImmutableMap.of("equals", true)));
+
+        //Set BOOLEAN Sensor to false
+        app.sensors().set(BOOLEAN_SENSOR, Boolean.FALSE);
+
+        try {
+            app.start(ImmutableList.of(loc));
+        } catch (final PropagatedRuntimeException pre) {
+            final AssertionError assertionError = Exceptions.getFirstThrowableOfType(pre, AssertionError.class);
+            assertThat(assertionError).isNotNull();
+            booleanAssertFailed = true;
+        } finally {
+            assertThat(booleanAssertFailed).isTrue();
+        }
+    }
+
+    @Test
+    public void testAssertEqualOnNullSenor() {
+        boolean booleanAssertFailed = false;
+
+        //Add Sensor Test for BOOLEAN sensor
+        app.createAndManageChild(EntitySpec.create(TestSensor.class)
+                .configure(TestSensor.TARGET_ENTITY, app)
+                .configure(TestSensor.SENSOR_NAME, BOOLEAN_SENSOR.getName())
+                .configure(TestSensor.ASSERTIONS, ImmutableMap.of("equals", false)));
+
+        try {
+            app.start(ImmutableList.of(loc));
+        } catch (final PropagatedRuntimeException pre) {
+            final AssertionError assertionError = Exceptions.getFirstThrowableOfType(pre, AssertionError.class);
+            assertThat(assertionError).isNotNull().as("An assertion error should have been thrown");
+            booleanAssertFailed = true;
+        } finally {
+            assertThat(booleanAssertFailed).isTrue().as("Equals assert should have failed as the sensor is NULL");
+        }
+    }
+
+    @Test
+    public void testAssertNull() {
+        //Add Sensor Test for BOOLEAN sensor
+        app.createAndManageChild(EntitySpec.create(TestSensor.class)
+                .configure(TestSensor.TARGET_ENTITY, app)
+                .configure(TestSensor.SENSOR_NAME, BOOLEAN_SENSOR.getName())
+                .configure(TestSensor.ASSERTIONS, ImmutableMap.of("isNull", true)));
+        //Add Sensor Test for STRING sensor
+        app.createAndManageChild(EntitySpec.create(TestSensor.class)
+                .configure(TestSensor.TARGET_ENTITY, app)
+                .configure(TestSensor.SENSOR_NAME, STRING_SENSOR.getName())
+                .configure(TestSensor.ASSERTIONS, ImmutableMap.of("isNull", false)));
+
+        //Set STRING sensor to random string
+        app.sensors().set(STRING_SENSOR, testId);
+
+        app.start(ImmutableList.of(loc));
+
+    }
+
+
+    @Test
+    public void testAssertNullFail() {
+        boolean sensorTestFail = false;
+        //Add Sensor Test for STRING sensor
+        app.createAndManageChild(EntitySpec.create(TestSensor.class)
+                .configure(TestSensor.TARGET_ENTITY, app)
+                .configure(TestSensor.SENSOR_NAME, STRING_SENSOR.getName())
+                .configure(TestSensor.ASSERTIONS, ImmutableMap.of("isNull", true)));
+
+        //Set STRING sensor to random string
+        app.sensors().set(STRING_SENSOR, testId);
+
+
+        try {
+            app.start(ImmutableList.of(loc));
+        } catch (final PropagatedRuntimeException pre) {
+            final AssertionError assertionError = Exceptions.getFirstThrowableOfType(pre, AssertionError.class);
+            assertThat(assertionError).isNotNull().as("An assertion error should have been thrown");
+            sensorTestFail = true;
+        } finally {
+            assertThat(sensorTestFail).isTrue().as("isNull assert should have failed as the sensor has been set");
+        }
+
+    }
+
+    @Test
+    public void testAssertRegex() {
+        final long time = System.currentTimeMillis();
+        final String sensorValue = String.format("%s%s%s", UUID.randomUUID().toString(), time, UUID.randomUUID().toString());
+
+        //Add Sensor Test for STRING sensor
+        app.createAndManageChild(EntitySpec.create(TestSensor.class)
+                .configure(TestSensor.TARGET_ENTITY, app)
+                .configure(TestSensor.SENSOR_NAME, STRING_SENSOR.getName())
+                .configure(TestSensor.ASSERTIONS, ImmutableMap.of("regex", String.format(".*%s.*", time))));
+        app.createAndManageChild(EntitySpec.create(TestSensor.class)
+                .configure(TestSensor.TARGET_ENTITY, app)
+                .configure(TestSensor.SENSOR_NAME, BOOLEAN_SENSOR.getName())
+                .configure(TestSensor.ASSERTIONS, ImmutableMap.of("regex", "true")));
+
+        //Set STRING sensor
+        app.sensors().set(STRING_SENSOR, sensorValue);
+        app.sensors().set(BOOLEAN_SENSOR, true);
+
+
+        app.start(ImmutableList.of(loc));
+    }
+
+    @Test
+    public void testAssertRegexFail() {
+        boolean sensorTestFail = false;
+        final String sensorValue = String.format("%s%s%s", UUID.randomUUID().toString(), System.currentTimeMillis(), UUID.randomUUID().toString());
+
+        //Add Sensor Test for STRING sensor
+        app.createAndManageChild(EntitySpec.create(TestSensor.class)
+                .configure(TestSensor.TARGET_ENTITY, app)
+                .configure(TestSensor.SENSOR_NAME, STRING_SENSOR.getName())
+                .configure(TestSensor.ASSERTIONS, ImmutableMap.of("regex", String.format(".*%s.*", UUID.randomUUID().toString()))));
+
+        //Set STRING sensor
+        app.sensors().set(STRING_SENSOR, sensorValue);
+
+
+        try {
+            app.start(ImmutableList.of(loc));
+        } catch (final PropagatedRuntimeException pre) {
+            final AssertionError assertionError = Exceptions.getFirstThrowableOfType(pre, AssertionError.class);
+            assertThat(assertionError).isNotNull().as("An assertion error should have been thrown");
+            sensorTestFail = true;
+        } finally {
+            assertThat(sensorTestFail).isTrue().as("regex assert should have failed");
+        }
+    }
+
+    @Test
+    public void testAssertRegexOnNullSensor() {
+        boolean sensorTestFail = false;
+        final String sensorValue = String.format("%s%s%s", UUID.randomUUID().toString(), System.currentTimeMillis(), UUID.randomUUID().toString());
+
+        //Add Sensor Test for STRING sensor
+        app.createAndManageChild(EntitySpec.create(TestSensor.class)
+                .configure(TestSensor.TARGET_ENTITY, app)
+                .configure(TestSensor.SENSOR_NAME, STRING_SENSOR.getName())
+                .configure(TestSensor.ASSERTIONS, ImmutableMap.of("regex", String.format(".*%s.*", UUID.randomUUID().toString()))));
+
+        try {
+            app.start(ImmutableList.of(loc));
+        } catch (final PropagatedRuntimeException pre) {
+            final AssertionError assertionError = Exceptions.getFirstThrowableOfType(pre, AssertionError.class);
+            assertThat(assertionError).isNotNull().as("An assertion error should have been thrown");
+            sensorTestFail = true;
+        } finally {
+            assertThat(sensorTestFail).isTrue().as("regex assert should have failed");
+        }
+    }
+
+
+    @Test
+    public void testAssertRegexOnNonStringSensor() {
+        //Add Sensor Test for OBJECT sensor
+        app.createAndManageChild(EntitySpec.create(TestSensor.class)
+                .configure(TestSensor.TARGET_ENTITY, app)
+                .configure(TestSensor.SENSOR_NAME, OBJECT_SENSOR.getName())
+                .configure(TestSensor.ASSERTIONS, ImmutableMap.of("regex", ".*TestObject.*id=.*")));
+
+        app.sensors().set(OBJECT_SENSOR, new TestObject());
+
+        app.start(ImmutableList.of(loc));
+
+    }
+
+
+    class TestObject {
+        private final String id;
+
+        public TestObject() {
+            id = UUID.randomUUID().toString();
+        }
+
+        public String getId() {
+            return id;
+        }
+
+        @Override
+        public String toString() {
+            return ToStringBuilder.reflectionToString(this);
+        }
+    }
+
+}


[10/21] incubator-brooklyn git commit: Moved etc directory to src/test/resources/test-framework-examples as the files are not needed at runtime

Posted by he...@apache.org.
Moved etc directory to src/test/resources/test-framework-examples as the files are not needed at runtime


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

Branch: refs/heads/master
Commit: b0405c89471c28c4a3c574ae68b2086ab883c521
Parents: 01f19e7
Author: Mark McKenna <m4...@gmail.com>
Authored: Wed Nov 11 10:56:11 2015 +0000
Committer: Mark McKenna <m4...@gmail.com>
Committed: Wed Nov 11 11:12:53 2015 +0000

----------------------------------------------------------------------
 .../test-framework/etc/example-catalog-test.bom |  22 ----
 usage/test-framework/etc/example-catalog.bom    |  15 ---
 .../test-framework/etc/nginx-test-examples.yml  |  98 ---------------
 .../etc/testhttpcall-examples.yml               | 124 -------------------
 .../test-framework/etc/tomcat-test-examples.yml |  45 -------
 .../resources/test-framework-examples/README.md |   0
 .../example-catalog-test.bom                    |  22 ++++
 .../test-framework-examples/example-catalog.bom |  15 +++
 .../nginx-test-examples.yml                     |  98 +++++++++++++++
 .../testhttpcall-examples.yml                   | 124 +++++++++++++++++++
 .../tomcat-test-examples.yml                    |  45 +++++++
 11 files changed, 304 insertions(+), 304 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/b0405c89/usage/test-framework/etc/example-catalog-test.bom
----------------------------------------------------------------------
diff --git a/usage/test-framework/etc/example-catalog-test.bom b/usage/test-framework/etc/example-catalog-test.bom
deleted file mode 100644
index 0605f9d..0000000
--- a/usage/test-framework/etc/example-catalog-test.bom
+++ /dev/null
@@ -1,22 +0,0 @@
-brooklyn.catalog:
-  id: simple-tomcat-test
-  version: 1.0
-  itemType: template
-  iconUrl: http://tomcat.apache.org/images/tomcat.png
-  name: Simple Tomcat Test
-  license: Apache-2.0
-  item:
-    brooklyn.config:
-      simple.confg: someValue
-    services:
-    - type: org.apache.brooklyn.test.framework.TestCase
-      name: Simple Tomcat Tests
-      brooklyn.children:
-      - type: simple-tomcat
-        id: tomcat
-      - type: org.apache.brooklyn.test.framework.TestSensor
-        target: $brooklyn:component("tomcat")
-        sensor: service.isUp
-        timeout: 10m
-        assert:
-          equals: true
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/b0405c89/usage/test-framework/etc/example-catalog.bom
----------------------------------------------------------------------
diff --git a/usage/test-framework/etc/example-catalog.bom b/usage/test-framework/etc/example-catalog.bom
deleted file mode 100644
index ab7e54b..0000000
--- a/usage/test-framework/etc/example-catalog.bom
+++ /dev/null
@@ -1,15 +0,0 @@
-brooklyn.catalog:
-  id: simple-tomcat
-  version: 1.0
-  itemType: template
-  iconUrl: http://tomcat.apache.org/images/tomcat.png
-  name: Simple Tomcat
-  license: Apache-2.0
-  item:
-    brooklyn.config:
-      simple.confg: someValue
-    services:
-    - type: org.apache.brooklyn.entity.webapp.tomcat.TomcatServer
-      id: tomcat
-      name: Tomcat
-      war: https://tomcat.apache.org/tomcat-6.0-doc/appdev/sample/sample.war
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/b0405c89/usage/test-framework/etc/nginx-test-examples.yml
----------------------------------------------------------------------
diff --git a/usage/test-framework/etc/nginx-test-examples.yml b/usage/test-framework/etc/nginx-test-examples.yml
deleted file mode 100644
index f1711ea..0000000
--- a/usage/test-framework/etc/nginx-test-examples.yml
+++ /dev/null
@@ -1,98 +0,0 @@
----
-# 1. Start an nginx
-# 2. Test it is running
-# 3. Stop it
-# 4. Test it stopped
-# Note there are two alternative forms to look up target - either just provide the 'targetId' to do an implicit DSL lookup,
-# or look it up with explicit DSL and provide it as 'target'.
-name: NGINX Test
-location: localhost
-services:
-- type: org.apache.brooklyn.test.framework.TestCase
-  name: Stop Test
-  brooklyn.children:
-  - type: org.apache.brooklyn.entity.proxy.nginx.NginxController
-    id: nginx1
-  - type: org.apache.brooklyn.test.framework.TestSensor
-    target: $brooklyn:component("nginx1")
-    sensor: service.isUp
-    equals: true
-    timeout: 5m
-  - type: org.apache.brooklyn.test.framework.TestEffector
-    target: $brooklyn:component("nginx1")
-    effector: stop
-  - type: org.apache.brooklyn.test.framework.TestSensor
-    target: $brooklyn:component("nginx1")
-    sensor: service.isUp
-    assert:
-      equals: false
-...
-
----
-name: NGINX Test
-location: localhost
-services:
-- type: org.apache.brooklyn.test.framework.TestCase
-  name: Stop Test
-  targetId: nginx1
-  brooklyn.children:
-  - type: org.apache.brooklyn.entity.proxy.nginx.NginxController
-    id: nginx1
-  - type: org.apache.brooklyn.test.framework.TestSensor
-    sensor: service.isUp
-    equals: true
-    timeout: 5m
-  - type: org.apache.brooklyn.test.framework.TestEffector
-    effector: stop
-  - type: org.apache.brooklyn.test.framework.TestSensor
-    sensor: service.isUp
-    equals: false
-
-
-
----
-name: NGINX Test
-location: localhost
-services:
-- type: org.apache.brooklyn.test.framework.TestCase
-  name: Stop Test
-  brooklyn.children:
-  - type: org.apache.brooklyn.entity.proxy.nginx.NginxController
-    id: nginx1
-  - type: org.apache.brooklyn.test.framework.TestSensor
-    target: $brooklyn:component("nginx1")
-    sensor: service.isUp
-    timeout: 5m
-    assert:
-      equals: true
-  - type: org.apache.brooklyn.test.framework.TestEffector
-    target: $brooklyn:component("nginx1")
-    effector: stop
-  - type: org.apache.brooklyn.test.framework.TestSensor
-    target: $brooklyn:component("nginx1")
-    sensor: service.isUp
-    assert:
-      equals: false
-      regex: .*
-...
-
----
-name: NGINX Test
-location: localhost
-services:
-- type: org.apache.brooklyn.entity.proxy.nginx.NginxController
-  id: nginx1
-- type: org.apache.brooklyn.test.framework.TestSensor
-  target: $brooklyn:component("nginx1")
-  sensor: service.isUp
-  timeout: 5m
-  assert:
-    equals: true
-- type: org.apache.brooklyn.test.framework.TestSensor
-  name: Test Regex
-  target: $brooklyn:component("nginx1")
-  sensor: service.isUp
-  timeout: 5m
-  assert:
-    regex: .*
-...
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/b0405c89/usage/test-framework/etc/testhttpcall-examples.yml
----------------------------------------------------------------------
diff --git a/usage/test-framework/etc/testhttpcall-examples.yml b/usage/test-framework/etc/testhttpcall-examples.yml
deleted file mode 100644
index a418fd8..0000000
--- a/usage/test-framework/etc/testhttpcall-examples.yml
+++ /dev/null
@@ -1,124 +0,0 @@
----
-name: Basic HTTP Call Tests
-location: localhost
-services:
-- type: org.apache.brooklyn.test.framework.TestCase
-  brooklyn.children:
-  - type: org.apache.brooklyn.entity.webapp.tomcat.TomcatServer
-    id: tomcat
-    brooklyn.config:
-      war: "http://search.maven.org/remotecontent?filepath=io/brooklyn/example/brooklyn-example-hello-world-sql-webapp/0.6.0/brooklyn-example-hello-world-sql-webapp-0.6.0.war"
-  - type: org.apache.brooklyn.test.framework.TestHttpCall
-    name: Status Code 200
-    url: $brooklyn:component("tomcat").attributeWhenReady("webapp.url")
-    assert:
-      status: 200
-  - type: org.apache.brooklyn.test.framework.TestHttpCall
-    name: Status Code 404
-    url: $brooklyn:formatString("%s/invalidpath/", component("tomcat").attributeWhenReady("webapp.url"))
-    timeout: 10s
-    assert:
-      status: 404
-  - type: org.apache.brooklyn.test.framework.TestHttpCall
-    name: String match
-    url: $brooklyn:component("tomcat").attributeWhenReady("webapp.url")
-    assert:
-      string: Sample Brooklyn Deployed
-  - type: org.apache.brooklyn.test.framework.TestHttpCall
-    name: Regex match
-    url: $brooklyn:component("tomcat").attributeWhenReady("webapp.url")
-    # the regex assert uses java.lang.String under the hood so if the url is expected to returns
-    # a multi-line response you should use the embedded dotall flag expression `(?s)` in your regex.
-    # See: http://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html
-    assert:
-      regex: "(?s).*illustrate(\\s)*how(\\s)*web(\\s)*applications.*"
-...
-
----
-name: HTTP Call Test with Effector
-location: localhost
-services:
-- type: org.apache.brooklyn.test.framework.TestCase
-  brooklyn.children:
-  - type: org.apache.brooklyn.entity.webapp.tomcat.TomcatServer
-    id: tomcat
-    brooklyn.config:
-      war: "http://search.maven.org/remotecontent?filepath=io/brooklyn/example/brooklyn-example-hello-world-sql-webapp/0.6.0/brooklyn-example-hello-world-sql-webapp-0.6.0.war"
-  - type: org.apache.brooklyn.test.framework.TestHttpCall
-    name: / Status Code 200
-    url: $brooklyn:component("tomcat").attributeWhenReady("webapp.url")
-    assert:
-      status: 200
-  - type: org.apache.brooklyn.test.framework.TestHttpCall
-    name: /newcontext Status Code 404
-    url: $brooklyn:formatString("%s/newcontext/", component("tomcat").attributeWhenReady("webapp.url"))
-    assert:
-      status: 404
-  - type: org.apache.brooklyn.test.framework.TestEffector
-    name: Deploy WAR in /newcontext
-    target: $brooklyn:component("tomcat")
-    effector: deploy
-    params:
-      url: http://search.maven.org/remotecontent?filepath=io/brooklyn/example/brooklyn-example-hello-world-sql-webapp/0.6.0/brooklyn-example-hello-world-sql-webapp-0.6.0.war
-      targetName: newcontext
-  - type: org.apache.brooklyn.test.framework.TestHttpCall
-    name: /newcontext Status Code 200
-    url: $brooklyn:formatString("%s/newcontext/", component("tomcat").attributeWhenReady("webapp.url"))
-    # Give Tomcat time to make the newly deployed War accessible
-    timeout: 10s
-    assert:
-      status: 200
-...
-
----
-name: HTTP Call Test with Eventual String and Regex Matches
-location: localhost
-services:
-- type: org.apache.brooklyn.test.framework.TestCase
-  brooklyn.children:
-  - type: org.apache.brooklyn.entity.webapp.tomcat.TomcatServer
-    id: tomcat
-    brooklyn.config:
-      war: "http://search.maven.org/remotecontent?filepath=io/brooklyn/example/brooklyn-example-hello-world-sql-webapp/0.6.0/brooklyn-example-hello-world-sql-webapp-0.6.0.war"
-  - type: org.apache.brooklyn.test.framework.TestEffector
-    name: Deploy WAR in /newcontext
-    target: $brooklyn:component("tomcat")
-    effector: deploy
-    params:
-      url: http://search.maven.org/remotecontent?filepath=io/brooklyn/example/brooklyn-example-hello-world-sql-webapp/0.6.0/brooklyn-example-hello-world-sql-webapp-0.6.0.war
-      targetName: newcontext
-  - type: org.apache.brooklyn.test.framework.TestHttpCall
-    name: Regex match
-    url: $brooklyn:formatString("%s/newcontext/", component("tomcat").attributeWhenReady("webapp.url"))
-    timeout: 10s
-    assert:
-      regex: "(?s).*illustrate(\\s)*how(\\s)*web(\\s)*applications.*"
-  - type: org.apache.brooklyn.test.framework.TestEffector
-    name: Deploy WAR in /newcontext2
-    target: $brooklyn:component("tomcat")
-    effector: deploy
-    params:
-      url: http://search.maven.org/remotecontent?filepath=io/brooklyn/example/brooklyn-example-hello-world-sql-webapp/0.6.0/brooklyn-example-hello-world-sql-webapp-0.6.0.war
-      targetName: newcontext2
-  - type: org.apache.brooklyn.test.framework.TestHttpCall
-    name: String match
-    url: $brooklyn:formatString("%s/newcontext2/", component("tomcat").attributeWhenReady("webapp.url"))
-    timeout: 10s
-    assert:
-      string: Sample Brooklyn Deployed
-    assert:
-      status: 404
-  - type: org.apache.brooklyn.test.framework.TestHttpCall
-    name: String match
-    url: $brooklyn:component("tomcat").attributeWhenReady("webapp.url")
-    assert:
-      string: Sample Brooklyn Deployed
-  - type: org.apache.brooklyn.test.framework.TestHttpCall
-    name: Regex match
-    url: $brooklyn:component("tomcat").attributeWhenReady("webapp.url")
-    # the regex assert uses java.lang.String under the hood so if the url is expected to returns
-    # a multi-line response you should use the embedded dotall flag expression `(?s)` in your regex.
-    # See: http://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html
-    assert:
-      regex: "(?s).*illustrate(\\s)*how(\\s)*web(\\s)*applications.*"
-...
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/b0405c89/usage/test-framework/etc/tomcat-test-examples.yml
----------------------------------------------------------------------
diff --git a/usage/test-framework/etc/tomcat-test-examples.yml b/usage/test-framework/etc/tomcat-test-examples.yml
deleted file mode 100644
index 37d7f4d..0000000
--- a/usage/test-framework/etc/tomcat-test-examples.yml
+++ /dev/null
@@ -1,45 +0,0 @@
----
-name: Tomcat Multi-War Test
-location: localhost
-services:
-- type: org.apache.brooklyn.entity.webapp.tomcat.TomcatServer
-  id: tomcat
-  name: Tomcat
-  brooklyn.config:
-    wars.by.context:
-      hello1: "http://search.maven.org/remotecontent?filepath=io/brooklyn/example/brooklyn-example-hello-world-sql-webapp/0.6.0/brooklyn-example-hello-world-sql-webapp-0.6.0.war"
-      hello2: "http://search.maven.org/remotecontent?filepath=io/brooklyn/example/brooklyn-example-hello-world-sql-webapp/0.6.0/brooklyn-example-hello-world-sql-webapp-0.6.0.war"
-    start.timeout: 10m
-- type: org.apache.brooklyn.test.framework.TestSensor
-  target: $brooklyn:component("tomcat")
-  sensor: service.isUp
-  assert:
-    equals: true
-  timeout: 10m
-...
-
----
-name: Tomcat Tests
-location: BYON 1
-services:
-  - type: org.apache.brooklyn.test.framework.TestCase
-    name: Effector - Deploy Test
-    brooklyn.children:
-    - type: org.apache.brooklyn.entity.webapp.tomcat.TomcatServer
-      id: tomcat
-      name: Tomcat
-      war: https://tomcat.apache.org/tomcat-6.0-doc/appdev/sample/sample.war
-    - type: org.apache.brooklyn.test.framework.TestEffector
-      name: Deploy Another WAR
-      target: $brooklyn:component("tomcat")
-      effector: deploy
-      params:
-        url: https://tomcat.apache.org/tomcat-6.0-doc/appdev/sample/sample.war
-        targetName: sample1
-#    - type: org.apache.brooklyn.test.framework.TestSensor
-#      target: $brooklyn:component("tomcat")
-#      sensor: webapp.deployedWars
-#      assert:
-#        regex: .*sample1.*
-#      timeout: 1m
-...
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/b0405c89/usage/test-framework/src/test/resources/test-framework-examples/README.md
----------------------------------------------------------------------
diff --git a/usage/test-framework/src/test/resources/test-framework-examples/README.md b/usage/test-framework/src/test/resources/test-framework-examples/README.md
new file mode 100644
index 0000000..e69de29

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/b0405c89/usage/test-framework/src/test/resources/test-framework-examples/example-catalog-test.bom
----------------------------------------------------------------------
diff --git a/usage/test-framework/src/test/resources/test-framework-examples/example-catalog-test.bom b/usage/test-framework/src/test/resources/test-framework-examples/example-catalog-test.bom
new file mode 100644
index 0000000..0605f9d
--- /dev/null
+++ b/usage/test-framework/src/test/resources/test-framework-examples/example-catalog-test.bom
@@ -0,0 +1,22 @@
+brooklyn.catalog:
+  id: simple-tomcat-test
+  version: 1.0
+  itemType: template
+  iconUrl: http://tomcat.apache.org/images/tomcat.png
+  name: Simple Tomcat Test
+  license: Apache-2.0
+  item:
+    brooklyn.config:
+      simple.confg: someValue
+    services:
+    - type: org.apache.brooklyn.test.framework.TestCase
+      name: Simple Tomcat Tests
+      brooklyn.children:
+      - type: simple-tomcat
+        id: tomcat
+      - type: org.apache.brooklyn.test.framework.TestSensor
+        target: $brooklyn:component("tomcat")
+        sensor: service.isUp
+        timeout: 10m
+        assert:
+          equals: true
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/b0405c89/usage/test-framework/src/test/resources/test-framework-examples/example-catalog.bom
----------------------------------------------------------------------
diff --git a/usage/test-framework/src/test/resources/test-framework-examples/example-catalog.bom b/usage/test-framework/src/test/resources/test-framework-examples/example-catalog.bom
new file mode 100644
index 0000000..ab7e54b
--- /dev/null
+++ b/usage/test-framework/src/test/resources/test-framework-examples/example-catalog.bom
@@ -0,0 +1,15 @@
+brooklyn.catalog:
+  id: simple-tomcat
+  version: 1.0
+  itemType: template
+  iconUrl: http://tomcat.apache.org/images/tomcat.png
+  name: Simple Tomcat
+  license: Apache-2.0
+  item:
+    brooklyn.config:
+      simple.confg: someValue
+    services:
+    - type: org.apache.brooklyn.entity.webapp.tomcat.TomcatServer
+      id: tomcat
+      name: Tomcat
+      war: https://tomcat.apache.org/tomcat-6.0-doc/appdev/sample/sample.war
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/b0405c89/usage/test-framework/src/test/resources/test-framework-examples/nginx-test-examples.yml
----------------------------------------------------------------------
diff --git a/usage/test-framework/src/test/resources/test-framework-examples/nginx-test-examples.yml b/usage/test-framework/src/test/resources/test-framework-examples/nginx-test-examples.yml
new file mode 100644
index 0000000..f1711ea
--- /dev/null
+++ b/usage/test-framework/src/test/resources/test-framework-examples/nginx-test-examples.yml
@@ -0,0 +1,98 @@
+---
+# 1. Start an nginx
+# 2. Test it is running
+# 3. Stop it
+# 4. Test it stopped
+# Note there are two alternative forms to look up target - either just provide the 'targetId' to do an implicit DSL lookup,
+# or look it up with explicit DSL and provide it as 'target'.
+name: NGINX Test
+location: localhost
+services:
+- type: org.apache.brooklyn.test.framework.TestCase
+  name: Stop Test
+  brooklyn.children:
+  - type: org.apache.brooklyn.entity.proxy.nginx.NginxController
+    id: nginx1
+  - type: org.apache.brooklyn.test.framework.TestSensor
+    target: $brooklyn:component("nginx1")
+    sensor: service.isUp
+    equals: true
+    timeout: 5m
+  - type: org.apache.brooklyn.test.framework.TestEffector
+    target: $brooklyn:component("nginx1")
+    effector: stop
+  - type: org.apache.brooklyn.test.framework.TestSensor
+    target: $brooklyn:component("nginx1")
+    sensor: service.isUp
+    assert:
+      equals: false
+...
+
+---
+name: NGINX Test
+location: localhost
+services:
+- type: org.apache.brooklyn.test.framework.TestCase
+  name: Stop Test
+  targetId: nginx1
+  brooklyn.children:
+  - type: org.apache.brooklyn.entity.proxy.nginx.NginxController
+    id: nginx1
+  - type: org.apache.brooklyn.test.framework.TestSensor
+    sensor: service.isUp
+    equals: true
+    timeout: 5m
+  - type: org.apache.brooklyn.test.framework.TestEffector
+    effector: stop
+  - type: org.apache.brooklyn.test.framework.TestSensor
+    sensor: service.isUp
+    equals: false
+
+
+
+---
+name: NGINX Test
+location: localhost
+services:
+- type: org.apache.brooklyn.test.framework.TestCase
+  name: Stop Test
+  brooklyn.children:
+  - type: org.apache.brooklyn.entity.proxy.nginx.NginxController
+    id: nginx1
+  - type: org.apache.brooklyn.test.framework.TestSensor
+    target: $brooklyn:component("nginx1")
+    sensor: service.isUp
+    timeout: 5m
+    assert:
+      equals: true
+  - type: org.apache.brooklyn.test.framework.TestEffector
+    target: $brooklyn:component("nginx1")
+    effector: stop
+  - type: org.apache.brooklyn.test.framework.TestSensor
+    target: $brooklyn:component("nginx1")
+    sensor: service.isUp
+    assert:
+      equals: false
+      regex: .*
+...
+
+---
+name: NGINX Test
+location: localhost
+services:
+- type: org.apache.brooklyn.entity.proxy.nginx.NginxController
+  id: nginx1
+- type: org.apache.brooklyn.test.framework.TestSensor
+  target: $brooklyn:component("nginx1")
+  sensor: service.isUp
+  timeout: 5m
+  assert:
+    equals: true
+- type: org.apache.brooklyn.test.framework.TestSensor
+  name: Test Regex
+  target: $brooklyn:component("nginx1")
+  sensor: service.isUp
+  timeout: 5m
+  assert:
+    regex: .*
+...
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/b0405c89/usage/test-framework/src/test/resources/test-framework-examples/testhttpcall-examples.yml
----------------------------------------------------------------------
diff --git a/usage/test-framework/src/test/resources/test-framework-examples/testhttpcall-examples.yml b/usage/test-framework/src/test/resources/test-framework-examples/testhttpcall-examples.yml
new file mode 100644
index 0000000..a418fd8
--- /dev/null
+++ b/usage/test-framework/src/test/resources/test-framework-examples/testhttpcall-examples.yml
@@ -0,0 +1,124 @@
+---
+name: Basic HTTP Call Tests
+location: localhost
+services:
+- type: org.apache.brooklyn.test.framework.TestCase
+  brooklyn.children:
+  - type: org.apache.brooklyn.entity.webapp.tomcat.TomcatServer
+    id: tomcat
+    brooklyn.config:
+      war: "http://search.maven.org/remotecontent?filepath=io/brooklyn/example/brooklyn-example-hello-world-sql-webapp/0.6.0/brooklyn-example-hello-world-sql-webapp-0.6.0.war"
+  - type: org.apache.brooklyn.test.framework.TestHttpCall
+    name: Status Code 200
+    url: $brooklyn:component("tomcat").attributeWhenReady("webapp.url")
+    assert:
+      status: 200
+  - type: org.apache.brooklyn.test.framework.TestHttpCall
+    name: Status Code 404
+    url: $brooklyn:formatString("%s/invalidpath/", component("tomcat").attributeWhenReady("webapp.url"))
+    timeout: 10s
+    assert:
+      status: 404
+  - type: org.apache.brooklyn.test.framework.TestHttpCall
+    name: String match
+    url: $brooklyn:component("tomcat").attributeWhenReady("webapp.url")
+    assert:
+      string: Sample Brooklyn Deployed
+  - type: org.apache.brooklyn.test.framework.TestHttpCall
+    name: Regex match
+    url: $brooklyn:component("tomcat").attributeWhenReady("webapp.url")
+    # the regex assert uses java.lang.String under the hood so if the url is expected to returns
+    # a multi-line response you should use the embedded dotall flag expression `(?s)` in your regex.
+    # See: http://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html
+    assert:
+      regex: "(?s).*illustrate(\\s)*how(\\s)*web(\\s)*applications.*"
+...
+
+---
+name: HTTP Call Test with Effector
+location: localhost
+services:
+- type: org.apache.brooklyn.test.framework.TestCase
+  brooklyn.children:
+  - type: org.apache.brooklyn.entity.webapp.tomcat.TomcatServer
+    id: tomcat
+    brooklyn.config:
+      war: "http://search.maven.org/remotecontent?filepath=io/brooklyn/example/brooklyn-example-hello-world-sql-webapp/0.6.0/brooklyn-example-hello-world-sql-webapp-0.6.0.war"
+  - type: org.apache.brooklyn.test.framework.TestHttpCall
+    name: / Status Code 200
+    url: $brooklyn:component("tomcat").attributeWhenReady("webapp.url")
+    assert:
+      status: 200
+  - type: org.apache.brooklyn.test.framework.TestHttpCall
+    name: /newcontext Status Code 404
+    url: $brooklyn:formatString("%s/newcontext/", component("tomcat").attributeWhenReady("webapp.url"))
+    assert:
+      status: 404
+  - type: org.apache.brooklyn.test.framework.TestEffector
+    name: Deploy WAR in /newcontext
+    target: $brooklyn:component("tomcat")
+    effector: deploy
+    params:
+      url: http://search.maven.org/remotecontent?filepath=io/brooklyn/example/brooklyn-example-hello-world-sql-webapp/0.6.0/brooklyn-example-hello-world-sql-webapp-0.6.0.war
+      targetName: newcontext
+  - type: org.apache.brooklyn.test.framework.TestHttpCall
+    name: /newcontext Status Code 200
+    url: $brooklyn:formatString("%s/newcontext/", component("tomcat").attributeWhenReady("webapp.url"))
+    # Give Tomcat time to make the newly deployed War accessible
+    timeout: 10s
+    assert:
+      status: 200
+...
+
+---
+name: HTTP Call Test with Eventual String and Regex Matches
+location: localhost
+services:
+- type: org.apache.brooklyn.test.framework.TestCase
+  brooklyn.children:
+  - type: org.apache.brooklyn.entity.webapp.tomcat.TomcatServer
+    id: tomcat
+    brooklyn.config:
+      war: "http://search.maven.org/remotecontent?filepath=io/brooklyn/example/brooklyn-example-hello-world-sql-webapp/0.6.0/brooklyn-example-hello-world-sql-webapp-0.6.0.war"
+  - type: org.apache.brooklyn.test.framework.TestEffector
+    name: Deploy WAR in /newcontext
+    target: $brooklyn:component("tomcat")
+    effector: deploy
+    params:
+      url: http://search.maven.org/remotecontent?filepath=io/brooklyn/example/brooklyn-example-hello-world-sql-webapp/0.6.0/brooklyn-example-hello-world-sql-webapp-0.6.0.war
+      targetName: newcontext
+  - type: org.apache.brooklyn.test.framework.TestHttpCall
+    name: Regex match
+    url: $brooklyn:formatString("%s/newcontext/", component("tomcat").attributeWhenReady("webapp.url"))
+    timeout: 10s
+    assert:
+      regex: "(?s).*illustrate(\\s)*how(\\s)*web(\\s)*applications.*"
+  - type: org.apache.brooklyn.test.framework.TestEffector
+    name: Deploy WAR in /newcontext2
+    target: $brooklyn:component("tomcat")
+    effector: deploy
+    params:
+      url: http://search.maven.org/remotecontent?filepath=io/brooklyn/example/brooklyn-example-hello-world-sql-webapp/0.6.0/brooklyn-example-hello-world-sql-webapp-0.6.0.war
+      targetName: newcontext2
+  - type: org.apache.brooklyn.test.framework.TestHttpCall
+    name: String match
+    url: $brooklyn:formatString("%s/newcontext2/", component("tomcat").attributeWhenReady("webapp.url"))
+    timeout: 10s
+    assert:
+      string: Sample Brooklyn Deployed
+    assert:
+      status: 404
+  - type: org.apache.brooklyn.test.framework.TestHttpCall
+    name: String match
+    url: $brooklyn:component("tomcat").attributeWhenReady("webapp.url")
+    assert:
+      string: Sample Brooklyn Deployed
+  - type: org.apache.brooklyn.test.framework.TestHttpCall
+    name: Regex match
+    url: $brooklyn:component("tomcat").attributeWhenReady("webapp.url")
+    # the regex assert uses java.lang.String under the hood so if the url is expected to returns
+    # a multi-line response you should use the embedded dotall flag expression `(?s)` in your regex.
+    # See: http://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html
+    assert:
+      regex: "(?s).*illustrate(\\s)*how(\\s)*web(\\s)*applications.*"
+...
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/b0405c89/usage/test-framework/src/test/resources/test-framework-examples/tomcat-test-examples.yml
----------------------------------------------------------------------
diff --git a/usage/test-framework/src/test/resources/test-framework-examples/tomcat-test-examples.yml b/usage/test-framework/src/test/resources/test-framework-examples/tomcat-test-examples.yml
new file mode 100644
index 0000000..37d7f4d
--- /dev/null
+++ b/usage/test-framework/src/test/resources/test-framework-examples/tomcat-test-examples.yml
@@ -0,0 +1,45 @@
+---
+name: Tomcat Multi-War Test
+location: localhost
+services:
+- type: org.apache.brooklyn.entity.webapp.tomcat.TomcatServer
+  id: tomcat
+  name: Tomcat
+  brooklyn.config:
+    wars.by.context:
+      hello1: "http://search.maven.org/remotecontent?filepath=io/brooklyn/example/brooklyn-example-hello-world-sql-webapp/0.6.0/brooklyn-example-hello-world-sql-webapp-0.6.0.war"
+      hello2: "http://search.maven.org/remotecontent?filepath=io/brooklyn/example/brooklyn-example-hello-world-sql-webapp/0.6.0/brooklyn-example-hello-world-sql-webapp-0.6.0.war"
+    start.timeout: 10m
+- type: org.apache.brooklyn.test.framework.TestSensor
+  target: $brooklyn:component("tomcat")
+  sensor: service.isUp
+  assert:
+    equals: true
+  timeout: 10m
+...
+
+---
+name: Tomcat Tests
+location: BYON 1
+services:
+  - type: org.apache.brooklyn.test.framework.TestCase
+    name: Effector - Deploy Test
+    brooklyn.children:
+    - type: org.apache.brooklyn.entity.webapp.tomcat.TomcatServer
+      id: tomcat
+      name: Tomcat
+      war: https://tomcat.apache.org/tomcat-6.0-doc/appdev/sample/sample.war
+    - type: org.apache.brooklyn.test.framework.TestEffector
+      name: Deploy Another WAR
+      target: $brooklyn:component("tomcat")
+      effector: deploy
+      params:
+        url: https://tomcat.apache.org/tomcat-6.0-doc/appdev/sample/sample.war
+        targetName: sample1
+#    - type: org.apache.brooklyn.test.framework.TestSensor
+#      target: $brooklyn:component("tomcat")
+#      sensor: webapp.deployedWars
+#      assert:
+#        regex: .*sample1.*
+#      timeout: 1m
+...
\ No newline at end of file