Call BrooklynInitialization.initAll() Previously, tests like JcloudsWinrmingLiveTest would fail unless another test had run previously in the suite. Given that this init is needed by Brooklyn, we should do it in the heart of Brooklyn (i.e. the ManagementContext) rather than just in AbstractEntity!
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/2a4a8a7e Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/2a4a8a7e Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/2a4a8a7e Branch: refs/heads/master Commit: 2a4a8a7e61e1df0a017667b63bf05f012a69b872 Parents: e0a9d53 Author: Aled Sage <aled.s...@gmail.com> Authored: Fri Dec 16 16:12:19 2016 +0000 Committer: Aled Sage <aled.s...@gmail.com> Committed: Mon Dec 19 11:11:35 2016 +0000 ---------------------------------------------------------------------- .../core/mgmt/internal/LocalManagementContext.java | 10 ++++++++++ 1 file changed, 10 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/2a4a8a7e/core/src/main/java/org/apache/brooklyn/core/mgmt/internal/LocalManagementContext.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/brooklyn/core/mgmt/internal/LocalManagementContext.java b/core/src/main/java/org/apache/brooklyn/core/mgmt/internal/LocalManagementContext.java index b1bf856..67cd15f 100644 --- a/core/src/main/java/org/apache/brooklyn/core/mgmt/internal/LocalManagementContext.java +++ b/core/src/main/java/org/apache/brooklyn/core/mgmt/internal/LocalManagementContext.java @@ -46,6 +46,7 @@ import org.apache.brooklyn.api.mgmt.TaskAdaptable; import org.apache.brooklyn.core.BrooklynFeatureEnablement; import org.apache.brooklyn.core.effector.Effectors; import org.apache.brooklyn.core.entity.drivers.downloads.BasicDownloadsManager; +import org.apache.brooklyn.core.internal.BrooklynInitialization; import org.apache.brooklyn.core.internal.BrooklynProperties; import org.apache.brooklyn.core.internal.BrooklynProperties.Factory.Builder; import org.apache.brooklyn.core.internal.storage.DataGridFactory; @@ -77,6 +78,15 @@ public class LocalManagementContext extends AbstractManagementContext { private static final Logger log = LoggerFactory.getLogger(LocalManagementContext.class); + // Any usage of Brooklyn must first create a management context. Therefore do our + // initialisation here. + // TODO We could delete our other calls to BrooklynInitialization.initAll(), to rely on + // just one (e.g. AbstractEntity should not need to do it; and that is insufficient if a test + // just deals with locations but not entities). + static { + BrooklynInitialization.initAll(); + } + private static final Set<LocalManagementContext> INSTANCES = Collections.synchronizedSet(Collections.newSetFromMap(new WeakHashMap<LocalManagementContext, Boolean>())); private final Builder builder;