You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by sv...@apache.org on 2016/10/21 09:20:44 UTC
[2/8] brooklyn-server git commit: LocalManagementContextForTests
supports properties map
LocalManagementContextForTests supports properties map
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/ff021884
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/ff021884
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/ff021884
Branch: refs/heads/master
Commit: ff021884ebd9d45bd330fe61731fc269544e2495
Parents: b1407d0
Author: Aled Sage <al...@gmail.com>
Authored: Tue Oct 18 19:13:17 2016 +0100
Committer: Aled Sage <al...@gmail.com>
Committed: Wed Oct 19 00:40:45 2016 +0100
----------------------------------------------------------------------
.../entity/LocalManagementContextForTests.java | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/ff021884/core/src/test/java/org/apache/brooklyn/core/test/entity/LocalManagementContextForTests.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/test/entity/LocalManagementContextForTests.java b/core/src/test/java/org/apache/brooklyn/core/test/entity/LocalManagementContextForTests.java
index 76e0698..d89ccaf 100644
--- a/core/src/test/java/org/apache/brooklyn/core/test/entity/LocalManagementContextForTests.java
+++ b/core/src/test/java/org/apache/brooklyn/core/test/entity/LocalManagementContextForTests.java
@@ -18,6 +18,8 @@
*/
package org.apache.brooklyn.core.test.entity;
+import java.util.Map;
+
import org.apache.brooklyn.config.ConfigKey;
import org.apache.brooklyn.core.internal.BrooklynProperties;
import org.apache.brooklyn.core.mgmt.internal.LocalManagementContext;
@@ -87,6 +89,7 @@ public class LocalManagementContextForTests extends LocalManagementContext {
boolean disableOsgi = false;
boolean emptyCatalog = false;
BrooklynProperties properties = null;
+ Map<String, ?> additionalProperties = null;
public Builder disablePersistenceBackups() { return disablePersistenceBackups(true); }
public Builder disableOsgi() { return disableOsgi(true); }
@@ -107,18 +110,31 @@ public class LocalManagementContextForTests extends LocalManagementContext {
disableOsgi();
emptyCatalog();
properties = null;
+ additionalProperties = null;
return this;
}
+ public Builder useAdditionalProperties(Map<String, ?> additionalProperties) {
+ if (hasCustomProperties() && additionalProperties != null)
+ throw new IllegalStateException("Cannot set multiple properties");
+ this.additionalProperties = additionalProperties;
+ return this;
+ }
+
public Builder useProperties(BrooklynProperties properties) {
- if (this.properties!=null && properties!=null)
+ if (hasCustomProperties() && properties != null)
throw new IllegalStateException("Cannot set multiple properties");
this.properties = properties;
return this;
}
+ protected boolean hasCustomProperties() {
+ return (properties != null) || (additionalProperties != null && additionalProperties.size() > 0);
+ }
+
public BrooklynProperties buildProperties() {
BrooklynProperties result = emptyIfNull(properties);
+ if (additionalProperties != null) result.putAll(additionalProperties);
if (disablePersistenceBackups) LocalManagementContextForTests.disablePersistenceBackups(result);
if (disableOsgi) LocalManagementContextForTests.disableOsgi(result);
if (emptyCatalog) LocalManagementContextForTests.setEmptyCatalogAsDefault(result);