You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by ha...@apache.org on 2015/08/14 05:42:55 UTC

[26/54] incubator-brooklyn git commit: [BROOKLYN-162] Renaming package brooklyn.location

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e2c57058/core/src/test/java/brooklyn/location/basic/SshMachineLocationPerformanceTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/location/basic/SshMachineLocationPerformanceTest.java b/core/src/test/java/brooklyn/location/basic/SshMachineLocationPerformanceTest.java
deleted file mode 100644
index 5f265ee..0000000
--- a/core/src/test/java/brooklyn/location/basic/SshMachineLocationPerformanceTest.java
+++ /dev/null
@@ -1,172 +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.location.basic;
-
-import java.io.ByteArrayOutputStream;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.brooklyn.test.PerformanceTestUtils;
-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.util.collections.MutableMap;
-import brooklyn.util.internal.ssh.SshTool;
-import brooklyn.util.net.Networking;
-import brooklyn.util.stream.Streams;
-import brooklyn.util.text.Identifiers;
-import brooklyn.util.time.Time;
-
-import com.google.common.base.Stopwatch;
-import com.google.common.base.Throwables;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Lists;
-import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.ListeningExecutorService;
-import com.google.common.util.concurrent.MoreExecutors;
-
-/**
- * Test the performance of different variants of invoking the sshj tool.
- * 
- * Intended for human-invocation and inspection, to see which parts are most expensive.
- */
-public class SshMachineLocationPerformanceTest {
-
-    private static final Logger LOG = LoggerFactory.getLogger(SshMachineLocationPerformanceTest.class);
-    
-    private SshMachineLocation machine;
-    private ListeningExecutorService executor;
-    
-    @BeforeMethod(alwaysRun=true)
-    public void setUp() throws Exception {
-        machine = new SshMachineLocation(MutableMap.of("address", "localhost"));
-        executor = MoreExecutors.listeningDecorator(Executors.newCachedThreadPool());
-    }
-    
-    @AfterMethod(alwaysRun=true)
-    public void afterMethod() throws Exception {
-        if (executor != null) executor.shutdownNow();
-        Streams.closeQuietly(machine);
-    }
-
-    @Test(groups = {"Integration"})
-    public void testConsecutiveSmallCommands() throws Exception {
-        runExecManyCommands(ImmutableList.of("true"), "small-cmd", 10);
-    }
-
-    // Mimics SshSensorAdapter's polling
-    @Test(groups = {"Integration"})
-    public void testConsecutiveSmallCommandsWithCustomStdoutAndErr() throws Exception {
-        final ByteArrayOutputStream stdout = new ByteArrayOutputStream();
-        final ByteArrayOutputStream stderr = new ByteArrayOutputStream();
-        
-        Runnable task = new Runnable() {
-            @Override public void run() {
-                machine.execScript(ImmutableMap.of("out", stdout, "err", stderr), "test", ImmutableList.of("true"));
-            }};
-        runMany(task, "small-cmd-custom-stdout", 1, 10);
-    }
-
-    @Test(groups = {"Integration"})
-    public void testConcurrentSmallCommands() throws Exception {
-        runExecManyCommands(ImmutableList.of("true"), "small-cmd", 10, 10);
-    }
-
-    @Test(groups = {"Integration"})
-    public void testConsecutiveBigStdoutCommands() throws Exception {
-        runExecManyCommands(ImmutableList.of("head -c 100000 /dev/urandom"), "big-stdout", 10);
-    }
-
-    @Test(groups = {"Integration"})
-    public void testConsecutiveBigStdinCommands() throws Exception {
-        String bigstr = Identifiers.makeRandomId(100000);
-        runExecManyCommands(ImmutableList.of("echo "+bigstr+" | wc -c"), "big-stdin", 10);
-    }
-
-    @Test(groups = {"Integration"})
-    public void testConsecutiveSmallCommandsWithDifferentProperties() throws Exception {
-        final Map<String, ?> emptyProperties = Collections.emptyMap();
-        final Map<String, ?> customProperties = MutableMap.of(
-                "address", Networking.getLocalHost(),
-                SshTool.PROP_SESSION_TIMEOUT.getName(), 20000,
-                SshTool.PROP_CONNECT_TIMEOUT.getName(), 50000,
-                SshTool.PROP_SCRIPT_HEADER.getName(), "#!/bin/bash");
-
-        Runnable task = new Runnable() {
-            @Override public void run() {
-                if (Math.random() < 0.5) {
-                    machine.execScript(emptyProperties, "test", ImmutableList.of("true"));
-                } else {
-                    machine.execScript(customProperties, "test", ImmutableList.of("true"));
-                }
-            }};
-        runMany(task, "small-cmd-custom-ssh-properties", 1, 10);
-    }
-
-    private void runExecManyCommands(final List<String> cmds, String context, int iterations) throws Exception {
-        runExecManyCommands(cmds, context, 1, iterations);
-    }
-    
-    private void runExecManyCommands(final List<String> cmds, String context, int concurrentRuns, int iterations) throws Exception {
-        Runnable task = new Runnable() {
-                @Override public void run() {
-                    execScript(cmds);
-                }};
-        runMany(task, context, concurrentRuns, iterations);
-    }
-    
-    private void runMany(final Runnable task, final String context, int concurrentRuns, int iterations) throws Exception {
-        long preCpuTime = PerformanceTestUtils.getProcessCpuTime();
-        Stopwatch stopwatch = Stopwatch.createStarted();
-
-        for (int i = 0; i < iterations; i++) {
-            List<ListenableFuture<?>> futures = Lists.newArrayList();
-            for (int j = 0; j < concurrentRuns; j++) {
-                futures.add(executor.submit(new Runnable() {
-                    public void run() {
-                        try {
-                            task.run();
-                        } catch (Exception e) {
-                            LOG.error("Error for "+context+", executing "+task, e);
-                            throw Throwables.propagate(e);
-                        }
-                    }}));
-            }
-            Futures.allAsList(futures).get();
-            
-            long postCpuTime = PerformanceTestUtils.getProcessCpuTime();
-            long elapsedTime = stopwatch.elapsed(TimeUnit.MILLISECONDS);
-            double fractionCpu = (elapsedTime > 0) ? ((double)postCpuTime-preCpuTime) / TimeUnit.MILLISECONDS.toNanos(elapsedTime) : -1;
-            LOG.info("Executing {}; completed {}; took {}; fraction cpu {}",
-                    new Object[] {context, (i+1), Time.makeTimeStringRounded(elapsedTime), fractionCpu});
-        }
-    }
-
-    private int execScript(List<String> cmds) {
-        return machine.execScript("mysummary", cmds);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e2c57058/core/src/test/java/brooklyn/location/basic/SshMachineLocationReuseIntegrationTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/location/basic/SshMachineLocationReuseIntegrationTest.java b/core/src/test/java/brooklyn/location/basic/SshMachineLocationReuseIntegrationTest.java
deleted file mode 100644
index cf9c058..0000000
--- a/core/src/test/java/brooklyn/location/basic/SshMachineLocationReuseIntegrationTest.java
+++ /dev/null
@@ -1,172 +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.location.basic;
-
-import static org.testng.Assert.assertEquals;
-
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import brooklyn.entity.basic.Entities;
-import brooklyn.location.LocationSpec;
-import brooklyn.management.internal.LocalManagementContext;
-import brooklyn.test.Asserts;
-import brooklyn.util.collections.MutableMap;
-import brooklyn.util.internal.ssh.SshTool;
-import brooklyn.util.internal.ssh.sshj.SshjTool;
-import brooklyn.util.net.Networking;
-import brooklyn.util.stream.Streams;
-import brooklyn.util.time.Duration;
-
-import com.google.common.collect.ImmutableList;
-
-/**
- * Tests the re-use of SshTools in SshMachineLocation
- */
-public class SshMachineLocationReuseIntegrationTest {
-
-    public static class RecordingSshjTool extends SshjTool {
-        public static final AtomicBoolean forbidden = new AtomicBoolean(false); 
-        public static final AtomicInteger connectionCount = new AtomicInteger(0);
-        public static final AtomicInteger disconnectionCount = new AtomicInteger();
-        
-        public RecordingSshjTool(Map<String, ?> map) {
-            super(map);
-        }
-
-        @Override
-        public void connect() {
-            if (forbidden.get()) throw new IllegalStateException("forbidden at this time");
-            connectionCount.incrementAndGet();
-            super.connect();
-        }
-
-        @Override
-        public void disconnect() {
-            disconnectionCount.incrementAndGet();
-            super.disconnect();
-        }
-
-        public static void reset() {
-            forbidden.set(false);
-            connectionCount.set(0);
-            disconnectionCount.set(0);
-        }
-
-        @Override
-        public int execCommands(Map<String, ?> props, List<String> commands, Map<String, ?> env) {
-            if (forbidden.get()) throw new IllegalStateException("forbidden at this time");
-            return super.execCommands(props, commands, env);
-        }
-        
-        @Override
-        public int execScript(Map<String, ?> props, List<String> commands, Map<String, ?> env) {
-            if (forbidden.get()) throw new IllegalStateException("forbidden at this time");
-            return super.execScript(props, commands, env);
-        }
-        
-        @Override
-        public int execShellDirect(Map<String, ?> props, List<String> commands, Map<String, ?> env) {
-            if (forbidden.get()) throw new IllegalStateException("forbidden at this time");
-            return super.execShellDirect(props, commands, env);
-        }
-    }
-
-    private SshMachineLocation host;
-    private LocalManagementContext managementContext;
-
-    @BeforeMethod(alwaysRun=true)
-    public void setUp() throws Exception {
-        managementContext = new LocalManagementContext();
-        host = managementContext.getLocationManager().createLocation(LocationSpec.create(SshMachineLocation.class)
-                .configure("address", Networking.getLocalHost())
-                .configure(SshTool.PROP_TOOL_CLASS, RecordingSshjTool.class.getName()));
-    }
-
-    @AfterMethod(alwaysRun=true)
-    public void tearDown() throws Exception {
-        if (host != null) Streams.closeQuietly(host);
-        if (managementContext != null) Entities.destroyAll(managementContext);
-        RecordingSshjTool.reset();
-    }
-
-    @Test(groups = "Integration")
-    public void testBasicReuse() throws Exception {
-        host.execScript("mysummary", ImmutableList.of("exit"));
-        host.execScript("mysummary", ImmutableList.of("exit"));
-        assertEquals(RecordingSshjTool.connectionCount.get(), 1, "Expected one SSH connection to have been recorded");
-    }
-
-    @Test(groups = "Integration")
-    public void testReuseWithInterestingProps() throws Exception {
-        host.execScript(customSshConfigKeys(), "mysummary", ImmutableList.of("exit"));
-        host.execScript(customSshConfigKeys(), "mysummary", ImmutableList.of("exit"));
-        assertEquals(RecordingSshjTool.connectionCount.get(), 1, "Expected one SSH connection to have been recorded");
-    }
-
-    @Test(groups = "Integration")
-    public void testNewConnectionForDifferentProps() throws Exception {
-        host.execScript("mysummary", ImmutableList.of("exit"));
-        host.execScript(customSshConfigKeys(), "mysummary", ImmutableList.of("exit"));
-        assertEquals(RecordingSshjTool.connectionCount.get(), 2, "Expected two SSH connections to have been recorded");
-    }
-
-    @Test(groups = "Integration")
-    public void testSshToolReusedWhenConfigDiffers() throws Exception {
-        Map<String, Object> props = customSshConfigKeys();
-        host.execScript(props, "mysummary", ImmutableList.of("exit"));
-
-        // Use another output stream for second request
-        props.put(SshTool.PROP_SCRIPT_HEADER.getName(), "#!/bin/bash -e\n");
-        host.execScript(props, "mysummary", ImmutableList.of("exit"));
-        assertEquals(RecordingSshjTool.connectionCount.get(), 1, "Expected one SSH connection to have been recorded even though out script header differed.");
-    }
-
-    @Test(groups = "Integration")
-    public void testSshCacheExpiresEvenIfNotUsed() throws Exception {
-        SshMachineLocation host2 = managementContext.getLocationManager().createLocation(LocationSpec.create(SshMachineLocation.class)
-                .configure("address", InetAddress.getLocalHost())
-                .configure(SshMachineLocation.SSH_CACHE_EXPIRY_DURATION, Duration.ONE_SECOND)
-                .configure(SshTool.PROP_TOOL_CLASS, RecordingSshjTool.class.getName()));
-        
-        Map<String, Object> props = customSshConfigKeys();
-        host2.execScript(props, "mysummary", ImmutableList.of("exit"));
-
-        Asserts.succeedsEventually(new Runnable() {
-            @Override public void run() {
-                assertEquals(RecordingSshjTool.disconnectionCount.get(), 1);
-            }});
-    }
-
-    public Map<String, Object> customSshConfigKeys() throws UnknownHostException {
-        return MutableMap.<String, Object>of(
-                "address", Networking.getLocalHost(),
-                SshTool.PROP_SESSION_TIMEOUT.getName(), 20000,
-                SshTool.PROP_CONNECT_TIMEOUT.getName(), 50000,
-                SshTool.PROP_SCRIPT_HEADER.getName(), "#!/bin/bash");
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e2c57058/core/src/test/java/brooklyn/location/basic/SshMachineLocationTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/location/basic/SshMachineLocationTest.java b/core/src/test/java/brooklyn/location/basic/SshMachineLocationTest.java
deleted file mode 100644
index 03df8fc..0000000
--- a/core/src/test/java/brooklyn/location/basic/SshMachineLocationTest.java
+++ /dev/null
@@ -1,340 +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.location.basic;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertNull;
-import static org.testng.Assert.assertSame;
-import static org.testng.Assert.assertTrue;
-
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.OutputStream;
-import java.net.InetAddress;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.Callable;
-
-import org.apache.brooklyn.api.entity.Effector;
-import org.apache.brooklyn.api.entity.basic.EntityLocal;
-import org.apache.brooklyn.api.entity.proxying.EntityInitializer;
-import org.apache.brooklyn.api.entity.proxying.EntitySpec;
-import org.apache.brooklyn.api.management.ManagementContext;
-import org.apache.brooklyn.test.entity.LocalManagementContextForTests;
-import org.apache.brooklyn.test.entity.TestApplication;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import brooklyn.entity.basic.ApplicationBuilder;
-import brooklyn.entity.basic.BrooklynConfigKeys;
-import brooklyn.entity.basic.Entities;
-import brooklyn.entity.basic.EntityInternal;
-import brooklyn.entity.effector.EffectorBody;
-import brooklyn.entity.effector.EffectorTaskTest;
-import brooklyn.entity.effector.Effectors;
-import brooklyn.location.LocationSpec;
-import brooklyn.location.MachineDetails;
-import brooklyn.location.MachineLocation;
-import brooklyn.location.PortRange;
-import brooklyn.location.basic.PortRanges.LinearPortRange;
-import brooklyn.test.Asserts;
-import brooklyn.util.collections.MutableMap;
-import brooklyn.util.config.ConfigBag;
-import brooklyn.util.file.ArchiveUtils;
-import brooklyn.util.guava.Maybe;
-import brooklyn.util.internal.ssh.RecordingSshTool;
-import brooklyn.util.internal.ssh.SshException;
-import brooklyn.util.internal.ssh.SshTool;
-import brooklyn.util.net.Networking;
-import brooklyn.util.net.Urls;
-import brooklyn.util.os.Os;
-import brooklyn.util.stream.Streams;
-import brooklyn.util.task.BasicExecutionContext;
-import brooklyn.util.task.BasicExecutionManager;
-import brooklyn.util.time.Duration;
-
-import com.google.common.base.Charsets;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.io.Files;
-
-/**
- * Test the {@link SshMachineLocation} implementation of the {@link brooklyn.location.Location} interface.
- */
-public class SshMachineLocationTest {
-
-    private SshMachineLocation host;
-    private ManagementContext mgmt;
-    
-    @BeforeMethod(alwaysRun=true)
-    public void setUp() throws Exception {
-        mgmt = LocalManagementContextForTests.newInstance();
-        host = new SshMachineLocation(MutableMap.of("address", Networking.getLocalHost()));
-    }
-
-    @AfterMethod(alwaysRun=true)
-    public void tearDown() throws Exception {
-        if (host != null) Streams.closeQuietly(host);
-        if (mgmt != null) Entities.destroyAll(mgmt);
-    }
-    
-    @Test(groups = "Integration")
-    public void testGetMachineDetails() throws Exception {
-        BasicExecutionManager execManager = new BasicExecutionManager("mycontextid");
-        BasicExecutionContext execContext = new BasicExecutionContext(execManager);
-        try {
-            MachineDetails details = execContext.submit(new Callable<MachineDetails>() {
-                public MachineDetails call() {
-                    return host.getMachineDetails();
-                }}).get();
-            assertNotNull(details);
-        } finally {
-            execManager.shutdownNow();
-        }
-    }
-    
-    @Test
-    public void testSupplyingMachineDetails() throws Exception {
-        MachineDetails machineDetails = new BasicMachineDetails(new BasicHardwareDetails(1, 1024), new BasicOsDetails("myname", "myarch", "myversion"));
-        SshMachineLocation host2 = mgmt.getLocationManager().createLocation(LocationSpec.create(SshMachineLocation.class)
-                .configure(SshMachineLocation.MACHINE_DETAILS, machineDetails));
-        
-        assertSame(host2.getMachineDetails(), machineDetails);
-    }
-    
-    @Test
-    public void testConfigurePrivateAddresses() throws Exception {
-        SshMachineLocation host2 = mgmt.getLocationManager().createLocation(LocationSpec.create(SshMachineLocation.class)
-                .configure("address", Networking.getLocalHost())
-                .configure(SshMachineLocation.PRIVATE_ADDRESSES, ImmutableList.of("1.2.3.4"))
-                .configure(BrooklynConfigKeys.SKIP_ON_BOX_BASE_DIR_RESOLUTION, true));
-
-        assertEquals(host2.getPrivateAddresses(), ImmutableSet.of("1.2.3.4"));
-    }
-    
-    // Wow, this is hard to test (until I accepted creating the entity + effector)! Code smell?
-    // Need to call getMachineDetails in a DynamicSequentialTask so that the "innessential" takes effect,
-    // to not fail its caller. But to get one of those outside of an effector is non-obvious.
-    @Test(groups = "Integration")
-    public void testGetMachineIsInessentialOnFailure() throws Exception {
-        SshMachineLocation host2 = mgmt.getLocationManager().createLocation(LocationSpec.create(SshMachineLocation.class)
-                .configure("address", Networking.getLocalHost())
-                .configure(SshTool.PROP_TOOL_CLASS, FailingSshTool.class.getName()));
-
-        final Effector<MachineDetails> GET_MACHINE_DETAILS = Effectors.effector(MachineDetails.class, "getMachineDetails")
-                .impl(new EffectorBody<MachineDetails>() {
-                    public MachineDetails call(ConfigBag parameters) {
-                        Maybe<MachineLocation> machine = Machines.findUniqueMachineLocation(entity().getLocations());
-                        try {
-                            machine.get().getMachineDetails();
-                            throw new IllegalStateException("Expected failure in ssh");
-                        } catch (RuntimeException e) {
-                            return null;
-                        }
-                    }})
-                .build();
-
-        EntitySpec<TestApplication> appSpec = EntitySpec.create(TestApplication.class)
-                .configure(BrooklynConfigKeys.SKIP_ON_BOX_BASE_DIR_RESOLUTION, true)
-                .addInitializer(new EntityInitializer() {
-                        public void apply(EntityLocal entity) {
-                            ((EntityInternal)entity).getMutableEntityType().addEffector(EffectorTaskTest.DOUBLE_1);
-                        }});
-
-        TestApplication app = ApplicationBuilder.newManagedApp(appSpec, mgmt);
-
-        app.start(ImmutableList.of(host2));
-        
-        MachineDetails details = app.invoke(GET_MACHINE_DETAILS, ImmutableMap.<String, Object>of()).get();
-        assertNull(details);
-    }
-    public static class FailingSshTool extends RecordingSshTool {
-        public FailingSshTool(Map<?, ?> props) {
-            super(props);
-        }
-        @Override public int execScript(Map<String, ?> props, List<String> commands, Map<String, ?> env) {
-            throw new RuntimeException("Simulating failure of ssh: cmds="+commands);
-        }
-        @Override public int execCommands(Map<String, ?> props, List<String> commands, Map<String, ?> env) {
-            throw new RuntimeException("Simulating failure of ssh: cmds="+commands);
-        }
-    }
-    
-    // Note: requires `ssh localhost` to be setup such that no password is required    
-    @Test(groups = "Integration")
-    public void testSshExecScript() throws Exception {
-        OutputStream outStream = new ByteArrayOutputStream();
-        String expectedName = Os.user();
-        host.execScript(MutableMap.of("out", outStream), "mysummary", ImmutableList.of("whoami; exit"));
-        String outString = outStream.toString();
-        
-        assertTrue(outString.contains(expectedName), outString);
-    }
-    
-    // Note: requires `ssh localhost` to be setup such that no password is required    
-    @Test(groups = "Integration")
-    public void testSshExecCommands() throws Exception {
-        OutputStream outStream = new ByteArrayOutputStream();
-        String expectedName = Os.user();
-        host.execCommands(MutableMap.of("out", outStream), "mysummary", ImmutableList.of("whoami; exit"));
-        String outString = outStream.toString();
-        
-        assertTrue(outString.contains(expectedName), outString);
-    }
-    
-    // For issue #230
-    @Test(groups = "Integration")
-    public void testOverridingPropertyOnExec() throws Exception {
-        SshMachineLocation host = new SshMachineLocation(MutableMap.of("address", Networking.getLocalHost(), "sshPrivateKeyData", "wrongdata"));
-        
-        OutputStream outStream = new ByteArrayOutputStream();
-        String expectedName = Os.user();
-        host.execCommands(MutableMap.of("sshPrivateKeyData", null, "out", outStream), "my summary", ImmutableList.of("whoami"));
-        String outString = outStream.toString();
-        
-        assertTrue(outString.contains(expectedName), "outString="+outString);
-    }
-
-    @Test(groups = "Integration", expectedExceptions={IllegalStateException.class, SshException.class})
-    public void testSshRunWithInvalidUserFails() throws Exception {
-        SshMachineLocation badHost = new SshMachineLocation(MutableMap.of("user", "doesnotexist", "address", Networking.getLocalHost()));
-        badHost.execScript("mysummary", ImmutableList.of("whoami; exit"));
-    }
-    
-    // Note: requires `ssh localhost` to be setup such that no password is required    
-    @Test(groups = "Integration")
-    public void testCopyFileTo() throws Exception {
-        File dest = Os.newTempFile(getClass(), ".dest.tmp");
-        File src = Os.newTempFile(getClass(), ".src.tmp");
-        try {
-            Files.write("abc", src, Charsets.UTF_8);
-            host.copyTo(src, dest);
-            assertEquals("abc", Files.readFirstLine(dest, Charsets.UTF_8));
-        } finally {
-            src.delete();
-            dest.delete();
-        }
-    }
-
-    // Note: requires `ssh localhost` to be setup such that no password is required    
-    @Test(groups = "Integration")
-    public void testCopyStreamTo() throws Exception {
-        String contents = "abc";
-        File dest = new File(Os.tmp(), "sssMachineLocationTest_dest.tmp");
-        try {
-            host.copyTo(Streams.newInputStreamWithContents(contents), dest.getAbsolutePath());
-            assertEquals("abc", Files.readFirstLine(dest, Charsets.UTF_8));
-        } finally {
-            dest.delete();
-        }
-    }
-
-    @Test(groups = "Integration")
-    public void testInstallUrlTo() throws Exception {
-        File dest = new File(Os.tmp(), "sssMachineLocationTest_dir/");
-        dest.mkdir();
-        try {
-            int result = host.installTo("https://raw.github.com/brooklyncentral/brooklyn/master/README.md", Urls.mergePaths(dest.getAbsolutePath(), "README.md"));
-            assertEquals(result, 0);
-            String contents = ArchiveUtils.readFullyString(new File(dest, "README.md"));
-            assertTrue(contents.contains("http://brooklyncentral.github.com"), "contents missing expected phrase; contains:\n"+contents);
-        } finally {
-            dest.delete();
-        }
-    }
-    
-    @Test(groups = "Integration")
-    public void testInstallClasspathCopyTo() throws Exception {
-        File dest = new File(Os.tmp(), "sssMachineLocationTest_dir/");
-        dest.mkdir();
-        try {
-            int result = host.installTo("classpath://brooklyn/config/sample.properties", Urls.mergePaths(dest.getAbsolutePath(), "sample.properties"));
-            assertEquals(result, 0);
-            String contents = ArchiveUtils.readFullyString(new File(dest, "sample.properties"));
-            assertTrue(contents.contains("Property 1"), "contents missing expected phrase; contains:\n"+contents);
-        } finally {
-            dest.delete();
-        }
-    }
-
-    // Note: requires `ssh localhost` to be setup such that no password is required    
-    @Test(groups = "Integration")
-    public void testIsSshableWhenTrue() throws Exception {
-        assertTrue(host.isSshable());
-    }
-    
-    // Note: on some (home/airport) networks, `ssh 123.123.123.123` hangs seemingly forever.
-    // Make sure we fail, waiting for longer than the 70 second TCP timeout.
-    //
-    // Times out in 2m7s on Ubuntu Vivid (syn retries set to 6)
-    @Test(groups = "Integration")
-    public void testIsSshableWhenFalse() throws Exception {
-        byte[] unreachableIp = new byte[] {123,123,123,123};
-        final SshMachineLocation unreachableHost = new SshMachineLocation(MutableMap.of("address", InetAddress.getByAddress("unreachablename", unreachableIp)));
-        Asserts.assertReturnsEventually(new Runnable() {
-            public void run() {
-                assertFalse(unreachableHost.isSshable());
-            }},
-            Duration.minutes(3));
-    }
-    
-    @Test
-    public void obtainSpecificPortGivesOutPortOnlyOnce() {
-        int port = 2345;
-        assertTrue(host.obtainSpecificPort(port));
-        assertFalse(host.obtainSpecificPort(port));
-        host.releasePort(port);
-        assertTrue(host.obtainSpecificPort(port));
-    }
-    
-    @Test
-    public void obtainPortInRangeGivesBackRequiredPortOnlyIfAvailable() {
-        int port = 2345;
-        assertEquals(host.obtainPort(new LinearPortRange(port, port)), port);
-        assertEquals(host.obtainPort(new LinearPortRange(port, port)), -1);
-        host.releasePort(port);
-        assertEquals(host.obtainPort(new LinearPortRange(port, port)), port);
-    }
-    
-    @Test
-    public void obtainPortInWideRange() {
-        int lowerPort = 2345;
-        int upperPort = 2350;
-        PortRange range = new LinearPortRange(lowerPort, upperPort);
-        for (int i = lowerPort; i <= upperPort; i++) {
-            assertEquals(host.obtainPort(range), i);
-        }
-        assertEquals(host.obtainPort(range), -1);
-        
-        host.releasePort(lowerPort);
-        assertEquals(host.obtainPort(range), lowerPort);
-        assertEquals(host.obtainPort(range), -1);
-    }
-    
-    @Test
-    public void testObtainPortDoesNotUsePreReservedPorts() {
-        host = new SshMachineLocation(MutableMap.of("address", Networking.getLocalHost(), "usedPorts", ImmutableSet.of(8000)));
-        assertEquals(host.obtainPort(PortRanges.fromString("8000")), -1);
-        assertEquals(host.obtainPort(PortRanges.fromString("8000+")), 8001);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e2c57058/core/src/test/java/brooklyn/location/basic/TestPortSupplierLocation.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/location/basic/TestPortSupplierLocation.java b/core/src/test/java/brooklyn/location/basic/TestPortSupplierLocation.java
deleted file mode 100644
index 193a31b..0000000
--- a/core/src/test/java/brooklyn/location/basic/TestPortSupplierLocation.java
+++ /dev/null
@@ -1,90 +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.location.basic;
-
-import static org.testng.Assert.assertEquals;
-
-import org.apache.brooklyn.api.entity.proxying.EntitySpec;
-import org.apache.brooklyn.test.entity.TestEntity;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import brooklyn.entity.BrooklynAppUnitTestSupport;
-import brooklyn.event.basic.PortAttributeSensorAndConfigKey;
-import brooklyn.event.feed.ConfigToAttributes;
-
-import com.google.common.collect.ImmutableList;
-
-public class TestPortSupplierLocation extends BrooklynAppUnitTestSupport {
-
-    SimulatedLocation loc;
-    PortAttributeSensorAndConfigKey ps;
-    TestEntity entity;
-    
-    @BeforeMethod(alwaysRun=true)
-    @Override
-    public void setUp() throws Exception {
-        super.setUp();
-        loc = app.newSimulatedLocation();
-        entity = app.createAndManageChild(EntitySpec.create(TestEntity.class));
-        app.start(ImmutableList.of(loc));
-        
-        ps = new PortAttributeSensorAndConfigKey("some.port", "for testing", "1234+");
-    }
-
-    @Test
-    public void testObtainsPort() throws Exception {
-        ConfigToAttributes.apply(entity, ps);
-        
-        int p = entity.getAttribute(ps);
-        assertEquals(p, 1234);
-        
-        //sensor access should keep the same value
-        p = entity.getAttribute(ps);
-        assertEquals(p, 1234);
-    }
-    
-    @Test
-    public void testRepeatedConvertAccessIncrements() throws Exception {
-        int p = ps.getAsSensorValue(entity);
-        assertEquals(p, 1234);
-
-        //but direct access should see it as being reserved (not required behaviour, but it is the current behaviour)
-        int p2 = ps.getAsSensorValue(entity);
-        assertEquals(p2, 1235);
-    }
-
-    @Test
-    public void testNullBeforeSetting() throws Exception {
-        // currently getting the attribute before explicitly setting return null; i.e. no "auto-set" -- 
-        // but this behaviour may be changed
-        Integer p = entity.getAttribute(ps);
-        assertEquals(p, null);
-    }
-
-    @Test
-    public void testSimulatedRestrictedPermitted() throws Exception {
-        loc.setPermittedPorts(PortRanges.fromString("1240+"));
-        
-        ConfigToAttributes.apply(entity, ps);
-        int p = entity.getAttribute(ps);
-        assertEquals((int)p, 1240);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e2c57058/core/src/test/java/brooklyn/location/cloud/CloudMachineNamerTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/location/cloud/CloudMachineNamerTest.java b/core/src/test/java/brooklyn/location/cloud/CloudMachineNamerTest.java
deleted file mode 100644
index a39c9dc..0000000
--- a/core/src/test/java/brooklyn/location/cloud/CloudMachineNamerTest.java
+++ /dev/null
@@ -1,161 +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.location.cloud;
-
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertTrue;
-
-import org.apache.brooklyn.api.entity.proxying.EntitySpec;
-import org.apache.brooklyn.test.entity.LocalManagementContextForTests;
-import org.apache.brooklyn.test.entity.TestApplication;
-import org.apache.brooklyn.test.entity.TestEntity;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.Assert;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.Test;
-
-import brooklyn.entity.basic.ApplicationBuilder;
-import brooklyn.entity.basic.Entities;
-import brooklyn.location.cloud.names.AbstractCloudMachineNamer;
-import brooklyn.location.cloud.names.BasicCloudMachineNamer;
-import brooklyn.location.cloud.names.CloudMachineNamer;
-import brooklyn.util.config.ConfigBag;
-import brooklyn.util.text.Strings;
-public class CloudMachineNamerTest {
-
-    private static final Logger log = LoggerFactory.getLogger(CloudMachineNamerTest.class);
-    
-    private TestApplication app;
-    
-    @AfterMethod(alwaysRun=true)
-    public void tearDown() throws Exception {
-        if (app != null) Entities.destroyAll(app.getManagementContext());
-    }
-
-    @Test
-    public void testGenerateGroupIdWithEntity() {
-        app = ApplicationBuilder.newManagedApp(EntitySpec.create(TestApplication.class).displayName("TistApp"), LocalManagementContextForTests.newInstance());
-        TestEntity child = app.createAndManageChild(EntitySpec.create(TestEntity.class).displayName("TestEnt"));
-
-        ConfigBag cfg = new ConfigBag()
-            .configure(CloudLocationConfig.CALLER_CONTEXT, child);
-
-        String result = new BasicCloudMachineNamer().generateNewGroupId(cfg);
-
-        log.info("test entity child group id gives: "+result);
-        // e.g. brooklyn-alex-tistapp-uube-testent-xisg-rwad
-        Assert.assertTrue(result.length() <= 60);
-
-        String user = Strings.maxlen(System.getProperty("user.name"), 4).toLowerCase();
-        Assert.assertTrue(result.indexOf(user) >= 0);
-        Assert.assertTrue(result.indexOf("-tistapp-") >= 0);
-        Assert.assertTrue(result.indexOf("-testent-") >= 0);
-        Assert.assertTrue(result.indexOf("-"+Strings.maxlen(app.getId(), 4).toLowerCase()) >= 0);
-        Assert.assertTrue(result.indexOf("-"+Strings.maxlen(child.getId(), 4).toLowerCase()) >= 0);
-    }
-    
-    @Test
-    public void testGenerateNewMachineName() {
-        app = ApplicationBuilder.newManagedApp(EntitySpec.create(TestApplication.class).displayName("TistApp"), LocalManagementContextForTests.newInstance());
-        TestEntity child = app.createAndManageChild(EntitySpec.create(TestEntity.class).displayName("TestEnt"));
-
-        ConfigBag cfg = new ConfigBag()
-            .configure(CloudLocationConfig.CALLER_CONTEXT, child);
-        BasicCloudMachineNamer namer = new BasicCloudMachineNamer();
-        
-        String result = namer.generateNewMachineUniqueName(cfg);
-        Assert.assertTrue(result.length() <= namer.getMaxNameLength(cfg));
-        String user = Strings.maxlen(System.getProperty("user.name"), 4).toLowerCase();
-        Assert.assertTrue(result.indexOf(user) >= 0);
-        Assert.assertTrue(result.indexOf("-tistapp-") >= 0);
-        Assert.assertTrue(result.indexOf("-testent-") >= 0);
-        Assert.assertTrue(result.indexOf("-"+Strings.maxlen(app.getId(), 4).toLowerCase()) >= 0);
-        Assert.assertTrue(result.indexOf("-"+Strings.maxlen(child.getId(), 4).toLowerCase()) >= 0);
-    }
-    
-    @Test
-    public void testGenerateNewMachineUniqueNameFromGroupId() {
-        app = ApplicationBuilder.newManagedApp(EntitySpec.create(TestApplication.class).displayName("TistApp"), LocalManagementContextForTests.newInstance());
-        TestEntity child = app.createAndManageChild(EntitySpec.create(TestEntity.class).displayName("TestEnt"));
-
-        ConfigBag cfg = new ConfigBag()
-            .configure(CloudLocationConfig.CALLER_CONTEXT, child);
-        CloudMachineNamer namer = new BasicCloudMachineNamer();
-        
-        String groupId = namer.generateNewGroupId(cfg);
-        String result = namer.generateNewMachineUniqueNameFromGroupId(cfg, groupId);
-        Assert.assertTrue(result.startsWith(groupId));
-        Assert.assertTrue(result.length() == groupId.length() + 5);
-    }
-    
-    @Test
-    public void testLengthMaxPermittedForMachineName() {
-        app = ApplicationBuilder.newManagedApp(EntitySpec.create(TestApplication.class).displayName("TistApp"), LocalManagementContextForTests.newInstance());
-        TestEntity child = app.createAndManageChild(EntitySpec.create(TestEntity.class).displayName("TestEnt"));
-        
-        ConfigBag cfg = new ConfigBag()
-            .configure(CloudLocationConfig.CALLER_CONTEXT, child);
-        BasicCloudMachineNamer namer = new BasicCloudMachineNamer();
-        namer.setDefaultMachineNameMaxLength(10);
-        String result = namer.generateNewMachineUniqueName(cfg);
-        Assert.assertEquals(result.length(), 10);
-    }
-    
-    @Test
-    public void testLengthReservedForNameInGroup() {
-        app = ApplicationBuilder.newManagedApp(EntitySpec.create(TestApplication.class).displayName("TistApp"), LocalManagementContextForTests.newInstance());
-        TestEntity child = app.createAndManageChild(EntitySpec.create(TestEntity.class).displayName("TestEnt"));
-        
-        ConfigBag cfg = new ConfigBag()
-            .configure(CloudLocationConfig.CALLER_CONTEXT, child);
-        BasicCloudMachineNamer namer = new BasicCloudMachineNamer();
-        namer.setDefaultMachineNameMaxLength(20);
-        namer.setDefaultMachineNameSeparatorAndSaltLength(":I", 5);
-        String groupId = namer.generateNewGroupId(cfg);
-        Assert.assertEquals(13, groupId.length(), "groupId="+groupId);
-        String machineId = namer.generateNewMachineUniqueNameFromGroupId(cfg, groupId);
-        Assert.assertEquals(20, machineId.length(), "machineId="+machineId);
-        // separator is not sanitized -- caller should know what they are doing there!
-        Assert.assertTrue(machineId.startsWith(groupId+"-i"), "machineId="+machineId);
-    }
-
-    @Test
-    public void testSanitizesNewMachineName() {
-        app = ApplicationBuilder.newManagedApp(EntitySpec.create(TestApplication.class).displayName("T_%$()\r\n\t[]*.!App"), LocalManagementContextForTests.newInstance());
-        TestEntity child = app.createAndManageChild(EntitySpec.create(TestEntity.class).displayName("ent"));
-
-        ConfigBag cfg = new ConfigBag()
-            .configure(CloudLocationConfig.CALLER_CONTEXT, child);
-        CloudMachineNamer namer = new BasicCloudMachineNamer();
-        
-        String result = namer.generateNewMachineUniqueName(cfg);
-        assertTrue(result.indexOf("t-ap") >= 0, "result="+result);
-        for (int c : "_%$()\r\n\t[]*.!".getBytes()) {
-            assertFalse(result.contains(new String(new char [] {(char)c})), "result="+result);
-        }
-    }
-    
-    @Test
-    public void testSanitize() {
-        Assert.assertEquals(AbstractCloudMachineNamer.sanitize(
-                "me & you like alphanumeric but not _ or !!! or dots...dots...dots %$()\r\n\t[]*etc"),
-                "me-you-like-alphanumeric-but-not-or-or-dots-dots-dots-etc");
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e2c57058/core/src/test/java/brooklyn/location/cloud/CustomMachineNamerTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/location/cloud/CustomMachineNamerTest.java b/core/src/test/java/brooklyn/location/cloud/CustomMachineNamerTest.java
deleted file mode 100644
index e901e33..0000000
--- a/core/src/test/java/brooklyn/location/cloud/CustomMachineNamerTest.java
+++ /dev/null
@@ -1,79 +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.location.cloud;
-
-import org.apache.brooklyn.api.entity.proxying.EntitySpec;
-import org.apache.brooklyn.test.entity.LocalManagementContextForTests;
-import org.apache.brooklyn.test.entity.TestApplication;
-import org.apache.brooklyn.test.entity.TestEntity;
-import org.testng.Assert;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import brooklyn.entity.basic.ApplicationBuilder;
-import brooklyn.entity.basic.Entities;
-import brooklyn.location.cloud.names.CustomMachineNamer;
-import brooklyn.util.config.ConfigBag;
-
-import com.google.common.collect.ImmutableMap;
-
-public class CustomMachineNamerTest {
-    
-    private TestApplication app;
-    private TestEntity child;
-    private ConfigBag config;
-    
-    @BeforeMethod(alwaysRun=true)
-    public void setUp() {
-        app = ApplicationBuilder.newManagedApp(EntitySpec.create(TestApplication.class).displayName("TestApp"), LocalManagementContextForTests.newInstance());
-        child = app.createAndManageChild(EntitySpec.create(TestEntity.class).displayName("TestEnt"));
-        config = new ConfigBag()
-            .configure(CloudLocationConfig.CALLER_CONTEXT, child);
-    }
-    
-    @AfterMethod(alwaysRun=true)
-    public void tearDown() throws Exception {
-        if (app != null) Entities.destroyAll(app.getManagementContext());
-    }
-
-    @Test
-    public void testMachineNameNoConfig() {
-        config.configure(CloudLocationConfig.CALLER_CONTEXT, child);
-        Assert.assertEquals(new CustomMachineNamer().generateNewMachineUniqueName(config), "TestEnt");
-    }
-    
-    @Test
-    public void testMachineNameWithConfig() {
-        child.setSequenceValue(999);
-        config.configure(CustomMachineNamer.MACHINE_NAME_TEMPLATE, "number${entity.sequenceValue}");
-        Assert.assertEquals(new CustomMachineNamer().generateNewMachineUniqueName(config), "number999");
-    }
-    
-    @Test
-    public void testMachineNameWithExtraSubstitutions() {
-        config.configure(CustomMachineNamer.MACHINE_NAME_TEMPLATE, "foo-${fooName}-bar-${barName}-baz-${bazName.substitution}")
-            .configure(CustomMachineNamer.EXTRA_SUBSTITUTIONS, ImmutableMap.of("fooName", "foo", "barName", "bar", "bazName", this));
-        Assert.assertEquals(new CustomMachineNamer().generateNewMachineUniqueName(config), "foo-foo-bar-bar-baz-baz");
-    }
-    
-    public String getSubstitution() {
-        return "baz";
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e2c57058/core/src/test/java/brooklyn/location/geo/HostGeoInfoTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/location/geo/HostGeoInfoTest.java b/core/src/test/java/brooklyn/location/geo/HostGeoInfoTest.java
deleted file mode 100644
index 1f82275..0000000
--- a/core/src/test/java/brooklyn/location/geo/HostGeoInfoTest.java
+++ /dev/null
@@ -1,52 +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.location.geo;
-
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertNotNull;
-
-import org.testng.annotations.Test;
-
-import brooklyn.location.Location;
-import brooklyn.location.basic.SimulatedLocation;
-import brooklyn.util.collections.MutableMap;
-
-public class HostGeoInfoTest {
-    private static final String IP = "192.168.0.1";
-    
-    private static final Location CUSTOM_LOCATION = new SimulatedLocation(MutableMap.of("name", "custom", "latitude", 50d, "longitude", 0d));
-    private static final Location CUSTOM_LOCATION_CHILD = new SimulatedLocation(MutableMap.of("name", "custom-child", "address", IP, "parentLocation", CUSTOM_LOCATION));
-        
-    @Test
-    public void testCustomLocationCoordinates() {
-        HostGeoInfo hgi = HostGeoInfo.fromLocation(CUSTOM_LOCATION);
-        assertNotNull(hgi);
-        assertEquals(50.0d, hgi.latitude);
-        assertEquals(0.0d, hgi.longitude);
-    }
-    
-    @Test
-    public void testCustomLocationChildCoordinates() {
-        HostGeoInfo hgi = HostGeoInfo.fromLocation(CUSTOM_LOCATION_CHILD);
-        assertNotNull(hgi);
-        assertEquals(50.0d, hgi.latitude);
-        assertEquals(0.0d, hgi.longitude);
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e2c57058/core/src/test/java/brooklyn/location/geo/HostGeoLookupIntegrationTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/location/geo/HostGeoLookupIntegrationTest.java b/core/src/test/java/brooklyn/location/geo/HostGeoLookupIntegrationTest.java
deleted file mode 100644
index c362ab4..0000000
--- a/core/src/test/java/brooklyn/location/geo/HostGeoLookupIntegrationTest.java
+++ /dev/null
@@ -1,84 +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.location.geo;
-
-import java.net.InetAddress;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-import brooklyn.location.basic.LocalhostMachineProvisioningLocation;
-import brooklyn.location.basic.SshMachineLocation;
-import brooklyn.util.time.Duration;
-
-import com.google.common.base.Objects;
-
-public class HostGeoLookupIntegrationTest {
-
-    public static final Logger log = LoggerFactory.getLogger(HostGeoLookupIntegrationTest.class);
-    
-    // Needs fast network connectivity to figure out the external IP. If response not returned in 2s fails.
-    @Test(groups = "Integration")
-    public void testLocalhostGetsLocation() throws Exception {
-        LocalhostMachineProvisioningLocation ll = new LocalhostMachineProvisioningLocation();
-        SshMachineLocation l = ll.obtain();
-        HostGeoInfo geo = HostGeoInfo.fromLocation(l);
-        Assert.assertNotNull(geo, "host lookup unavailable - is the maxmind database installed? or else network unavailable or too slow?");
-        log.info("localhost is in "+geo);
-        Assert.assertNotNull(geo, "couldn't load data; must have a valid HostGeoLookup impl (e.g. MaxMind installed, or online and with Utrace credit)");
-        Assert.assertTrue(-90 <= geo.latitude && geo.latitude <= 90); 
-        ll.close();
-    }
-
-    @Deprecated // see GeoBytesHostGeoLookup - their API changed
-    @Test(groups = "Integration", enabled=false)
-    public void testGeobytesLookup() throws Exception {
-        HostGeoInfo geo = new GeoBytesHostGeoLookup().getHostGeoInfo(InetAddress.getByName("geobytes.com"));
-        Assert.assertNotNull(geo, "host lookup unavailable");
-        Assert.assertEquals(geo.displayName, "Baltimore (US)");
-        Assert.assertEquals(geo.latitude, 39.2894, 0.1);
-        Assert.assertEquals(geo.longitude, -76.6384, 0.1);
-    }
-
-    @Test(groups = "Integration")
-    public void testUtraceLookup() throws Exception {
-        // The test times out in a VM - VirtualBox + Ubuntu Vivid, possibly due to proxy usage?
-        // Increase the timeout so we can actually test it's working correctly, regardless of test environment.
-        HostGeoInfo geo = new UtraceHostGeoLookup().getHostGeoInfo(InetAddress.getByName("utrace.de"), Duration.THIRTY_SECONDS);
-        Assert.assertNotNull(geo, "host lookup unavailable - maybe network not available ");
-        Assert.assertTrue(geo.displayName.contains("(DE)"));
-        Assert.assertEquals(geo.latitude, 51, 2);
-        Assert.assertEquals(geo.longitude, 9, 5);
-    }
-
-    @Test(groups = "Integration")  // only works if maxmind database is installed to ~/.brooklyn/
-    public void testMaxmindLookup() throws Exception {
-        HostGeoInfo geo = new MaxMind2HostGeoLookup().getHostGeoInfo(InetAddress.getByName("maxmind.com"));
-        Assert.assertNotNull(geo, "host lookup unavailable - is the maxmind database installed?");
-        log.info("maxmind.com at "+geo);
-        
-        // used to be Washington; now Dallas - in case this changes again, we will accept either!
-        // also have seen variation in lat/lon reported, so happy to within one degree now
-        Assert.assertTrue(Objects.equal(geo.displayName, "Washington, DC (US)") || Objects.equal(geo.displayName, "Dallas, TX (US)"), "name="+geo.displayName);
-        Assert.assertTrue(Math.abs(geo.latitude - 38.90) <= 1 || Math.abs(geo.latitude - 32.78) <= 1, "lat="+geo.latitude);
-        Assert.assertTrue(Math.abs(geo.longitude - -77.02) <= 1 || Math.abs(geo.longitude - -96.82) <= 1, "lon="+geo.longitude);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e2c57058/core/src/test/java/brooklyn/location/geo/LocalhostExternalIpLoaderIntegrationTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/location/geo/LocalhostExternalIpLoaderIntegrationTest.java b/core/src/test/java/brooklyn/location/geo/LocalhostExternalIpLoaderIntegrationTest.java
deleted file mode 100644
index 6ec9b00..0000000
--- a/core/src/test/java/brooklyn/location/geo/LocalhostExternalIpLoaderIntegrationTest.java
+++ /dev/null
@@ -1,53 +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.location.geo;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
-
-import java.util.Set;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.Sets;
-
-public class LocalhostExternalIpLoaderIntegrationTest {
-
-    private static final Logger LOG = LoggerFactory.getLogger(LocalhostExternalIpLoaderIntegrationTest.class);
-
-    @Test(groups = "Integration")
-    public void testHostsAgreeOnExternalIp() {
-        Set<String> ips = Sets.newHashSet();
-        for (String url : LocalhostExternalIpLoader.getIpAddressWebsites()) {
-            String ip = LocalhostExternalIpLoader.getIpAddressFrom(url);
-            LOG.debug("IP from {}: {}", url, ip);
-            ips.add(ip);
-        }
-        assertEquals(ips.size(), 1, "Expected all IP suppliers to agree on the external IP address of Brooklyn. " +
-                "Check logs for source responses. ips=" + ips);
-    }
-
-    @Test(groups = "Integration")
-    public void testLoadExternalIp() {
-        assertNotNull(LocalhostExternalIpLoader.getLocalhostIpWaiting());
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e2c57058/core/src/test/java/brooklyn/management/entitlement/AcmeEntitlementManagerTestFixture.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/management/entitlement/AcmeEntitlementManagerTestFixture.java b/core/src/test/java/brooklyn/management/entitlement/AcmeEntitlementManagerTestFixture.java
index 361c636..018641e 100644
--- a/core/src/test/java/brooklyn/management/entitlement/AcmeEntitlementManagerTestFixture.java
+++ b/core/src/test/java/brooklyn/management/entitlement/AcmeEntitlementManagerTestFixture.java
@@ -36,10 +36,7 @@ import brooklyn.config.BrooklynProperties;
 import brooklyn.entity.basic.ApplicationBuilder;
 import brooklyn.entity.basic.BasicApplication;
 import brooklyn.entity.basic.Entities;
-import brooklyn.location.Location;
-import brooklyn.management.entitlement.Entitlements;
-import brooklyn.management.entitlement.NotEntitledException;
-import brooklyn.management.entitlement.WebEntitlementContext;
+import org.apache.brooklyn.location.Location;
 import brooklyn.management.entitlement.Entitlements.EntityAndItem;
 import brooklyn.management.entitlement.Entitlements.StringAndArgument;
 import brooklyn.util.config.ConfigBag;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e2c57058/core/src/test/java/brooklyn/management/entitlement/EntityEntitlementTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/management/entitlement/EntityEntitlementTest.java b/core/src/test/java/brooklyn/management/entitlement/EntityEntitlementTest.java
index 6aa9167..c4c8956 100644
--- a/core/src/test/java/brooklyn/management/entitlement/EntityEntitlementTest.java
+++ b/core/src/test/java/brooklyn/management/entitlement/EntityEntitlementTest.java
@@ -34,7 +34,7 @@ import brooklyn.config.BrooklynProperties;
 import brooklyn.entity.basic.ApplicationBuilder;
 import brooklyn.entity.basic.BasicApplication;
 import brooklyn.entity.basic.Entities;
-import brooklyn.location.Location;
+import org.apache.brooklyn.location.Location;
 import brooklyn.management.entitlement.Entitlements.EntityAndItem;
 import brooklyn.management.entitlement.Entitlements.StringAndArgument;
 import brooklyn.management.internal.LocalManagementContext;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e2c57058/core/src/test/java/brooklyn/management/ha/HighAvailabilityManagerInMemoryTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/management/ha/HighAvailabilityManagerInMemoryTest.java b/core/src/test/java/brooklyn/management/ha/HighAvailabilityManagerInMemoryTest.java
index b4d4def..1062229 100644
--- a/core/src/test/java/brooklyn/management/ha/HighAvailabilityManagerInMemoryTest.java
+++ b/core/src/test/java/brooklyn/management/ha/HighAvailabilityManagerInMemoryTest.java
@@ -34,10 +34,10 @@ import org.testng.annotations.Test;
 import brooklyn.entity.basic.EntityInternal;
 import brooklyn.entity.rebind.persister.InMemoryObjectStore;
 import brooklyn.entity.rebind.persister.PersistenceObjectStore;
-import brooklyn.location.Location;
-import brooklyn.location.NoMachinesAvailableException;
-import brooklyn.location.basic.LocalhostMachineProvisioningLocation;
-import brooklyn.location.basic.SshMachineLocation;
+import org.apache.brooklyn.location.Location;
+import org.apache.brooklyn.location.NoMachinesAvailableException;
+import org.apache.brooklyn.location.basic.LocalhostMachineProvisioningLocation;
+import org.apache.brooklyn.location.basic.SshMachineLocation;
 import brooklyn.management.internal.LocalManagementContext;
 import brooklyn.util.collections.MutableList;
 

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e2c57058/core/src/test/java/brooklyn/management/ha/HighAvailabilityManagerSplitBrainTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/management/ha/HighAvailabilityManagerSplitBrainTest.java b/core/src/test/java/brooklyn/management/ha/HighAvailabilityManagerSplitBrainTest.java
index d085acf..ea99621 100644
--- a/core/src/test/java/brooklyn/management/ha/HighAvailabilityManagerSplitBrainTest.java
+++ b/core/src/test/java/brooklyn/management/ha/HighAvailabilityManagerSplitBrainTest.java
@@ -50,7 +50,7 @@ import brooklyn.entity.rebind.persister.ListeningObjectStore;
 import brooklyn.entity.rebind.persister.PersistMode;
 import brooklyn.entity.rebind.persister.PersistenceObjectStore;
 import brooklyn.internal.BrooklynFeatureEnablement;
-import brooklyn.location.Location;
+import org.apache.brooklyn.location.Location;
 import brooklyn.management.ha.TestEntityFailingRebind.RebindException;
 import brooklyn.management.internal.ManagementContextInternal;
 import brooklyn.test.Asserts;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e2c57058/core/src/test/java/brooklyn/management/ha/HotStandbyTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/management/ha/HotStandbyTest.java b/core/src/test/java/brooklyn/management/ha/HotStandbyTest.java
index 192a649..ae9e3b4 100644
--- a/core/src/test/java/brooklyn/management/ha/HotStandbyTest.java
+++ b/core/src/test/java/brooklyn/management/ha/HotStandbyTest.java
@@ -58,9 +58,9 @@ import brooklyn.entity.rebind.persister.InMemoryObjectStore;
 import brooklyn.entity.rebind.persister.ListeningObjectStore;
 import brooklyn.entity.rebind.persister.PersistMode;
 import brooklyn.entity.rebind.persister.PersistenceObjectStore;
-import brooklyn.location.Location;
-import brooklyn.location.LocationSpec;
-import brooklyn.location.basic.LocalhostMachineProvisioningLocation.LocalhostMachine;
+import org.apache.brooklyn.location.Location;
+import org.apache.brooklyn.location.LocationSpec;
+import org.apache.brooklyn.location.basic.LocalhostMachineProvisioningLocation.LocalhostMachine;
 import brooklyn.management.internal.AbstractManagementContext;
 import brooklyn.management.internal.ManagementContextInternal;
 import brooklyn.util.collections.MutableList;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e2c57058/core/src/test/java/brooklyn/management/ha/WarmStandbyTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/management/ha/WarmStandbyTest.java b/core/src/test/java/brooklyn/management/ha/WarmStandbyTest.java
index e4ab1ca..4afc78c 100644
--- a/core/src/test/java/brooklyn/management/ha/WarmStandbyTest.java
+++ b/core/src/test/java/brooklyn/management/ha/WarmStandbyTest.java
@@ -42,7 +42,7 @@ import brooklyn.entity.rebind.persister.InMemoryObjectStore;
 import brooklyn.entity.rebind.persister.ListeningObjectStore;
 import brooklyn.entity.rebind.persister.PersistMode;
 import brooklyn.entity.rebind.persister.PersistenceObjectStore;
-import brooklyn.location.Location;
+import org.apache.brooklyn.location.Location;
 import brooklyn.management.internal.ManagementContextInternal;
 import brooklyn.util.collections.MutableList;
 import brooklyn.util.collections.MutableMap;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e2c57058/core/src/test/java/brooklyn/management/internal/AccessManagerTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/management/internal/AccessManagerTest.java b/core/src/test/java/brooklyn/management/internal/AccessManagerTest.java
index 4faf676..59d92c7 100644
--- a/core/src/test/java/brooklyn/management/internal/AccessManagerTest.java
+++ b/core/src/test/java/brooklyn/management/internal/AccessManagerTest.java
@@ -33,9 +33,9 @@ import org.testng.annotations.Test;
 
 import brooklyn.entity.basic.ApplicationBuilder;
 import brooklyn.entity.basic.Entities;
-import brooklyn.location.Location;
-import brooklyn.location.LocationSpec;
-import brooklyn.location.basic.SimulatedLocation;
+import org.apache.brooklyn.location.Location;
+import org.apache.brooklyn.location.LocationSpec;
+import org.apache.brooklyn.location.basic.SimulatedLocation;
 import brooklyn.util.exceptions.Exceptions;
 
 import com.google.common.collect.ImmutableSet;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e2c57058/core/src/test/java/brooklyn/management/internal/LocalManagementContextTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/management/internal/LocalManagementContextTest.java b/core/src/test/java/brooklyn/management/internal/LocalManagementContextTest.java
index 2d1f296..a648c74 100644
--- a/core/src/test/java/brooklyn/management/internal/LocalManagementContextTest.java
+++ b/core/src/test/java/brooklyn/management/internal/LocalManagementContextTest.java
@@ -33,7 +33,7 @@ import org.testng.annotations.Test;
 
 import brooklyn.config.BrooklynProperties;
 import brooklyn.config.BrooklynProperties.Factory.Builder;
-import brooklyn.location.Location;
+import org.apache.brooklyn.location.Location;
 import brooklyn.util.os.Os;
 
 import com.google.common.base.Charsets;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e2c57058/core/src/test/java/brooklyn/policy/basic/PolicySubscriptionTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/policy/basic/PolicySubscriptionTest.java b/core/src/test/java/brooklyn/policy/basic/PolicySubscriptionTest.java
index 3981af7..e3b2dc8 100644
--- a/core/src/test/java/brooklyn/policy/basic/PolicySubscriptionTest.java
+++ b/core/src/test/java/brooklyn/policy/basic/PolicySubscriptionTest.java
@@ -31,7 +31,7 @@ import org.apache.brooklyn.entity.basic.RecordingSensorEventListener;
 import org.apache.brooklyn.test.entity.TestEntity;
 
 import brooklyn.event.basic.BasicSensorEvent;
-import brooklyn.location.basic.SimulatedLocation;
+import org.apache.brooklyn.location.basic.SimulatedLocation;
 import brooklyn.test.Asserts;
 
 import com.google.common.collect.ImmutableList;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e2c57058/core/src/test/java/brooklyn/qa/longevity/EntityCleanupLongevityTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/qa/longevity/EntityCleanupLongevityTest.java b/core/src/test/java/brooklyn/qa/longevity/EntityCleanupLongevityTest.java
index 4e2cb24..6b8f87c 100644
--- a/core/src/test/java/brooklyn/qa/longevity/EntityCleanupLongevityTest.java
+++ b/core/src/test/java/brooklyn/qa/longevity/EntityCleanupLongevityTest.java
@@ -20,8 +20,8 @@ package brooklyn.qa.longevity;
 
 import org.testng.annotations.Test;
 
-import brooklyn.location.LocationSpec;
-import brooklyn.location.basic.SimulatedLocation;
+import org.apache.brooklyn.location.LocationSpec;
+import org.apache.brooklyn.location.basic.SimulatedLocation;
 import brooklyn.util.javalang.JavaClassNames;
 
 /**

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e2c57058/core/src/test/java/brooklyn/qa/longevity/EntityCleanupLongevityTestFixture.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/qa/longevity/EntityCleanupLongevityTestFixture.java b/core/src/test/java/brooklyn/qa/longevity/EntityCleanupLongevityTestFixture.java
index a6843e4..225dc08 100644
--- a/core/src/test/java/brooklyn/qa/longevity/EntityCleanupLongevityTestFixture.java
+++ b/core/src/test/java/brooklyn/qa/longevity/EntityCleanupLongevityTestFixture.java
@@ -39,8 +39,8 @@ import brooklyn.entity.basic.Entities;
 import brooklyn.internal.storage.BrooklynStorage;
 import brooklyn.internal.storage.DataGrid;
 import brooklyn.internal.storage.impl.BrooklynStorageImpl;
-import brooklyn.location.LocationSpec;
-import brooklyn.location.basic.SimulatedLocation;
+import org.apache.brooklyn.location.LocationSpec;
+import org.apache.brooklyn.location.basic.SimulatedLocation;
 import brooklyn.management.internal.AbstractManagementContext;
 import brooklyn.management.internal.LocalManagementContext;
 import brooklyn.management.internal.ManagementContextInternal;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e2c57058/core/src/test/java/brooklyn/qa/longevity/EntityCleanupTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/qa/longevity/EntityCleanupTest.java b/core/src/test/java/brooklyn/qa/longevity/EntityCleanupTest.java
index 1e3898c..2313e08 100644
--- a/core/src/test/java/brooklyn/qa/longevity/EntityCleanupTest.java
+++ b/core/src/test/java/brooklyn/qa/longevity/EntityCleanupTest.java
@@ -20,8 +20,8 @@ package brooklyn.qa.longevity;
 
 import org.testng.annotations.Test;
 
-import brooklyn.location.LocationSpec;
-import brooklyn.location.basic.SimulatedLocation;
+import org.apache.brooklyn.location.LocationSpec;
+import org.apache.brooklyn.location.basic.SimulatedLocation;
 import brooklyn.util.javalang.JavaClassNames;
 
 public class EntityCleanupTest extends EntityCleanupLongevityTestFixture {

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e2c57058/core/src/test/java/brooklyn/qa/performance/AbstractPerformanceTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/qa/performance/AbstractPerformanceTest.java b/core/src/test/java/brooklyn/qa/performance/AbstractPerformanceTest.java
index 87784f0..ec6553d 100644
--- a/core/src/test/java/brooklyn/qa/performance/AbstractPerformanceTest.java
+++ b/core/src/test/java/brooklyn/qa/performance/AbstractPerformanceTest.java
@@ -31,7 +31,7 @@ import org.testng.annotations.BeforeMethod;
 
 import brooklyn.entity.basic.ApplicationBuilder;
 import brooklyn.entity.basic.Entities;
-import brooklyn.location.basic.SimulatedLocation;
+import org.apache.brooklyn.location.basic.SimulatedLocation;
 import brooklyn.util.internal.DoubleSystemProperty;
 
 import com.google.common.base.Stopwatch;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e2c57058/core/src/test/java/brooklyn/qa/performance/EntityPersistencePerformanceTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/qa/performance/EntityPersistencePerformanceTest.java b/core/src/test/java/brooklyn/qa/performance/EntityPersistencePerformanceTest.java
index 84ce2f1..1f8b669 100644
--- a/core/src/test/java/brooklyn/qa/performance/EntityPersistencePerformanceTest.java
+++ b/core/src/test/java/brooklyn/qa/performance/EntityPersistencePerformanceTest.java
@@ -30,8 +30,8 @@ import org.apache.brooklyn.test.entity.TestEntity;
 import org.testng.annotations.Test;
 
 import brooklyn.entity.rebind.RebindTestFixtureWithApp;
-import brooklyn.location.LocationSpec;
-import brooklyn.location.basic.SimulatedLocation;
+import org.apache.brooklyn.location.LocationSpec;
+import org.apache.brooklyn.location.basic.SimulatedLocation;
 import brooklyn.test.policy.TestPolicy;
 import brooklyn.util.repeat.Repeater;
 import brooklyn.util.time.Duration;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e2c57058/core/src/test/java/brooklyn/test/HttpService.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/test/HttpService.java b/core/src/test/java/brooklyn/test/HttpService.java
index 6b9aa94..8a73541 100644
--- a/core/src/test/java/brooklyn/test/HttpService.java
+++ b/core/src/test/java/brooklyn/test/HttpService.java
@@ -39,8 +39,8 @@ import org.eclipse.jetty.webapp.WebAppContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import brooklyn.location.PortRange;
-import brooklyn.location.basic.LocalhostMachineProvisioningLocation;
+import org.apache.brooklyn.location.PortRange;
+import org.apache.brooklyn.location.basic.LocalhostMachineProvisioningLocation;
 import brooklyn.util.ResourceUtils;
 import brooklyn.util.crypto.SecureKeys;
 import brooklyn.util.javalang.Threads;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e2c57058/core/src/test/java/brooklyn/test/location/TestPaasLocation.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/test/location/TestPaasLocation.java b/core/src/test/java/brooklyn/test/location/TestPaasLocation.java
index be2ba56..0021d89 100644
--- a/core/src/test/java/brooklyn/test/location/TestPaasLocation.java
+++ b/core/src/test/java/brooklyn/test/location/TestPaasLocation.java
@@ -18,11 +18,11 @@
  */
 package brooklyn.test.location;
 
-import brooklyn.location.basic.AbstractLocation;
-import brooklyn.location.paas.PaasLocation;
+import org.apache.brooklyn.location.basic.AbstractLocation;
+import org.apache.brooklyn.location.paas.PaasLocation;
 
 /**
- * Mock {@link brooklyn.location.paas.PaasLocation} for test purposes
+ * Mock {@link PaasLocation} for test purposes
  */
 public class TestPaasLocation extends AbstractLocation implements PaasLocation {
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e2c57058/core/src/test/java/brooklyn/util/file/ArchiveUtilsTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/util/file/ArchiveUtilsTest.java b/core/src/test/java/brooklyn/util/file/ArchiveUtilsTest.java
index dba8410..6715444 100644
--- a/core/src/test/java/brooklyn/util/file/ArchiveUtilsTest.java
+++ b/core/src/test/java/brooklyn/util/file/ArchiveUtilsTest.java
@@ -32,7 +32,7 @@ import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
 import brooklyn.entity.BrooklynAppUnitTestSupport;
-import brooklyn.location.basic.SshMachineLocation;
+import org.apache.brooklyn.location.basic.SshMachineLocation;
 import brooklyn.util.ResourceUtils;
 import brooklyn.util.os.Os;
 

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e2c57058/core/src/test/java/brooklyn/util/http/HttpToolIntegrationTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/util/http/HttpToolIntegrationTest.java b/core/src/test/java/brooklyn/util/http/HttpToolIntegrationTest.java
index f6fc1cd..dc9fc31 100644
--- a/core/src/test/java/brooklyn/util/http/HttpToolIntegrationTest.java
+++ b/core/src/test/java/brooklyn/util/http/HttpToolIntegrationTest.java
@@ -27,7 +27,7 @@ import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
-import brooklyn.location.basic.PortRanges;
+import org.apache.brooklyn.location.basic.PortRanges;
 import brooklyn.test.HttpService;
 
 import com.google.common.collect.ImmutableMap;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e2c57058/core/src/test/java/brooklyn/util/ssh/BashCommandsIntegrationTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/util/ssh/BashCommandsIntegrationTest.java b/core/src/test/java/brooklyn/util/ssh/BashCommandsIntegrationTest.java
index 1f8ba28..accac56 100644
--- a/core/src/test/java/brooklyn/util/ssh/BashCommandsIntegrationTest.java
+++ b/core/src/test/java/brooklyn/util/ssh/BashCommandsIntegrationTest.java
@@ -44,8 +44,8 @@ import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
 import brooklyn.entity.basic.Entities;
-import brooklyn.location.basic.LocalhostMachineProvisioningLocation;
-import brooklyn.location.basic.SshMachineLocation;
+import org.apache.brooklyn.location.basic.LocalhostMachineProvisioningLocation;
+import org.apache.brooklyn.location.basic.SshMachineLocation;
 import brooklyn.util.javalang.JavaClassNames;
 import brooklyn.util.net.Networking;
 import brooklyn.util.os.Os;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e2c57058/core/src/test/java/brooklyn/util/task/ssh/SshTasksTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/util/task/ssh/SshTasksTest.java b/core/src/test/java/brooklyn/util/task/ssh/SshTasksTest.java
index 1f31447..6fd7560 100644
--- a/core/src/test/java/brooklyn/util/task/ssh/SshTasksTest.java
+++ b/core/src/test/java/brooklyn/util/task/ssh/SshTasksTest.java
@@ -32,9 +32,9 @@ import org.testng.annotations.Test;
 
 import brooklyn.entity.basic.BrooklynConfigKeys;
 import brooklyn.entity.basic.Entities;
-import brooklyn.location.LocationSpec;
-import brooklyn.location.basic.LocalhostMachineProvisioningLocation;
-import brooklyn.location.basic.SshMachineLocation;
+import org.apache.brooklyn.location.LocationSpec;
+import org.apache.brooklyn.location.basic.LocalhostMachineProvisioningLocation;
+import org.apache.brooklyn.location.basic.SshMachineLocation;
 import brooklyn.management.internal.LocalManagementContext;
 import brooklyn.util.net.Urls;
 import brooklyn.util.os.Os;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e2c57058/core/src/test/java/org/apache/brooklyn/location/access/PortForwardManagerLocationResolverTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/location/access/PortForwardManagerLocationResolverTest.java b/core/src/test/java/org/apache/brooklyn/location/access/PortForwardManagerLocationResolverTest.java
new file mode 100644
index 0000000..da69b24
--- /dev/null
+++ b/core/src/test/java/org/apache/brooklyn/location/access/PortForwardManagerLocationResolverTest.java
@@ -0,0 +1,83 @@
+/*
+ * 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.location.access;
+
+import org.apache.brooklyn.location.Location;
+import org.apache.brooklyn.test.entity.LocalManagementContextForTests;
+import org.testng.Assert;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import brooklyn.entity.basic.Entities;
+import brooklyn.management.internal.LocalManagementContext;
+
+public class PortForwardManagerLocationResolverTest {
+
+    private LocalManagementContext managementContext;
+
+    @BeforeMethod(alwaysRun=true)
+    public void setUp() throws Exception {
+        managementContext = LocalManagementContextForTests.newInstance();
+    }
+    
+    @AfterMethod(alwaysRun=true)
+    public void tearDown() throws Exception {
+        if (managementContext != null) Entities.destroyAll(managementContext);
+    }
+    
+    @Test
+    public void testReturnsSameInstanceBasedOnScope() {
+        Location global1 = resolve("portForwardManager()"); // defaults to global
+        Location global2 = resolve("portForwardManager()");
+        Location global3 = resolve("portForwardManager(scope=global)");
+        assertSame(global1, global2);
+        assertSame(global1, global3);
+        
+        Location a1 = resolve("portForwardManager(scope=a)");
+        Location a2 = resolve("portForwardManager(scope=a)");
+        assertSame(a1, a2);
+        assertNotSame(global1, a1);
+        
+        Location b1 = resolve("portForwardManager(scope=b)");
+        assertNotSame(global1, b1);
+        assertNotSame(a1, b1);
+    }
+
+    private Location resolve(String val) {
+        Location l = managementContext.getLocationRegistry().resolve(val);
+        Assert.assertNotNull(l);
+        return l;
+    }
+    
+    private void assertSame(Location loc1, Location loc2) {
+        Assert.assertNotNull(loc1);
+        Assert.assertTrue(loc1 instanceof PortForwardManager, "loc1="+loc1);
+        Assert.assertSame(loc1, loc2);
+    }
+    
+    private void assertNotSame(Location loc1, Location loc2) {
+        Assert.assertNotNull(loc1);
+        Assert.assertNotNull(loc2);
+        Assert.assertTrue(loc1 instanceof PortForwardManager, "loc1="+loc1);
+        Assert.assertTrue(loc2 instanceof PortForwardManager, "loc2="+loc2);
+        Assert.assertNotSame(loc1, loc2);
+        Assert.assertNotEquals(((PortForwardManager)loc1).getId(), ((PortForwardManager)loc2).getId());
+    }
+}