brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sjcorb...@apache.org
Subject [2/4] incubator-brooklyn git commit: Make default values for assertions config be immutable.
Date Wed, 02 Dec 2015 18:20:36 GMT
Make default values for assertions config be immutable.

This is in response to the comment on 1066, https://github.com/apache/incubator-brooklyn/pull/1066/#issuecomment-160699587.


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

Branch: refs/heads/master
Commit: 6c40f4d894b3ce1fb3d071a8b8a8877157b469ee
Parents: 3474022
Author: Geoff Macartney <geoff.macartney@cloudsoftcorp.com>
Authored: Wed Dec 2 10:03:37 2015 +0000
Committer: Geoff Macartney <geoff.macartney@cloudsoftcorp.com>
Committed: Wed Dec 2 10:03:37 2015 +0000

----------------------------------------------------------------------
 .../java/org/apache/brooklyn/test/framework/BaseTest.java   | 3 ++-
 .../brooklyn/test/framework/SimpleShellCommandTest.java     | 6 +++---
 .../brooklyn/test/framework/SimpleShellCommandTestImpl.java | 9 +++++++--
 .../org/apache/brooklyn/test/framework/TestHttpCall.java    | 3 ++-
 4 files changed, 14 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/6c40f4d8/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 d316268..a97b9db 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
@@ -18,6 +18,7 @@
  */
 package org.apache.brooklyn.test.framework;
 
+import com.google.common.collect.ImmutableList;
 import com.google.common.reflect.TypeToken;
 import org.apache.brooklyn.api.entity.Entity;
 import org.apache.brooklyn.api.mgmt.ExecutionContext;
@@ -50,7 +51,7 @@ public interface BaseTest extends Entity, Startable {
      * The assertions to be made.
      */
     ConfigKey<Object> ASSERTIONS = ConfigKeys.newConfigKey(Object.class, "assert",
"Assertions to be evaluated",
-        new ArrayList<Map<String, Object>>());
+        ImmutableList.<Map<String, Object>>of());
 
     /**
      * THe duration to wait for an assertion to succeed or fail before throwing an exception.

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/6c40f4d8/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/SimpleShellCommandTest.java
----------------------------------------------------------------------
diff --git a/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/SimpleShellCommandTest.java
b/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/SimpleShellCommandTest.java
index 4fb2def..f9ffda6 100644
--- a/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/SimpleShellCommandTest.java
+++ b/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/SimpleShellCommandTest.java
@@ -83,20 +83,20 @@ public interface SimpleShellCommandTest extends BaseTest {
      */
     @SetFromFlag("assertStatus")
     ConfigKey<Object> ASSERT_STATUS = ConfigKeys.newConfigKey(Object.class, "assert.status",
"Assertions on command exit code",
-        new ArrayList<Map<String, Object>>());
+        ImmutableList.<Map<String, Object>>of());
 
     /**
      * Assertions on the standard output of the command as a String.
      */
     @SetFromFlag("assertOut")
     ConfigKey<Object> ASSERT_OUT = ConfigKeys.newConfigKey(Object.class, "assert.out",
"Assertions on command standard output",
-        new ArrayList<Map<String, Object>>());
+        ImmutableList.<Map<String, Object>>of());
 
     /**
      * Assertions on the standard error of the command as a String.
      */
     @SetFromFlag("assertErr")
     ConfigKey<Object> ASSERT_ERR = ConfigKeys.newConfigKey(Object.class, "assert.err",
"Assertions on command standard error",
-        new ArrayList<Map<String, Object>>());
+        ImmutableList.<Map<String, Object>>of());
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/6c40f4d8/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/SimpleShellCommandTestImpl.java
----------------------------------------------------------------------
diff --git a/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/SimpleShellCommandTestImpl.java
b/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/SimpleShellCommandTestImpl.java
index e01c482..6f2ef12 100644
--- a/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/SimpleShellCommandTestImpl.java
+++ b/usage/test-framework/src/main/java/org/apache/brooklyn/test/framework/SimpleShellCommandTestImpl.java
@@ -32,6 +32,7 @@ import org.apache.brooklyn.core.location.Machines;
 import org.apache.brooklyn.location.ssh.SshMachineLocation;
 import org.apache.brooklyn.test.framework.TestFrameworkAssertions.AssertionSupport;
 import org.apache.brooklyn.util.collections.MutableList;
+import org.apache.brooklyn.util.collections.MutableMap;
 import org.apache.brooklyn.util.core.task.DynamicTasks;
 import org.apache.brooklyn.util.core.task.ssh.SshTasks;
 import org.apache.brooklyn.util.core.task.system.ProcessTaskWrapper;
@@ -232,15 +233,19 @@ public class SimpleShellCommandTestImpl extends AbstractTest implements
SimpleSh
     
 
     private List<Map<String, Object>> exitCodeAssertions() {
+
         List<Map<String, Object>> assertStatus = getAssertions(this, ASSERT_STATUS);
         List<Map<String, Object>> assertOut = getAssertions(this, ASSERT_OUT);
         List<Map<String, Object>> assertErr = getAssertions(this, ASSERT_ERR);
 
+        List<Map<String, Object>> result;
         if (assertStatus.isEmpty() && assertOut.isEmpty() && assertErr.isEmpty())
{
             Map<String, Object> shouldSucceed = DEFAULT_ASSERTION;
-            assertStatus.add(shouldSucceed);
+            result = MutableList.of(shouldSucceed);
+        } else {
+            result = assertStatus;
         }
-        return assertStatus;
+        return result;
     }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/6c40f4d8/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 c9faeb1..36fb16e 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
@@ -34,7 +34,8 @@ public interface TestHttpCall extends BaseTest {
     @SetFromFlag(nullable = false)
     ConfigKey<String> TARGET_URL = ConfigKeys.newStringConfigKey("url", "URL to test");
 
-    ConfigKey<HttpAssertionTarget> ASSERTION_TARGET = ConfigKeys.newConfigKey(HttpAssertionTarget.class,
"applyAssertionTo", "The HTTP field to apply the assertion to [body,status]", HttpAssertionTarget.body);
+    ConfigKey<HttpAssertionTarget> ASSERTION_TARGET = ConfigKeys.newConfigKey(HttpAssertionTarget.class,
"applyAssertionTo",
+        "The HTTP field to apply the assertion to [body,status]", HttpAssertionTarget.body);
 
     enum HttpAssertionTarget {
         body("body"), status("status");


Mime
View raw message