You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by he...@apache.org on 2016/03/18 12:06:27 UTC

[06/18] brooklyn-server git commit: update most tests to pass specs when configuring entity spec

update most tests to pass specs when configuring entity spec


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

Branch: refs/heads/master
Commit: d2c5cc81d1ac784f21c5aa0ebff365c0da6b85b6
Parents: 2876a9e
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Authored: Tue Mar 15 13:28:15 2016 +0000
Committer: Alex Heneveld <al...@cloudsoftcorp.com>
Committed: Tue Mar 15 13:28:15 2016 +0000

----------------------------------------------------------------------
 .../ssh/SshCommandEffectorIntegrationTest.java  |  5 +-
 .../brooklyn/core/location/MachinesTest.java    | 64 ++++++++++-------
 .../BrooklynMementoPersisterTestFixture.java    |  7 +-
 .../core/mgmt/rebind/RebindEntityTest.java      |  4 +-
 .../core/sensor/http/HttpRequestSensorTest.java | 17 ++---
 .../password/CreatePasswordSensorTest.java      |  3 +-
 .../ssh/SshCommandSensorIntegrationTest.java    |  9 +--
 .../core/test/entity/TestApplication.java       |  9 ++-
 .../util/core/text/TemplateProcessorTest.java   |  4 +-
 .../ActivityApiEntitlementsTest.java            |  5 +-
 .../ActivityApiEntitlementsTest.java            |  5 +-
 .../brooklynnode/SelectMasterEffectorTest.java  |  3 +-
 .../SimpleShellCommandIntegrationTest.java      | 74 +++++++++-----------
 13 files changed, 113 insertions(+), 96 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d2c5cc81/core/src/test/java/org/apache/brooklyn/core/effector/ssh/SshCommandEffectorIntegrationTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/effector/ssh/SshCommandEffectorIntegrationTest.java b/core/src/test/java/org/apache/brooklyn/core/effector/ssh/SshCommandEffectorIntegrationTest.java
index 7b5dd9a..c265ef4 100644
--- a/core/src/test/java/org/apache/brooklyn/core/effector/ssh/SshCommandEffectorIntegrationTest.java
+++ b/core/src/test/java/org/apache/brooklyn/core/effector/ssh/SshCommandEffectorIntegrationTest.java
@@ -25,6 +25,7 @@ import org.apache.brooklyn.api.location.Location;
 import org.apache.brooklyn.api.sensor.AttributeSensor;
 import org.apache.brooklyn.core.effector.Effectors;
 import org.apache.brooklyn.core.entity.Entities;
+import org.apache.brooklyn.core.location.Locations;
 import org.apache.brooklyn.core.sensor.Sensors;
 import org.apache.brooklyn.core.test.entity.TestApplication;
 import org.apache.brooklyn.core.test.entity.TestEntity;
