brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hadr...@apache.org
Subject [4/5] incubator-brooklyn git commit: Remove deprecated uses of Entities.manage
Date Sat, 17 Oct 2015 16:17:37 GMT
Remove deprecated uses of Entities.manage


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

Branch: refs/heads/master
Commit: f1d8cba1e570441ed6884d1acf757921efbaed3b
Parents: 5f2a296
Author: Aled Sage <aled.sage@gmail.com>
Authored: Thu Oct 15 16:35:25 2015 +0200
Committer: Aled Sage <aled.sage@gmail.com>
Committed: Thu Oct 15 21:19:35 2015 +0100

----------------------------------------------------------------------
 .../entity/AbstractApplicationLegacyTest.java   |  16 +-
 .../brooklyn/core/entity/AttributeMapTest.java  |  14 +-
 .../core/entity/EntityAutomanagedTest.java      |   4 +-
 .../core/entity/EntityPreManagementTest.java    | 146 -------------------
 .../core/entity/hello/LocalEntitiesTest.java    |  15 +-
 .../internal/EntityConfigMapUsageTest.java      |   6 +-
 .../ApplicationBuilderOverridingTest.java       |  15 +-
 .../core/feed/ConfigToAttributesTest.java       |   1 -
 .../brooklyn/core/mgmt/ha/HotStandbyTest.java   |   4 -
 .../internal/LocalSubscriptionManagerTest.java  |   6 -
 .../mgmt/rebind/ActivePartialRebindTest.java    |   3 -
 .../core/mgmt/rebind/CheckpointEntityTest.java  |   1 -
 .../mgmt/rebind/RebindDynamicGroupTest.java     |   1 -
 .../core/test/entity/TestApplicationImpl.java   |   5 +-
 .../stock/CustomAggregatingEnricherTest.java    |  11 +-
 .../brooklyn/enricher/stock/EnrichersTest.java  |   3 -
 .../entity/group/DynamicFabricTest.java         |   4 +-
 .../brooklyn/entity/group/DynamicGroupTest.java |  21 ++-
 .../entity/group/DynamicMultiGroupTest.java     |   5 -
 .../group/MembershipTrackingPolicyTest.java     |   1 -
 .../entity/stock/BasicStartableTest.java        |   5 -
 .../feed/ssh/SshFeedIntegrationTest.java        |  11 +-
 ...lusterDatabaseExampleAppIntegrationTest.java |   1 -
 .../BalanceableWorkerPoolTest.java              |   1 -
 .../BrooklynNodeIntegrationTest.java            |   1 -
 .../entity/brooklynnode/BrooklynNodeTest.java   |  20 +--
 .../entity/java/VanillaJavaAppRebindTest.java   |   4 +-
 .../software/base/SameServerEntityTest.java     |   2 -
 ...ftwareProcessAndChildrenIntegrationTest.java |   1 -
 .../location/WinRmMachineLocationLiveTest.java  |   3 +
 .../monitoring/monit/MonitIntegrationTest.java  |  13 +-
 .../network/bind/BindDnsServerLiveTest.java     |   2 -
 .../entity/proxy/AbstractControllerTest.java    |   2 -
 .../nginx/NginxClusterIntegrationTest.java      |   6 +-
 .../proxy/nginx/NginxRebindIntegrationTest.java |   7 +-
 .../nginx/NginxUrlMappingIntegrationTest.java   |  66 +++------
 .../org/apache/brooklyn/qa/load/LoadTest.java   |   5 +-
 .../brooklyn/rest/domain/ApplicationTest.java   |  16 +-
 .../util/BrooklynRestResourceUtilsTest.java     |  37 ++---
 39 files changed, 133 insertions(+), 352 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f1d8cba1/core/src/test/java/org/apache/brooklyn/core/entity/AbstractApplicationLegacyTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/entity/AbstractApplicationLegacyTest.java b/core/src/test/java/org/apache/brooklyn/core/entity/AbstractApplicationLegacyTest.java
index 3f4c38b..647e102 100644
--- a/core/src/test/java/org/apache/brooklyn/core/entity/AbstractApplicationLegacyTest.java
+++ b/core/src/test/java/org/apache/brooklyn/core/entity/AbstractApplicationLegacyTest.java
@@ -26,13 +26,13 @@ import java.util.List;
 
 import org.apache.brooklyn.api.entity.EntitySpec;
 import org.apache.brooklyn.api.location.LocationSpec;
-import org.apache.brooklyn.core.entity.AbstractApplication;
-import org.apache.brooklyn.core.entity.Entities;
 import org.apache.brooklyn.core.entity.factory.ApplicationBuilder;
 import org.apache.brooklyn.core.location.SimulatedLocation;
 import org.apache.brooklyn.core.test.BrooklynAppUnitTestSupport;
 import org.apache.brooklyn.core.test.entity.TestApplication;
+import org.apache.brooklyn.core.test.entity.TestApplicationImpl;
 import org.apache.brooklyn.core.test.entity.TestEntity;
