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 2015/08/19 13:09:30 UTC

[12/72] [abbrv] incubator-brooklyn git commit: BROOKLYN-162 - apply org.apache package prefix to software-base, tidying package names, and moving a few sensory things to core

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/64c2b2e5/software/base/src/test/java/brooklyn/event/feed/jmx/JmxHelperTest.java
----------------------------------------------------------------------
diff --git a/software/base/src/test/java/brooklyn/event/feed/jmx/JmxHelperTest.java b/software/base/src/test/java/brooklyn/event/feed/jmx/JmxHelperTest.java
deleted file mode 100644
index 91bed65..0000000
--- a/software/base/src/test/java/brooklyn/event/feed/jmx/JmxHelperTest.java
+++ /dev/null
@@ -1,311 +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 brooklyn.event.feed.jmx;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.fail;
-
-import java.io.IOException;
-import java.util.List;
-
-import javax.management.DynamicMBean;
-import javax.management.MBeanOperationInfo;
-import javax.management.MBeanParameterInfo;
-import javax.management.Notification;
-import javax.management.NotificationListener;
-import javax.management.ObjectName;
-import javax.management.StandardEmitterMBean;
-
-import org.apache.brooklyn.test.TestUtils;
-import org.apache.brooklyn.util.collections.MutableMap;
-import org.apache.brooklyn.util.exceptions.Exceptions;
-import org.jclouds.util.Throwables2;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-import org.testng.collections.Lists;
-
-import brooklyn.test.GeneralisedDynamicMBean;
-import brooklyn.test.JmxService;
-
-import com.google.common.base.Function;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-
-public class JmxHelperTest {
-
-    private static final Logger log = LoggerFactory.getLogger(JmxHelperTest.class);
-    
-    private static final String LOCALHOST_NAME = "localhost";
-    
-    private static final int TIMEOUT_MS = 5000;
-    private static final int SHORT_WAIT_MS = 250;
-
-    private JmxService jmxService;
-    private JmxHelper jmxHelper;
-    
-    private String objectName = "Brooklyn:type=MyTestMBean,name=myname";
-    private String objectNameWithWildcard = "Brooklyn:type=MyTestMBean,name=mynam*";
-    private ObjectName jmxObjectName;
-    private ObjectName jmxObjectNameWithWildcard;
-    private String attributeName = "myattrib";
-    private String opName = "myop";
-    
-    @BeforeMethod(alwaysRun=true)
-    public void setUp() throws Exception {
-        jmxObjectName = new ObjectName(objectName);
-        jmxObjectNameWithWildcard = new ObjectName(objectNameWithWildcard);
-        jmxService = newJmxServiceRetrying(LOCALHOST_NAME, 5);
-        jmxHelper = new JmxHelper(jmxService.getUrl());
-        jmxHelper.setMinTimeBetweenReconnectAttempts(0);
-        jmxHelper.connect(TIMEOUT_MS);
-    }
-    
-    @AfterMethod(alwaysRun=true)
-    public void tearDown() throws Exception {
-        if (jmxHelper != null) jmxHelper.disconnect();
-        if (jmxService != null) jmxService.shutdown();
-        jmxHelper = null;
-        jmxService = null;
-    }
-
-    @Test
-    public void testGetAttribute() throws Exception {
-        GeneralisedDynamicMBean mbean = jmxService.registerMBean(MutableMap.of("myattr", "myval"), objectName);
-        assertEquals(jmxHelper.getAttribute(jmxObjectName, "myattr"), "myval");
-    }
-
-    @Test
-    public void testGetAttributeUsingObjectNameWildcard() throws Exception {
-        GeneralisedDynamicMBean mbean = jmxService.registerMBean(MutableMap.of("myattr", "myval"), objectName);
-        assertEquals(jmxHelper.getAttribute(jmxObjectNameWithWildcard, "myattr"), "myval");
-    }
-
-    @Test
-    public void testSetAttribute() throws Exception {
-        DynamicMBean mbean = jmxService.registerMBean(MutableMap.of("myattr", "myval"), objectName);
-
-        jmxHelper.setAttribute(jmxObjectName, "myattr", "abc");
-        Object actual = jmxHelper.getAttribute(jmxObjectName, "myattr");
-        assertEquals(actual, "abc");
-    }
-
-    @Test
-    public void testSetAttributeUsingObjectNameWildcard() throws Exception {
-        DynamicMBean mbean = jmxService.registerMBean(MutableMap.of("myattr", "myval"), objectName);
-
-        jmxHelper.setAttribute(jmxObjectNameWithWildcard, "myattr", "abc");
-        Object actual = jmxHelper.getAttribute(jmxObjectName, "myattr");
-        assertEquals(actual, "abc");
-    }
-
-    @Test
-    public void testInvokeOperationWithNoArgs() throws Exception {
-        final String opReturnVal = "my result";
-        MBeanOperationInfo opInfo = new MBeanOperationInfo(opName, "my descr", new MBeanParameterInfo[0], String.class.getName(), MBeanOperationInfo.ACTION);
-        Function<Object[], String> opImpl = new Function<Object[], String>() {
-            @Override public String apply(Object[] args) {
-                assertEquals(args.length, 0, "args="+args);
-                return opReturnVal;
-            }
-        };
-        GeneralisedDynamicMBean mbean = jmxService.registerMBean(ImmutableMap.of(), ImmutableMap.of(opInfo, opImpl), objectName);
-        
-        assertEquals(jmxHelper.operation(objectName, opName), opReturnVal);
-    }
-
-    @Test
-    public void testInvokeOperationUsingObjectNameWildcard() throws Exception {
-        final String opReturnVal = "my result";
-        MBeanOperationInfo opInfo = new MBeanOperationInfo(opName, "my descr", new MBeanParameterInfo[0], String.class.getName(), MBeanOperationInfo.ACTION);
-        Function<Object[], String> opImpl = new Function<Object[], String>() {
-            @Override public String apply(Object[] args) {
-                assertEquals(args.length, 0, "args="+args);
-                return opReturnVal;
-            }
-        };
-        GeneralisedDynamicMBean mbean = jmxService.registerMBean(ImmutableMap.of(), ImmutableMap.of(opInfo, opImpl), objectName);
-        
-        assertEquals(jmxHelper.operation(objectNameWithWildcard, opName), opReturnVal);
-    }
-
-    @Test
-    public void testInvokeOperationWithArgs() throws Exception {
-        final String opReturnPrefix = "my result prefix/";
-        String opParam1 = "my param 1";
-        MBeanOperationInfo opInfo = new MBeanOperationInfo(
-                opName, 
-                "my descr", 
-                new MBeanParameterInfo[] {new MBeanParameterInfo("myParam1", String.class.getName(), "my param1 descr")}, 
-                String.class.getName(), 
-                MBeanOperationInfo.ACTION);
-        Function<Object[],String> opImpl = new Function<Object[],String>() {
-            public String apply(Object[] input) {
-                return opReturnPrefix+input[0];
-            }
-        };
-        GeneralisedDynamicMBean mbean = jmxService.registerMBean(ImmutableMap.of(), ImmutableMap.of(opInfo, opImpl), objectName);
-        
-        assertEquals(jmxHelper.operation(objectName, opName, opParam1), opReturnPrefix+opParam1);
-    }
-
-    @Test
-    public void testReconnectsOnJmxServerTemporaryFailure() throws Exception {
-        int port = jmxService.getJmxPort();
-        GeneralisedDynamicMBean mbean = jmxService.registerMBean(MutableMap.of("myattr", "myval"), objectName);
-        assertEquals(jmxHelper.getAttribute(jmxObjectName, "myattr"), "myval");
-        
-        // Simulate temporary network-failure
-        jmxService.shutdown();
-
-        // Ensure that we have a failed query while the "network is down"         
-        try {
-            jmxHelper.getAttribute(jmxObjectName, attributeName);
-            fail();
-        } catch (Exception e) {
-            if (Throwables2.getFirstThrowableOfType(e, IOException.class) == null) {
-                throw e;
-            }
-        }
-
-        // Simulate the network restarting
-        jmxService = new JmxService(LOCALHOST_NAME, port);
-        
-        GeneralisedDynamicMBean mbean2 = jmxService.registerMBean(MutableMap.of("myattr", "myval2"), objectName);
-        assertEquals(jmxHelper.getAttribute(jmxObjectName, "myattr"), "myval2");
-    }
-    
-    @Test(expectedExceptions = {IllegalStateException.class})
-    public void testJmxCheckInstanceExistsEventuallyThrowsIfNotFound() throws Exception {
-        jmxHelper.assertMBeanExistsEventually(new ObjectName("Brooklyn:type=DoesNotExist,name=doesNotExist"), 1L);
-    }
-
-    @Test
-    public void testJmxObjectCheckExistsEventuallyReturnsIfFoundImmediately() throws Exception {
-        GeneralisedDynamicMBean mbean = jmxService.registerMBean(objectName);
-        jmxHelper.assertMBeanExistsEventually(jmxObjectName, 1L);
-    }
-
-    @Test
-    public void testJmxObjectCheckExistsEventuallyTakingLongReturnsIfFoundImmediately() throws Exception {
-        GeneralisedDynamicMBean mbean = jmxService.registerMBean(objectName);
-        jmxHelper.assertMBeanExistsEventually(jmxObjectName, 1L);
-    }
-
-    @Test
-    public void testJmxObjectCheckExistsEventuallyReturnsIfCreatedDuringPolling() throws Exception {
-        Thread t = new Thread(new Runnable() {
-                public void run() {
-                    try {
-                        Thread.sleep(SHORT_WAIT_MS);
-                        GeneralisedDynamicMBean mbean = jmxService.registerMBean(objectName);
-                    } catch (InterruptedException e) {
-                        return; // graceful return
-                    } catch (Exception e) {
-                        throw Exceptions.propagate(e);
-                    }
-                }});
-        try {
-            t.start();
-            
-            jmxHelper.assertMBeanExistsEventually(jmxObjectName, TIMEOUT_MS);
-        } finally {
-            t.interrupt();
-            t.join(TIMEOUT_MS);
-            assertFalse(t.isAlive());
-        }        
-    }
-
-    @Test
-    public void testSubscribeToJmxNotificationsDirectlyWithJmxHelper() throws Exception {
-        StandardEmitterMBean mbean = jmxService.registerMBean(ImmutableList.of("one"), objectName);
-        int sequence = 0;
-        final List<Notification> received = Lists.newArrayList();
-
-        jmxHelper.addNotificationListener(jmxObjectName, new NotificationListener() {
-            public void handleNotification(Notification notif, Object callback) {
-                received.add(notif);
-            }});
-                    
-
-        final Notification notif = sendNotification(mbean, "one", sequence++, "abc");
-
-        TestUtils.executeUntilSucceeds(ImmutableMap.of("timeout", TIMEOUT_MS), new Runnable() {
-            public void run() {
-                assertEquals(received.size(), 1);
-                assertNotificationsEqual(received.get(0), notif);
-            }});
-    }
-
-    // Visual-inspection test that LOG.warn happens only once; TODO setup a listener to the logging output
-    @Test
-    public void testMBeanNotFoundLoggedOnlyOncePerUrl() throws Exception {
-        ObjectName wrongObjectName = new ObjectName("DoesNotExist:type=DoesNotExist");
-
-        // Expect just one log message about:
-        //     JMX object DoesNotExist:type=DoesNotExist not found at service:jmx:rmi://localhost:1099/jndi/rmi://localhost:9001/jmxrmi"
-        for (int i = 0; i < 10; i++) {
-            jmxHelper.findMBean(wrongObjectName);
-        }
-
-        jmxService.shutdown();
-        jmxHelper.disconnect();
-        
-        jmxService = newJmxServiceRetrying(LOCALHOST_NAME, 5);
-        jmxHelper = new JmxHelper(jmxService.getUrl());
-        jmxHelper.connect();
-        
-        // Expect just one log message about:
-        //     JMX object DoesNotExist:type=DoesNotExist not found at service:jmx:rmi://localhost:1099/jndi/rmi://localhost:9001/jmxrmi"
-        for (int i = 0; i < 10; i++) {
-            jmxHelper.findMBean(wrongObjectName);
-        }
-    }
-
-    private JmxService newJmxServiceRetrying(String host, int retries) throws Exception {
-        Exception lastexception = null;
-        for (int i = 0; i < retries; i++) {
-            try {
-                return new JmxService(host, (int)(11000+(500*Math.random())));
-            } catch (Exception e) {
-                log.debug("Unable to create JMX service during test - "+retries+" retries remaining");
-                lastexception = e;
-            }
-        }
-        throw lastexception;
-    }
-
-    private Notification sendNotification(StandardEmitterMBean mbean, String type, long seq, Object userData) {
-        Notification notif = new Notification(type, mbean, seq);
-        notif.setUserData(userData);
-        mbean.sendNotification(notif);
-        return notif;
-    }
-    
-    private void assertNotificationsEqual(Notification n1, Notification n2) {
-        assertEquals(n1.getType(), n2.getType());
-        assertEquals(n1.getSequenceNumber(), n2.getSequenceNumber());
-        assertEquals(n1.getUserData(), n2.getUserData());
-        assertEquals(n1.getTimeStamp(), n2.getTimeStamp());
-        assertEquals(n1.getMessage(), n2.getMessage());
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/64c2b2e5/software/base/src/test/java/brooklyn/event/feed/jmx/RebindJmxFeedTest.java
----------------------------------------------------------------------
diff --git a/software/base/src/test/java/brooklyn/event/feed/jmx/RebindJmxFeedTest.java b/software/base/src/test/java/brooklyn/event/feed/jmx/RebindJmxFeedTest.java
deleted file mode 100644
index 271fd98..0000000
--- a/software/base/src/test/java/brooklyn/event/feed/jmx/RebindJmxFeedTest.java
+++ /dev/null
@@ -1,148 +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 brooklyn.event.feed.jmx;
-
-import static org.testng.Assert.assertEquals;
-
-import java.util.Collection;
-
-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.api.sensor.Feed;
-import org.apache.brooklyn.config.ConfigKey;
-import org.apache.brooklyn.core.config.ConfigKeys;
-import org.apache.brooklyn.core.mgmt.rebind.RebindTestFixtureWithApp;
-import org.apache.brooklyn.core.test.entity.TestEntity;
-import org.apache.brooklyn.core.test.entity.TestEntityImpl;
-import org.apache.brooklyn.entity.core.Attributes;
-import org.apache.brooklyn.sensor.core.Sensors;
-import org.apache.brooklyn.sensor.feed.ConfigToAttributes;
-import org.apache.brooklyn.test.EntityTestUtils;
-import org.apache.brooklyn.util.collections.MutableMap;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import brooklyn.entity.java.UsesJmx;
-import brooklyn.entity.java.UsesJmx.JmxAgentModes;
-
-import org.apache.brooklyn.location.basic.LocalhostMachineProvisioningLocation;
-import org.apache.brooklyn.location.basic.PortRanges;
-
-import brooklyn.test.GeneralisedDynamicMBean;
-import brooklyn.test.JmxService;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
-
-public class RebindJmxFeedTest extends RebindTestFixtureWithApp {
-
-    private static final Logger log = LoggerFactory.getLogger(RebindJmxFeedTest.class);
-
-    private static final String LOCALHOST_NAME = "localhost";
-
-    static final AttributeSensor<String> SENSOR_STRING = Sensors.newStringSensor("aString", "");
-    static final AttributeSensor<Integer> SENSOR_INT = Sensors.newIntegerSensor( "aLong", "");
-
-    static final String JMX_ATTRIBUTE_NAME = "myattr";
-    static final String OBJECT_NAME = "Brooklyn:type=MyTestMBean,name=myname";
-    
-    private JmxService jmxService;
-    
-    @BeforeMethod(alwaysRun=true)
-    @Override
-    public void setUp() throws Exception {
-        super.setUp();
-        
-        // Create an entity and configure it with the above JMX service
-        //jmxService = newJmxServiceRetrying(LOCALHOST_NAME, 5);
-    }
-    
-    @AfterMethod(alwaysRun=true)
-    @Override
-    public void tearDown() throws Exception {
-        if (jmxService != null) jmxService.shutdown();
-        super.tearDown();
-    }
-
-    @Test
-    public void testJmxFeedIsPersisted() throws Exception {
-        runJmxFeedIsPersisted(false);
-    }
-
-    @Test
-    public void testJmxFeedIsPersistedWithPreCreatedJmxHelper() throws Exception {
-        runJmxFeedIsPersisted(true);
-    }
-
-    protected void runJmxFeedIsPersisted(boolean preCreateJmxHelper) throws Exception {
-        TestEntity origEntity = origApp.createAndManageChild(EntitySpec.create(TestEntity.class).impl(MyEntityWithJmxFeedImpl.class)
-                .configure(MyEntityWithJmxFeedImpl.PRE_CREATE_JMX_HELPER, preCreateJmxHelper));
-        origApp.start(ImmutableList.<Location>of());
-        
-        jmxService = new JmxService(origEntity);
-        GeneralisedDynamicMBean mbean = jmxService.registerMBean(MutableMap.of(JMX_ATTRIBUTE_NAME, "myval"), OBJECT_NAME);
-        
-        EntityTestUtils.assertAttributeEqualsEventually(origEntity, SENSOR_STRING, "myval");
-        assertEquals(origEntity.feeds().getFeeds().size(), 1);
-
-        newApp = rebind();
-        TestEntity newEntity = (TestEntity) Iterables.getOnlyElement(newApp.getChildren());
-        
-        Collection<Feed> newFeeds = newEntity.feeds().getFeeds();
-        assertEquals(newFeeds.size(), 1);
-        
-        // Expect the feed to still be polling
-        newEntity.setAttribute(SENSOR_STRING, null);
-        EntityTestUtils.assertAttributeEqualsEventually(newEntity, SENSOR_STRING, "myval");
-    }
-
-    public static class MyEntityWithJmxFeedImpl extends TestEntityImpl {
-        public static final ConfigKey<Boolean> PRE_CREATE_JMX_HELPER = ConfigKeys.newBooleanConfigKey("test.rebindjmx.preCreateJmxHelper", "", false);
-        
-        @Override
-        public void start(Collection<? extends Location> locs) {
-            // TODO Auto-generated method stub
-            super.start(locs);
-            
-            setAttribute(Attributes.HOSTNAME, "localhost");
-            setAttribute(UsesJmx.JMX_PORT, 
-                    LocalhostMachineProvisioningLocation.obtainPort(PortRanges.fromString("40123+")));
-            // only supports no-agent, at the moment
-            setConfig(UsesJmx.JMX_AGENT_MODE, JmxAgentModes.NONE);
-            setAttribute(UsesJmx.RMI_REGISTRY_PORT, -1);  // -1 means to use the JMX_PORT only
-            ConfigToAttributes.apply(this, UsesJmx.JMX_CONTEXT);
-            
-            JmxFeed.Builder feedBuilder = JmxFeed.builder()
-                    .entity(this)
-                    .pollAttribute(new JmxAttributePollConfig<String>(SENSOR_STRING)
-                            .objectName(OBJECT_NAME)
-                            .period(50)
-                            .attributeName(JMX_ATTRIBUTE_NAME));
-            if (getConfig(PRE_CREATE_JMX_HELPER)) {
-                JmxHelper jmxHelper = new JmxHelper(this);
-                feedBuilder.helper(jmxHelper);
-            }
-            addFeed(feedBuilder.build());
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/64c2b2e5/software/base/src/test/java/brooklyn/management/usage/ApplicationUsageTrackingTest.java
----------------------------------------------------------------------
diff --git a/software/base/src/test/java/brooklyn/management/usage/ApplicationUsageTrackingTest.java b/software/base/src/test/java/brooklyn/management/usage/ApplicationUsageTrackingTest.java
deleted file mode 100644
index 9b275c9..0000000
--- a/software/base/src/test/java/brooklyn/management/usage/ApplicationUsageTrackingTest.java
+++ /dev/null
@@ -1,224 +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 brooklyn.management.usage;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertTrue;
-import static org.testng.Assert.fail;
-
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.brooklyn.api.entity.Application;
-import org.apache.brooklyn.api.location.Location;
-import org.apache.brooklyn.core.mgmt.internal.ManagementContextInternal;
-import org.apache.brooklyn.core.mgmt.internal.UsageListener.ApplicationMetadata;
-import org.apache.brooklyn.core.mgmt.usage.ApplicationUsage;
-import org.apache.brooklyn.core.mgmt.usage.ApplicationUsage.ApplicationEvent;
-import org.apache.brooklyn.core.objs.proxy.EntityProxy;
-import org.apache.brooklyn.core.test.entity.LocalManagementContextForTests;
-import org.apache.brooklyn.core.test.entity.TestApplication;
-import org.apache.brooklyn.entity.core.Entities;
-import org.apache.brooklyn.entity.lifecycle.Lifecycle;
-import org.apache.brooklyn.test.Asserts;
-import org.apache.brooklyn.util.time.Time;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import com.google.common.base.Predicates;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Iterables;
-
-public class ApplicationUsageTrackingTest {
-
-    private static final Logger LOG = LoggerFactory.getLogger(ApplicationUsageTrackingTest.class);
-
-    protected TestApplication app;
-    protected ManagementContextInternal mgmt;
-
-    protected boolean shouldSkipOnBoxBaseDirResolution() {
-        return true;
-    }
-
-    @BeforeMethod(alwaysRun=true)
-    public void setUp() throws Exception {
-        mgmt = LocalManagementContextForTests.newInstance();
-    }
-
-    @AfterMethod(alwaysRun=true)
-    public void tearDown() throws Exception {
-        try {
-            if (mgmt != null) Entities.destroyAll(mgmt);
-        } catch (Throwable t) {
-            LOG.error("Caught exception in tearDown method", t);
-        } finally {
-            mgmt = null;
-        }
-    }
-
-    @Test
-    public void testUsageInitiallyEmpty() {
-        Set<ApplicationUsage> usage = mgmt.getUsageManager().getApplicationUsage(Predicates.alwaysTrue());
-        assertEquals(usage, ImmutableSet.of());
-    }
-
-    @Test
-    @SuppressWarnings("deprecation")
-    public void testAddAndRemoveLegacyUsageListener() throws Exception {
-        final RecordingLegacyUsageListener listener = new RecordingLegacyUsageListener();
-        mgmt.getUsageManager().addUsageListener(listener);
-        
-        app = TestApplication.Factory.newManagedInstanceForTests(mgmt);
-        app.setCatalogItemId("testCatalogItem");
-        app.start(ImmutableList.<Location>of());
-
-        Asserts.succeedsEventually(new Runnable() {
-            @Override public void run() {
-                List<List<?>> events = listener.getApplicationEvents();
-                assertEquals(events.size(), 2, "events="+events); // expect STARTING and RUNNING
-                
-                String appId = (String) events.get(0).get(1);
-                String appName = (String) events.get(0).get(2);
-                String entityType = (String) events.get(0).get(3);
-                String catalogItemId = (String) events.get(0).get(4);
-                Map<?,?> metadata = (Map<?, ?>) events.get(0).get(5);
-                ApplicationEvent appEvent = (ApplicationEvent) events.get(0).get(6);
-                
-                assertEquals(appId, app.getId(), "events="+events);
-                assertNotNull(appName, "events="+events);
-                assertEquals(catalogItemId, app.getCatalogItemId(), "events="+events);
-                assertNotNull(entityType, "events="+events);
-                assertNotNull(metadata, "events="+events);
-                assertEquals(appEvent.getState(), Lifecycle.STARTING, "events="+events);
-            }});
-
-
-        // Remove the listener; will get no more notifications
-        listener.clearEvents();
-        mgmt.getUsageManager().removeUsageListener(listener);
-        
-        app.start(ImmutableList.<Location>of());
-        Asserts.succeedsContinually(new Runnable() {
-            @Override public void run() {
-                List<List<?>> events = listener.getLocationEvents();
-                assertEquals(events.size(), 0, "events="+events);
-            }});
-    }
-
-    @Test
-    public void testAddAndRemoveUsageListener() throws Exception {
-        final RecordingUsageListener listener = new RecordingUsageListener();
-        mgmt.getUsageManager().addUsageListener(listener);
-        
-        app = TestApplication.Factory.newManagedInstanceForTests(mgmt);
-        app.setCatalogItemId("testCatalogItem");
-        app.start(ImmutableList.<Location>of());
-
-        Asserts.succeedsEventually(new Runnable() {
-            @Override public void run() {
-                List<List<?>> events = listener.getApplicationEvents();
-                assertEquals(events.size(), 2, "events="+events); // expect STARTING and RUNNING
-                ApplicationMetadata appMetadata = (ApplicationMetadata) events.get(0).get(1);
-                ApplicationEvent appEvent = (ApplicationEvent) events.get(0).get(2);
-                
-                assertEquals(appMetadata.getApplication(), app, "events="+events);
-                assertTrue(appMetadata.getApplication() instanceof EntityProxy, "events="+events);
-                assertEquals(appMetadata.getApplicationId(), app.getId(), "events="+events);
-                assertNotNull(appMetadata.getApplicationName(), "events="+events);
-                assertEquals(appMetadata.getCatalogItemId(), app.getCatalogItemId(), "events="+events);
-                assertNotNull(appMetadata.getEntityType(), "events="+events);
-                assertNotNull(appMetadata.getMetadata(), "events="+events);
-                assertEquals(appEvent.getState(), Lifecycle.STARTING, "events="+events);
-            }});
-
-
-        // Remove the listener; will get no more notifications
-        listener.clearEvents();
-        mgmt.getUsageManager().removeUsageListener(listener);
-        
-        app.start(ImmutableList.<Location>of());
-        Asserts.succeedsContinually(new Runnable() {
-            @Override public void run() {
-                List<List<?>> events = listener.getLocationEvents();
-                assertEquals(events.size(), 0, "events="+events);
-            }});
-    }
-    
-    @Test
-    public void testUsageIncludesStartAndStopEvents() {
-        // Start event
-        long preStart = System.currentTimeMillis();
-        app = TestApplication.Factory.newManagedInstanceForTests(mgmt);
-        app.start(ImmutableList.<Location>of());
-        long postStart = System.currentTimeMillis();
-
-        Set<ApplicationUsage> usages1 = mgmt.getUsageManager().getApplicationUsage(Predicates.alwaysTrue());
-        ApplicationUsage usage1 = Iterables.getOnlyElement(usages1);
-        assertApplicationUsage(usage1, app);
-        assertApplicationEvent(usage1.getEvents().get(0), Lifecycle.STARTING, preStart, postStart);
-        assertApplicationEvent(usage1.getEvents().get(1), Lifecycle.RUNNING, preStart, postStart);
-
-        // Stop events
-        long preStop = System.currentTimeMillis();
-        app.stop();
-        long postStop = System.currentTimeMillis();
-
-        Set<ApplicationUsage> usages2 = mgmt.getUsageManager().getApplicationUsage(Predicates.alwaysTrue());
-        ApplicationUsage usage2 = Iterables.getOnlyElement(usages2);
-        assertApplicationUsage(usage2, app);
-        assertApplicationEvent(usage2.getEvents().get(2), Lifecycle.STOPPING, preStop, postStop);
-        assertApplicationEvent(usage2.getEvents().get(3), Lifecycle.STOPPED, preStop, postStop);
-        //Apps unmanage themselves on stop
-        assertApplicationEvent(usage2.getEvents().get(4), Lifecycle.DESTROYED, preStop, postStop);
-        
-        assertFalse(mgmt.getEntityManager().isManaged(app), "App should already be unmanaged");
-        
-        Set<ApplicationUsage> usages3 = mgmt.getUsageManager().getApplicationUsage(Predicates.alwaysTrue());
-        ApplicationUsage usage3 = Iterables.getOnlyElement(usages3);
-        assertApplicationUsage(usage3, app);
-        
-        assertEquals(usage3.getEvents().size(), 5, "usage="+usage3);
-    }
-    
-    private void assertApplicationUsage(ApplicationUsage usage, Application expectedApp) {
-        assertEquals(usage.getApplicationId(), expectedApp.getId());
-        assertEquals(usage.getApplicationName(), expectedApp.getDisplayName());
-        assertEquals(usage.getEntityType(), expectedApp.getEntityType().getName());
-    }
-    
-    private void assertApplicationEvent(ApplicationEvent event, Lifecycle expectedState, long preEvent, long postEvent) {
-        // Saw times differ by 1ms - perhaps different threads calling currentTimeMillis() can get out-of-order times?!
-        final int TIMING_GRACE = 5;
-        
-        assertEquals(event.getState(), expectedState);
-        long eventTime = event.getDate().getTime();
-        if (eventTime < (preEvent - TIMING_GRACE) || eventTime > (postEvent + TIMING_GRACE)) {
-            fail("for "+expectedState+": event=" + Time.makeDateString(eventTime) + "("+eventTime + "); "
-                    + "pre=" + Time.makeDateString(preEvent) + " ("+preEvent+ "); "
-                    + "post=" + Time.makeDateString(postEvent) + " ("+postEvent + ")");
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/64c2b2e5/software/base/src/test/java/brooklyn/management/usage/LocationUsageTrackingTest.java
----------------------------------------------------------------------
diff --git a/software/base/src/test/java/brooklyn/management/usage/LocationUsageTrackingTest.java b/software/base/src/test/java/brooklyn/management/usage/LocationUsageTrackingTest.java
deleted file mode 100644
index ce1ea1d..0000000
--- a/software/base/src/test/java/brooklyn/management/usage/LocationUsageTrackingTest.java
+++ /dev/null
@@ -1,212 +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 brooklyn.management.usage;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.fail;
-
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-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.location.LocationSpec;
-import org.apache.brooklyn.api.location.NoMachinesAvailableException;
-import org.apache.brooklyn.core.mgmt.internal.UsageListener.LocationMetadata;
-import org.apache.brooklyn.core.mgmt.usage.LocationUsage;
-import org.apache.brooklyn.core.mgmt.usage.LocationUsage.LocationEvent;
-import org.apache.brooklyn.core.test.BrooklynAppUnitTestSupport;
-import org.apache.brooklyn.entity.lifecycle.Lifecycle;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import brooklyn.entity.basic.SoftwareProcessEntityTest;
-
-import org.apache.brooklyn.location.basic.LocalhostMachineProvisioningLocation;
-import org.apache.brooklyn.location.basic.SshMachineLocation;
-import org.apache.brooklyn.test.Asserts;
-import org.apache.brooklyn.util.time.Time;
-
-import com.google.common.base.Predicates;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Iterables;
-
-public class LocationUsageTrackingTest extends BrooklynAppUnitTestSupport {
-
-    private DynamicLocalhostMachineProvisioningLocation loc;
-
-    @BeforeMethod(alwaysRun = true)
-    @Override
-    public void setUp() throws Exception {
-        super.setUp();
-        loc = mgmt.getLocationManager().createLocation(LocationSpec.create(DynamicLocalhostMachineProvisioningLocation.class));
-    }
-
-    @Test
-    public void testUsageInitiallyEmpty() {
-        Set<LocationUsage> usage = mgmt.getUsageManager().getLocationUsage(Predicates.alwaysTrue());
-        assertEquals(usage, ImmutableSet.of());
-    }
-
-    @Test
-    @SuppressWarnings("deprecation")
-    public void testAddAndRemoveLegacyUsageListener() throws Exception {
-        final RecordingLegacyUsageListener listener = new RecordingLegacyUsageListener();
-        mgmt.getUsageManager().addUsageListener(listener);
-        
-        app.createAndManageChild(EntitySpec.create(SoftwareProcessEntityTest.MyService.class));
-        app.start(ImmutableList.of(loc));
-        final SshMachineLocation machine = Iterables.getOnlyElement(loc.getAllMachines());
-        
-        Asserts.succeedsEventually(new Runnable() {
-            @Override public void run() {
-                List<List<?>> events = listener.getLocationEvents();
-                String locId = (String) events.get(0).get(1);
-                LocationEvent locEvent = (LocationEvent) events.get(0).get(3);
-                Map<?,?> metadata = (Map<?, ?>) events.get(0).get(2);
-                
-                assertEquals(events.size(), 1, "events="+events);
-                assertEquals(locId, machine.getId(), "events="+events);
-                assertNotNull(metadata, "events="+events);
-                assertEquals(locEvent.getApplicationId(), app.getId(), "events="+events);
-                assertEquals(locEvent.getState(), Lifecycle.CREATED, "events="+events);
-            }});
-
-        // Remove the listener; will get no more notifications
-        listener.clearEvents();
-        mgmt.getUsageManager().removeUsageListener(listener);
-        
-        app.stop();
-        Asserts.succeedsContinually(new Runnable() {
-            @Override public void run() {
-                List<List<?>> events = listener.getLocationEvents();
-                assertEquals(events.size(), 0, "events="+events);
-            }});
-    }
-
-    @Test
-    public void testAddAndRemoveUsageListener() throws Exception {
-        final RecordingUsageListener listener = new RecordingUsageListener();
-        mgmt.getUsageManager().addUsageListener(listener);
-        
-        app.createAndManageChild(EntitySpec.create(SoftwareProcessEntityTest.MyService.class));
-        app.start(ImmutableList.of(loc));
-        final SshMachineLocation machine = Iterables.getOnlyElement(loc.getAllMachines());
-        
-        Asserts.succeedsEventually(new Runnable() {
-            @Override public void run() {
-                List<List<?>> events = listener.getLocationEvents();
-                LocationMetadata locMetadata = (LocationMetadata) events.get(0).get(1);
-                LocationEvent locEvent = (LocationEvent) events.get(0).get(2);
-                
-                assertEquals(events.size(), 1, "events="+events);
-                assertEquals(locMetadata.getLocation(), machine, "events="+events);
-                assertEquals(locMetadata.getLocationId(), machine.getId(), "events="+events);
-                assertNotNull(locMetadata.getMetadata(), "events="+events);
-                assertEquals(locEvent.getApplicationId(), app.getId(), "events="+events);
-                assertEquals(locEvent.getState(), Lifecycle.CREATED, "events="+events);
-            }});
-
-        // Remove the listener; will get no more notifications
-        listener.clearEvents();
-        mgmt.getUsageManager().removeUsageListener(listener);
-        
-        app.stop();
-        Asserts.succeedsContinually(new Runnable() {
-            @Override public void run() {
-                List<List<?>> events = listener.getLocationEvents();
-                assertEquals(events.size(), 0, "events="+events);
-            }});
-    }
-
-    @Test
-    public void testUsageIncludesStartAndStopEvents() {
-        SoftwareProcessEntityTest.MyService entity = app.createAndManageChild(EntitySpec.create(SoftwareProcessEntityTest.MyService.class));
-
-        // Start the app; expect record of location in use
-        long preStart = System.currentTimeMillis();
-        app.start(ImmutableList.of(loc));
-        long postStart = System.currentTimeMillis();
-        SshMachineLocation machine = Iterables.getOnlyElement(loc.getAllMachines());
-
-        Set<LocationUsage> usages1 = mgmt.getUsageManager().getLocationUsage(Predicates.alwaysTrue());
-        LocationUsage usage1 = Iterables.getOnlyElement(usages1);
-        assertLocationUsage(usage1, machine);
-        assertLocationEvent(usage1.getEvents().get(0), entity, Lifecycle.CREATED, preStart, postStart);
-
-        // Stop the app; expect record of location no longer in use
-        long preStop = System.currentTimeMillis();
-        app.stop();
-        long postStop = System.currentTimeMillis();
-
-        Set<LocationUsage> usages2 = mgmt.getUsageManager().getLocationUsage(Predicates.alwaysTrue());
-        LocationUsage usage2 = Iterables.getOnlyElement(usages2);
-        assertLocationUsage(usage2, machine);
-        assertLocationEvent(usage2.getEvents().get(1), app.getApplicationId(), entity.getId(), entity.getEntityType().getName(), Lifecycle.DESTROYED, preStop, postStop);
-        
-        assertEquals(usage2.getEvents().size(), 2, "usage="+usage2);
-    }
-
-    public static class DynamicLocalhostMachineProvisioningLocation extends LocalhostMachineProvisioningLocation {
-        private static final long serialVersionUID = 4822009936654077946L;
-
-        @Override
-        public SshMachineLocation obtain(Map<?, ?> flags) throws NoMachinesAvailableException {
-            System.out.println("called DynamicLocalhostMachineProvisioningLocation.obtain");
-            return super.obtain(flags);
-        }
-
-        @Override
-        public void release(SshMachineLocation machine) {
-            System.out.println("called DynamicLocalhostMachineProvisioningLocation.release");
-            super.release(machine);
-            super.machines.remove(machine);
-            super.removeChild(machine);
-        }
-    }
-    
-    private void assertLocationUsage(LocationUsage usage, Location expectedLoc) {
-        assertEquals(usage.getLocationId(), expectedLoc.getId(), "usage="+usage);
-        assertNotNull(usage.getMetadata(), "usage="+usage);
-    }
-
-    private void assertLocationEvent(LocationEvent event, Entity expectedEntity, Lifecycle expectedState, long preEvent, long postEvent) {
-        assertLocationEvent(event, expectedEntity.getApplicationId(), expectedEntity.getId(), expectedEntity.getEntityType().getName(), expectedState, preEvent, postEvent);
-    }
-    
-    private void assertLocationEvent(LocationEvent event, String expectedAppId, String expectedEntityId, String expectedEntityType, Lifecycle expectedState, long preEvent, long postEvent) {
-        // Saw times differ by 1ms - perhaps different threads calling currentTimeMillis() can get out-of-order times?!
-        final int TIMING_GRACE = 5;
-        
-        assertEquals(event.getApplicationId(), expectedAppId);
-        assertEquals(event.getEntityId(), expectedEntityId);
-        assertEquals(event.getEntityType(), expectedEntityType);
-        assertEquals(event.getState(), expectedState);
-        long eventTime = event.getDate().getTime();
-        if (eventTime < (preEvent - TIMING_GRACE) || eventTime > (postEvent + TIMING_GRACE)) {
-            fail("for "+expectedState+": event=" + Time.makeDateString(eventTime) + "("+eventTime + "); "
-                    + "pre=" + Time.makeDateString(preEvent) + " ("+preEvent+ "); "
-                    + "post=" + Time.makeDateString(postEvent) + " ("+postEvent + ")");
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/64c2b2e5/software/base/src/test/java/brooklyn/management/usage/RecordingLegacyUsageListener.java
----------------------------------------------------------------------
diff --git a/software/base/src/test/java/brooklyn/management/usage/RecordingLegacyUsageListener.java b/software/base/src/test/java/brooklyn/management/usage/RecordingLegacyUsageListener.java
deleted file mode 100644
index 918e890..0000000
--- a/software/base/src/test/java/brooklyn/management/usage/RecordingLegacyUsageListener.java
+++ /dev/null
@@ -1,70 +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 brooklyn.management.usage;
-
-import java.util.List;
-import java.util.Map;
-
-import org.apache.brooklyn.core.mgmt.usage.ApplicationUsage.ApplicationEvent;
-import org.apache.brooklyn.core.mgmt.usage.LocationUsage.LocationEvent;
-import org.apache.brooklyn.util.collections.MutableList;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Lists;
-
-@Deprecated
-public class RecordingLegacyUsageListener implements org.apache.brooklyn.core.mgmt.internal.UsageManager.UsageListener {
-
-    private final List<List<?>> events = Lists.newCopyOnWriteArrayList();
-    
-    @Override
-    public void onApplicationEvent(String applicationId, String applicationName, String entityType, 
-            String catalogItemId, Map<String, String> metadata, ApplicationEvent event) {
-        events.add(MutableList.of("application", applicationId, applicationName, entityType, catalogItemId, metadata, event));
-    }
-
-    @Override
-    public void onLocationEvent(String locationId, Map<String, String> metadata, LocationEvent event) {
-        events.add(MutableList.of("location", locationId, metadata, event));
-    }
-    
-    public void clearEvents() {
-        events.clear();
-    }
-    
-    public List<List<?>> getEvents() {
-        return ImmutableList.copyOf(events);
-    }
-    
-    public List<List<?>> getLocationEvents() {
-        List<List<?>> result = Lists.newArrayList();
-        for (List<?> event : events) {
-            if (event.get(0).equals("location")) result.add(event);
-        }
-        return ImmutableList.copyOf(result);
-    }
-    
-    public List<List<?>> getApplicationEvents() {
-        List<List<?>> result = Lists.newArrayList();
-        for (List<?> event : events) {
-            if (event.get(0).equals("application")) result.add(event);
-        }
-        return ImmutableList.copyOf(result);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/64c2b2e5/software/base/src/test/java/brooklyn/management/usage/RecordingUsageListener.java
----------------------------------------------------------------------
diff --git a/software/base/src/test/java/brooklyn/management/usage/RecordingUsageListener.java b/software/base/src/test/java/brooklyn/management/usage/RecordingUsageListener.java
deleted file mode 100644
index b3fe39f..0000000
--- a/software/base/src/test/java/brooklyn/management/usage/RecordingUsageListener.java
+++ /dev/null
@@ -1,67 +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 brooklyn.management.usage;
-
-import java.util.List;
-
-import org.apache.brooklyn.core.mgmt.usage.ApplicationUsage.ApplicationEvent;
-import org.apache.brooklyn.core.mgmt.usage.LocationUsage.LocationEvent;
-import org.apache.brooklyn.util.collections.MutableList;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Lists;
-
-public class RecordingUsageListener implements org.apache.brooklyn.core.mgmt.internal.UsageListener {
-
-    private final List<List<?>> events = Lists.newCopyOnWriteArrayList();
-    
-    @Override
-    public void onApplicationEvent(ApplicationMetadata app, ApplicationEvent event) {
-        events.add(MutableList.of("application", app, event));
-    }
-
-    @Override
-    public void onLocationEvent(LocationMetadata loc, LocationEvent event) {
-        events.add(MutableList.of("location", loc, event));
-    }
-    
-    public void clearEvents() {
-        events.clear();
-    }
-    
-    public List<List<?>> getEvents() {
-        return ImmutableList.copyOf(events);
-    }
-    
-    public List<List<?>> getLocationEvents() {
-        List<List<?>> result = Lists.newArrayList();
-        for (List<?> event : events) {
-            if (event.get(0).equals("location")) result.add(event);
-        }
-        return ImmutableList.copyOf(result);
-    }
-    
-    public List<List<?>> getApplicationEvents() {
-        List<List<?>> result = Lists.newArrayList();
-        for (List<?> event : events) {
-            if (event.get(0).equals("application")) result.add(event);
-        }
-        return ImmutableList.copyOf(result);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/64c2b2e5/software/base/src/test/java/brooklyn/management/usage/UsageListenerTest.java
----------------------------------------------------------------------
diff --git a/software/base/src/test/java/brooklyn/management/usage/UsageListenerTest.java b/software/base/src/test/java/brooklyn/management/usage/UsageListenerTest.java
deleted file mode 100644
index 64d6723..0000000
--- a/software/base/src/test/java/brooklyn/management/usage/UsageListenerTest.java
+++ /dev/null
@@ -1,142 +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 brooklyn.management.usage;
-
-import static org.testng.Assert.assertTrue;
-
-import java.util.List;
-
-import org.apache.brooklyn.test.Asserts;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-import org.apache.brooklyn.api.location.Location;
-import org.apache.brooklyn.core.internal.BrooklynProperties;
-import org.apache.brooklyn.core.mgmt.internal.ManagementContextInternal;
-import org.apache.brooklyn.core.mgmt.internal.UsageManager;
-import org.apache.brooklyn.core.test.entity.LocalManagementContextForTests;
-import org.apache.brooklyn.core.test.entity.TestApplication;
-import org.apache.brooklyn.entity.core.Entities;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
-
-public class UsageListenerTest {
-
-    // Also see {Application|Location}UsageTrackingTest for listener functionality
-    
-    private static final Logger LOG = LoggerFactory.getLogger(ApplicationUsageTrackingTest.class);
-
-    protected TestApplication app;
-    protected ManagementContextInternal mgmt;
-
-    protected boolean shouldSkipOnBoxBaseDirResolution() {
-        return true;
-    }
-
-    @BeforeMethod(alwaysRun=true)
-    public void setUp() throws Exception {
-        RecordingStaticLegacyUsageListener.clearInstances();
-        RecordingStaticUsageListener.clearInstances();
-    }
-
-    @AfterMethod(alwaysRun=true)
-    public void tearDown() throws Exception {
-        try {
-            if (mgmt != null) Entities.destroyAll(mgmt);
-        } catch (Throwable t) {
-            LOG.error("Caught exception in tearDown method", t);
-        } finally {
-            mgmt = null;
-            RecordingStaticLegacyUsageListener.clearInstances();
-            RecordingStaticUsageListener.clearInstances();
-        }
-    }
-
-    @Test
-    public void testAddLegacyUsageListenerViaProperties() throws Exception {
-        BrooklynProperties brooklynProperties = BrooklynProperties.Factory.newEmpty();
-        brooklynProperties.put(UsageManager.USAGE_LISTENERS, RecordingStaticLegacyUsageListener.class.getName());
-        mgmt = LocalManagementContextForTests.newInstance(brooklynProperties);
-        
-        app = TestApplication.Factory.newManagedInstanceForTests(mgmt);
-        app.start(ImmutableList.<Location>of());
-
-        Asserts.succeedsEventually(new Runnable() {
-            @Override public void run() {
-                List<List<?>> events = RecordingStaticLegacyUsageListener.getInstance().getApplicationEvents();
-                assertTrue(events.size() > 0, "events="+events); // expect some events
-            }});
-    }
-    
-    @Test
-    public void testAddUsageListenerViaProperties() throws Exception {
-        BrooklynProperties brooklynProperties = BrooklynProperties.Factory.newEmpty();
-        brooklynProperties.put(UsageManager.USAGE_LISTENERS, RecordingStaticUsageListener.class.getName());
-        mgmt = LocalManagementContextForTests.newInstance(brooklynProperties);
-        
-        app = TestApplication.Factory.newManagedInstanceForTests(mgmt);
-        app.start(ImmutableList.<Location>of());
-
-        Asserts.succeedsEventually(new Runnable() {
-            @Override public void run() {
-                List<List<?>> events = RecordingStaticUsageListener.getInstance().getApplicationEvents();
-                assertTrue(events.size() > 0, "events="+events); // expect some events
-            }});
-    }
-    
-    public static class RecordingStaticLegacyUsageListener extends RecordingLegacyUsageListener implements org.apache.brooklyn.core.mgmt.internal.UsageManager.UsageListener {
-        private static final List<RecordingStaticLegacyUsageListener> STATIC_INSTANCES = Lists.newCopyOnWriteArrayList();
-        
-        public static RecordingStaticLegacyUsageListener getInstance() {
-            return Iterables.getOnlyElement(STATIC_INSTANCES);
-        }
-
-        public static void clearInstances() {
-            STATIC_INSTANCES.clear();
-        }
-        
-        public RecordingStaticLegacyUsageListener() {
-            // Bad to leak a ref to this before constructor finished, but we'll live with it because
-            // it's just test code!
-            STATIC_INSTANCES.add(this);
-        }
-    }
-    
-    public static class RecordingStaticUsageListener extends RecordingUsageListener implements org.apache.brooklyn.core.mgmt.internal.UsageListener {
-        private static final List<RecordingStaticUsageListener> STATIC_INSTANCES = Lists.newCopyOnWriteArrayList();
-        
-        public static RecordingStaticUsageListener getInstance() {
-            return Iterables.getOnlyElement(STATIC_INSTANCES);
-        }
-
-        public static void clearInstances() {
-            STATIC_INSTANCES.clear();
-        }
-        
-        public RecordingStaticUsageListener() {
-            // Bad to leak a ref to this before constructor finished, but we'll live with it because
-            // it's just test code!
-            STATIC_INSTANCES.add(this);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/64c2b2e5/software/base/src/test/java/brooklyn/test/GeneralisedDynamicMBean.java
----------------------------------------------------------------------
diff --git a/software/base/src/test/java/brooklyn/test/GeneralisedDynamicMBean.java b/software/base/src/test/java/brooklyn/test/GeneralisedDynamicMBean.java
deleted file mode 100644
index 11c8fbb..0000000
--- a/software/base/src/test/java/brooklyn/test/GeneralisedDynamicMBean.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 brooklyn.test;
-
-import static com.google.common.base.Preconditions.checkArgument;
-
-import java.util.Map;
-import java.util.Map.Entry;
-
-import javax.management.Attribute;
-import javax.management.AttributeList;
-import javax.management.DynamicMBean;
-import javax.management.MBeanAttributeInfo;
-import javax.management.MBeanConstructorInfo;
-import javax.management.MBeanInfo;
-import javax.management.MBeanNotificationInfo;
-import javax.management.MBeanOperationInfo;
-import javax.management.MBeanParameterInfo;
-
-import com.google.common.base.Function;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Maps;
-
-/**
- * A quick-and-simple general-purpose implementation of DynamicMBean.
- *
- * This class provides an implementation of {@link DynamicMBean}. Its initial set of attribute names and values are
- * provided to the constructor; from this it figures an {@link MBeanInfo}.
- * <p>
- * It presently assumes that all attributes are read-only; operations and notifications are not currently supported.
- * Choosing the descriptions is not supported - they are set to be the same as the name.
- * <p>
- * Getting a valid dynamic MBean (in Groovy) is as simple as:
- * <pre>
- * new GeneralisedDynamicMBean(meaning: 42, advice: "Don't panic")
- * </pre>
- */
-public class GeneralisedDynamicMBean implements DynamicMBean {
-    private final MBeanInfo mBeanInfo;
-    private final Map<String,Object> attributes = Maps.newLinkedHashMap();
-    private final Map<String,Function> operations = Maps.newLinkedHashMap();
-    
-    public GeneralisedDynamicMBean(Map<String,?> initialAttributes, Map<?,?> initialOperations) {
-        attributes.putAll(initialAttributes);
-
-        for (Entry<?,?> entry : initialOperations.entrySet()) {
-            checkArgument(entry.getKey() instanceof String || entry.getKey() instanceof MBeanOperationInfo, "entry.key=%s", entry.getKey());
-            String opName = (entry.getKey() instanceof String) ? (String)entry.getKey() : ((MBeanOperationInfo)entry.getKey()).getName();
-            operations.put(opName, (Function) entry.getValue());
-        }
-        
-        Iterable<MBeanAttributeInfo> attrInfo = Iterables.transform(initialAttributes.entrySet(), new Function<Map.Entry<String,?>, MBeanAttributeInfo>() {
-            @Override public MBeanAttributeInfo apply(Map.Entry<String,?> entry) {
-                return new MBeanAttributeInfo(entry.getKey(), entry.getValue().getClass().getName(), entry.getKey(), true, false, false);
-            }
-        });
-        
-        Iterable<MBeanOperationInfo> opInfo = Iterables.transform(initialOperations.keySet(), new Function<Object, MBeanOperationInfo>() {
-            public MBeanOperationInfo apply(Object it) {
-                if (it instanceof MBeanOperationInfo) {
-                    return (MBeanOperationInfo) it;
-                } else if (it instanceof CharSequence) {
-                    return new MBeanOperationInfo(
-                            it.toString(),
-                            "my descr", 
-                            new MBeanParameterInfo[0], 
-                            "void", 
-                            MBeanOperationInfo.ACTION_INFO);
-                } else {
-                    throw new IllegalArgumentException("Cannot convert "+it+" to MBeanOperationInfo");
-                }
-            }});
-        
-        mBeanInfo = new MBeanInfo(
-                GeneralisedDynamicMBean.class.getName(), 
-                GeneralisedDynamicMBean.class.getName(), 
-                Iterables.toArray(attrInfo, MBeanAttributeInfo.class),
-                new MBeanConstructorInfo[0], 
-                Iterables.toArray(opInfo, MBeanOperationInfo.class),
-                new MBeanNotificationInfo[0]);
-    }
-
-    public void updateAttributeValue(String name, Object value) {
-        attributes.put(name, value);
-    }
-
-    @Override
-    public Object getAttribute(String s) {
-        return attributes.get(s);
-    }
-
-    @Override
-    public void setAttribute(Attribute attribute) {
-        attributes.put(attribute.getName(), attribute.getValue());
-    }
-
-    @Override
-    public AttributeList getAttributes(String[] strings) {
-        AttributeList result = new AttributeList();
-        for (Object obj : mBeanInfo.getAttributes()) {
-            Attribute attrib = (Attribute) obj;
-            result.add(new Attribute(attrib.getName(), attributes.get(attrib.getName())));
-        }
-        return result;
-    }
-
-    @Override
-    public AttributeList setAttributes(AttributeList attributeList) {
-        for (Object element : attributeList) {
-            Attribute attrib = (Attribute) element;
-            attributes.put(attrib.getName(), attrib.getValue());
-        }
-        return attributeList;
-    }
-
-    @Override
-    public Object invoke(String s, Object[] objects, String[] strings) {
-        Function op = operations.get(s);
-        if (op != null) {
-            return op.apply(objects);
-        } else {
-            throw new RuntimeException("Unknown operation "+s);
-        }
-    }
-
-    @Override
-    public MBeanInfo getMBeanInfo() {
-        return mBeanInfo;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/64c2b2e5/software/base/src/test/java/brooklyn/test/JmxService.java
----------------------------------------------------------------------
diff --git a/software/base/src/test/java/brooklyn/test/JmxService.java b/software/base/src/test/java/brooklyn/test/JmxService.java
deleted file mode 100644
index 197f4d4..0000000
--- a/software/base/src/test/java/brooklyn/test/JmxService.java
+++ /dev/null
@@ -1,173 +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 brooklyn.test;
-
-import java.io.IOException;
-import java.util.List;
-import java.util.Map;
-import java.util.Random;
-
-import javax.management.InstanceAlreadyExistsException;
-import javax.management.MBeanNotificationInfo;
-import javax.management.MBeanRegistrationException;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerFactory;
-import javax.management.MBeanServerInvocationHandler;
-import javax.management.MalformedObjectNameException;
-import javax.management.NotCompliantMBeanException;
-import javax.management.Notification;
-import javax.management.NotificationBroadcasterSupport;
-import javax.management.NotificationEmitter;
-import javax.management.ObjectName;
-import javax.management.StandardEmitterMBean;
-import javax.management.remote.JMXConnectorServer;
-import javax.management.remote.JMXConnectorServerFactory;
-import javax.management.remote.JMXServiceURL;
-
-import mx4j.tools.naming.NamingService;
-import mx4j.tools.naming.NamingServiceMBean;
-
-import org.apache.brooklyn.api.entity.Entity;
-import org.apache.brooklyn.entity.core.Attributes;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import brooklyn.entity.java.UsesJmx;
-import brooklyn.event.feed.jmx.JmxHelper;
-
-import com.google.common.base.Preconditions;
-import com.google.common.collect.ImmutableMap;
-
-/**
- * Set up a JMX service ready for clients to connect. This consists of an MBean server, a connector server and a naming
- * service.
- */
-public class JmxService {
-    private static final Logger logger = LoggerFactory.getLogger(JmxService.class);
-
-    private MBeanServer server;
-    private NamingServiceMBean namingServiceMBean;
-    private JMXConnectorServer connectorServer;
-    private String jmxHost;
-    private int jmxPort;
-    private String url;
-
-    public JmxService() throws Exception {
-        this("localhost", 28000 + (int)Math.floor(new Random().nextDouble() * 1000));
-        logger.warn("use of deprecated default host and port in JmxService");
-    }
-    
-    /**
-     * @deprecated since 0.6.0; either needs abandoning, or updating to support JmxSupport (and JmxmpAgent, etc) */
-    public JmxService(Entity e) throws Exception {
-        this(e.getAttribute(Attributes.HOSTNAME) != null ? e.getAttribute(Attributes.HOSTNAME) : "localhost", 
-                 e.getAttribute(UsesJmx.JMX_PORT) != null ? e.getAttribute(UsesJmx.JMX_PORT) : null);
-    }
-    
-    public JmxService(String jmxHost, Integer jmxPort) throws Exception {
-        this.jmxHost = jmxHost;
-        Preconditions.checkNotNull(jmxPort, "JMX_PORT must be set when starting JmxService"); 
-        this.jmxPort = jmxPort;
-        url = JmxHelper.toRmiJmxUrl(jmxHost, jmxPort, jmxPort, "jmxrmi");
-
-        try {
-            JMXServiceURL address = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://" + jmxHost + ":" + jmxPort + "/jmxrmi");
-            connectorServer = JMXConnectorServerFactory.newJMXConnectorServer(address, null, null);
-            server = MBeanServerFactory.createMBeanServer();
-            ObjectName cntorServerName = ObjectName.getInstance("connectors:protocol=rmi");
-            server.registerMBean(connectorServer, cntorServerName);
-    
-            ObjectName naming = new ObjectName("Naming:type=registry");
-            server.registerMBean(new NamingService(jmxPort), naming);
-            Object proxy = MBeanServerInvocationHandler.newProxyInstance(server, naming, NamingServiceMBean.class, false);
-            namingServiceMBean = (NamingServiceMBean) proxy;
-            try {
-                namingServiceMBean.start();
-            } catch (Exception e) {
-                // may take a bit of time for port to be available, if it had just been used
-                logger.warn("JmxService couldn't start test mbean ("+e+"); will delay then retry once");
-                Thread.sleep(1000);
-                namingServiceMBean.start();
-            }
-    
-            connectorServer.start();
-            logger.info("JMX tester service started at URL {}", address);
-        } catch (Exception e) {
-            try {
-                shutdown();
-            } catch (Exception e2) {
-                logger.warn("Error shutting down JmxService, after error during startup; rethrowing original error", e2);
-            }
-            throw e;
-        }
-    }
-
-    public int getJmxPort() {
-        return jmxPort;
-    }
-    
-    public void shutdown() throws IOException {
-        if (connectorServer != null) connectorServer.stop();
-        if (namingServiceMBean != null) namingServiceMBean.stop();
-        if (server != null) MBeanServerFactory.releaseMBeanServer(server);
-        connectorServer = null;
-        namingServiceMBean = null;
-        server = null;
-        logger.info("JMX tester service stopped ({}:{})", jmxHost, jmxPort);
-    }
-
-    public String getUrl() {
-        return url;
-    }
-    
-    public GeneralisedDynamicMBean registerMBean(String name) throws InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException, MalformedObjectNameException, NullPointerException {
-        return registerMBean(ImmutableMap.of(), ImmutableMap.of(), name);
-    }
-
-    /**
-     * Construct a {@link GeneralisedDynamicMBean} and register it with this MBean server.
-     *
-     * @param initialAttributes a {@link Map} of attributes that make up the MBean's initial set of attributes and their * values
-     * @param name the name of the MBean
-     * @return the newly created and registered MBean
-     * @throws NullPointerException 
-     * @throws MalformedObjectNameException 
-     * @throws NotCompliantMBeanException 
-     * @throws MBeanRegistrationException 
-     * @throws InstanceAlreadyExistsException 
-     */
-    public GeneralisedDynamicMBean registerMBean(Map initialAttributes, String name) throws InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException, MalformedObjectNameException, NullPointerException {
-        return registerMBean(initialAttributes, ImmutableMap.of(), name);
-    }
-    
-    public GeneralisedDynamicMBean registerMBean(Map initialAttributes, Map operations, String name) throws InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException, MalformedObjectNameException, NullPointerException {
-        GeneralisedDynamicMBean mbean = new GeneralisedDynamicMBean(initialAttributes, operations);
-        server.registerMBean(mbean, new ObjectName(name));
-        return mbean;
-    }
-    
-    public StandardEmitterMBean registerMBean(List<String> notifications, String name) throws InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException, MalformedObjectNameException, NullPointerException {
-        String[] types = (String[]) notifications.toArray(new String[0]);
-        MBeanNotificationInfo info = new MBeanNotificationInfo(types, Notification.class.getName(), "Notification");
-        NotificationEmitter emitter = new NotificationBroadcasterSupport(info);
-        StandardEmitterMBean mbean = new StandardEmitterMBean(emitter, NotificationEmitter.class, emitter);
-        server.registerMBean(mbean, new ObjectName(name));
-        return mbean;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/64c2b2e5/software/base/src/test/java/org/apache/brooklyn/entity/AbstractEc2LiveTest.java
----------------------------------------------------------------------
diff --git a/software/base/src/test/java/org/apache/brooklyn/entity/AbstractEc2LiveTest.java b/software/base/src/test/java/org/apache/brooklyn/entity/AbstractEc2LiveTest.java
new file mode 100644
index 0000000..0a1e9d7
--- /dev/null
+++ b/software/base/src/test/java/org/apache/brooklyn/entity/AbstractEc2LiveTest.java
@@ -0,0 +1,139 @@
+/*
+ * 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.entity;
+
+import java.util.Map;
+
+import org.apache.brooklyn.util.collections.MutableMap;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+import org.apache.brooklyn.api.location.Location;
+import org.apache.brooklyn.core.internal.BrooklynProperties;
+import org.apache.brooklyn.core.test.BrooklynAppLiveTestSupport;
+import org.apache.brooklyn.core.test.entity.LocalManagementContextForTests;
+import org.apache.brooklyn.location.jclouds.JcloudsLocation;
+import org.apache.brooklyn.location.jclouds.JcloudsLocationConfig;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+
+/**
+ * Runs a test with many different distros and versions.
+ */
+public abstract class AbstractEc2LiveTest extends BrooklynAppLiveTestSupport {
+    
+    // FIXME Currently have just focused on test_Debian_6; need to test the others as well!
+
+    // TODO No nice fedora VMs
+    
+    // TODO Instead of this sub-classing approach, we could use testng's "provides" mechanism
+    // to say what combo of provider/region/flags should be used. The problem with that is the
+    // IDE integration: one can't just select a single test to run.
+    
+    public static final String PROVIDER = "aws-ec2";
+    public static final String REGION_NAME = "us-east-1";
+    public static final String LOCATION_SPEC = PROVIDER + (REGION_NAME == null ? "" : ":" + REGION_NAME);
+    public static final String TINY_HARDWARE_ID = "t1.micro";
+    public static final String SMALL_HARDWARE_ID = "m1.small";
+    
+    protected BrooklynProperties brooklynProperties;
+    
+    protected Location jcloudsLocation;
+    
+    @BeforeMethod(alwaysRun=true)
+    @Override
+    public void setUp() throws Exception {
+        // Don't let any defaults from brooklyn.properties (except credentials) interfere with test
+        brooklynProperties = BrooklynProperties.Factory.newDefault();
+        brooklynProperties.remove("brooklyn.jclouds."+PROVIDER+".image-description-regex");
+        brooklynProperties.remove("brooklyn.jclouds."+PROVIDER+".image-name-regex");
+        brooklynProperties.remove("brooklyn.jclouds."+PROVIDER+".image-id");
+        brooklynProperties.remove("brooklyn.jclouds."+PROVIDER+".inboundPorts");
+        brooklynProperties.remove("brooklyn.jclouds."+PROVIDER+".hardware-id");
+
+        // Also removes scriptHeader (e.g. if doing `. ~/.bashrc` and `. ~/.profile`, then that can cause "stdin: is not a tty")
+        brooklynProperties.remove("brooklyn.ssh.config.scriptHeader");
+        
+        mgmt = new LocalManagementContextForTests(brooklynProperties);
+        
+        super.setUp();
+    }
+
+    // Image ids for Debian: https://wiki.debian.org/Cloud/AmazonEC2Image/Squeeze
+    @Test(groups = {"Live"})
+    public void test_Debian_6() throws Exception {
+        // release codename "squeeze"
+        runTest(ImmutableMap.of("imageId", "us-east-1/ami-5e12dc36", "loginUser", "admin", "hardwareId", SMALL_HARDWARE_ID));
+    }
+
+    @Test(groups = {"Live"})
+    public void test_Debian_7_2() throws Exception {
+        // release codename "wheezy"
+        runTest(ImmutableMap.of("imageId", "us-east-1/ami-5586a43c", "loginUser", "admin", "hardwareId", SMALL_HARDWARE_ID));
+    }
+
+    @Test(groups = {"Live"})
+    public void test_Ubuntu_10_0() throws Exception {
+        // Image: {id=us-east-1/ami-5e008437, providerId=ami-5e008437, name=RightImage_Ubuntu_10.04_x64_v5.8.8.3, location={scope=REGION, id=us-east-1, description=us-east-1, parent=aws-ec2, iso3166Codes=[US-VA]}, os={family=ubuntu, arch=paravirtual, version=10.04, description=rightscale-us-east/RightImage_Ubuntu_10.04_x64_v5.8.8.3.manifest.xml, is64Bit=true}, description=rightscale-us-east/RightImage_Ubuntu_10.04_x64_v5.8.8.3.manifest.xml, version=5.8.8.3, status=AVAILABLE[available], loginUser=root, userMetadata={owner=411009282317, rootDeviceType=instance-store, virtualizationType=paravirtual, hypervisor=xen}}
+        runTest(ImmutableMap.of("imageId", "us-east-1/ami-5e008437", "loginUser", "root", "hardwareId", SMALL_HARDWARE_ID));
+    }
+
+    @Test(groups = {"Live"})
+    public void test_Ubuntu_12_0() throws Exception {
+        // Image: {id=us-east-1/ami-d0f89fb9, providerId=ami-d0f89fb9, name=ubuntu/images/ebs/ubuntu-precise-12.04-amd64-server-20130411.1, location={scope=REGION, id=us-east-1, description=us-east-1, parent=aws-ec2, iso3166Codes=[US-VA]}, os={family=ubuntu, arch=paravirtual, version=12.04, description=099720109477/ubuntu/images/ebs/ubuntu-precise-12.04-amd64-server-20130411.1, is64Bit=true}, description=099720109477/ubuntu/images/ebs/ubuntu-precise-12.04-amd64-server-20130411.1, version=20130411.1, status=AVAILABLE[available], loginUser=ubuntu, userMetadata={owner=099720109477, rootDeviceType=ebs, virtualizationType=paravirtual, hypervisor=xen}}
+        runTest(ImmutableMap.of("imageId", "us-east-1/ami-d0f89fb9", "loginUser", "ubuntu", "hardwareId", SMALL_HARDWARE_ID));
+    }
+
+    @Test(groups = {"Live"})
+    public void test_CentOS_6_3() throws Exception {
+        // TODO Should openIptables=true be the default?!
+        // Image: {id=us-east-1/ami-a96b01c0, providerId=ami-a96b01c0, name=CentOS-6.3-x86_64-GA-EBS-02-85586466-5b6c-4495-b580-14f72b4bcf51-ami-bb9af1d2.1, location={scope=REGION, id=us-east-1, description=us-east-1, parent=aws-ec2, iso3166Codes=[US-VA]}, os={family=centos, arch=paravirtual, version=6.3, description=aws-marketplace/CentOS-6.3-x86_64-GA-EBS-02-85586466-5b6c-4495-b580-14f72b4bcf51-ami-bb9af1d2.1, is64Bit=true}, description=CentOS-6.3-x86_64-GA-EBS-02 on EBS x86_64 20130527:1219, version=bb9af1d2.1, status=AVAILABLE[available], loginUser=root, userMetadata={owner=679593333241, rootDeviceType=ebs, virtualizationType=paravirtual, hypervisor=xen}})
+        runTest(ImmutableMap.of("imageId", "us-east-1/ami-a96b01c0", "hardwareId", SMALL_HARDWARE_ID, JcloudsLocation.OPEN_IPTABLES.getName(), true));
+    }
+
+    @Test(groups = {"Live"})
+    public void test_CentOS_5() throws Exception {
+        // Image: {id=us-east-1/ami-e4bffe8d, providerId=ami-e4bffe8d, name=RightImage_CentOS_5.9_x64_v12.11.4_EBS, location={scope=REGION, id=us-east-1, description=us-east-1, parent=aws-ec2, iso3166Codes=[US-VA]}, os={family=centos, arch=paravirtual, version=5.0, description=411009282317/RightImage_CentOS_5.9_x64_v12.11.4_EBS, is64Bit=true}, description=RightImage_CentOS_5.9_x64_v12.11.4_EBS, version=12.11.4_EBS, status=AVAILABLE[available], loginUser=root, userMetadata={owner=411009282317, rootDeviceType=ebs, virtualizationType=paravirtual, hypervisor=xen}}
+        runTest(ImmutableMap.of("imageId", "us-east-1/ami-e4bffe8d", "hardwareId", SMALL_HARDWARE_ID));
+    }
+
+    @Test(groups = {"Live"})
+    public void test_Red_Hat_Enterprise_Linux_6() throws Exception {
+        // Image: {id=us-east-1/ami-a35a33ca, providerId=ami-a35a33ca, name=RHEL-6.3_GA-x86_64-5-Hourly2, location={scope=REGION, id=us-east-1, description=us-east-1, parent=aws-ec2, iso3166Codes=[US-VA]}, os={family=rhel, arch=paravirtual, version=6.0, description=309956199498/RHEL-6.3_GA-x86_64-5-Hourly2, is64Bit=true}, description=309956199498/RHEL-6.3_GA-x86_64-5-Hourly2, version=Hourly2, status=AVAILABLE[available], loginUser=root, userMetadata={owner=309956199498, rootDeviceType=ebs, virtualizationType=paravirtual, hypervisor=xen}}
+        runTest(ImmutableMap.of("imageId", "us-east-1/ami-a35a33ca", "hardwareId", SMALL_HARDWARE_ID, JcloudsLocationConfig.OPEN_IPTABLES.getName(), "true"));
+    }
+    
+    @Test(groups = {"Live"})
+    public void test_Suse_11sp3() throws Exception {
+        // Image: {id=us-east-1/ami-c08fcba8, providerId=ami-c08fcba8, name=suse-sles-11-sp3-v20150127-pv-ssd-x86_64, location={scope=REGION, id=us-east-1, description=us-east-1, parent=aws-ec2, iso3166Codes=[US-VA]}, os={family=suse, arch=paravirtual, version=, description=amazon/suse-sles-11-sp3-v20150127-pv-ssd-x86_64, is64Bit=true}, description=SUSE Linux Enterprise Server 11 Service Pack 3 (PV, 64-bit, SSD-Backed), version=x86_64, status=AVAILABLE[available], loginUser=root, userMetadata={owner=013907871322, rootDeviceType=ebs, virtualizationType=paravirtual, hypervisor=xen}}
+        runTest(ImmutableMap.of("imageId", "us-east-1/ami-c08fcba8", "hardwareId", SMALL_HARDWARE_ID, "loginUser", "ec2-user"));//, JcloudsLocationConfig.OPEN_IPTABLES.getName(), "true"));
+    }
+    
+    protected void runTest(Map<String,?> flags) throws Exception {
+        Map<String,?> allFlags = MutableMap.<String,Object>builder()
+                .put("tags", ImmutableList.of(getClass().getName()))
+                .putAll(flags)
+                .build();
+        jcloudsLocation = mgmt.getLocationRegistry().resolve(LOCATION_SPEC, allFlags);
+
+        doTest(jcloudsLocation);
+    }
+    
+    protected abstract void doTest(Location loc) throws Exception;
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/64c2b2e5/software/base/src/test/java/org/apache/brooklyn/entity/AbstractGoogleComputeLiveTest.java
----------------------------------------------------------------------
diff --git a/software/base/src/test/java/org/apache/brooklyn/entity/AbstractGoogleComputeLiveTest.java b/software/base/src/test/java/org/apache/brooklyn/entity/AbstractGoogleComputeLiveTest.java
new file mode 100644
index 0000000..54911fd
--- /dev/null
+++ b/software/base/src/test/java/org/apache/brooklyn/entity/AbstractGoogleComputeLiveTest.java
@@ -0,0 +1,137 @@
+/*
+ * 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.entity;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.brooklyn.api.location.Location;
+import org.apache.brooklyn.api.mgmt.ManagementContext;
+import org.apache.brooklyn.core.internal.BrooklynProperties;
+import org.apache.brooklyn.core.mgmt.internal.LocalManagementContext;
+import org.apache.brooklyn.core.test.entity.TestApplication;
+import org.apache.brooklyn.entity.core.Entities;
+import org.apache.brooklyn.entity.factory.ApplicationBuilder;
+import org.apache.brooklyn.util.collections.MutableMap;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import com.google.common.base.CaseFormat;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+
+/**
+ * Runs a test with many different distros and versions.
+ */
+public abstract class AbstractGoogleComputeLiveTest {
+    
+    // TODO See todos in AbstractEc2LiveTest
+    
+    public static final String PROVIDER = "google-compute-engine";
+    public static final String REGION_NAME = null;//"us-central1";
+    public static final String LOCATION_SPEC = PROVIDER + (REGION_NAME == null ? "" : ":" + REGION_NAME);
+    public static final String STANDARD_HARDWARE_ID = "us-central1-b/n1-standard-1-d";
+    private static final int MAX_TAG_LENGTH = 63;
+
+    protected BrooklynProperties brooklynProperties;
+    protected ManagementContext ctx;
+    
+    protected TestApplication app;
+    protected Location jcloudsLocation;
+    
+    @BeforeMethod(alwaysRun=true)
+    public void setUp() throws Exception {
+        List<String> propsToRemove = ImmutableList.of("imageId", "imageDescriptionRegex", "imageNameRegex", "inboundPorts", "hardwareId", "minRam");
+        
+     // Don't let any defaults from brooklyn.properties (except credentials) interfere with test
+        brooklynProperties = BrooklynProperties.Factory.newDefault();
+        for (String propToRemove : propsToRemove) {
+            for (String propVariant : ImmutableList.of(propToRemove, CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_HYPHEN, propToRemove))) {
+                brooklynProperties.remove("brooklyn.locations.jclouds."+PROVIDER+"."+propVariant);
+                brooklynProperties.remove("brooklyn.locations."+propVariant);
+                brooklynProperties.remove("brooklyn.jclouds."+PROVIDER+"."+propVariant);
+                brooklynProperties.remove("brooklyn.jclouds."+propVariant);
+            }
+        }
+
+        // Also removes scriptHeader (e.g. if doing `. ~/.bashrc` and `. ~/.profile`, then that can cause "stdin: is not a tty")
+        brooklynProperties.remove("brooklyn.ssh.config.scriptHeader");
+        
+        ctx = new LocalManagementContext(brooklynProperties);
+        app = ApplicationBuilder.newManagedApp(TestApplication.class, ctx);
+    }
+
+    @AfterMethod(alwaysRun=true)
+    public void tearDown() throws Exception {
+        if (app != null) Entities.destroyAllCatching(app.getManagementContext());
+    }
+
+    @Test(groups = {"Live"})
+    public void test_DefaultImage() throws Exception {
+        runTest(ImmutableMap.<String,String>of());
+    }
+
+    // most of these not available
+    
+//    @Test(groups = {"Live"})
+//    public void test_GCEL_10_04() throws Exception {
+//        // release codename "squeeze"
+//        runTest(ImmutableMap.of("imageId", "gcel-10-04-v20130325", "loginUser", "admin", "hardwareId", STANDARD_HARDWARE_ID));
+//    }
+//
+//    @Test(groups = {"Live"})
+//    public void test_GCEL_12_04() throws Exception {
+//        // release codename "squeeze"
+//        runTest(ImmutableMap.of("imageId", "gcel-12-04-v20130325", "loginUser", "admin", "hardwareId", STANDARD_HARDWARE_ID));
+//    }
+//
+//    @Test(groups = {"Live"})
+//    public void test_Ubuntu_10_04() throws Exception {
+//        // release codename "squeeze"
+//        runTest(ImmutableMap.of("imageId", "ubuntu-10-04-v20120912", "loginUser", "admin", "hardwareId", STANDARD_HARDWARE_ID));
+//    }
+//
+//    @Test(groups = {"Live"})
+//    public void test_Ubuntu_12_04() throws Exception {
+//        // release codename "squeeze"
+//        runTest(ImmutableMap.of("imageId", "ubuntu-10-04-v20120912", "loginUser", "admin", "hardwareId", STANDARD_HARDWARE_ID));
+//    }
+//
+//    @Test(groups = {"Live"})
+//    public void test_CentOS_6() throws Exception {
+//        runTest(ImmutableMap.of("imageId", "centos-6-v20130325", "hardwareId", STANDARD_HARDWARE_ID));
+//    }
+
+    protected void runTest(Map<String,?> flags) throws Exception {
+        String tag = getClass().getSimpleName().toLowerCase();
+        int length = tag.length();
+        if (length > MAX_TAG_LENGTH)
+            tag = tag.substring(length - MAX_TAG_LENGTH, length);
+        Map<String,?> allFlags = MutableMap.<String,Object>builder()
+                .put("tags", ImmutableList.of(tag))
+                .putAll(flags)
+                .build();
+        jcloudsLocation = ctx.getLocationRegistry().resolve(LOCATION_SPEC, allFlags);
+
+        doTest(jcloudsLocation);
+    }
+
+    protected abstract void doTest(Location loc) throws Exception;
+}