@@ -51,8 +52,8 @@ public class SshCommandEffectorIntegrationTest {
     @BeforeMethod(alwaysRun=true)
     public void setUp() throws Exception {
         app = TestApplication.Factory.newManagedInstanceForTests();
-        machine = app.newLocalhostProvisioningLocation().obtain();
-        entity = app.createAndManageChild(EntitySpec.create(TestEntity.class).location(machine));
+        entity = app.createAndManageChild(EntitySpec.create(TestEntity.class).location(TestApplication.LOCALHOST_MACHINE_SPEC));
+        machine = Locations.findUniqueSshMachineLocation(entity.getLocations()).get();
         app.start(ImmutableList.<Location>of());
     }
 

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d2c5cc81/core/src/test/java/org/apache/brooklyn/core/location/MachinesTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/location/MachinesTest.java b/core/src/test/java/org/apache/brooklyn/core/location/MachinesTest.java
index 6e3875f..19c88df 100644
--- a/core/src/test/java/org/apache/brooklyn/core/location/MachinesTest.java
+++ b/core/src/test/java/org/apache/brooklyn/core/location/MachinesTest.java
@@ -23,9 +23,11 @@ import static org.testng.Assert.assertFalse;
 import static org.testng.Assert.assertTrue;
 
 import org.apache.brooklyn.api.entity.EntitySpec;
+import org.apache.brooklyn.api.location.Location;
 import org.apache.brooklyn.api.location.LocationSpec;
 import org.apache.brooklyn.core.entity.Attributes;
 import org.apache.brooklyn.core.test.BrooklynAppUnitTestSupport;
+import org.apache.brooklyn.core.test.entity.TestApplication;
 import org.apache.brooklyn.core.test.entity.TestEntity;
 import org.apache.brooklyn.location.localhost.LocalhostMachineProvisioningLocation;
 import org.apache.brooklyn.location.localhost.LocalhostMachineProvisioningLocation.LocalhostMachine;
@@ -40,46 +42,56 @@ public class MachinesTest extends BrooklynAppUnitTestSupport {
     protected String publicAddr = "1.2.3.4";
     protected String privateAddr = "10.1.2.3";
     
-    protected SshMachineLocation sshMachine;
-    protected SshMachineLocation sshMachineWithoutPrivate;
-    protected SshMachineLocation localMachine;
-    protected LocalhostMachineProvisioningLocation otherLoc;
+    protected LocationSpec<SshMachineLocation> sshMachineSpec;
+    protected LocationSpec<SshMachineLocation> sshMachineWithoutPrivateSpec;
+    protected LocationSpec<LocalhostMachineProvisioningLocation> otherLocSpec;
+    protected LocationSpec<LocalhostMachine> localMachineSpec;
     
     @BeforeMethod(alwaysRun=true)
     public void setUp() throws Exception {
         super.setUp();
-        sshMachine = mgmt.getLocationManager().createLocation(LocationSpec.create(SshMachineLocation.class)
+        sshMachineSpec = LocationSpec.create(SshMachineLocation.class)
                 .configure("address", publicAddr)
-                .configure(SshMachineLocation.PRIVATE_ADDRESSES, ImmutableList.of(privateAddr)));
-        sshMachineWithoutPrivate = mgmt.getLocationManager().createLocation(LocationSpec.create(SshMachineLocation.class)
-                .configure("address", publicAddr));
-        otherLoc = app.newLocalhostProvisioningLocation();
-        localMachine = otherLoc.obtain();
+                .configure(SshMachineLocation.PRIVATE_ADDRESSES, ImmutableList.of(privateAddr));
+        sshMachineWithoutPrivateSpec = LocationSpec.create(SshMachineLocation.class)
+                .configure("address", publicAddr);
+        otherLocSpec = TestApplication.LOCALHOST_PROVISIONER_SPEC;
+        localMachineSpec = TestApplication.LOCALHOST_MACHINE_SPEC;
+    }
+    
+    private <T extends Location> T create(LocationSpec<T> spec) {
+        return mgmt.getLocationManager().createLocation(spec);
     }
     
     @Test
     public void testFindUniqueMachineLocation() throws Exception {
-        assertEquals(Machines.findUniqueMachineLocation(ImmutableList.of(sshMachine, otherLoc)).get(), sshMachine);
-        assertFalse(Machines.findUniqueMachineLocation(ImmutableList.of(otherLoc)).isPresent());
+        SshMachineLocation l1 = create(sshMachineSpec);
+        LocalhostMachineProvisioningLocation l2 = create(otherLocSpec);
+        assertEquals(Machines.findUniqueMachineLocation(ImmutableList.of(l1, l2)).get(), l1);
+        assertFalse(Machines.findUniqueMachineLocation(ImmutableList.of(l2)).isPresent());
     }
     
     @Test
     @SuppressWarnings("deprecation")
     public void testFindUniqueSshMachineLocation() throws Exception {
-        assertEquals(Machines.findUniqueSshMachineLocation(ImmutableList.of(sshMachine, otherLoc)).get(), sshMachine);
-        assertFalse(Machines.findUniqueSshMachineLocation(ImmutableList.of(otherLoc)).isPresent());
+        SshMachineLocation l1 = create(sshMachineSpec);
+        LocalhostMachineProvisioningLocation l2 = create(otherLocSpec);
+        assertEquals(Machines.findUniqueSshMachineLocation(ImmutableList.of(l1, l2)).get(), l1);
+        assertFalse(Machines.findUniqueSshMachineLocation(ImmutableList.of(l2)).isPresent());
     }
     
     @Test
     public void testFindUniqueMachineLocationOfType() throws Exception {
-        assertEquals(Machines.findUniqueMachineLocation(ImmutableList.of(sshMachine, otherLoc), SshMachineLocation.class).get(), sshMachine);
-        assertFalse(Machines.findUniqueMachineLocation(ImmutableList.of(sshMachine), LocalhostMachine.class).isPresent());
+        SshMachineLocation l1 = create(sshMachineSpec);
+        LocalhostMachineProvisioningLocation l2 = create(otherLocSpec);
+        assertEquals(Machines.findUniqueMachineLocation(ImmutableList.of(l1, l2), SshMachineLocation.class).get(), l1);
+        assertFalse(Machines.findUniqueMachineLocation(ImmutableList.of(l2), LocalhostMachine.class).isPresent());
     }
     
     @Test
     public void testFindSubnetIpFromAttribute() throws Exception {
         TestEntity entity = app.addChild(EntitySpec.create(TestEntity.class)
-                .location(sshMachine));
+                .location(sshMachineSpec));
         entity.sensors().set(Attributes.SUBNET_ADDRESS, "myaddr");
         
         assertEquals(Machines.findSubnetIp(entity).get(), "myaddr");
@@ -88,7 +100,7 @@ public class MachinesTest extends BrooklynAppUnitTestSupport {
     @Test
     public void testFindSubnetIpFromLocation() throws Exception {
         TestEntity entity = app.addChild(EntitySpec.create(TestEntity.class)
-                .location(sshMachine));
+                .location(sshMachineSpec));
         
         assertEquals(Machines.findSubnetIp(entity).get(), privateAddr);
     }
@@ -96,7 +108,7 @@ public class MachinesTest extends BrooklynAppUnitTestSupport {
     @Test
     public void testFindSubnetHostnameFromAttribute() throws Exception {
         TestEntity entity = app.addChild(EntitySpec.create(TestEntity.class)
-                .location(sshMachine));
+                .location(sshMachineSpec));
         entity.sensors().set(Attributes.SUBNET_HOSTNAME, "myval");
         assertEquals(Machines.findSubnetHostname(entity).get(), "myval");
     }
@@ -104,7 +116,7 @@ public class MachinesTest extends BrooklynAppUnitTestSupport {
     @Test
     public void testFindSubnetHostnameFromLocation() throws Exception {
         TestEntity entity = app.addChild(EntitySpec.create(TestEntity.class)
-                .location(sshMachine));
+                .location(sshMachineSpec));
         
         assertEquals(Machines.findSubnetHostname(entity).get(), publicAddr);
     }
@@ -112,7 +124,7 @@ public class MachinesTest extends BrooklynAppUnitTestSupport {
     @Test
     public void testFindSubnetOrPrivateIpWithAddressAttributePrefersLocationPrivateIp() throws Exception {
         TestEntity entity = app.addChild(EntitySpec.create(TestEntity.class)
-                .location(sshMachine));
+                .location(sshMachineSpec));
         entity.sensors().set(Attributes.ADDRESS, "myval");
         
         assertEquals(Machines.findSubnetOrPrivateIp(entity).get(), privateAddr);
@@ -122,7 +134,7 @@ public class MachinesTest extends BrooklynAppUnitTestSupport {
     @Test
     public void testFindSubnetOrPrivateIpFromAttribute() throws Exception {
         TestEntity entity = app.addChild(EntitySpec.create(TestEntity.class)
-                .location(sshMachine));
+                .location(sshMachineSpec));
         entity.sensors().set(Attributes.ADDRESS, "ignored-val");
         entity.sensors().set(Attributes.SUBNET_ADDRESS, "myval");
         
@@ -133,7 +145,7 @@ public class MachinesTest extends BrooklynAppUnitTestSupport {
     @Test
     public void testFindSubnetOrPrivateIpFromLocation() throws Exception {
         TestEntity entity = app.addChild(EntitySpec.create(TestEntity.class)
-                .location(sshMachine));
+                .location(sshMachineSpec));
         entity.sensors().set(Attributes.ADDRESS, "ignored-val");
         
         assertEquals(Machines.findSubnetOrPrivateIp(entity).get(), privateAddr);
@@ -142,7 +154,7 @@ public class MachinesTest extends BrooklynAppUnitTestSupport {
     @Test
     public void testFindSubnetOrPrivateIpFromLocationWithoutPrivate() throws Exception {
         TestEntity entity = app.addChild(EntitySpec.create(TestEntity.class)
-                .location(sshMachineWithoutPrivate));
+                .location(sshMachineWithoutPrivateSpec));
         entity.sensors().set(Attributes.ADDRESS, "ignored-val");
         
         assertEquals(Machines.findSubnetOrPrivateIp(entity).get(), publicAddr);
@@ -150,9 +162,9 @@ public class MachinesTest extends BrooklynAppUnitTestSupport {
     
     @Test
     public void testWarnIfLocalhost() throws Exception {
-        assertFalse(Machines.warnIfLocalhost(ImmutableList.of(sshMachine), "my message"));
+        assertFalse(Machines.warnIfLocalhost(ImmutableList.of(create(sshMachineSpec)), "my message"));
         
         // Visual inspection test - expect a log.warn
-        assertTrue(Machines.warnIfLocalhost(ImmutableList.of(localMachine), "my message"));
+        assertTrue(Machines.warnIfLocalhost(ImmutableList.of(create(localMachineSpec)), "my message"));
     }
 }

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d2c5cc81/core/src/test/java/org/apache/brooklyn/core/mgmt/persist/BrooklynMementoPersisterTestFixture.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/mgmt/persist/BrooklynMementoPersisterTestFixture.java b/core/src/test/java/org/apache/brooklyn/core/mgmt/persist/BrooklynMementoPersisterTestFixture.java
index a355abd..4c8aac0 100644
--- a/core/src/test/java/org/apache/brooklyn/core/mgmt/persist/BrooklynMementoPersisterTestFixture.java
+++ b/core/src/test/java/org/apache/brooklyn/core/mgmt/persist/BrooklynMementoPersisterTestFixture.java
@@ -81,10 +81,9 @@ public abstract class BrooklynMementoPersisterTestFixture {
             objectStore = ((BrooklynMementoPersisterToObjectStore)persister).getObjectStore();
         }
         app = ApplicationBuilder.newManagedApp(EntitySpec.create(TestApplication.class), localManagementContext);
-        location =  localManagementContext.getLocationManager()
-            .createLocation(LocationSpec.create(SshMachineLocation.class)
-                .configure("address", "localhost"));
-        entity = app.createAndManageChild(EntitySpec.create(TestEntity.class).location(location));
+        entity = app.createAndManageChild(EntitySpec.create(TestEntity.class).location(
+            LocationSpec.create(SshMachineLocation.class).configure("address", "localhost")));
+        location = Iterables.getOnlyElement( entity.getLocations() );
         enricher = app.enrichers().add(Enrichers.builder().propagatingAll().from(entity).build());
         app.policies().add(policy = new TestPolicy());
     }

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d2c5cc81/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindEntityTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindEntityTest.java b/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindEntityTest.java
index 7c726e4..032f36d 100644
--- a/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindEntityTest.java
+++ b/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindEntityTest.java
@@ -187,8 +187,8 @@ public class RebindEntityTest extends RebindTestFixtureWithApp {
 
     @Test
     public void testRestoresEntityLocationAndCleansUp() throws Exception {
-        MyLocation loc = origManagementContext.getLocationManager().createLocation(LocationSpec.create(MyLocation.class));
-        origApp.createAndManageChild(EntitySpec.create(MyEntity.class).location(loc));
+        MyEntity child = origApp.createAndManageChild(EntitySpec.create(MyEntity.class).location(LocationSpec.create(MyLocation.class)));
+        Location loc = Iterables.getOnlyElement(child.getLocations());
         
         newApp = rebind();
         MyEntity newE = (MyEntity) Iterables.find(newApp.getChildren(), Predicates.instanceOf(MyEntity.class));

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d2c5cc81/core/src/test/java/org/apache/brooklyn/core/sensor/http/HttpRequestSensorTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/sensor/http/HttpRequestSensorTest.java b/core/src/test/java/org/apache/brooklyn/core/sensor/http/HttpRequestSensorTest.java
index 20169a9..34b2d79 100644
--- a/core/src/test/java/org/apache/brooklyn/core/sensor/http/HttpRequestSensorTest.java
+++ b/core/src/test/java/org/apache/brooklyn/core/sensor/http/HttpRequestSensorTest.java
@@ -18,18 +18,18 @@
  */
 package org.apache.brooklyn.core.sensor.http;
 
-import org.apache.brooklyn.api.entity.EntityLocal;
+import org.apache.brooklyn.api.entity.Entity;
 import org.apache.brooklyn.api.entity.EntitySpec;
 import org.apache.brooklyn.api.location.Location;
 import org.apache.brooklyn.api.sensor.AttributeSensor;
 import org.apache.brooklyn.core.entity.Attributes;
 import org.apache.brooklyn.core.entity.Entities;
+import org.apache.brooklyn.core.entity.EntityAsserts;
 import org.apache.brooklyn.core.sensor.Sensors;
-import org.apache.brooklyn.test.http.TestHttpRequestHandler;
-import org.apache.brooklyn.test.http.TestHttpServer;
 import org.apache.brooklyn.core.test.entity.TestApplication;
 import org.apache.brooklyn.core.test.entity.TestEntity;
-import org.apache.brooklyn.test.EntityTestUtils;
+import org.apache.brooklyn.test.http.TestHttpRequestHandler;
+import org.apache.brooklyn.test.http.TestHttpServer;
 import org.apache.brooklyn.util.core.config.ConfigBag;
 import org.apache.brooklyn.util.time.Duration;
 import org.testng.annotations.AfterMethod;
@@ -43,7 +43,7 @@ public class HttpRequestSensorTest {
     final static String TARGET_TYPE = "java.lang.String";
 
     private TestApplication app;
-    private EntityLocal entity;
+    private Entity entity;
 
     private TestHttpServer server;
     private String serverUrl;
@@ -57,7 +57,7 @@ public class HttpRequestSensorTest {
 
         app = TestApplication.Factory.newManagedInstanceForTests();
         entity = app.createAndManageChild(EntitySpec.create(TestEntity.class)
-                .location(app.newLocalhostProvisioningLocation().obtain()));
+                .location(TestApplication.LOCALHOST_MACHINE_SPEC));
         app.start(ImmutableList.<Location>of());
     }
 
@@ -67,6 +67,7 @@ public class HttpRequestSensorTest {
         server.stop();
     }
 
+    @SuppressWarnings("deprecation")
     @Test
     public void testHttpSensor() throws Exception {
         HttpRequestSensor<Integer> sensor = new HttpRequestSensor<Integer>(ConfigBag.newInstance()
@@ -75,10 +76,10 @@ public class HttpRequestSensorTest {
                 .configure(HttpRequestSensor.SENSOR_TYPE, TARGET_TYPE)
                 .configure(HttpRequestSensor.JSON_PATH, "$.myKey")
                 .configure(HttpRequestSensor.SENSOR_URI, serverUrl + "/myKey/myValue"));
-        sensor.apply(entity);
+        sensor.apply((org.apache.brooklyn.api.entity.EntityLocal)entity);
         entity.sensors().set(Attributes.SERVICE_UP, true);
 
-        EntityTestUtils.assertAttributeEqualsEventually(entity, SENSOR_STRING, "myValue");
+        EntityAsserts.assertAttributeEqualsEventually(entity, SENSOR_STRING, "myValue");
     }
 
 }

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d2c5cc81/core/src/test/java/org/apache/brooklyn/core/sensor/password/CreatePasswordSensorTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/sensor/password/CreatePasswordSensorTest.java b/core/src/test/java/org/apache/brooklyn/core/sensor/password/CreatePasswordSensorTest.java
index 0dc1126..d033e3d 100644
--- a/core/src/test/java/org/apache/brooklyn/core/sensor/password/CreatePasswordSensorTest.java
+++ b/core/src/test/java/org/apache/brooklyn/core/sensor/password/CreatePasswordSensorTest.java
@@ -24,6 +24,7 @@ import org.apache.brooklyn.api.sensor.AttributeSensor;
 import org.apache.brooklyn.core.entity.EntityInternal;
 import org.apache.brooklyn.core.sensor.Sensors;
 import org.apache.brooklyn.core.test.BrooklynAppUnitTestSupport;
+import org.apache.brooklyn.core.test.entity.TestApplication;
 import org.apache.brooklyn.core.test.entity.TestEntity;
 import org.apache.brooklyn.test.Asserts;
 import org.apache.brooklyn.util.core.config.ConfigBag;
@@ -42,7 +43,7 @@ public class CreatePasswordSensorTest extends BrooklynAppUnitTestSupport{
         super.setUp();
 
         entity = app.createAndManageChild(EntitySpec.create(TestEntity.class)
-                .location(app.newLocalhostProvisioningLocation().obtain()));
+                .location(TestApplication.LOCALHOST_MACHINE_SPEC));
         app.start(ImmutableList.<Location>of());
     }
 

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d2c5cc81/core/src/test/java/org/apache/brooklyn/core/sensor/ssh/SshCommandSensorIntegrationTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/sensor/ssh/SshCommandSensorIntegrationTest.java b/core/src/test/java/org/apache/brooklyn/core/sensor/ssh/SshCommandSensorIntegrationTest.java
index 54af885..86fed90 100644
--- a/core/src/test/java/org/apache/brooklyn/core/sensor/ssh/SshCommandSensorIntegrationTest.java
+++ b/core/src/test/java/org/apache/brooklyn/core/sensor/ssh/SshCommandSensorIntegrationTest.java
@@ -30,11 +30,12 @@ import org.apache.brooklyn.api.sensor.AttributeSensor;
 import org.apache.brooklyn.core.effector.Effectors;
 import org.apache.brooklyn.core.entity.Attributes;
 import org.apache.brooklyn.core.entity.Entities;
+import org.apache.brooklyn.core.entity.EntityAsserts;
+import org.apache.brooklyn.core.location.Locations;
 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.location.ssh.SshMachineLocation;
-import org.apache.brooklyn.test.EntityTestUtils;
 import org.apache.brooklyn.util.core.config.ConfigBag;
 import org.apache.brooklyn.util.time.Duration;
 import org.testng.Assert;
@@ -58,8 +59,8 @@ public class SshCommandSensorIntegrationTest {
     @BeforeMethod(alwaysRun=true)
     public void setUp() throws Exception {
         app = TestApplication.Factory.newManagedInstanceForTests();
-        machine = app.newLocalhostProvisioningLocation().obtain();
-        entity = app.createAndManageChild(EntitySpec.create(TestEntity.class).location(machine));
+        entity = app.createAndManageChild(EntitySpec.create(TestEntity.class).location(TestApplication.LOCALHOST_MACHINE_SPEC));
+        machine = Locations.findUniqueSshMachineLocation(entity.getLocations()).get();
         app.start(ImmutableList.<Location>of());
         tempFile = File.createTempFile("testSshCommand", ".txt");
     }
@@ -80,7 +81,7 @@ public class SshCommandSensorIntegrationTest {
             .apply(entity);
         entity.sensors().set(Attributes.SERVICE_UP, true);
 
-        String val = EntityTestUtils.assertAttributeEventuallyNonNull(entity, SENSOR_STRING);
+        String val = EntityAsserts.assertAttributeEventuallyNonNull(entity, SENSOR_STRING);
         assertTrue(val.contains("1"), "val="+val);
         String[] counts = val.trim().split("\\s+");
         Assert.assertEquals(counts.length, 4, "val="+val);

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d2c5cc81/core/src/test/java/org/apache/brooklyn/core/test/entity/TestApplication.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/test/entity/TestApplication.java b/core/src/test/java/org/apache/brooklyn/core/test/entity/TestApplication.java
index 974d4e6..358b6d4 100644
--- a/core/src/test/java/org/apache/brooklyn/core/test/entity/TestApplication.java
+++ b/core/src/test/java/org/apache/brooklyn/core/test/entity/TestApplication.java
@@ -23,6 +23,7 @@ import java.util.Map;
 import org.apache.brooklyn.api.entity.Entity;
 import org.apache.brooklyn.api.entity.EntitySpec;
 import org.apache.brooklyn.api.entity.ImplementedBy;
+import org.apache.brooklyn.api.location.LocationSpec;
 import org.apache.brooklyn.api.mgmt.ManagementContext;
 import org.apache.brooklyn.api.sensor.AttributeSensor;
 import org.apache.brooklyn.core.entity.EntityInternal;
@@ -40,11 +41,17 @@ import org.apache.brooklyn.location.localhost.LocalhostMachineProvisioningLocati
 public interface TestApplication extends StartableApplication, EntityInternal {
 
     public static final AttributeSensor<String> MY_ATTRIBUTE = Sensors.newStringSensor("test.myattribute", "Test attribute sensor");
+    
+    public static final LocationSpec<LocalhostMachineProvisioningLocation> LOCALHOST_PROVISIONER_SPEC = LocationSpec.create(LocalhostMachineProvisioningLocation.class);
+    public static final LocationSpec<LocalhostMachineProvisioningLocation.LocalhostMachine> LOCALHOST_MACHINE_SPEC = LocationSpec.create(LocalhostMachineProvisioningLocation.LocalhostMachine.class);
 
     public <T extends Entity> T createAndManageChild(EntitySpec<T> spec);
 
-    public SimulatedLocation newSimulatedLocation();
+    /** @deprecated since 0.9.0 give the location spec spec to the entity spec instead, 
+     * using {@link #LOCALHOST_PROVISIONER_SPEC} or {@link #LOCALHOST_MACHINE_SPEC} */ @Deprecated
     public LocalhostMachineProvisioningLocation newLocalhostProvisioningLocation();
+    // items below it would be nice to update; there are fewer of them but they are more involved 
+    public SimulatedLocation newSimulatedLocation();
     public LocalhostMachineProvisioningLocation newLocalhostProvisioningLocation(Map<?,?> flags);
 
     public static class Factory {

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d2c5cc81/core/src/test/java/org/apache/brooklyn/util/core/text/TemplateProcessorTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/util/core/text/TemplateProcessorTest.java b/core/src/test/java/org/apache/brooklyn/util/core/text/TemplateProcessorTest.java
index 8046725..0f8bf47 100644
--- a/core/src/test/java/org/apache/brooklyn/util/core/text/TemplateProcessorTest.java
+++ b/core/src/test/java/org/apache/brooklyn/util/core/text/TemplateProcessorTest.java
@@ -178,8 +178,8 @@ public class TemplateProcessorTest extends BrooklynAppUnitTestSupport {
 
     @Test
     public void testApplyTemplatedConfigWithAtributeWhenReadyInSpec() {
-        DynamicCluster cluster = app.createAndManageChild(EntitySpec.create(DynamicCluster.class).configure(DynamicCluster.INITIAL_SIZE, 0).location(
-                app.getManagementContext().getLocationManager().createLocation(LocationSpec.create(LocalhostMachineProvisioningLocation.LocalhostMachine.class))));
+        DynamicCluster cluster = app.createAndManageChild(EntitySpec.create(DynamicCluster.class).configure(DynamicCluster.INITIAL_SIZE, 0)
+            .location(LocationSpec.create(LocalhostMachineProvisioningLocation.LocalhostMachine.class)));
         cluster.config().set(DynamicCluster.MEMBER_SPEC,
                 EntitySpec.create(TestEntity.class).configure(TestEntity.CONF_NAME,
                         DependentConfiguration.attributeWhenReady(cluster, TestEntity.NAME)));

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d2c5cc81/rest/rest-server-jersey/src/test/java/org/apache/brooklyn/rest/entitlement/ActivityApiEntitlementsTest.java
----------------------------------------------------------------------
diff --git a/rest/rest-server-jersey/src/test/java/org/apache/brooklyn/rest/entitlement/ActivityApiEntitlementsTest.java b/rest/rest-server-jersey/src/test/java/org/apache/brooklyn/rest/entitlement/ActivityApiEntitlementsTest.java
index bb10197..2f1cc7b 100644
--- a/rest/rest-server-jersey/src/test/java/org/apache/brooklyn/rest/entitlement/ActivityApiEntitlementsTest.java
+++ b/rest/rest-server-jersey/src/test/java/org/apache/brooklyn/rest/entitlement/ActivityApiEntitlementsTest.java
@@ -32,9 +32,9 @@ import org.apache.brooklyn.api.mgmt.entitlement.EntitlementManager;
 import org.apache.brooklyn.core.entity.BrooklynConfigKeys;
 import org.apache.brooklyn.core.mgmt.BrooklynTaskTags;
 import org.apache.brooklyn.core.mgmt.entitlement.Entitlements;
+import org.apache.brooklyn.core.test.entity.TestApplication;
 import org.apache.brooklyn.entity.machine.MachineEntity;
 import org.apache.brooklyn.entity.software.base.AbstractSoftwareProcessStreamsTest;
-import org.apache.brooklyn.location.localhost.LocalhostMachineProvisioningLocation;
 import org.apache.brooklyn.util.core.task.TaskPredicates;
 import org.apache.brooklyn.util.text.StringPredicates;
 import org.testng.annotations.BeforeMethod;
@@ -55,10 +55,9 @@ public class ActivityApiEntitlementsTest extends AbstractRestApiEntitlementsTest
     public void setUp() throws Exception {
         super.setUp();
         
-        LocalhostMachineProvisioningLocation loc = app.newLocalhostProvisioningLocation();
         machineEntity = app.addChild(EntitySpec.create(MachineEntity.class)
                 .configure(BrooklynConfigKeys.SKIP_ON_BOX_BASE_DIR_RESOLUTION, true)
-                .location(loc));
+                .location(TestApplication.LOCALHOST_PROVISIONER_SPEC));
         machineEntity.start(ImmutableList.<Location>of());
         
         machineEntity.execCommand("echo myval");

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d2c5cc81/rest/rest-server/src/test/java/org/apache/brooklyn/rest/entitlement/ActivityApiEntitlementsTest.java
----------------------------------------------------------------------
diff --git a/rest/rest-server/src/test/java/org/apache/brooklyn/rest/entitlement/ActivityApiEntitlementsTest.java b/rest/rest-server/src/test/java/org/apache/brooklyn/rest/entitlement/ActivityApiEntitlementsTest.java
index bb10197..2f1cc7b 100644
--- a/rest/rest-server/src/test/java/org/apache/brooklyn/rest/entitlement/ActivityApiEntitlementsTest.java
+++ b/rest/rest-server/src/test/java/org/apache/brooklyn/rest/entitlement/ActivityApiEntitlementsTest.java
@@ -32,9 +32,9 @@ import org.apache.brooklyn.api.mgmt.entitlement.EntitlementManager;
 import org.apache.brooklyn.core.entity.BrooklynConfigKeys;
 import org.apache.brooklyn.core.mgmt.BrooklynTaskTags;
 import org.apache.brooklyn.core.mgmt.entitlement.Entitlements;
+import org.apache.brooklyn.core.test.entity.TestApplication;
 import org.apache.brooklyn.entity.machine.MachineEntity;
 import org.apache.brooklyn.entity.software.base.AbstractSoftwareProcessStreamsTest;
-import org.apache.brooklyn.location.localhost.LocalhostMachineProvisioningLocation;
 import org.apache.brooklyn.util.core.task.TaskPredicates;
 import org.apache.brooklyn.util.text.StringPredicates;
 import org.testng.annotations.BeforeMethod;
@@ -55,10 +55,9 @@ public class ActivityApiEntitlementsTest extends AbstractRestApiEntitlementsTest
     public void setUp() throws Exception {
         super.setUp();
         
-        LocalhostMachineProvisioningLocation loc = app.newLocalhostProvisioningLocation();
         machineEntity = app.addChild(EntitySpec.create(MachineEntity.class)
                 .configure(BrooklynConfigKeys.SKIP_ON_BOX_BASE_DIR_RESOLUTION, true)
-                .location(loc));
+                .location(TestApplication.LOCALHOST_PROVISIONER_SPEC));
         machineEntity.start(ImmutableList.<Location>of());
         
         machineEntity.execCommand("echo myval");

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d2c5cc81/software/base/src/test/java/org/apache/brooklyn/entity/brooklynnode/SelectMasterEffectorTest.java
----------------------------------------------------------------------
diff --git a/software/base/src/test/java/org/apache/brooklyn/entity/brooklynnode/SelectMasterEffectorTest.java b/software/base/src/test/java/org/apache/brooklyn/entity/brooklynnode/SelectMasterEffectorTest.java
index 4346d15..137e0a4 100644
--- a/software/base/src/test/java/org/apache/brooklyn/entity/brooklynnode/SelectMasterEffectorTest.java
+++ b/software/base/src/test/java/org/apache/brooklyn/entity/brooklynnode/SelectMasterEffectorTest.java
@@ -38,6 +38,7 @@ import org.apache.brooklyn.core.feed.AttributePollHandler;
 import org.apache.brooklyn.core.feed.DelegatingPollHandler;
 import org.apache.brooklyn.core.feed.Poller;
 import org.apache.brooklyn.core.test.BrooklynAppUnitTestSupport;
+import org.apache.brooklyn.core.test.entity.TestApplication;
 import org.apache.brooklyn.entity.brooklynnode.BrooklynCluster;
 import org.apache.brooklyn.entity.brooklynnode.BrooklynClusterImpl;
 import org.apache.brooklyn.entity.brooklynnode.BrooklynNode;
@@ -90,7 +91,7 @@ public class SelectMasterEffectorTest extends BrooklynAppUnitTestSupport {
         super.setUpApp();
         http = new HttpCallback();
         cluster = app.createAndManageChild(EntitySpec.create(BrooklynCluster.class)
-            .location(app.newLocalhostProvisioningLocation())
+            .location(TestApplication.LOCALHOST_PROVISIONER_SPEC)
             .configure(BrooklynCluster.MEMBER_SPEC, EntitySpec.create(BrooklynNode.class)
                 .impl(MockBrooklynNode.class)
                 .configure(MockBrooklynNode.HTTP_CLIENT_CALLBACK, http)));

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/d2c5cc81/test-framework/src/test/java/org/apache/brooklyn/test/framework/SimpleShellCommandIntegrationTest.java
----------------------------------------------------------------------
diff --git a/test-framework/src/test/java/org/apache/brooklyn/test/framework/SimpleShellCommandIntegrationTest.java b/test-framework/src/test/java/org/apache/brooklyn/test/framework/SimpleShellCommandIntegrationTest.java
index 9a3b339..7e53d59 100644
--- a/test-framework/src/test/java/org/apache/brooklyn/test/framework/SimpleShellCommandIntegrationTest.java
+++ b/test-framework/src/test/java/org/apache/brooklyn/test/framework/SimpleShellCommandIntegrationTest.java
@@ -18,47 +18,43 @@
  */
 package org.apache.brooklyn.test.framework;
 
-import com.google.common.collect.ImmutableList;
+import static org.apache.brooklyn.core.entity.trait.Startable.SERVICE_UP;
+import static org.apache.brooklyn.test.framework.SimpleShellCommandTest.ASSERT_OUT;
+import static org.apache.brooklyn.test.framework.SimpleShellCommandTest.ASSERT_STATUS;
+import static org.apache.brooklyn.test.framework.SimpleShellCommandTest.COMMAND;
+import static org.apache.brooklyn.test.framework.SimpleShellCommandTest.DOWNLOAD_URL;
+import static org.apache.brooklyn.test.framework.SimpleShellCommandTest.RUN_DIR;
+import static org.apache.brooklyn.test.framework.TargetableTestComponent.TARGET_ENTITY;
+import static org.apache.brooklyn.test.framework.TestFrameworkAssertions.CONTAINS;
+import static org.apache.brooklyn.test.framework.TestFrameworkAssertions.EQUALS;
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
 import org.apache.brooklyn.api.entity.EntitySpec;
+import org.apache.brooklyn.api.location.Location;
 import org.apache.brooklyn.core.entity.lifecycle.Lifecycle;
 import org.apache.brooklyn.core.entity.lifecycle.ServiceStateLogic;
 import org.apache.brooklyn.core.test.BrooklynAppUnitTestSupport;
+import org.apache.brooklyn.core.test.entity.TestApplication;
 import org.apache.brooklyn.core.test.entity.TestEntity;
-import org.apache.brooklyn.location.localhost.LocalhostMachineProvisioningLocation;
-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.exceptions.Exceptions;
 import org.apache.brooklyn.util.text.Identifiers;
-import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.DataProvider;
 import org.testng.annotations.Test;
 
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import static org.apache.brooklyn.test.framework.BaseTest.TARGET_ENTITY;
-import static org.apache.brooklyn.test.framework.SimpleShellCommandTest.*;
-import static org.apache.brooklyn.test.framework.TestFrameworkAssertions.CONTAINS;
-import static org.apache.brooklyn.test.framework.TestFrameworkAssertions.EQUALS;
-import static org.assertj.core.api.Assertions.assertThat;
+import com.google.common.collect.ImmutableList;
 
 public class SimpleShellCommandIntegrationTest extends BrooklynAppUnitTestSupport {
 
     private static final String UP = "up";
-    private LocalhostMachineProvisioningLocation loc;
-    private SshMachineLocation machine;
-
-    @BeforeMethod(alwaysRun = true)
-    public void setUp() throws Exception {
-        super.setUp();
-        loc = app.newLocalhostProvisioningLocation();
-        machine = loc.obtain();
-    }
 
     @DataProvider(name = "shouldInsistOnJustOneOfCommandAndScript")
     public Object[][] createData1() {
@@ -79,7 +75,7 @@ public class SimpleShellCommandIntegrationTest extends BrooklynAppUnitTestSuppor
             scriptPath = createTempScript("pwd", "pwd");
             scriptUrl = "file:" + scriptPath;
         }
-        TestEntity testEntity = app.createAndManageChild(EntitySpec.create(TestEntity.class).location(machine));
+        TestEntity testEntity = app.createAndManageChild(EntitySpec.create(TestEntity.class).location(TestApplication.LOCALHOST_MACHINE_SPEC));
 
         app.createAndManageChild(EntitySpec.create(SimpleShellCommandTest.class)
             .configure(TARGET_ENTITY, testEntity)
@@ -87,7 +83,7 @@ public class SimpleShellCommandIntegrationTest extends BrooklynAppUnitTestSuppor
             .configure(DOWNLOAD_URL, scriptUrl));
 
         try {
-            app.start(ImmutableList.of(loc));
+            app.start(ImmutableList.<Location>of());
             if (!valid) {
                 Asserts.shouldHaveFailedPreviously();
             }
@@ -114,13 +110,13 @@ public class SimpleShellCommandIntegrationTest extends BrooklynAppUnitTestSuppor
 
     @Test(groups = "Integration")
     public void shouldSucceedUsingSuccessfulExitAsDefaultCondition() {
-        TestEntity testEntity = app.createAndManageChild(EntitySpec.create(TestEntity.class).location(machine));
+        TestEntity testEntity = app.createAndManageChild(EntitySpec.create(TestEntity.class).location(TestApplication.LOCALHOST_MACHINE_SPEC));
 
         SimpleShellCommandTest uptime = app.createAndManageChild(EntitySpec.create(SimpleShellCommandTest.class)
             .configure(TARGET_ENTITY, testEntity)
             .configure(COMMAND, "uptime"));
 
-        app.start(ImmutableList.of(loc));
+        app.start(ImmutableList.<Location>of());
 
         assertThat(uptime.sensors().get(SERVICE_UP)).isTrue()
             .withFailMessage("Service should be up");
@@ -131,14 +127,14 @@ public class SimpleShellCommandIntegrationTest extends BrooklynAppUnitTestSuppor
 
     @Test(groups = "Integration")
     public void shouldFailUsingSuccessfulExitAsDefaultCondition() {
-        TestEntity testEntity = app.createAndManageChild(EntitySpec.create(TestEntity.class).location(machine));
+        TestEntity testEntity = app.createAndManageChild(EntitySpec.create(TestEntity.class).location(TestApplication.LOCALHOST_MACHINE_SPEC));
 
         SimpleShellCommandTest uptime = app.createAndManageChild(EntitySpec.create(SimpleShellCommandTest.class)
             .configure(TARGET_ENTITY, testEntity)
             .configure(COMMAND, "ls /tmp/bogus-" + Identifiers.randomLong()));
 
         try {
-            app.start(ImmutableList.of(loc));
+            app.start(ImmutableList.<Location>of());
         } catch (Throwable t) {
             Asserts.expectedFailureContains(t, "exit code equals 0");
         }
@@ -153,7 +149,7 @@ public class SimpleShellCommandIntegrationTest extends BrooklynAppUnitTestSuppor
 
     @Test(groups = "Integration")
     public void shouldInvokeCommand() {
-        TestEntity testEntity = app.createAndManageChild(EntitySpec.create(TestEntity.class).location(machine));
+        TestEntity testEntity = app.createAndManageChild(EntitySpec.create(TestEntity.class).location(TestApplication.LOCALHOST_MACHINE_SPEC));
 
         Map<String, Object> equalsZero = MutableMap.of();
         equalsZero.put(EQUALS, 0);
@@ -167,7 +163,7 @@ public class SimpleShellCommandIntegrationTest extends BrooklynAppUnitTestSuppor
             .configure(ASSERT_STATUS, makeAssertions(equalsZero))
             .configure(ASSERT_OUT, makeAssertions(containsUp)));
 
-        app.start(ImmutableList.of(loc));
+        app.start(ImmutableList.<Location>of());
 
         assertThat(uptime.sensors().get(SERVICE_UP)).isTrue()
             .withFailMessage("Service should be up");
@@ -178,7 +174,7 @@ public class SimpleShellCommandIntegrationTest extends BrooklynAppUnitTestSuppor
 
     @Test(groups = "Integration")
     public void shouldNotBeUpIfAssertionsFail() {
-        TestEntity testEntity = app.createAndManageChild(EntitySpec.create(TestEntity.class).location(machine));
+        TestEntity testEntity = app.createAndManageChild(EntitySpec.create(TestEntity.class).location(TestApplication.LOCALHOST_MACHINE_SPEC));
 
         Map<String, Object> equalsOne = MutableMap.of();
         equalsOne.put(EQUALS, 1);
@@ -192,7 +188,7 @@ public class SimpleShellCommandIntegrationTest extends BrooklynAppUnitTestSuppor
             .configure(ASSERT_STATUS, makeAssertions(equalsOne, equals255)));
 
         try {
-            app.start(ImmutableList.of(loc));
+            app.start(ImmutableList.<Location>of());
         } catch (Exception e) {
             Asserts.expectedFailureContains(e, "exit code equals 1", "exit code equals 255");
         }
@@ -204,7 +200,7 @@ public class SimpleShellCommandIntegrationTest extends BrooklynAppUnitTestSuppor
 
     @Test(groups = "Integration")
     public void shouldInvokeScript() throws Exception {
-        TestEntity testEntity = app.createAndManageChild(EntitySpec.create(TestEntity.class).location(machine));
+        TestEntity testEntity = app.createAndManageChild(EntitySpec.create(TestEntity.class).location(TestApplication.LOCALHOST_MACHINE_SPEC));
 
         String text = "hello world";
         Path testScript = createTempScript("script", "echo " + text);
@@ -223,7 +219,7 @@ public class SimpleShellCommandIntegrationTest extends BrooklynAppUnitTestSuppor
                 .configure(ASSERT_STATUS, makeAssertions(equalsZero))
                 .configure(ASSERT_OUT, makeAssertions(containsText)));
 
-            app.start(ImmutableList.of(loc));
+            app.start(ImmutableList.<Location>of());
 
             assertThat(uptime.sensors().get(SERVICE_UP)).isTrue()
                 .withFailMessage("Service should be up");
@@ -237,7 +233,7 @@ public class SimpleShellCommandIntegrationTest extends BrooklynAppUnitTestSuppor
 
     @Test(groups = "Integration")
     public void shouldExecuteInTheRunDir() throws Exception {
-        TestEntity testEntity = app.createAndManageChild(EntitySpec.create(TestEntity.class).location(machine));
+        TestEntity testEntity = app.createAndManageChild(EntitySpec.create(TestEntity.class).location(TestApplication.LOCALHOST_MACHINE_SPEC));
 
         Path pwdPath = createTempScript("pwd", "pwd");
 
@@ -264,7 +260,7 @@ public class SimpleShellCommandIntegrationTest extends BrooklynAppUnitTestSuppor
                 .configure(ASSERT_STATUS, makeAssertions(equalsZero))
                 .configure(ASSERT_OUT, makeAssertions(containsTmp)));
 
-            app.start(ImmutableList.of(loc));
+            app.start(ImmutableList.<Location>of());
 
             assertThat(pwd.sensors().get(SERVICE_UP)).isTrue().withFailMessage("Service should be up");
             assertThat(ServiceStateLogic.getExpectedState(pwd)).isEqualTo(Lifecycle.RUNNING)