+import org.apache.brooklyn.core.test.entity.TestEntityImpl;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
@@ -61,8 +61,8 @@ public class AbstractApplicationLegacyTest extends BrooklynAppUnitTestSupport {
     @Test
     public void testStartAndStopUnmanagedAppAutomanagesTheAppAndChildren() throws Exception {
         // deliberately unmanaged
-        TestApplication app2 = mgmt.getEntityManager().createEntity(EntitySpec.create(TestApplication.class));
-        TestEntity child = app2.addChild(EntitySpec.create(TestEntity.class));
+        TestApplication app2 = new TestApplicationImpl();
+        TestEntity child = new TestEntityImpl(app2);
         assertFalse(Entities.isManaged(app2));
         assertFalse(Entities.isManaged(child));
         
@@ -96,7 +96,9 @@ public class AbstractApplicationLegacyTest extends BrooklynAppUnitTestSupport {
     
     @Test
     public void testStartOnManagedAppDoesNotStartPremanagedChildren() {
-        TestEntity child = app.addChild(EntitySpec.create(TestEntity.class));
+        // deliberately unmanaged
+        TestEntity child = new TestEntityImpl(app);
+        assertFalse(Entities.isManaged(child));
         
         app.start(locs);
         assertEquals(child.getCallHistory(), ImmutableList.of());
@@ -128,7 +130,9 @@ public class AbstractApplicationLegacyTest extends BrooklynAppUnitTestSupport {
     public void testStopOnManagedAppDoesNotStopPremanagedChildren() {
         app.start(locs);
         
-        TestEntity child = app.addChild(EntitySpec.create(TestEntity.class));
+        // deliberately unmanaged
+        TestEntity child = new TestEntityImpl(app);
+        assertFalse(Entities.isManaged(child));
         
         app.stop();
         assertEquals(child.getCallHistory(), ImmutableList.of());

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f1d8cba1/core/src/test/java/org/apache/brooklyn/core/entity/AttributeMapTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/entity/AttributeMapTest.java b/core/src/test/java/org/apache/brooklyn/core/entity/AttributeMapTest.java
index 95d9bad..c1ae306 100644
--- a/core/src/test/java/org/apache/brooklyn/core/entity/AttributeMapTest.java
+++ b/core/src/test/java/org/apache/brooklyn/core/entity/AttributeMapTest.java
@@ -30,11 +30,12 @@ import java.util.concurrent.Executors;
 import java.util.concurrent.Future;
 
 import org.apache.brooklyn.api.entity.Application;
+import org.apache.brooklyn.api.entity.EntitySpec;
 import org.apache.brooklyn.api.sensor.AttributeSensor;
-import org.apache.brooklyn.core.entity.Entities;
 import org.apache.brooklyn.core.sensor.AttributeMap;
 import org.apache.brooklyn.core.sensor.Sensors;
 import org.apache.brooklyn.core.test.entity.TestApplication;
+import org.apache.brooklyn.core.test.entity.TestEntity;
 import org.apache.brooklyn.core.test.entity.TestEntityImpl;
 import org.apache.brooklyn.test.Asserts;
 import org.apache.brooklyn.util.collections.MutableMap;
@@ -53,16 +54,17 @@ public class AttributeMapTest {
     final int NUM_TASKS = Math.min(500 * Runtime.getRuntime().availableProcessors(), 1000);
 
     Application app;
-    TestEntityImpl entity;
+    TestEntity entity;
+    TestEntityImpl entityImpl;
     AttributeMap map;
     ExecutorService executor;
     
     @BeforeMethod(alwaysRun=true)
     public void setUp() {
         app = TestApplication.Factory.newManagedInstanceForTests();
-        entity = new TestEntityImpl(app);
-        map = new AttributeMap(entity, Collections.synchronizedMap(MutableMap.<Collection<String>,Object>of()));
-        Entities.manage(entity);
+        TestEntity entity = app.addChild(EntitySpec.create(TestEntity.class));
+        entityImpl = (TestEntityImpl) Entities.deproxy(entity);
+        map = new AttributeMap(entityImpl, Collections.synchronizedMap(MutableMap.<Collection<String>,Object>of()));
         executor = Executors.newCachedThreadPool();
     }
     
@@ -189,7 +191,7 @@ public class AttributeMapTest {
         AttributeSensor<Integer> childSensor = Sensors.newIntegerSensor("a.b", "");
         
         final RecordingSensorEventListener<Object> listener = new RecordingSensorEventListener<>();
-        entity.subscriptions().subscribe(entity, sensor, listener);
+        entityImpl.subscriptions().subscribe(entityImpl, sensor, listener);
         
         map.modify(childSensor, Functions.constant(Maybe.<Integer>absent()));
         

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f1d8cba1/core/src/test/java/org/apache/brooklyn/core/entity/EntityAutomanagedTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/entity/EntityAutomanagedTest.java b/core/src/test/java/org/apache/brooklyn/core/entity/EntityAutomanagedTest.java
index a940a11..741b936 100644
--- a/core/src/test/java/org/apache/brooklyn/core/entity/EntityAutomanagedTest.java
+++ b/core/src/test/java/org/apache/brooklyn/core/entity/EntityAutomanagedTest.java
@@ -212,8 +212,8 @@ public class EntityAutomanagedTest extends BrooklynAppUnitTestSupport {
         try {
             Entities.manage(child);
             fail("Managed deleted entity "+child+" in "+mgmt);
-        } catch (IllegalStateException e) {
-            if (!(e.toString().contains("No concrete entity known"))) throw e;
+        } catch (IllegalArgumentException e) {
+            if (!(e.toString().contains("Can't manage"))) throw e;
         }
     }
     

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f1d8cba1/core/src/test/java/org/apache/brooklyn/core/entity/EntityPreManagementTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/entity/EntityPreManagementTest.java b/core/src/test/java/org/apache/brooklyn/core/entity/EntityPreManagementTest.java
deleted file mode 100644
index 043de6d..0000000
--- a/core/src/test/java/org/apache/brooklyn/core/entity/EntityPreManagementTest.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.brooklyn.core.entity;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.brooklyn.api.entity.EntityLocal;
-import org.apache.brooklyn.api.entity.EntitySpec;
-import org.apache.brooklyn.api.mgmt.EntityManager;
-import org.apache.brooklyn.api.mgmt.ManagementContext;
-import org.apache.brooklyn.api.sensor.SensorEvent;
-import org.apache.brooklyn.api.sensor.SensorEventListener;
-import org.apache.brooklyn.core.entity.Attributes;
-import org.apache.brooklyn.core.entity.Entities;
-import org.apache.brooklyn.core.entity.factory.ApplicationBuilder;
-import org.apache.brooklyn.core.policy.AbstractPolicy;
-import org.apache.brooklyn.core.test.entity.LocalManagementContextForTests;
-import org.apache.brooklyn.core.test.entity.TestApplication;
-import org.apache.brooklyn.core.test.entity.TestEntity;
-import org.apache.brooklyn.test.Asserts;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.Assert;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-
-@SuppressWarnings({"rawtypes","unchecked"})
-public class EntityPreManagementTest {
-
-    @SuppressWarnings("unused")
-    private static final Logger log = LoggerFactory.getLogger(EntityPreManagementTest.class);
-
-    private ManagementContext managementContext;
-    private EntityManager entityManager;
-    private TestApplication app;
-    
-    @BeforeMethod(alwaysRun=true)
-    public void setUp() throws Exception {
-        managementContext = new LocalManagementContextForTests();
-        entityManager = managementContext.getEntityManager();
-    }
-    
-    @AfterMethod(alwaysRun=true)
-    public void tearDown() throws Exception {
-        if (managementContext != null) Entities.destroyAll(managementContext);
-    }
-    
-    @Test
-    public void testSetSensorBeforeManaged() {
-        TestEntity e = entityManager.createEntity(EntitySpec.create(TestEntity.class));
-
-        e.sensors().set(Attributes.HOSTNAME, "martian.martian");
-        Assert.assertEquals(e.getAttribute(Attributes.HOSTNAME), "martian.martian");
-        
-        Assert.assertFalse(e.getManagementSupport().isManagementContextReal());
-    }
-    
-    @Test
-    public void testAddPolicyToEntityBeforeManaged() {
-        TestEntity e = entityManager.createEntity(EntitySpec.create(TestEntity.class));
-        final List events = new ArrayList();
-        
-        e.policies().add(new AbstractPolicy() {
-            @Override
-            public void setEntity(EntityLocal entity) {
-                super.setEntity(entity);
-                subscriptions().subscribe(entity, Attributes.HOSTNAME, new SensorEventListener() {
-                    @Override
-                    public void onEvent(SensorEvent event) {
-                        events.add(event);
-                    }
-                });
-            }
-        });
-        
-        e.sensors().set(Attributes.HOSTNAME, "martian.martian");
-        Assert.assertEquals(e.getAttribute(Attributes.HOSTNAME), "martian.martian");
-        
-        if (!events.isEmpty()) Assert.fail("Shouldn't have events yet: "+events);
-        Assert.assertFalse(e.getManagementSupport().isManagementContextReal());
-        
-        TestApplication app = ApplicationBuilder.newManagedApp(TestApplication.class, managementContext);
-        e.setParent(app);
-        Entities.manage(e);
-        
-        Asserts.succeedsEventually(new Runnable() {
-            @Override
-            public void run() {
-                if (events.isEmpty()) Assert.fail("no events received");
-            }});
-        Assert.assertEquals(events.size(), 1, "Expected 1 event; got: "+events);
-    }
-
-    @Test
-    public void testAddPolicyToApplicationBeforeManaged() {
-        app = entityManager.createEntity(EntitySpec.create(TestApplication.class));
-        final List events = new ArrayList();
-        
-        app.policies().add(new AbstractPolicy() {
-            @Override
-            public void setEntity(EntityLocal entity) {
-                super.setEntity(entity);
-                subscriptions().subscribe(entity, Attributes.HOSTNAME, new SensorEventListener() {
-                    @Override
-                    public void onEvent(SensorEvent event) {
-                        events.add(event);
-                    }
-                });
-            }
-        });
-        
-        app.sensors().set(Attributes.HOSTNAME, "martian.martian");
-        Assert.assertEquals(app.getAttribute(Attributes.HOSTNAME), "martian.martian");
-        
-        if (!events.isEmpty()) Assert.fail("Shouldn't have events yet: "+events);
-        
-        Entities.startManagement(app, managementContext);
-        
-        Asserts.succeedsEventually(new Runnable() {
-            @Override
-            public void run() {
-                if (events.isEmpty()) Assert.fail("no events received");
-            }});
-        Assert.assertEquals(events.size(), 1, "Expected 1 event; got: "+events);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f1d8cba1/core/src/test/java/org/apache/brooklyn/core/entity/hello/LocalEntitiesTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/entity/hello/LocalEntitiesTest.java b/core/src/test/java/org/apache/brooklyn/core/entity/hello/LocalEntitiesTest.java
index 9ce3b73..320d7a3 100644
--- a/core/src/test/java/org/apache/brooklyn/core/entity/hello/LocalEntitiesTest.java
+++ b/core/src/test/java/org/apache/brooklyn/core/entity/hello/LocalEntitiesTest.java
@@ -177,8 +177,7 @@ public class LocalEntitiesTest extends BrooklynAppUnitTestSupport {
         app.config().set(HelloEntity.MY_NAME, "Bob");
         
         HelloEntity dad = app.createAndManageChild(EntitySpec.create(HelloEntity.class));
-        HelloEntity son = entityManager.createEntity(EntitySpec.create(HelloEntity.class).parent(dad));
-        Entities.manage(son);
+        HelloEntity son = dad.addChild(EntitySpec.create(HelloEntity.class));
         
         //config is inherited
         assertEquals("Bob", app.getConfig(HelloEntity.MY_NAME));
@@ -195,13 +194,11 @@ public class LocalEntitiesTest extends BrooklynAppUnitTestSupport {
         app.config().set(HelloEntity.MY_NAME, "Bob");
         
         final HelloEntity dad = app.createAndManageChild(EntitySpec.create(HelloEntity.class));
-        final HelloEntity son = entityManager.createEntity(EntitySpec.create(HelloEntity.class)
-                .parent(dad)
+        final HelloEntity son = dad.addChild(EntitySpec.create(HelloEntity.class)
                 .configure(HelloEntity.MY_NAME, attributeWhenReady(dad, HelloEntity.FAVOURITE_NAME
                         /* third param is closure; defaults to groovy truth (see google), but could be e.g.
                            , { it!=null && it.length()>0 && it!="Jebediah" }
                          */ )));
-        Entities.manage(son);
         
         app.start(ImmutableList.of(loc));
          
@@ -247,13 +244,11 @@ public class LocalEntitiesTest extends BrooklynAppUnitTestSupport {
         app.config().set(HelloEntity.MY_NAME, "Bob");
         
         HelloEntity dad = app.createAndManageChild(EntitySpec.create(HelloEntity.class));
-        HelloEntity son = entityManager.createEntity(EntitySpec.create(HelloEntity.class)
-                .parent(dad)
+        HelloEntity son = dad.addChild(EntitySpec.create(HelloEntity.class)
                 .configure(HelloEntity.MY_NAME, transform(attributeWhenReady(dad, HelloEntity.FAVOURITE_NAME), new Function<String,String>() {
                     public String apply(String input) {
                         return input+input.charAt(input.length()-1)+"y";
                     }})));
-        Entities.manage(son);
         
         app.start(ImmutableList.of(loc));
         ((EntityLocal)dad).sensors().set(HelloEntity.FAVOURITE_NAME, "Dan");
@@ -266,13 +261,11 @@ public class LocalEntitiesTest extends BrooklynAppUnitTestSupport {
         
         HelloEntity dad = app.createAndManageChild(EntitySpec.create(HelloEntity.class));
         // the unnecessary (HelloEntity) cast is required as a work-around to an IntelliJ issue that prevents Brooklyn from launching from the IDE
-        HelloEntity son = (HelloEntity)entityManager.createEntity(EntitySpec.create(HelloEntity.class)
-                .parent(dad)
+        HelloEntity son = (HelloEntity) dad.addChild(EntitySpec.create(HelloEntity.class)
                 .configure(HelloEntity.MY_NAME, transform(attributeWhenReady(dad, HelloEntity.FAVOURITE_NAME, (Closure)null), new Function<String,String>() {
                     public String apply(String input) {
                         return input+input.charAt(input.length()-1)+"y";
                     }})));
-        Entities.manage(son);
         
         app.start(ImmutableList.of(loc));
         ((EntityLocal)dad).sensors().set(HelloEntity.FAVOURITE_NAME, "Dan");

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f1d8cba1/core/src/test/java/org/apache/brooklyn/core/entity/internal/EntityConfigMapUsageTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/entity/internal/EntityConfigMapUsageTest.java b/core/src/test/java/org/apache/brooklyn/core/entity/internal/EntityConfigMapUsageTest.java
index 5dd9a5a..e5e39a4 100644
--- a/core/src/test/java/org/apache/brooklyn/core/entity/internal/EntityConfigMapUsageTest.java
+++ b/core/src/test/java/org/apache/brooklyn/core/entity/internal/EntityConfigMapUsageTest.java
@@ -126,7 +126,6 @@ public class EntityConfigMapUsageTest extends BrooklynAppUnitTestSupport {
         TestEntity entity = app.addChild(EntitySpec.create(TestEntity.class));
         ((EntityLocal)entity).config().set(strKey, "aval");
         ((EntityLocal)entity).config().set(intKey, 2);
-        Entities.manage(entity);
         
         assertEquals(entity.getConfig(strKey), "aval");
         assertEquals(entity.getConfig(intKey), (Integer)2);
@@ -137,7 +136,6 @@ public class EntityConfigMapUsageTest extends BrooklynAppUnitTestSupport {
         TestEntity parent = app.addChild(EntitySpec.create(TestEntity.class)
                 .configure(strKey, "aval"));
         ((EntityLocal)parent).config().set(intKey, 2);
-        Entities.manage(parent);
         TestEntity entity = parent.createAndManageChild(EntitySpec.create(TestEntity.class));
         
         assertEquals(entity.getConfig(strKey), "aval");
@@ -169,17 +167,15 @@ public class EntityConfigMapUsageTest extends BrooklynAppUnitTestSupport {
         TestEntity entity = app.createAndManageChild(EntitySpec.create(TestEntity.class)
                 .configure(strKey, "aval"));
         ((EntityLocal)entity).config().set(strKey, "diffval");
-        Entities.manage(entity);
         
         assertEquals(entity.getConfig(strKey), "diffval");
     }
 
     @Test
-    public void testConfigSetOnParentInheritedByExistingChildrenBeforeStarted() throws Exception {
+    public void testConfigSetOnParentInheritedByExistingChildren() throws Exception {
         TestEntity parent = app.addChild(EntitySpec.create(TestEntity.class));
         TestEntity entity = parent.createChild(EntitySpec.create(TestEntity.class));
         ((EntityLocal)parent).config().set(strKey,"aval");
-        Entities.manage(entity);
         
         assertEquals(entity.getConfig(strKey), "aval");
     }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f1d8cba1/core/src/test/java/org/apache/brooklyn/core/entity/proxying/ApplicationBuilderOverridingTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/entity/proxying/ApplicationBuilderOverridingTest.java b/core/src/test/java/org/apache/brooklyn/core/entity/proxying/ApplicationBuilderOverridingTest.java
index 5a8003d..824439b 100644
--- a/core/src/test/java/org/apache/brooklyn/core/entity/proxying/ApplicationBuilderOverridingTest.java
+++ b/core/src/test/java/org/apache/brooklyn/core/entity/proxying/ApplicationBuilderOverridingTest.java
@@ -119,11 +119,24 @@ public class ApplicationBuilderOverridingTest {
         assertEquals(expectedChild.get().getParent(), app);
     }
 
-    @Test
+    @Test(enabled=false)
     public void testAppHierarchyIsManaged() {
         app = new ApplicationBuilder() {
             @Override public void doBuild() {
                 Entity entity = addChild(EntitySpec.create(TestEntity.class));
+            }
+        }.manage();
+        
+        assertIsManaged(app);
+        assertIsManaged(Iterables.get(app.getChildren(), 0));
+    }
+
+    // TODO Can't assert the child added in doBuild is unmanaged
+    @Test(enabled=false)
+    public void testEntityAddedInDoBuildIsUnmanagedUntilAppIsManaged() {
+        app = new ApplicationBuilder() {
+            @Override public void doBuild() {
+                Entity entity = addChild(EntitySpec.create(TestEntity.class));
                 assertFalse(getManagementContext().getEntityManager().isManaged(entity));
             }
         }.manage();

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f1d8cba1/core/src/test/java/org/apache/brooklyn/core/feed/ConfigToAttributesTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/feed/ConfigToAttributesTest.java b/core/src/test/java/org/apache/brooklyn/core/feed/ConfigToAttributesTest.java
index 1cc48df..f392bad 100644
--- a/core/src/test/java/org/apache/brooklyn/core/feed/ConfigToAttributesTest.java
+++ b/core/src/test/java/org/apache/brooklyn/core/feed/ConfigToAttributesTest.java
@@ -51,7 +51,6 @@ public class ConfigToAttributesTest {
     public void testApplyTemplatedConfigWithEntity() {
         TestApplication app = managementContext.getEntityManager().createEntity(EntitySpec.create(TestApplication.class)
                 .configure(TestEntity.CONF_NAME, "myval"));
-        Entities.startManagement(app, managementContext);
         
         BasicAttributeSensorAndConfigKey<String> key = new TemplatedStringAttributeSensorAndConfigKey("mykey", "my descr", "${config['test.confName']!'notfound'}");
         String val = ConfigToAttributes.apply(app, key);

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f1d8cba1/core/src/test/java/org/apache/brooklyn/core/mgmt/ha/HotStandbyTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/mgmt/ha/HotStandbyTest.java b/core/src/test/java/org/apache/brooklyn/core/mgmt/ha/HotStandbyTest.java
index 2eaebcf..cb4baad 100644
--- a/core/src/test/java/org/apache/brooklyn/core/mgmt/ha/HotStandbyTest.java
+++ b/core/src/test/java/org/apache/brooklyn/core/mgmt/ha/HotStandbyTest.java
@@ -298,7 +298,6 @@ public class HotStandbyTest {
         // test additions - new child, new app
         
         TestEntity child = app.addChild(EntitySpec.create(TestEntity.class).configure(TestEntity.CONF_NAME, "first-child"));
-        Entities.manage(child);
         TestApplication app2 = TestApplication.Factory.newManagedInstanceForTests(n1.mgmt);
         app2.config().set(TestEntity.CONF_NAME, "second-app");
         
@@ -477,7 +476,6 @@ public class HotStandbyTest {
         assertUsedMemoryMaxDelta("Standby created", DELTA);
         
         TestEntity lastChild = app.addChild(EntitySpec.create(TestEntity.class).configure(TestEntity.CONF_NAME, "first-child"));
-        Entities.manage(lastChild);
         forcePersistNow(n1);
         forceRebindNow(n2);
         assertUsedMemoryMaxDelta("Child created and rebinded once", DELTA);
@@ -488,7 +486,6 @@ public class HotStandbyTest {
                 usedMemory.removeLast();
             }
             TestEntity newChild = app.addChild(EntitySpec.create(TestEntity.class).configure(TestEntity.CONF_NAME, "first-child"));
-            Entities.manage(newChild);
             Entities.unmanage(lastChild);
             lastChild = newChild;
             
@@ -523,7 +520,6 @@ public class HotStandbyTest {
         HaMgmtNode n2 = createHotStandby(Duration.PRACTICALLY_FOREVER);
 
         TestEntity child = app.addChild(EntitySpec.create(TestEntity.class).configure(TestEntity.CONF_NAME, "first-child"));
-        Entities.manage(child);
         TestApplication app2 = TestApplication.Factory.newManagedInstanceForTests(n1.mgmt);
         app2.config().set(TestEntity.CONF_NAME, "second-app");
 

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f1d8cba1/core/src/test/java/org/apache/brooklyn/core/mgmt/internal/LocalSubscriptionManagerTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/mgmt/internal/LocalSubscriptionManagerTest.java b/core/src/test/java/org/apache/brooklyn/core/mgmt/internal/LocalSubscriptionManagerTest.java
index 10f07ab..a077f31 100644
--- a/core/src/test/java/org/apache/brooklyn/core/mgmt/internal/LocalSubscriptionManagerTest.java
+++ b/core/src/test/java/org/apache/brooklyn/core/mgmt/internal/LocalSubscriptionManagerTest.java
@@ -56,11 +56,6 @@ public class LocalSubscriptionManagerTest extends BrooklynAppUnitTestSupport {
         entity = app.createAndManageChild(EntitySpec.create(TestEntity.class));
     }
 
-    private void manage(Entity ...entities) {
-        for (Entity e: entities)
-            Entities.manage(e);
-    }
-
     @Test
     public void testSubscribeToEntityAttributeChange() throws Exception {
         final CountDownLatch latch = new CountDownLatch(1);
@@ -117,7 +112,6 @@ public class LocalSubscriptionManagerTest extends BrooklynAppUnitTestSupport {
     public void testSubscribeToMemberAttributeChange() throws Exception {
         BasicGroup group = app.createAndManageChild(EntitySpec.create(BasicGroup.class));
         TestEntity member = app.createAndManageChild(EntitySpec.create(TestEntity.class));
-        manage(group, member);
         
         group.addMember(member);
 

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f1d8cba1/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/ActivePartialRebindTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/ActivePartialRebindTest.java b/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/ActivePartialRebindTest.java
index bf74df9..771171d 100644
--- a/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/ActivePartialRebindTest.java
+++ b/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/ActivePartialRebindTest.java
@@ -44,7 +44,6 @@ public class ActivePartialRebindTest extends RebindTestFixtureWithApp {
     @Test
     public void testRebindChildSimple() throws Exception {
         TestEntity c1 = origApp.addChild(EntitySpec.create(TestEntity.class));
-        Entities.manage(c1);
         AbstractEntity c1r = Entities.deproxy(c1);
         
         doPartialRebindOfIds(c1.getId());
@@ -59,7 +58,6 @@ public class ActivePartialRebindTest extends RebindTestFixtureWithApp {
     @Test
     public void testRebindParentSimple() throws Exception {
         TestEntity c1 = origApp.addChild(EntitySpec.create(TestEntity.class));
-        Entities.manage(c1);
         
         AbstractEntity origAppr = Entities.deproxy(origApp);
         
@@ -82,7 +80,6 @@ public class ActivePartialRebindTest extends RebindTestFixtureWithApp {
     @Test(groups="Integration")
     public void testRebindCheckingMemoryLeak() throws Exception {
         TestEntity c1 = origApp.addChild(EntitySpec.create(TestEntity.class));
-        Entities.manage(c1);
         c1.config().set(TestEntity.CONF_NAME, Strings.makeRandomId(1000000));
         
         gcAndLog("before");

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f1d8cba1/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/CheckpointEntityTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/CheckpointEntityTest.java b/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/CheckpointEntityTest.java
index 2c3b281..d2aa5d6 100644
--- a/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/CheckpointEntityTest.java
+++ b/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/CheckpointEntityTest.java
@@ -68,7 +68,6 @@ public class CheckpointEntityTest extends RebindTestFixtureWithApp {
     @Test
     public void testAutoCheckpointsOnManageDynamicEntity() throws Exception {
         final MyEntity origE2 = origApp.createAndManageChild(EntitySpec.create(MyEntity.class).configure("myconfig", "myval2"));
-        Entities.manage(origE2);
         
         newApp = rebind();
         MyEntity newE2 = (MyEntity) Iterables.find(newApp.getChildren(), new Predicate<Entity>() {

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f1d8cba1/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindDynamicGroupTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindDynamicGroupTest.java b/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindDynamicGroupTest.java
index 7232e52..2f9bc8e 100644
--- a/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindDynamicGroupTest.java
+++ b/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindDynamicGroupTest.java
@@ -52,7 +52,6 @@ public class RebindDynamicGroupTest extends RebindTestFixtureWithApp {
 
         // And should detect new members that match the filter
         final MyEntity newE2 = newApp.createAndManageChild(EntitySpec.create(MyEntity.class));
-        Entities.manage(newE2);
         
         Asserts.succeedsEventually(new Runnable() {
             @Override public void run() {

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f1d8cba1/core/src/test/java/org/apache/brooklyn/core/test/entity/TestApplicationImpl.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/test/entity/TestApplicationImpl.java b/core/src/test/java/org/apache/brooklyn/core/test/entity/TestApplicationImpl.java
index 7ce08d3..ae3cc5f 100644
--- a/core/src/test/java/org/apache/brooklyn/core/test/entity/TestApplicationImpl.java
+++ b/core/src/test/java/org/apache/brooklyn/core/test/entity/TestApplicationImpl.java
@@ -53,12 +53,11 @@ public class TestApplicationImpl extends AbstractApplication implements TestAppl
         super(flags);
     }
 
+    // TODO Deprecate this; no longer needed - can always use {@link #addChild(EntitySpec)}
     @Override
     public <T extends Entity> T createAndManageChild(EntitySpec<T> spec) {
         if (!getManagementSupport().isDeployed()) throw new IllegalStateException("Entity "+this+" not managed");
-        T child = addChild(spec);
-        getEntityManager().manage(child);
-        return child;
+        return addChild(spec);
     }
     
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f1d8cba1/core/src/test/java/org/apache/brooklyn/enricher/stock/CustomAggregatingEnricherTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/enricher/stock/CustomAggregatingEnricherTest.java b/core/src/test/java/org/apache/brooklyn/enricher/stock/CustomAggregatingEnricherTest.java
index 4aed5c6..9216381 100644
--- a/core/src/test/java/org/apache/brooklyn/enricher/stock/CustomAggregatingEnricherTest.java
+++ b/core/src/test/java/org/apache/brooklyn/enricher/stock/CustomAggregatingEnricherTest.java
@@ -47,7 +47,6 @@ public class CustomAggregatingEnricherTest extends BrooklynAppUnitTestSupport {
 
     public static final Logger log = LoggerFactory.getLogger(CustomAggregatingEnricherTest.class);
             
-    private static final long TIMEOUT_MS = 10*1000;
     private static final long SHORT_WAIT_MS = 50;
     
     TestEntity entity;
@@ -358,12 +357,11 @@ public class CustomAggregatingEnricherTest extends BrooklynAppUnitTestSupport {
     @Test
     public void testAggregatesExistingMembersOfGroup() {
         BasicGroup group = app.addChild(EntitySpec.create(BasicGroup.class));
-        TestEntity p1 = app.getManagementContext().getEntityManager().createEntity(EntitySpec.create(TestEntity.class).parent(group)); 
-        TestEntity p2 = app.getManagementContext().getEntityManager().createEntity(EntitySpec.create(TestEntity.class).parent(group)); 
+        TestEntity p1 = group.addChild(EntitySpec.create(TestEntity.class)); 
+        TestEntity p2 = group.addChild(EntitySpec.create(TestEntity.class)); 
         group.addMember(p1);
         group.addMember(p2);
         p1.sensors().set(intSensor, 1);
-        Entities.manage(group);
         
         group.enrichers().add(Enrichers.builder()
                 .aggregating(intSensor)
@@ -385,12 +383,11 @@ public class CustomAggregatingEnricherTest extends BrooklynAppUnitTestSupport {
     @Test
     public void testAggregatesMembersOfProducer() {
         BasicGroup group = app.addChild(EntitySpec.create(BasicGroup.class));
-        TestEntity p1 = app.getManagementContext().getEntityManager().createEntity(EntitySpec.create(TestEntity.class).parent(group)); 
-        TestEntity p2 = app.getManagementContext().getEntityManager().createEntity(EntitySpec.create(TestEntity.class).parent(group)); 
+        TestEntity p1 = group.addChild(EntitySpec.create(TestEntity.class)); 
+        TestEntity p2 = group.addChild(EntitySpec.create(TestEntity.class)); 
         group.addMember(p1);
         group.addMember(p2);
         p1.sensors().set(intSensor, 1);
-        Entities.manage(group);
         
         app.enrichers().add(Enrichers.builder()
                 .aggregating(intSensor)

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f1d8cba1/core/src/test/java/org/apache/brooklyn/enricher/stock/EnrichersTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/enricher/stock/EnrichersTest.java b/core/src/test/java/org/apache/brooklyn/enricher/stock/EnrichersTest.java
index 832b974..371d2b5 100644
--- a/core/src/test/java/org/apache/brooklyn/enricher/stock/EnrichersTest.java
+++ b/core/src/test/java/org/apache/brooklyn/enricher/stock/EnrichersTest.java
@@ -268,7 +268,6 @@ public class EnrichersTest extends BrooklynAppUnitTestSupport {
     @Test
     public void testAggregatingGroupSum() {
         TestEntity child1 = group.addChild(EntitySpec.create(TestEntity.class));
-        Entities.manage(child1);
         group.addMember(entity);
         group.addMember(entity2);
         group.enrichers().add(Enrichers.builder()
@@ -288,9 +287,7 @@ public class EnrichersTest extends BrooklynAppUnitTestSupport {
     public void testAggregatingChildrenSum() {
         group.addMember(entity);
         TestEntity child1 = group.addChild(EntitySpec.create(TestEntity.class));
-        Entities.manage(child1);
         TestEntity child2 = group.addChild(EntitySpec.create(TestEntity.class));
-        Entities.manage(child2);
         group.enrichers().add(Enrichers.builder()
                 .aggregating(NUM1)
                 .publishing(NUM2)

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f1d8cba1/core/src/test/java/org/apache/brooklyn/entity/group/DynamicFabricTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/entity/group/DynamicFabricTest.java b/core/src/test/java/org/apache/brooklyn/entity/group/DynamicFabricTest.java
index 9d1830e..015c168 100644
--- a/core/src/test/java/org/apache/brooklyn/entity/group/DynamicFabricTest.java
+++ b/core/src/test/java/org/apache/brooklyn/entity/group/DynamicFabricTest.java
@@ -348,9 +348,7 @@ public class DynamicFabricTest extends BrooklynAppUnitTestSupport {
 
         fabric.start(ImmutableList.of(loc1));
         
-        BasicEntity extraChild = app.getManagementContext().getEntityManager().createEntity(EntitySpec.create(BasicEntity.class)
-                .parent(fabric));
-        Entities.manage(extraChild);
+        BasicEntity extraChild = fabric.addChild(EntitySpec.create(BasicEntity.class));
 
         fabric.stop();
     }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f1d8cba1/core/src/test/java/org/apache/brooklyn/entity/group/DynamicGroupTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/entity/group/DynamicGroupTest.java b/core/src/test/java/org/apache/brooklyn/entity/group/DynamicGroupTest.java
index dc327e3..eefe4a3 100644
--- a/core/src/test/java/org/apache/brooklyn/entity/group/DynamicGroupTest.java
+++ b/core/src/test/java/org/apache/brooklyn/entity/group/DynamicGroupTest.java
@@ -120,13 +120,8 @@ public class DynamicGroupTest {
     
     @Test
     public void testGroupDetectsNewlyManagedMatchingMember() throws Exception {
-        final Entity e3 = new AbstractEntity() {};
-        group.setEntityFilter(EntityPredicates.idEqualTo(e3.getId()));
-        e3.setParent(app);
-        
-        assertEqualsIgnoringOrder(group.getMembers(), ImmutableSet.of());
-        
-        Entities.manage(e3);
+        group.setEntityFilter(EntityPredicates.displayNameEqualTo("myname"));
+        final Entity e3 = app.addChild(EntitySpec.create(TestEntity.class).displayName("myname"));
         
         Asserts.succeedsEventually(new Runnable() {
             public void run() {
@@ -136,9 +131,9 @@ public class DynamicGroupTest {
 
     @Test
     public void testGroupUsesNewFilter() throws Exception {
-        Entity e3 = new AbstractEntity(app) {};
-        Entities.manage(e3);
-        group.setEntityFilter(EntityPredicates.idEqualTo(e3.getId()));
+        final Entity e3 = app.addChild(EntitySpec.create(TestEntity.class).displayName("myname"));
+
+        group.setEntityFilter(EntityPredicates.displayNameEqualTo("myname"));
         
         assertEqualsIgnoringOrder(group.getMembers(), ImmutableSet.of(e3));
     }
@@ -146,7 +141,7 @@ public class DynamicGroupTest {
     @Test
     public void testGroupDetectsChangedEntities() throws Exception {
         final AttributeSensor<String> MY_ATTRIBUTE = Sensors.newStringSensor("test.myAttribute", "My test attribute");
-    
+        
         group.setEntityFilter(EntityPredicates.attributeEqualTo(MY_ATTRIBUTE, "yes"));
         group.addSubscription(null, MY_ATTRIBUTE);
         
@@ -395,7 +390,9 @@ public class DynamicGroupTest {
     }
     
     // See Deadlock in https://github.com/brooklyncentral/brooklyn/issues/378
-    @Test
+    // TODO Now that entities are auto-managed, this test is no longer appropriate.
+    // Should it be re-written or deleted?
+    @Test(groups="WIP")
     public void testDoesNotDeadlockOnManagedAndMemberAddedConcurrently() throws Exception {
         final CountDownLatch rescanReachedLatch = new CountDownLatch(1);
         final CountDownLatch entityAddedReachedLatch = new CountDownLatch(1);

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f1d8cba1/core/src/test/java/org/apache/brooklyn/entity/group/DynamicMultiGroupTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/entity/group/DynamicMultiGroupTest.java b/core/src/test/java/org/apache/brooklyn/entity/group/DynamicMultiGroupTest.java
index 7f96d71..b156bb5 100644
--- a/core/src/test/java/org/apache/brooklyn/entity/group/DynamicMultiGroupTest.java
+++ b/core/src/test/java/org/apache/brooklyn/entity/group/DynamicMultiGroupTest.java
@@ -85,8 +85,6 @@ public class DynamicMultiGroupTest {
         EntitySpec<TestEntity> childSpec = EntitySpec.create(TestEntity.class);
         TestEntity child1 = group.addChild(EntitySpec.create(childSpec).displayName("child1"));
         TestEntity child2 = group.addChild(EntitySpec.create(childSpec).displayName("child2"));
-        Entities.manage(child1);
-        Entities.manage(child2);
 
         checkDistribution(group, dmg, childSpec, child1, child2);
     }
@@ -104,8 +102,6 @@ public class DynamicMultiGroupTest {
         EntitySpec<TestEntity> childSpec = EntitySpec.create(TestEntity.class);
         TestEntity child1 = group.addChild(EntitySpec.create(childSpec).displayName("child1"));
         TestEntity child2 = group.addChild(EntitySpec.create(childSpec).displayName("child2"));
-        Entities.manage(child1);
-        Entities.manage(child2);
         
         checkDistribution(group, dmg, childSpec, child1, child2);
     }
@@ -186,7 +182,6 @@ public class DynamicMultiGroupTest {
 
         // Add new child 3, associated with new bucket C
         final TestEntity child3 = group.addChild(EntitySpec.create(childSpec).displayName("child3"));
-        Entities.manage(child3);
         child3.sensors().set(SENSOR, "bucketC");
         Asserts.succeedsEventually(new Runnable() {
             public void run() {

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f1d8cba1/core/src/test/java/org/apache/brooklyn/entity/group/MembershipTrackingPolicyTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/entity/group/MembershipTrackingPolicyTest.java b/core/src/test/java/org/apache/brooklyn/entity/group/MembershipTrackingPolicyTest.java
index 2f17540..5325a1d 100644
--- a/core/src/test/java/org/apache/brooklyn/entity/group/MembershipTrackingPolicyTest.java
+++ b/core/src/test/java/org/apache/brooklyn/entity/group/MembershipTrackingPolicyTest.java
@@ -75,7 +75,6 @@ public class MembershipTrackingPolicyTest extends BrooklynAppUnitTestSupport {
     private TestEntity createAndManageChildOf(Entity parent) {
         EntityManager entityManager = app.getManagementContext().getEntityManager();
         TestEntity result = entityManager.createEntity(EntitySpec.create(TestEntity.class).parent(parent));
-        Entities.manage(result);
         return result;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f1d8cba1/core/src/test/java/org/apache/brooklyn/entity/stock/BasicStartableTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/entity/stock/BasicStartableTest.java b/core/src/test/java/org/apache/brooklyn/entity/stock/BasicStartableTest.java
index 1746777..f257f63 100644
--- a/core/src/test/java/org/apache/brooklyn/entity/stock/BasicStartableTest.java
+++ b/core/src/test/java/org/apache/brooklyn/entity/stock/BasicStartableTest.java
@@ -78,7 +78,6 @@ public class BasicStartableTest {
     @Test
     public void testSetsLocations() throws Exception {
         startable = app.addChild(EntitySpec.create(BasicStartable.class));
-        Entities.startManagement(startable);
         app.start(ImmutableList.of(loc1, loc2));
         
         assertEqualsIgnoringOrder(startable.getLocations(), ImmutableSet.of(loc1, loc2));
@@ -89,7 +88,6 @@ public class BasicStartableTest {
         startable = app.addChild(EntitySpec.create(BasicStartable.class));
         entity = startable.addChild(EntitySpec.create(TestEntity.class));
         entity2 = startable.addChild(EntitySpec.create(TestEntity.class));
-        Entities.startManagement(startable);
         app.start(ImmutableList.of(loc1, loc2));
         
         assertEqualsIgnoringOrder(entity.getLocations(), ImmutableSet.of(loc1, loc2));
@@ -122,7 +120,6 @@ public class BasicStartableTest {
                 .configure(BasicStartable.LOCATIONS_FILTER, filter));
         entity = startable.addChild(EntitySpec.create(TestEntity.class).displayName("1"));
         entity2 = startable.addChild(EntitySpec.create(TestEntity.class).displayName("2"));
-        Entities.startManagement(startable);
         app.start(ImmutableList.of(loc1, loc2));
         
         assertEqualsIgnoringOrder(entity.getLocations(), ImmutableSet.of(loc1));
@@ -142,7 +139,6 @@ public class BasicStartableTest {
         startable = app.addChild(EntitySpec.create(BasicStartable.class)
                 .configure(BasicStartable.LOCATIONS_FILTER, filter));
         BasicEntity entity = startable.addChild(EntitySpec.create(BasicEntity.class));
-        Entities.startManagement(startable);
         app.start(ImmutableList.of(loc1, loc2));
         
         assertEqualsIgnoringOrder(entity.getLocations(), ImmutableSet.of());
@@ -156,7 +152,6 @@ public class BasicStartableTest {
         managementContext.getSubscriptionContext(startable)
                 .subscribe(startable, Attributes.SERVICE_STATE_ACTUAL, listener);
 
-        Entities.startManagement(startable);
         app.start(ImmutableList.of(loc1));
         app.stop();
 

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f1d8cba1/core/src/test/java/org/apache/brooklyn/feed/ssh/SshFeedIntegrationTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/feed/ssh/SshFeedIntegrationTest.java b/core/src/test/java/org/apache/brooklyn/feed/ssh/SshFeedIntegrationTest.java
index d926903..4559247 100644
--- a/core/src/test/java/org/apache/brooklyn/feed/ssh/SshFeedIntegrationTest.java
+++ b/core/src/test/java/org/apache/brooklyn/feed/ssh/SshFeedIntegrationTest.java
@@ -200,14 +200,11 @@ public class SshFeedIntegrationTest extends BrooklynAppUnitTestSupport {
                         .build();
                 }
             }));
-        Time.sleep(Duration.seconds(2));
-        // would be nice to hook in and assert no errors
-        Assert.assertEquals(entity2.getAttribute(SENSOR_STRING), null);
-        Entities.manage(entity2);
-        Time.sleep(Duration.seconds(2));
-        Assert.assertEquals(entity2.getAttribute(SENSOR_STRING), null);
+
+        // TODO would be nice to hook in and assert no errors
+        EntityTestUtils.assertAttributeEqualsContinually(entity2, SENSOR_STRING, null);
+
         entity2.sensors().set(Attributes.SERVICE_UP, true);
-    
         EntityTestUtils.assertAttributeEventually(entity2, SENSOR_STRING, StringPredicates.containsLiteral("hello"));
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f1d8cba1/examples/simple-web-cluster/src/test/java/org/apache/brooklyn/demo/RebindWebClusterDatabaseExampleAppIntegrationTest.java
----------------------------------------------------------------------
diff --git a/examples/simple-web-cluster/src/test/java/org/apache/brooklyn/demo/RebindWebClusterDatabaseExampleAppIntegrationTest.java b/examples/simple-web-cluster/src/test/java/org/apache/brooklyn/demo/RebindWebClusterDatabaseExampleAppIntegrationTest.java
index 001d81c..349c268 100644
--- a/examples/simple-web-cluster/src/test/java/org/apache/brooklyn/demo/RebindWebClusterDatabaseExampleAppIntegrationTest.java
+++ b/examples/simple-web-cluster/src/test/java/org/apache/brooklyn/demo/RebindWebClusterDatabaseExampleAppIntegrationTest.java
@@ -99,7 +99,6 @@ public class RebindWebClusterDatabaseExampleAppIntegrationTest extends RebindTes
         StartableApplication result = origManagementContext.getEntityManager().createEntity(EntitySpec.create(StartableApplication.class)
                 .impl(WebClusterDatabaseExampleApp.class)
                 .configure(DynamicCluster.INITIAL_SIZE, 2));
-        Entities.startManagement(result, origManagementContext);
         return result;
     }
     

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f1d8cba1/policy/src/test/java/org/apache/brooklyn/policy/loadbalancing/BalanceableWorkerPoolTest.java
----------------------------------------------------------------------
diff --git a/policy/src/test/java/org/apache/brooklyn/policy/loadbalancing/BalanceableWorkerPoolTest.java b/policy/src/test/java/org/apache/brooklyn/policy/loadbalancing/BalanceableWorkerPoolTest.java
index 5b657ed..770e3f5 100644
--- a/policy/src/test/java/org/apache/brooklyn/policy/loadbalancing/BalanceableWorkerPoolTest.java
+++ b/policy/src/test/java/org/apache/brooklyn/policy/loadbalancing/BalanceableWorkerPoolTest.java
@@ -96,7 +96,6 @@ public class BalanceableWorkerPoolTest {
         
         BalanceableWorkerPool pool2 = app.createAndManageChild(EntitySpec.create(BalanceableWorkerPool.class));
         pool2.setContents(resizable, itemGroup);
-        Entities.manage(pool2);
         
         pool2.resize(123);
         assertEquals(resizable.getCurrentSize(), (Integer) 123);

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f1d8cba1/software/base/src/test/java/org/apache/brooklyn/entity/brooklynnode/BrooklynNodeIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/base/src/test/java/org/apache/brooklyn/entity/brooklynnode/BrooklynNodeIntegrationTest.java b/software/base/src/test/java/org/apache/brooklyn/entity/brooklynnode/BrooklynNodeIntegrationTest.java
index 32899da..92ec962 100644
--- a/software/base/src/test/java/org/apache/brooklyn/entity/brooklynnode/BrooklynNodeIntegrationTest.java
+++ b/software/base/src/test/java/org/apache/brooklyn/entity/brooklynnode/BrooklynNodeIntegrationTest.java
@@ -644,7 +644,6 @@ services:
         Entity mirror = brooklynNode.addChild(EntitySpec.create(BrooklynEntityMirror.class)
                 .configure(BrooklynEntityMirror.MIRRORED_ENTITY_URL, entityUrl)
                 .configure(BrooklynEntityMirror.MIRRORED_ENTITY_ID, id));
-        Entities.manage(mirror);
 
         assertEquals(brooklynNode.getChildren().size(), 1);
         return brooklynNode;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f1d8cba1/software/base/src/test/java/org/apache/brooklyn/entity/brooklynnode/BrooklynNodeTest.java
----------------------------------------------------------------------
diff --git a/software/base/src/test/java/org/apache/brooklyn/entity/brooklynnode/BrooklynNodeTest.java b/software/base/src/test/java/org/apache/brooklyn/entity/brooklynnode/BrooklynNodeTest.java
index 27f627e..b367422 100644
--- a/software/base/src/test/java/org/apache/brooklyn/entity/brooklynnode/BrooklynNodeTest.java
+++ b/software/base/src/test/java/org/apache/brooklyn/entity/brooklynnode/BrooklynNodeTest.java
@@ -23,6 +23,7 @@ import static org.testng.Assert.assertTrue;
 
 import java.util.List;
 
+import org.apache.brooklyn.api.entity.EntityLocal;
 import org.apache.brooklyn.api.entity.EntitySpec;
 import org.apache.brooklyn.api.entity.drivers.downloads.DownloadResolver;
 import org.apache.brooklyn.api.location.Location;
@@ -31,9 +32,7 @@ import org.apache.brooklyn.core.entity.Entities;
 import org.apache.brooklyn.core.entity.trait.Startable;
 import org.apache.brooklyn.core.feed.ConfigToAttributes;
 import org.apache.brooklyn.core.test.entity.TestApplication;
-import org.apache.brooklyn.entity.brooklynnode.BrooklynNode;
-import org.apache.brooklyn.entity.brooklynnode.BrooklynNodeImpl;
-import org.apache.brooklyn.entity.brooklynnode.BrooklynNodeSshDriver;
+import org.apache.brooklyn.location.ssh.SshMachineLocation;
 import org.apache.brooklyn.test.Asserts;
 import org.apache.brooklyn.util.collections.MutableMap;
 import org.apache.brooklyn.util.collections.MutableSet;
@@ -46,8 +45,6 @@ import org.testng.annotations.Test;
 
 import com.google.common.collect.ImmutableMap;
 
-import org.apache.brooklyn.location.ssh.SshMachineLocation;
-
 public class BrooklynNodeTest {
 
     // TODO Need test for copying/setting classpath
@@ -96,12 +93,12 @@ public class BrooklynNodeTest {
     private void runTestGeneratesCorrectDownloadUrl(String version, String expectedUrl) throws Exception {
         // TODO Using BrooklynNodeImpl directly, because want to instantiate a BroolynNodeSshDriver.
         //      Really want to make that easier to test, without going through "wrong" code path for creating entity.
-        BrooklynNodeImpl entity = new BrooklynNodeImpl();
-        entity.config().set(BrooklynNode.SUGGESTED_VERSION, version);
-        entity.setParent(app);
-        Entities.manage(entity);
-        ConfigToAttributes.apply(entity);
-        BrooklynNodeSshDriver driver = new BrooklynNodeSshDriver(entity, loc);
+        BrooklynNode entity = app.addChild(EntitySpec.create(BrooklynNode.class)
+                .configure(BrooklynNode.SUGGESTED_VERSION, version));
+        BrooklynNodeImpl entityImpl = (BrooklynNodeImpl) Entities.deproxy(entity);
+        
+        ConfigToAttributes.apply((EntityLocal)entity);
+        BrooklynNodeSshDriver driver = new BrooklynNodeSshDriver(entityImpl, loc);
         
         DownloadResolver resolver = Entities.newDownloader(driver);
         List<String> urls = resolver.getTargets();
@@ -113,7 +110,6 @@ public class BrooklynNodeTest {
     @Test(groups = "Integration")
     public void testUnmanageOnStop() throws Exception {
         final BrooklynNode node = app.addChild(EntitySpec.create(BrooklynNode.class).impl(SlowStopBrooklynNode.class));
-        Entities.manage(node);
         assertTrue(Entities.isManaged(node), "Entity " + node + " must be managed.");
         node.invoke(Startable.STOP, ImmutableMap.<String,Object>of()).asTask().getUnchecked();
         //The UnmanageTask will unblock after the STOP effector completes, so we are competing with it here.

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f1d8cba1/software/base/src/test/java/org/apache/brooklyn/entity/java/VanillaJavaAppRebindTest.java
----------------------------------------------------------------------
diff --git a/software/base/src/test/java/org/apache/brooklyn/entity/java/VanillaJavaAppRebindTest.java b/software/base/src/test/java/org/apache/brooklyn/entity/java/VanillaJavaAppRebindTest.java
index c2187a4..6b31151 100644
--- a/software/base/src/test/java/org/apache/brooklyn/entity/java/VanillaJavaAppRebindTest.java
+++ b/software/base/src/test/java/org/apache/brooklyn/entity/java/VanillaJavaAppRebindTest.java
@@ -95,7 +95,6 @@ public class VanillaJavaAppRebindTest {
         VanillaJavaApp javaProcess = app.addChild(EntitySpec.create(VanillaJavaApp.class, TestingJavaOptsVanillaJavaAppImpl.class)
             .configure("main", MAIN_CLASS.getCanonicalName()).configure("classpath", ImmutableList.of(BROOKLYN_THIS_CLASSPATH)));
 
-        Entities.manage(javaProcess);
         app.start(ImmutableList.of(loc));
 
         rebind();
@@ -108,7 +107,7 @@ public class VanillaJavaAppRebindTest {
     public void testRebindToKilledJavaApp() throws Exception {
         VanillaJavaApp javaProcess = app.addChild(EntitySpec.create(VanillaJavaApp.class, TestingJavaOptsVanillaJavaAppImpl.class)
             .configure("main", MAIN_CLASS.getCanonicalName()).configure("classpath", ImmutableList.of(BROOKLYN_THIS_CLASSPATH)));
-        Entities.manage(javaProcess);
+
         app.start(ImmutableList.of(loc));
         javaProcess.kill();
         
@@ -129,7 +128,6 @@ public class VanillaJavaAppRebindTest {
         VanillaJavaApp javaProcess = app.addChild(EntitySpec.create(VanillaJavaApp.class, EnrichedVanillaJavaAppImpl.class)
             .configure("main", MAIN_CLASS.getCanonicalName()).configure("classpath", ImmutableList.of(BROOKLYN_THIS_CLASSPATH)));
 
-        Entities.manage(javaProcess);
         app.start(ImmutableList.of(loc));
 
         EntityTestUtils.assertAttributeEventuallyNonNull(javaProcess, EnrichedVanillaJavaAppImpl.AVG1);

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f1d8cba1/software/base/src/test/java/org/apache/brooklyn/entity/software/base/SameServerEntityTest.java
----------------------------------------------------------------------
diff --git a/software/base/src/test/java/org/apache/brooklyn/entity/software/base/SameServerEntityTest.java b/software/base/src/test/java/org/apache/brooklyn/entity/software/base/SameServerEntityTest.java
index 23b56fb..c9a0d5c 100644
--- a/software/base/src/test/java/org/apache/brooklyn/entity/software/base/SameServerEntityTest.java
+++ b/software/base/src/test/java/org/apache/brooklyn/entity/software/base/SameServerEntityTest.java
@@ -64,8 +64,6 @@ public class SameServerEntityTest {
     public void testUsesSameMachineLocationForEachChild() throws Exception {
         Entity child1 = entity.addChild(EntitySpec.create(TestEntity.class));
         Entity child2 = entity.addChild(EntitySpec.create(TestEntity.class));
-        Entities.manage(child1);
-        Entities.manage(child2);
         
         app.start(ImmutableList.of(loc));
         

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f1d8cba1/software/base/src/test/java/org/apache/brooklyn/entity/software/base/VanillaSoftwareProcessAndChildrenIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/base/src/test/java/org/apache/brooklyn/entity/software/base/VanillaSoftwareProcessAndChildrenIntegrationTest.java b/software/base/src/test/java/org/apache/brooklyn/entity/software/base/VanillaSoftwareProcessAndChildrenIntegrationTest.java
index f6e8bf0..228c441 100644
--- a/software/base/src/test/java/org/apache/brooklyn/entity/software/base/VanillaSoftwareProcessAndChildrenIntegrationTest.java
+++ b/software/base/src/test/java/org/apache/brooklyn/entity/software/base/VanillaSoftwareProcessAndChildrenIntegrationTest.java
@@ -187,7 +187,6 @@ public class VanillaSoftwareProcessAndChildrenIntegrationTest {
             );
         p2 = p1.addChild(EntitySpec.create(VanillaSoftwareProcess.class)
             .configure(VanillaSoftwareProcess.LAUNCH_COMMAND, childCmd));
-        Entities.manage(p2);
         
         log.info("testing "+JavaClassNames.callerNiceClassAndMethod(1)+", using "+p1+" and "+p2);
     }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f1d8cba1/software/base/src/test/java/org/apache/brooklyn/entity/software/base/test/location/WinRmMachineLocationLiveTest.java
----------------------------------------------------------------------
diff --git a/software/base/src/test/java/org/apache/brooklyn/entity/software/base/test/location/WinRmMachineLocationLiveTest.java b/software/base/src/test/java/org/apache/brooklyn/entity/software/base/test/location/WinRmMachineLocationLiveTest.java
index 615eda7..4eab220 100644
--- a/software/base/src/test/java/org/apache/brooklyn/entity/software/base/test/location/WinRmMachineLocationLiveTest.java
+++ b/software/base/src/test/java/org/apache/brooklyn/entity/software/base/test/location/WinRmMachineLocationLiveTest.java
@@ -101,6 +101,9 @@ public class WinRmMachineLocationLiveTest {
         
         loc = WindowsTestFixture.setUpWindowsLocation(mgmt);
         machine = loc.obtain(ImmutableMap.of());
+        
+        LOG.info("PROVISIONED: "+machine.getAddress()+":"+machine.config().get(WinRmMachineLocation.WINRM_PORT)
+                +", "+machine.getUser()+":"+machine.config().get(WinRmMachineLocation.PASSWORD));
     }
     
     @AfterClass(alwaysRun=true)

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f1d8cba1/software/monitoring/src/test/java/org/apache/brooklyn/entity/monitoring/monit/MonitIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/monitoring/src/test/java/org/apache/brooklyn/entity/monitoring/monit/MonitIntegrationTest.java b/software/monitoring/src/test/java/org/apache/brooklyn/entity/monitoring/monit/MonitIntegrationTest.java
index 685f662..f19e6b9 100644
--- a/software/monitoring/src/test/java/org/apache/brooklyn/entity/monitoring/monit/MonitIntegrationTest.java
+++ b/software/monitoring/src/test/java/org/apache/brooklyn/entity/monitoring/monit/MonitIntegrationTest.java
@@ -88,7 +88,7 @@ public class MonitIntegrationTest extends BrooklynAppLiveTestSupport {
     public void test_monitorMySql() throws Exception {
         SameServerEntity sameServerEntity = app.createAndManageChild(EntitySpec.create(SameServerEntity.class));
         MySqlNode mySqlNode = sameServerEntity.addChild(EntitySpec.create(MySqlNode.class));
-        Entities.manage(mySqlNode);
+
         Function<String, Map<String, Object>> controlFileSubstitutionsFunction = new Function<String, Map<String, Object>>() {
             public Map<String, Object> apply(String input) {
                 return ImmutableMap.<String, Object>of("targetPidFile", input);
@@ -99,7 +99,7 @@ public class MonitIntegrationTest extends BrooklynAppLiveTestSupport {
                 .configure(MonitNode.CONTROL_FILE_SUBSTITUTIONS, DependentConfiguration.valueWhenAttributeReady(mySqlNode,
                         SoftwareProcess.PID_FILE, controlFileSubstitutionsFunction));
         final MonitNode monitNode = sameServerEntity.addChild(monitSpec);
-        Entities.manage(monitNode);
+
         app.start(ImmutableSet.of(loc));
         LOG.info("Monit and MySQL started");
         EntityTestUtils.assertAttributeEqualsEventually(monitNode, MonitNode.MONIT_TARGET_PROCESS_STATUS, "Running");
@@ -145,7 +145,7 @@ public class MonitIntegrationTest extends BrooklynAppLiveTestSupport {
             .configure(MySqlNode.INSTALL_DIR, mySqlInstallDir)
             .configure(MySqlNode.RUN_DIR, mySqlRunDir)
             .configure(MySqlNode.DATA_DIR, mySqlDataDir));
-        Entities.manage(mySqlNode);
+
         Function<String, Map<String, Object>> controlFileSubstitutionsFunction = new Function<String, Map<String, Object>>() {
             public Map<String, Object> apply(String input) {
                 return ImmutableMap.<String, Object>of(
@@ -158,12 +158,11 @@ public class MonitIntegrationTest extends BrooklynAppLiveTestSupport {
             }
         };
         
-        EntitySpec<MonitNode> monitSpec = EntitySpec.create(MonitNode.class)
+        final MonitNode monitNode = sameServerEntity.addChild(EntitySpec.create(MonitNode.class)
                 .configure(MonitNode.CONTROL_FILE_URL, "classpath:///org/apache/brooklyn/entity/monitoring/monit/monitmysqlwithrestart.monitrc")
                 .configure(MonitNode.CONTROL_FILE_SUBSTITUTIONS, DependentConfiguration.valueWhenAttributeReady(mySqlNode,
-                        SoftwareProcess.PID_FILE, controlFileSubstitutionsFunction));
-        final MonitNode monitNode = sameServerEntity.addChild(monitSpec);
-        Entities.manage(monitNode);
+                        SoftwareProcess.PID_FILE, controlFileSubstitutionsFunction)));
+
         app.start(ImmutableSet.of(loc));
         LOG.info("Monit and MySQL started");
         final String[] initialPid = {""};

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f1d8cba1/software/network/src/test/java/org/apache/brooklyn/entity/network/bind/BindDnsServerLiveTest.java
----------------------------------------------------------------------
diff --git a/software/network/src/test/java/org/apache/brooklyn/entity/network/bind/BindDnsServerLiveTest.java b/software/network/src/test/java/org/apache/brooklyn/entity/network/bind/BindDnsServerLiveTest.java
index bff8068..56273c7 100644
--- a/software/network/src/test/java/org/apache/brooklyn/entity/network/bind/BindDnsServerLiveTest.java
+++ b/software/network/src/test/java/org/apache/brooklyn/entity/network/bind/BindDnsServerLiveTest.java
@@ -59,8 +59,6 @@ public class BindDnsServerLiveTest {
         dns = sse.addChild((EntitySpec.create(BindDnsServer.class)
                 .configure(BindDnsServer.ENTITY_FILTER, Predicates.instanceOf(EmptySoftwareProcess.class))
                 .configure(BindDnsServer.HOSTNAME_SENSOR, PrefixAndIdEnricher.SENSOR)));
-        Entities.manage(cluster);
-        Entities.manage(dns);
 
         app.start(ImmutableList.of(testLocation));
         assertAttributeEqualsEventually(dns, Attributes.SERVICE_UP, true);

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f1d8cba1/software/webapp/src/test/java/org/apache/brooklyn/entity/proxy/AbstractControllerTest.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/org/apache/brooklyn/entity/proxy/AbstractControllerTest.java b/software/webapp/src/test/java/org/apache/brooklyn/entity/proxy/AbstractControllerTest.java
index ff84dce..7e98d41 100644
--- a/software/webapp/src/test/java/org/apache/brooklyn/entity/proxy/AbstractControllerTest.java
+++ b/software/webapp/src/test/java/org/apache/brooklyn/entity/proxy/AbstractControllerTest.java
@@ -104,7 +104,6 @@ public class AbstractControllerTest extends BrooklynAppUnitTestSupport {
     @Test
     public void testUpdateCalledWhenChildHostnameAndPortChanges() throws Exception {
         TestEntity child = cluster.addChild(EntitySpec.create(TestEntity.class));
-        Entities.manage(child);
         cluster.addMember(child);
 
         List<Collection<String>> u = Lists.newArrayList(controller.getUpdates());
@@ -213,7 +212,6 @@ public class AbstractControllerTest extends BrooklynAppUnitTestSupport {
         controller.start(Arrays.asList(loc));
         
         TestEntity child = cluster.addChild(EntitySpec.create(TestEntity.class));
-        Entities.manage(child);
         cluster.addMember(child);
 
         List<Collection<String>> u = Lists.newArrayList(controller.getUpdates());

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f1d8cba1/software/webapp/src/test/java/org/apache/brooklyn/entity/proxy/nginx/NginxClusterIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/org/apache/brooklyn/entity/proxy/nginx/NginxClusterIntegrationTest.java b/software/webapp/src/test/java/org/apache/brooklyn/entity/proxy/nginx/NginxClusterIntegrationTest.java
index f7ee033..4c5d85b 100644
--- a/software/webapp/src/test/java/org/apache/brooklyn/entity/proxy/nginx/NginxClusterIntegrationTest.java
+++ b/software/webapp/src/test/java/org/apache/brooklyn/entity/proxy/nginx/NginxClusterIntegrationTest.java
@@ -134,12 +134,10 @@ public class NginxClusterIntegrationTest extends BrooklynAppLiveTestSupport {
                 .configure("initialSize", 1)
                 .configure(JavaWebAppService.NAMED_WARS, ImmutableList.of(getTestWar())));
 
-        UrlMapping urlMapping = entityManager.createEntity(EntitySpec.create(UrlMapping.class)
+        UrlMapping urlMapping = urlMappings.addChild(EntitySpec.create(UrlMapping.class)
                 .configure("domain", "localhost")
                 .configure("path", "/hello-world($|/.*)")
-                .configure("target", c1)
-                .parent(urlMappings));
-        Entities.manage(urlMapping);
+                .configure("target", c1));
         
         loadBalancerCluster = app.createAndManageChild(EntitySpec.create(LoadBalancerCluster.class)
                 .configure("urlMappings", urlMappings)

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f1d8cba1/software/webapp/src/test/java/org/apache/brooklyn/entity/proxy/nginx/NginxRebindIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/org/apache/brooklyn/entity/proxy/nginx/NginxRebindIntegrationTest.java b/software/webapp/src/test/java/org/apache/brooklyn/entity/proxy/nginx/NginxRebindIntegrationTest.java
index 4eb0a9a..e9bc684 100644
--- a/software/webapp/src/test/java/org/apache/brooklyn/entity/proxy/nginx/NginxRebindIntegrationTest.java
+++ b/software/webapp/src/test/java/org/apache/brooklyn/entity/proxy/nginx/NginxRebindIntegrationTest.java
@@ -34,7 +34,6 @@ import org.apache.brooklyn.api.entity.EntitySpec;
 import org.apache.brooklyn.api.entity.Group;
 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.entity.lifecycle.Lifecycle;
 import org.apache.brooklyn.core.mgmt.rebind.RebindOptions;
 import org.apache.brooklyn.core.mgmt.rebind.RebindTestFixtureWithApp;
@@ -238,12 +237,10 @@ public class NginxRebindIntegrationTest extends RebindTestFixtureWithApp {
                 .configure(DynamicCluster.MEMBER_SPEC, EntitySpec.create(Tomcat8Server.class).configure("war", getTestWar()))
                 .configure("initialSize", 1)); 
 
-        UrlMapping origMapping = origApp.getManagementContext().getEntityManager().createEntity(EntitySpec.create(UrlMapping.class)
+        UrlMapping origMapping = origUrlMappingsGroup.addChild(EntitySpec.create(UrlMapping.class)
                 .configure("domain", "localhost1")
                 .configure("target", origServerPool)
-                .configure("rewrites", ImmutableList.of(new UrlRewriteRule("/foo/(.*)", "/$1")))
-                .parent(origUrlMappingsGroup));
-        Entities.manage(origMapping);
+                .configure("rewrites", ImmutableList.of(new UrlRewriteRule("/foo/(.*)", "/$1"))));
         
         NginxController origNginx = origApp.createAndManageChild(EntitySpec.create(NginxController.class)
                 .configure("domain", "localhost")

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f1d8cba1/software/webapp/src/test/java/org/apache/brooklyn/entity/proxy/nginx/NginxUrlMappingIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/org/apache/brooklyn/entity/proxy/nginx/NginxUrlMappingIntegrationTest.java b/software/webapp/src/test/java/org/apache/brooklyn/entity/proxy/nginx/NginxUrlMappingIntegrationTest.java
index 11672cf..1aee752 100644
--- a/software/webapp/src/test/java/org/apache/brooklyn/entity/proxy/nginx/NginxUrlMappingIntegrationTest.java
+++ b/software/webapp/src/test/java/org/apache/brooklyn/entity/proxy/nginx/NginxUrlMappingIntegrationTest.java
@@ -125,35 +125,29 @@ public class NginxUrlMappingIntegrationTest extends BrooklynAppLiveTestSupport {
                 .configure("initialSize", 1)
                 .configure(DynamicCluster.MEMBER_SPEC, EntitySpec.create(Tomcat8Server.class).configure("httpPort", "8100+"))
                 .configure(JavaWebAppService.ROOT_WAR, getTestWar()));
-        UrlMapping u0 = entityManager.createEntity(EntitySpec.create(UrlMapping.class)
+        UrlMapping u0 = urlMappingsGroup.addChild(EntitySpec.create(UrlMapping.class)
                 .configure("domain", "localhost1")
-                .configure("target", c0)
-                .parent(urlMappingsGroup));
-        Entities.manage(u0);
+                .configure("target", c0));
         
         //cluster 1 at localhost2 /hello-world/
         DynamicCluster c1 = app.createAndManageChild(EntitySpec.create(DynamicCluster.class)
                 .configure("initialSize", 1)
                 .configure(DynamicCluster.MEMBER_SPEC, EntitySpec.create(Tomcat8Server.class).configure("httpPort", "8100+"))
                 .configure(JavaWebAppService.NAMED_WARS, ImmutableList.of(getTestWar())));
-        UrlMapping u1 = entityManager.createEntity(EntitySpec.create(UrlMapping.class)
+        UrlMapping u1 = urlMappingsGroup.addChild(EntitySpec.create(UrlMapping.class)
                 .configure("domain", "localhost2")
                 .configure("path", "/hello-world($|/.*)")
-                .configure("target", c1)
-                .parent(urlMappingsGroup));
-        Entities.manage(u1);
+                .configure("target", c1));
 
         // cluster 2 at localhost3 /c2/  and mapping /hello/xxx to /hello/new xxx
         DynamicCluster c2 = app.createAndManageChild(EntitySpec.create(DynamicCluster.class)
                 .configure("initialSize", 1)
                 .configure(DynamicCluster.MEMBER_SPEC, EntitySpec.create(Tomcat8Server.class).configure("httpPort", "8100+")));
-        UrlMapping u2 = entityManager.createEntity(EntitySpec.create(UrlMapping.class)
+        UrlMapping u2 = urlMappingsGroup.addChild(EntitySpec.create(UrlMapping.class)
                 .configure("domain", "localhost3")
                 .configure("path", "/c2($|/.*)")
                 .configure("target", c2)
-                .configure("rewrites", ImmutableList.of(new UrlRewriteRule("(.*/|)(hello/)(.*)", "$1$2new $3").setBreak()))
-                .parent(urlMappingsGroup));
-        Entities.manage(u2);
+                .configure("rewrites", ImmutableList.of(new UrlRewriteRule("(.*/|)(hello/)(.*)", "$1$2new $3").setBreak())));
         // FIXME rewrite not a config
         
         app.start(ImmutableList.of(localLoc));
@@ -208,22 +202,18 @@ public class NginxUrlMappingIntegrationTest extends BrooklynAppLiveTestSupport {
         DynamicCluster c0 = app.createAndManageChild(EntitySpec.create(DynamicCluster.class)
                 .configure("initialSize", 1)
                 .configure(DynamicCluster.MEMBER_SPEC, EntitySpec.create(Tomcat8Server.class).configure("httpPort", "8100+")));
-        UrlMapping u0 = entityManager.createEntity(EntitySpec.create(UrlMapping.class)
+        UrlMapping u0 = urlMappingsGroup.addChild(EntitySpec.create(UrlMapping.class)
                 .configure("domain", "localhost")
                 .configure("path", "/atC0($|/.*)")
-                .configure("target", c0)
-                .parent(urlMappingsGroup));
-        Entities.manage(u0);
+                .configure("target", c0));
 
         DynamicCluster c1 = app.createAndManageChild(EntitySpec.create(DynamicCluster.class)
                 .configure("initialSize", 1)
                 .configure(DynamicCluster.MEMBER_SPEC, EntitySpec.create(Tomcat8Server.class).configure("httpPort", "8100+")));
-        UrlMapping u1 = entityManager.createEntity(EntitySpec.create(UrlMapping.class)
+        UrlMapping u1 = urlMappingsGroup.addChild(EntitySpec.create(UrlMapping.class)
                 .configure("domain", "localhost")
                 .configure("path", "/atC1($|/.*)")
-                .configure("target", c1)
-                .parent(urlMappingsGroup));
-        Entities.manage(u1);
+                .configure("target", c1));
 
         nginx = app.createAndManageChild(EntitySpec.create(NginxController.class)
                 .configure("domain", "localhost")
@@ -262,11 +252,9 @@ public class NginxUrlMappingIntegrationTest extends BrooklynAppLiveTestSupport {
                 .configure("initialSize", 1)
                 .configure(DynamicCluster.MEMBER_SPEC, EntitySpec.create(Tomcat8Server.class).configure("httpPort", "8100+"))
                 .configure(JavaWebAppService.ROOT_WAR, getTestWar()));
-        UrlMapping u0 = entityManager.createEntity(EntitySpec.create(UrlMapping.class)
+        UrlMapping u0 = urlMappingsGroup.addChild(EntitySpec.create(UrlMapping.class)
                 .configure("domain", "localhost2")
-                .configure("target", c0)
-                .parent(urlMappingsGroup));
-        Entities.manage(u0);
+                .configure("target", c0));
         
         nginx = app.createAndManageChild(EntitySpec.create(NginxController.class)
                 .configure("domain", "localhost")
@@ -301,11 +289,9 @@ public class NginxUrlMappingIntegrationTest extends BrooklynAppLiveTestSupport {
                 .configure("initialSize", 1)
                 .configure(DynamicCluster.MEMBER_SPEC, EntitySpec.create(Tomcat8Server.class).configure("httpPort", "8100+"))
                 .configure(JavaWebAppService.NAMED_WARS, ImmutableList.of(getTestWar())));
-        UrlMapping u1 = entityManager.createEntity(EntitySpec.create(UrlMapping.class)
+        UrlMapping u1 = urlMappingsGroup.addChild(EntitySpec.create(UrlMapping.class)
                 .configure("domain", "localhost1")
-                .configure("target", c1)
-                .parent(urlMappingsGroup));
-        Entities.manage(u1);
+                .configure("target", c1));
         
         nginx = app.createAndManageChild(EntitySpec.create(NginxController.class)
                 .configure("serverPool", coreCluster)
@@ -338,15 +324,13 @@ public class NginxUrlMappingIntegrationTest extends BrooklynAppLiveTestSupport {
                 .configure("initialSize", 1)
                 .configure(DynamicCluster.MEMBER_SPEC, EntitySpec.create(Tomcat8Server.class).configure("httpPort", "8100+"))
                 .configure(JavaWebAppService.ROOT_WAR, getTestWar()));
-        UrlMapping u0 = entityManager.createEntity(EntitySpec.create(UrlMapping.class)
+        UrlMapping u0 = urlMappingsGroup.addChild(EntitySpec.create(UrlMapping.class)
                 .configure("domain", "localhost1")
-                .configure("target", c0)
-                .parent(urlMappingsGroup));
+                .configure("target", c0));
         u0.addRewrite("/goodbye/al(.*)", "/hello/al$1");
         u0.addRewrite(new UrlRewriteRule("/goodbye(|/.*)$", "/hello$1").setBreak());
         u0.addRewrite("(.*)/hello/al(.*)", "$1/hello/Big Al$2");
         u0.addRewrite("/hello/an(.*)", "/hello/Sir An$1");
-        Entities.manage(u0);
 
         app.start(ImmutableList.of(localLoc));
         final int port = nginx.getAttribute(NginxController.PROXY_HTTP_PORT);
@@ -391,11 +375,9 @@ public class NginxUrlMappingIntegrationTest extends BrooklynAppLiveTestSupport {
                 .configure("initialSize", 1)
                 .configure(DynamicCluster.MEMBER_SPEC, EntitySpec.create(Tomcat8Server.class).configure("httpPort", "8100+"))
                 .configure(JavaWebAppService.ROOT_WAR, getTestWar()));
-        final UrlMapping u1 = entityManager.createEntity(EntitySpec.create(UrlMapping.class)
+        final UrlMapping u1 = urlMappingsGroup.addChild(EntitySpec.create(UrlMapping.class)
                 .configure("domain", "localhost1")
-                .configure("target", c1)
-                .parent(urlMappingsGroup));
-        Entities.manage(u1);
+                .configure("target", c1));
         
         app.start(ImmutableList.of(localLoc));
         int port = nginx.getAttribute(NginxController.PROXY_HTTP_PORT);
@@ -455,12 +437,10 @@ public class NginxUrlMappingIntegrationTest extends BrooklynAppLiveTestSupport {
         DynamicCluster c0 = app.createAndManageChild(EntitySpec.create(DynamicCluster.class)
                 .configure("initialSize", 1)
                 .configure(DynamicCluster.MEMBER_SPEC, EntitySpec.create(Tomcat8Server.class).configure("httpPort", "8100+")));
-        UrlMapping u0 = entityManager.createEntity(EntitySpec.create(UrlMapping.class)
+        UrlMapping u0 = urlMappingsGroup.addChild(EntitySpec.create(UrlMapping.class)
                 .configure("domain", "localhost")
                 .configure("path", "/atC0($|/.*)")
-                .configure("target", c0)
-                .parent(urlMappingsGroup));
-        Entities.manage(u0);
+                .configure("target", c0));
 
         nginx = app.createAndManageChild(EntitySpec.create(NginxController.class)
                 .configure("cluster", nullCluster)
@@ -497,11 +477,9 @@ public class NginxUrlMappingIntegrationTest extends BrooklynAppLiveTestSupport {
                 .configure("initialSize", 1)
                 .configure(DynamicCluster.MEMBER_SPEC, EntitySpec.create(Tomcat8Server.class).configure("httpPort", "8100+"))
                 .configure(JavaWebAppService.ROOT_WAR, getTestWar()));
-        UrlMapping u0 = entityManager.createEntity(EntitySpec.create(UrlMapping.class)
+        UrlMapping u0 = urlMappingsGroup.addChild(EntitySpec.create(UrlMapping.class)
                 .configure("domain", "localhost1")
-                .configure("target", c0)
-                .parent(urlMappingsGroup));
-        Entities.manage(u0);
+                .configure("target", c0));
 
         nginx = app.createAndManageChild(EntitySpec.create(NginxController.class)
                 .configure("urlMappings", urlMappingsGroup));

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f1d8cba1/usage/qa/src/test/java/org/apache/brooklyn/qa/load/LoadTest.java
----------------------------------------------------------------------
diff --git a/usage/qa/src/test/java/org/apache/brooklyn/qa/load/LoadTest.java b/usage/qa/src/test/java/org/apache/brooklyn/qa/load/LoadTest.java
index 8567b8a..6a57570 100644
--- a/usage/qa/src/test/java/org/apache/brooklyn/qa/load/LoadTest.java
+++ b/usage/qa/src/test/java/org/apache/brooklyn/qa/load/LoadTest.java
@@ -224,12 +224,11 @@ public class LoadTest {
         }
     }
     
-    protected <T extends StartableApplication> Callable<T> newProvisionAppTask(final ManagementContext managementContext, final EntitySpec<T> entitySpec) {
+    protected <T extends StartableApplication> Callable<T> newProvisionAppTask(final ManagementContext managementContext, final EntitySpec<T> appSpec) {
         return new Callable<T>() {
             public T call() {
                 Stopwatch stopwatch = Stopwatch.createStarted();
-                T app = managementContext.getEntityManager().createEntity(entitySpec);
-                Entities.startManagement(app, managementContext);
+                T app = managementContext.getEntityManager().createEntity(appSpec);
                 app.start(ImmutableList.of(localhost));
                 Duration duration = Duration.of(stopwatch.elapsed(TimeUnit.MILLISECONDS), TimeUnit.MILLISECONDS);
                 LOG.info("Provisioning time: "+duration);

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f1d8cba1/usage/rest-server/src/test/java/org/apache/brooklyn/rest/domain/ApplicationTest.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/test/java/org/apache/brooklyn/rest/domain/ApplicationTest.java b/usage/rest-server/src/test/java/org/apache/brooklyn/rest/domain/ApplicationTest.java
index b09d829..c992ec2 100644
--- a/usage/rest-server/src/test/java/org/apache/brooklyn/rest/domain/ApplicationTest.java
+++ b/usage/rest-server/src/test/java/org/apache/brooklyn/rest/domain/ApplicationTest.java
@@ -30,10 +30,12 @@ import java.util.Map;
 import org.apache.brooklyn.api.entity.Entity;
 import org.apache.brooklyn.api.mgmt.ManagementContext;
 import org.apache.brooklyn.core.entity.Entities;
-import org.apache.brooklyn.core.test.entity.TestApplicationImpl;
-import org.testng.Assert;
+import org.apache.brooklyn.core.test.entity.LocalManagementContextForTests;
+import org.apache.brooklyn.core.test.entity.TestApplication;
+import org.apache.brooklyn.test.Asserts;
 import org.testng.annotations.Test;
 
+import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.ImmutableSet;
 
@@ -79,13 +81,11 @@ public class ApplicationTest {
 
     @Test
     public void testAppInAppTest() throws IOException {
-        TestApplicationImpl app = new TestApplicationImpl();
-        ManagementContext mgmt = Entities.startManagement(app);
+        ManagementContext mgmt = LocalManagementContextForTests.newInstance();
         try {
-            Entity e2 = app.addChild(new TestApplicationImpl());
-            Entities.manage(e2);
-            if (mgmt.getApplications().size()!=1)
-                Assert.fail("Apps in Apps should not be listed at top level: "+mgmt.getApplications());
+            TestApplication app = mgmt.getEntityManager().createEntity(org.apache.brooklyn.api.entity.EntitySpec.create(TestApplication.class));
+            TestApplication e2 = app.addChild(org.apache.brooklyn.api.entity.EntitySpec.create(TestApplication.class));
+            Asserts.assertEqualsIgnoringOrder(mgmt.getApplications(), ImmutableList.of(app));
         } finally {
             Entities.destroyAll(mgmt);
         }


Mime
View raw message