http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/64c2b2e5/software/base/src/test/java/brooklyn/entity/brooklynnode/SelectMasterEffectorTest.java
----------------------------------------------------------------------
diff --git 
a/software/base/src/test/java/brooklyn/entity/brooklynnode/SelectMasterEffectorTest.java
 
b/software/base/src/test/java/brooklyn/entity/brooklynnode/SelectMasterEffectorTest.java
deleted file mode 100644
index efef932..0000000
--- 
a/software/base/src/test/java/brooklyn/entity/brooklynnode/SelectMasterEffectorTest.java
+++ /dev/null
@@ -1,257 +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.entity.brooklynnode;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
-import static org.testng.Assert.fail;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.concurrent.Callable;
-
-import org.apache.brooklyn.api.entity.Entity;
-import org.apache.brooklyn.api.entity.EntitySpec;
-import org.apache.brooklyn.api.entity.Group;
-import org.apache.brooklyn.api.internal.EntityLocal;
-import org.apache.brooklyn.api.mgmt.ha.ManagementNodeState;
-import org.apache.brooklyn.core.test.BrooklynAppUnitTestSupport;
-import org.apache.brooklyn.effector.core.Effectors;
-import org.apache.brooklyn.entity.core.Entities;
-import org.apache.brooklyn.entity.group.DynamicCluster;
-import org.apache.brooklyn.sensor.feed.AttributePollHandler;
-import org.apache.brooklyn.sensor.feed.DelegatingPollHandler;
-import org.apache.brooklyn.sensor.feed.Poller;
-import org.apache.brooklyn.test.EntityTestUtils;
-import org.apache.brooklyn.util.collections.MutableList;
-import org.apache.brooklyn.util.time.Duration;
-import org.apache.http.client.methods.HttpPost;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.Assert;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import brooklyn.entity.brooklynnode.BrooklynCluster.SelectMasterEffector;
-import brooklyn.entity.brooklynnode.CallbackEntityHttpClient.Request;
-
-import com.google.common.base.Function;
-import com.google.common.base.Objects;
-import com.google.common.collect.ImmutableMap;
-
-public class SelectMasterEffectorTest extends BrooklynAppUnitTestSupport {
-    private static final Logger LOG = 
LoggerFactory.getLogger(BrooklynClusterImpl.class);
-
-    protected BrooklynCluster cluster;
-    protected HttpCallback http; 
-    protected Poller<Void> poller;
-
-    @BeforeMethod(alwaysRun=true)
-    public void setUp() throws Exception {
-        super.setUp();
-
-        // because the effector calls wait for a state change, use a separate 
thread to drive that 
-        poller = new Poller<Void>((EntityLocal)app, false);
-        poller.scheduleAtFixedRate(
-            new Callable<Void>() {
-                @Override
-                public Void call() throws Exception {
-                    masterFailoverIfNeeded();
-                    return null;
-                }
-            },
-            new 
DelegatingPollHandler<Void>(Collections.<AttributePollHandler<? super 
Void>>emptyList()),
-            Duration.millis(20));
-        poller.start();
-    }
-
-    @Override
-    protected void setUpApp() {
-        super.setUpApp();
-        http = new HttpCallback();
-        cluster = 
app.createAndManageChild(EntitySpec.create(BrooklynCluster.class)
-            .location(app.newLocalhostProvisioningLocation())
-            .configure(BrooklynCluster.MEMBER_SPEC, 
EntitySpec.create(BrooklynNode.class)
-                .impl(MockBrooklynNode.class)
-                .configure(MockBrooklynNode.HTTP_CLIENT_CALLBACK, http)));
-    }
-    
-    @AfterMethod(alwaysRun=true)
-    public void tearDown() throws Exception {
-        poller.stop();
-        super.tearDown();
-    }
-
-    @Test
-    public void testInvalidNewMasterIdFails() {
-        try {
-            selectMaster(cluster, "1234");
-            fail("Non-existend entity ID provided.");
-        } catch (Exception e) {
-            assertTrue(e.toString().contains("1234 is not an ID of brooklyn 
node in this cluster"));
-        }
-    }
-
-    @Test(groups="Integration") // because slow, due to sensor feeds
-    public void testSelectMasterAfterChange() {
-        List<Entity> nodes = makeTwoNodes();
-        EntityTestUtils.assertAttributeEqualsEventually(cluster, 
BrooklynCluster.MASTER_NODE, (BrooklynNode)nodes.get(0));
-
-        selectMaster(cluster, nodes.get(1).getId());
-        checkMaster(cluster, nodes.get(1));
-    }
-
-    @Test
-    public void testFindMaster() {
-        List<Entity> nodes = makeTwoNodes();
-        
Assert.assertEquals(((BrooklynClusterImpl)Entities.deproxy(cluster)).findMasterChild(),
 nodes.get(0));
-    }
-    
-    @Test(groups="Integration") // because slow, due to sensor feeds
-    public void testSelectMasterFailsAtChangeState() {
-        http.setFailAtStateChange(true);
-
-        List<Entity> nodes = makeTwoNodes();
-        
-        EntityTestUtils.assertAttributeEqualsEventually(cluster, 
BrooklynCluster.MASTER_NODE, (BrooklynNode)nodes.get(0));
-
-        try {
-            selectMaster(cluster, nodes.get(1).getId());
-            fail("selectMaster should have failed");
-        } catch (Exception e) {
-            // expected
-        }
-        checkMaster(cluster, nodes.get(0));
-    }
-
-    private List<Entity> makeTwoNodes() {
-        List<Entity> nodes = MutableList.copyOf(cluster.resizeByDelta(2));
-        setManagementState(nodes.get(0), ManagementNodeState.MASTER);
-        setManagementState(nodes.get(1), ManagementNodeState.HOT_STANDBY);
-        return nodes;
-    }
-
-    private void checkMaster(Group cluster, Entity node) {
-        assertEquals(node.getAttribute(BrooklynNode.MANAGEMENT_NODE_STATE), 
ManagementNodeState.MASTER);
-        assertEquals(cluster.getAttribute(BrooklynCluster.MASTER_NODE), node);
-        for (Entity member : cluster.getMembers()) {
-            if (member != node) {
-                
assertEquals(member.getAttribute(BrooklynNode.MANAGEMENT_NODE_STATE), 
ManagementNodeState.HOT_STANDBY);
-            }
-            
assertEquals((int)member.getAttribute(MockBrooklynNode.HA_PRIORITY), 0);
-        }
-    }
-
-    private static class HttpCallback implements 
Function<CallbackEntityHttpClient.Request, String> {
-        private enum State {
-            INITIAL,
-            PROMOTED
-        }
-        private State state = State.INITIAL;
-        private boolean failAtStateChange;
-
-        @Override
-        public String apply(Request input) {
-            if ("/v1/server/ha/state".equals(input.getPath())) {
-                if (failAtStateChange) {
-                    throw new RuntimeException("Testing failure at changing 
node state");
-                }
-
-                checkRequest(input, HttpPost.METHOD_NAME, 
"/v1/server/ha/state", "mode", "HOT_STANDBY");
-                Entity entity = input.getEntity();
-                EntityTestUtils.assertAttributeEquals(entity, 
BrooklynNode.MANAGEMENT_NODE_STATE, ManagementNodeState.MASTER);
-                EntityTestUtils.assertAttributeEquals(entity, 
MockBrooklynNode.HA_PRIORITY, 0);
-
-                setManagementState(entity, ManagementNodeState.HOT_STANDBY);
-
-                return "MASTER";
-            } else {
-                switch(state) {
-                case INITIAL:
-                    checkRequest(input, HttpPost.METHOD_NAME, 
"/v1/server/ha/priority", "priority", "1");
-                    state = State.PROMOTED;
-                    setPriority(input.getEntity(), 
Integer.parseInt(input.getParams().get("priority")));
-                    return "0";
-                case PROMOTED:
-                    checkRequest(input, HttpPost.METHOD_NAME, 
"/v1/server/ha/priority", "priority", "0");
-                    state = State.INITIAL;
-                    setPriority(input.getEntity(), 
Integer.parseInt(input.getParams().get("priority")));
-                    return "1";
-                default: throw new IllegalStateException("Illegal call at 
state " + state + ". Request = " + input.getMethod() + " " + input.getPath());
-                }
-            }
-        }
-
-        public void checkRequest(Request input, String methodName, String 
path, String key, String value) {
-            if (!input.getMethod().equals(methodName) || 
!input.getPath().equals(path)) {
-                throw new IllegalStateException("Request doesn't match 
expected state. Expected = " + input.getMethod() + " " + input.getPath() + ". " 
+
-                        "Actual = " + methodName + " " + path);
-            }
-
-            String inputValue = input.getParams().get(key);
-            if(!Objects.equal(value, inputValue)) {
-                throw new IllegalStateException("Request doesn't match 
expected parameter " + methodName + " " + path + ". Parameter " + key + 
-                    " expected = " + value + ", actual = " + inputValue);
-            }
-        }
-
-        public void setFailAtStateChange(boolean failAtStateChange) {
-            this.failAtStateChange = failAtStateChange;
-        }
-
-    }
-
-    private void masterFailoverIfNeeded() {
-        if (!Entities.isManaged(cluster)) return;
-        if (cluster.getAttribute(BrooklynCluster.MASTER_NODE) == null) {
-            Collection<Entity> members = cluster.getMembers();
-            if (members.size() > 0) {
-                for (Entity member : members) {
-                    if (member.getAttribute(MockBrooklynNode.HA_PRIORITY) == 
1) {
-                        masterFailover(member);
-                        return;
-                    }
-                }
-                masterFailover(members.iterator().next());
-            }
-        }
-    }
-
-    private void masterFailover(Entity member) {
-        LOG.debug("Master failover to " + member);
-        setManagementState(member, ManagementNodeState.MASTER);
-        EntityTestUtils.assertAttributeEqualsEventually(cluster, 
BrooklynCluster.MASTER_NODE, (BrooklynNode)member);
-        return;
-    }
-
-    public static void setManagementState(Entity entity, ManagementNodeState 
state) {
-        ((EntityLocal)entity).setAttribute(BrooklynNode.MANAGEMENT_NODE_STATE, 
state);
-    }
-
-    public static void setPriority(Entity entity, int priority) {
-        ((EntityLocal)entity).setAttribute(MockBrooklynNode.HA_PRIORITY, 
priority);
-    }
-
-    private void selectMaster(DynamicCluster cluster, String id) {
-        app.getExecutionContext().submit(Effectors.invocation(cluster, 
BrooklynCluster.SELECT_MASTER, 
ImmutableMap.of(SelectMasterEffector.NEW_MASTER_ID.getName(), 
id))).asTask().getUnchecked();
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/64c2b2e5/software/base/src/test/java/brooklyn/entity/chef/ChefConfigsTest.java
----------------------------------------------------------------------
diff --git 
a/software/base/src/test/java/brooklyn/entity/chef/ChefConfigsTest.java 
b/software/base/src/test/java/brooklyn/entity/chef/ChefConfigsTest.java
deleted file mode 100644
index f2e25ad..0000000
--- a/software/base/src/test/java/brooklyn/entity/chef/ChefConfigsTest.java
+++ /dev/null
@@ -1,50 +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.entity.chef;
-
-import java.util.Set;
-
-import org.apache.brooklyn.core.test.entity.TestApplication;
-import org.apache.brooklyn.entity.core.Entities;
-import org.apache.brooklyn.entity.factory.ApplicationBuilder;
-import org.testng.Assert;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.Test;
-
-public class ChefConfigsTest {
-
-    private TestApplication app = null;
-
-    @AfterMethod(alwaysRun=true)
-    public void tearDown() {
-        if (app!=null) Entities.destroyAll(app.getManagementContext());
-        app = null;
-    }
-    
-    @Test
-    public void testAddToRunList() {
-        app = ApplicationBuilder.newManagedApp(TestApplication.class);
-        ChefConfigs.addToLaunchRunList(app, "a", "b");
-        Set<? extends String> runs = 
app.getConfig(ChefConfig.CHEF_LAUNCH_RUN_LIST);
-        Assert.assertEquals(runs.size(), 2, "runs="+runs);
-        Assert.assertTrue(runs.contains("a"));
-        Assert.assertTrue(runs.contains("b"));
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/64c2b2e5/software/base/src/test/java/brooklyn/entity/chef/ChefLiveTestSupport.java
----------------------------------------------------------------------
diff --git 
a/software/base/src/test/java/brooklyn/entity/chef/ChefLiveTestSupport.java 
b/software/base/src/test/java/brooklyn/entity/chef/ChefLiveTestSupport.java
deleted file mode 100644
index 038657b..0000000
--- a/software/base/src/test/java/brooklyn/entity/chef/ChefLiveTestSupport.java
+++ /dev/null
@@ -1,98 +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.entity.chef;
-
-import java.io.File;
-import java.io.IOException;
-
-import org.apache.brooklyn.api.entity.Entity;
-import org.apache.brooklyn.api.location.Location;
-import org.apache.brooklyn.api.location.MachineProvisioningLocation;
-import org.apache.brooklyn.api.mgmt.ManagementContext;
-import org.apache.brooklyn.core.test.BrooklynAppLiveTestSupport;
-import org.apache.brooklyn.entity.core.EntityInternal;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.annotations.BeforeMethod;
-import org.apache.brooklyn.location.basic.SshMachineLocation;
-import org.apache.brooklyn.util.core.ResourceUtils;
-import org.apache.brooklyn.util.io.FileUtil;
-import org.apache.brooklyn.util.stream.InputStreamSupplier;
-
-import com.google.common.base.Throwables;
-import com.google.common.io.Files;
-
-public class ChefLiveTestSupport extends BrooklynAppLiveTestSupport {
-
-    private static final Logger log = 
LoggerFactory.getLogger(ChefLiveTestSupport.class);
-    
-    protected MachineProvisioningLocation<? extends SshMachineLocation> 
targetLocation;
-
-    @BeforeMethod(alwaysRun=true)
-    @Override
-    public void setUp() throws Exception {
-        super.setUp();
-        
-        targetLocation = createLocation();
-    }
-
-    protected MachineProvisioningLocation<? extends SshMachineLocation> 
createLocation() {
-        return createLocation(mgmt);
-    }
-    
-    /** convenience for setting up a pre-built / fixed IP machine
-     * (because you might not want to set up Chef on localhost) 
-     * and ensuring tests against Chef use the same configured location 
-     **/
-    @SuppressWarnings("unchecked")
-    public static MachineProvisioningLocation<? extends SshMachineLocation> 
createLocation(ManagementContext mgmt) {
-        Location bestLocation = 
mgmt.getLocationRegistry().resolve("named:ChefTests", true, null).orNull();
-        if (bestLocation==null) {
-            log.info("using AWS for chef tests because named:ChefTests does 
not exist");
-            bestLocation = 
mgmt.getLocationRegistry().resolve("jclouds:aws-ec2:us-east-1");
-        }
-        if (bestLocation==null) {
-            throw new IllegalStateException("Need a location called 
named:ChefTests or AWS configured for these tests");
-        }
-        return (MachineProvisioningLocation<? extends 
SshMachineLocation>)bestLocation; 
-    }
-    
-    private static String defaultConfigFile = null; 
-    public synchronized static String installBrooklynChefHostedConfig() {
-        if (defaultConfigFile!=null) return defaultConfigFile;
-        File tempDir = Files.createTempDir();
-        ResourceUtils r = 
ResourceUtils.create(ChefServerTasksIntegrationTest.class);
-        try {
-            for (String f: new String[] { "knife.rb", "brooklyn-tests.pem", 
"brooklyn-validator.pem" }) {
-                String contents = 
r.getResourceAsString("classpath:///brooklyn/entity/chef/hosted-chef-brooklyn-credentials/"+f);
-                
FileUtil.copyTo(InputStreamSupplier.fromString(contents).getInput(), new 
File(tempDir, f));
-            }
-        } catch (IOException e) {
-            throw Throwables.propagate(e);
-        }
-        File knifeConfig = new File(tempDir, "knife.rb");
-        defaultConfigFile = knifeConfig.getPath();
-        return defaultConfigFile;
-    }
-
-    public static void installBrooklynChefHostedConfig(Entity entity) {
-        ((EntityInternal)entity).setConfig(ChefConfig.KNIFE_CONFIG_FILE, 
ChefLiveTestSupport.installBrooklynChefHostedConfig());
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/64c2b2e5/software/base/src/test/java/brooklyn/entity/chef/ChefServerTasksIntegrationTest.java
----------------------------------------------------------------------
diff --git 
a/software/base/src/test/java/brooklyn/entity/chef/ChefServerTasksIntegrationTest.java
 
b/software/base/src/test/java/brooklyn/entity/chef/ChefServerTasksIntegrationTest.java
deleted file mode 100644
index 1df48e5..0000000
--- 
a/software/base/src/test/java/brooklyn/entity/chef/ChefServerTasksIntegrationTest.java
+++ /dev/null
@@ -1,124 +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.entity.chef;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-
-import org.apache.brooklyn.api.mgmt.ManagementContext;
-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.core.task.system.ProcessTaskWrapper;
-import org.apache.brooklyn.util.stream.StreamGobbler;
-import org.apache.brooklyn.util.time.Duration;
-import org.apache.brooklyn.util.time.Time;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.Assert;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-/** Many tests expect knife on the path, but none require any configuration 
beyond that.
- * They will use the Brooklyn registered account (which has been set up with 
mysql cookbooks and more).
- * <p>
- * Note this is a free account so cannot manage many nodes. 
- * You can use the credentials in 
src/test/resources/hosted-chef-brooklyn-credentials/
- * to log in and configure the settings for our tests using knife. You can 
also log in at:
- * <p>
- * https://manage.opscode.com/
- * <p>
- * with credentials for those with need to know (which is a lot of people, but 
not everyone
- * with access to this github repo!).
- * <p>
- * You can easily set up your own new account, for free; download the starter 
kit and
- * point {@link ChefConfig#KNIFE_CONFIG_FILE} at the knife.rb.
- * <p>
- * Note that if you are porting an existing machine to be managed by a new 
chef account, you may need to do the following:
- * <p>
- * ON management machine:
- * <li>knife client delete HOST   # or bulk delete, but don't delete your 
validator! it is a PITA recreating and adding back all the permissions! 
- * <li>knife node delete HOST
- * <p>
- * ON machine being managed:
- * <li>rm -rf /{etc,var}/chef
- * <p>
- * Note also that some tests require a location  named:ChefLive  to be set up 
in your brooklyn.properties.
- * This can be a cloud (but will require frequent chef-node pruning) or a 
permanently set-up machine.
- **/
-public class ChefServerTasksIntegrationTest {
-
-    private static final Logger log = 
LoggerFactory.getLogger(ChefServerTasksIntegrationTest.class);
-    
-    protected TestApplication app;
-    protected ManagementContext mgmt;
-
-    @BeforeMethod(alwaysRun=true)
-    public void setup() throws Exception {
-        app = ApplicationBuilder.newManagedApp(TestApplication.class);
-        mgmt = app.getManagementContext();
-    }
-
-    @AfterMethod(alwaysRun=true)
-    public void tearDown() throws Exception {
-        if (mgmt != null) Entities.destroyAll(mgmt);
-        mgmt = null;
-    }
-
-    /** @deprecated use {@link ChefLiveTestSupport} */
-    @Deprecated
-    public synchronized static String installBrooklynChefHostedConfig() {
-        return ChefLiveTestSupport.installBrooklynChefHostedConfig();
-    }
-    
-    @Test(groups="Integration")
-    @SuppressWarnings("resource")
-    public void testWhichKnife() throws IOException, InterruptedException {
-        // requires that knife is installed on the path of login shells
-        Process p = Runtime.getRuntime().exec(new String[] { "bash", "-l", 
"-c", "which knife" });
-        ByteArrayOutputStream out = new ByteArrayOutputStream();
-        new StreamGobbler(p.getInputStream(), out, log).start();
-        new StreamGobbler(p.getErrorStream(), out, log).start();
-        log.info("bash -l -c 'which knife' gives exit code: "+p.waitFor());
-        Time.sleep(Duration.millis(1000));
-        log.info("output:\n"+out);
-        Assert.assertEquals(p.exitValue(), 0);
-    }
-
-    @Test(groups="Integration")
-    public void testKnifeWithoutConfig() {
-        // without config it shouldn't pass
-        // (assumes that knife global config is *not* installed on your 
machine)
-        ProcessTaskWrapper<Boolean> t = Entities.submit(app, 
ChefServerTasks.isKnifeInstalled());
-        log.info("isKnifeInstalled without config returned: "+t.get()+" 
("+t.getExitCode()+")\n"+t.getStdout()+"\nERR:\n"+t.getStderr());
-        Assert.assertFalse(t.get());
-    }
-
-    @Test(groups="Integration")
-    public void testKnifeWithConfig() {
-        // requires that knife is installed on the path of login shells
-        // (creates the config in a temp space)
-        ChefLiveTestSupport.installBrooklynChefHostedConfig(app);
-        ProcessTaskWrapper<Boolean> t = Entities.submit(app, 
ChefServerTasks.isKnifeInstalled());
-        log.info("isKnifeInstalled *with* config returned: "+t.get()+" 
("+t.getExitCode()+")\n"+t.getStdout()+"\nERR:\n"+t.getStderr());
-        Assert.assertTrue(t.get());
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/64c2b2e5/software/base/src/test/java/brooklyn/entity/chef/mysql/AbstractChefToyMySqlEntityLiveTest.java
----------------------------------------------------------------------
diff --git 
a/software/base/src/test/java/brooklyn/entity/chef/mysql/AbstractChefToyMySqlEntityLiveTest.java
 
b/software/base/src/test/java/brooklyn/entity/chef/mysql/AbstractChefToyMySqlEntityLiveTest.java
deleted file mode 100644
index 92bb587..0000000
--- 
a/software/base/src/test/java/brooklyn/entity/chef/mysql/AbstractChefToyMySqlEntityLiveTest.java
+++ /dev/null
@@ -1,42 +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.entity.chef.mysql;
-
-import org.testng.annotations.Test;
-
-import brooklyn.entity.chef.ChefLiveTestSupport;
-import brooklyn.entity.software.mysql.AbstractToyMySqlEntityTest;
-
-import org.apache.brooklyn.api.location.MachineProvisioningLocation;
-import org.apache.brooklyn.location.basic.SshMachineLocation;
-
-public abstract class AbstractChefToyMySqlEntityLiveTest extends 
AbstractToyMySqlEntityTest {
-
-    @Override
-    // mark as live here
-    @Test(groups = "Live")
-    public void testMySqlOnProvisioningLocation() throws Exception {
-        super.testMySqlOnProvisioningLocation();
-    }
-    
-    protected MachineProvisioningLocation<? extends SshMachineLocation> 
createLocation() {
-        return ChefLiveTestSupport.createLocation(mgmt);
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/64c2b2e5/software/base/src/test/java/brooklyn/entity/chef/mysql/ChefSoloDriverMySqlEntityLiveTest.java
----------------------------------------------------------------------
diff --git 
a/software/base/src/test/java/brooklyn/entity/chef/mysql/ChefSoloDriverMySqlEntityLiveTest.java
 
b/software/base/src/test/java/brooklyn/entity/chef/mysql/ChefSoloDriverMySqlEntityLiveTest.java
deleted file mode 100644
index 77e9590..0000000
--- 
a/software/base/src/test/java/brooklyn/entity/chef/mysql/ChefSoloDriverMySqlEntityLiveTest.java
+++ /dev/null
@@ -1,50 +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.entity.chef.mysql;
-
-import org.apache.brooklyn.api.entity.Entity;
-import org.apache.brooklyn.api.entity.EntitySpec;
-import org.apache.brooklyn.entity.core.Entities;
-import org.apache.brooklyn.util.core.task.system.ProcessTaskWrapper;
-import org.testng.annotations.Test;
-
-import brooklyn.entity.basic.SoftwareProcess;
-import brooklyn.entity.software.SshEffectorTasks;
-
-public class ChefSoloDriverMySqlEntityLiveTest extends 
AbstractChefToyMySqlEntityLiveTest {
-
-    // test here just so Eclipse IDE picks it up
-    @Override @Test(groups="Live")
-    public void testMySqlOnProvisioningLocation() throws Exception {
-        super.testMySqlOnProvisioningLocation();
-    }
-
-    @Override
-    protected Integer getPid(Entity mysql) {
-        ProcessTaskWrapper<Integer> t = Entities.submit(mysql, 
SshEffectorTasks.ssh("sudo cat "+ChefSoloDriverToyMySqlEntity.PID_FILE));
-        return Integer.parseInt(t.block().getStdout().trim());
-    }
-    
-    @Override
-    protected Entity createMysql() {
-        return app.createAndManageChild(EntitySpec.create(Entity.class, 
ChefSoloDriverToyMySqlEntity.class).
-                additionalInterfaces(SoftwareProcess.class));
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/64c2b2e5/software/base/src/test/java/brooklyn/entity/chef/mysql/ChefSoloDriverToyMySqlEntity.java
----------------------------------------------------------------------
diff --git 
a/software/base/src/test/java/brooklyn/entity/chef/mysql/ChefSoloDriverToyMySqlEntity.java
 
b/software/base/src/test/java/brooklyn/entity/chef/mysql/ChefSoloDriverToyMySqlEntity.java
deleted file mode 100644
index 68ad137..0000000
--- 
a/software/base/src/test/java/brooklyn/entity/chef/mysql/ChefSoloDriverToyMySqlEntity.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.entity.chef.mysql;
-
-import org.apache.brooklyn.api.mgmt.TaskAdaptable;
-import org.apache.brooklyn.api.mgmt.TaskFactory;
-import org.apache.brooklyn.config.ConfigKey;
-import org.apache.brooklyn.core.config.ConfigKeys;
-import org.apache.brooklyn.sensor.feed.ssh.SshFeed;
-import org.apache.brooklyn.sensor.feed.ssh.SshPollConfig;
-import org.apache.brooklyn.util.collections.MutableMap;
-import org.apache.brooklyn.util.time.Duration;
-
-import brooklyn.entity.basic.SoftwareProcessImpl;
-import brooklyn.entity.chef.ChefConfig;
-import brooklyn.entity.chef.ChefConfigs;
-import brooklyn.entity.chef.ChefSoloDriver;
-import brooklyn.entity.software.SshEffectorTasks;
-
-@Deprecated /** @deprecated since 0.7.0 use see examples 
{Dynamic,Typed}ToyMySqlEntityChef */
-public class ChefSoloDriverToyMySqlEntity extends SoftwareProcessImpl 
implements ChefConfig {
-
-    public static final String PID_FILE = "/var/run/mysqld/mysqld.pid";
-    public static final ConfigKey<TaskFactory<? extends 
TaskAdaptable<Boolean>>> IS_RUNNING_TASK =
-            ConfigKeys.newConfigKeyWithDefault(ChefSoloDriver.IS_RUNNING_TASK, 
-            SshEffectorTasks.isPidFromFileRunning(PID_FILE).runAsRoot());
-
-    public static final ConfigKey<TaskFactory<?>> STOP_TASK =
-            ConfigKeys.newConfigKeyWithDefault(ChefSoloDriver.STOP_TASK, 
-            SshEffectorTasks.ssh("/etc/init.d/mysql 
stop").allowingNonZeroExitCode().runAsRoot());
-
-    private SshFeed upFeed;
-    
-    @Override
-    public Class<?> getDriverInterface() {
-        return ChefSoloDriver.class;
-    }
-
-    @Override
-    protected void connectSensors() {
-        super.connectSensors();
-        
-        // TODO have a TaskFactoryFeed which reuses the IS_RUNNING_TASK
-        upFeed = 
SshFeed.builder().entity(this).period(Duration.FIVE_SECONDS.toMilliseconds())
-            .poll(new SshPollConfig<Boolean>(SERVICE_UP)
-                    .command("ps -p `sudo cat /var/run/mysqld/mysqld.pid`")
-                    .setOnSuccess(true).setOnFailureOrException(false))
-            .build();
-    }
-    
-    @Override
-    protected void disconnectSensors() {
-        // TODO nicer way to disconnect
-        if (upFeed != null) upFeed.stop();
-        super.disconnectSensors();
-    }
-    
-    @Override
-    public void init() {
-        super.init();
-        ChefConfigs.addToLaunchRunList(this, "mysql::server");
-        ChefConfigs.addToCookbooksFromGithub(this, "mysql", "build-essential", 
"openssl");
-        ChefConfigs.setLaunchAttribute(this, "mysql",  
-                MutableMap.of()
-                    .add("server_root_password", "MyPassword")
-                    .add("server_debian_password", "MyPassword")
-                    .add("server_repl_password", "MyPassword")
-                );
-        
-        // TODO other attributes, eg:
-        // node['mysql']['port']
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/64c2b2e5/software/base/src/test/java/brooklyn/entity/chef/mysql/DynamicChefAutodetectToyMySqlEntityLiveTest.java
----------------------------------------------------------------------
diff --git 
a/software/base/src/test/java/brooklyn/entity/chef/mysql/DynamicChefAutodetectToyMySqlEntityLiveTest.java
 
b/software/base/src/test/java/brooklyn/entity/chef/mysql/DynamicChefAutodetectToyMySqlEntityLiveTest.java
deleted file mode 100644
index d275a54..0000000
--- 
a/software/base/src/test/java/brooklyn/entity/chef/mysql/DynamicChefAutodetectToyMySqlEntityLiveTest.java
+++ /dev/null
@@ -1,43 +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.entity.chef.mysql;
-
-import org.apache.brooklyn.api.entity.Entity;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.annotations.Test;
-
-public class DynamicChefAutodetectToyMySqlEntityLiveTest extends 
AbstractChefToyMySqlEntityLiveTest {
-
-    private static final Logger log = 
LoggerFactory.getLogger(DynamicChefAutodetectToyMySqlEntityLiveTest.class);
-    
-    // test here just so Eclipse IDE picks it up
-    @Override @Test(groups="Live")
-    public void testMySqlOnProvisioningLocation() throws Exception {
-        super.testMySqlOnProvisioningLocation();
-    }
-    
-    @Override
-    protected Entity createMysql() {
-        Entity mysql = 
app.createAndManageChild(DynamicToyMySqlEntityChef.spec());
-        log.debug("created "+mysql);
-        return mysql;
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/64c2b2e5/software/base/src/test/java/brooklyn/entity/chef/mysql/DynamicChefServerToyMySqlEntityLiveTest.java
----------------------------------------------------------------------
diff --git 
a/software/base/src/test/java/brooklyn/entity/chef/mysql/DynamicChefServerToyMySqlEntityLiveTest.java
 
b/software/base/src/test/java/brooklyn/entity/chef/mysql/DynamicChefServerToyMySqlEntityLiveTest.java
deleted file mode 100644
index 7a47b05..0000000
--- 
a/software/base/src/test/java/brooklyn/entity/chef/mysql/DynamicChefServerToyMySqlEntityLiveTest.java
+++ /dev/null
@@ -1,51 +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.entity.chef.mysql;
-
-import org.apache.brooklyn.api.entity.Entity;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.annotations.Test;
-
-import brooklyn.entity.chef.ChefLiveTestSupport;
-import brooklyn.entity.chef.ChefServerTasksIntegrationTest;
-
-/** Expects knife on the path, but will use Brooklyn registered account,
- * and that account has the mysql recipe installed.
- * <p>
- * See {@link ChefServerTasksIntegrationTest} for more info. */
-public class DynamicChefServerToyMySqlEntityLiveTest extends 
AbstractChefToyMySqlEntityLiveTest {
-
-    private static final Logger log = 
LoggerFactory.getLogger(DynamicChefServerToyMySqlEntityLiveTest.class);
-    
-    // test here just so Eclipse IDE picks it up
-    @Override @Test(groups="Live")
-    public void testMySqlOnProvisioningLocation() throws Exception {
-        super.testMySqlOnProvisioningLocation();
-    }
-    
-    @Override
-    protected Entity createMysql() {
-        ChefLiveTestSupport.installBrooklynChefHostedConfig(app);
-        Entity mysql = 
app.createAndManageChild(DynamicToyMySqlEntityChef.specKnife());
-        log.debug("created "+mysql);
-        return mysql;
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/64c2b2e5/software/base/src/test/java/brooklyn/entity/chef/mysql/DynamicChefSoloToyMySqlEntityLiveTest.java
----------------------------------------------------------------------
diff --git 
a/software/base/src/test/java/brooklyn/entity/chef/mysql/DynamicChefSoloToyMySqlEntityLiveTest.java
 
b/software/base/src/test/java/brooklyn/entity/chef/mysql/DynamicChefSoloToyMySqlEntityLiveTest.java
deleted file mode 100644
index 8503069..0000000
--- 
a/software/base/src/test/java/brooklyn/entity/chef/mysql/DynamicChefSoloToyMySqlEntityLiveTest.java
+++ /dev/null
@@ -1,43 +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.entity.chef.mysql;
-
-import org.apache.brooklyn.api.entity.Entity;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.annotations.Test;
-
-public class DynamicChefSoloToyMySqlEntityLiveTest extends 
AbstractChefToyMySqlEntityLiveTest {
-
-    private static final Logger log = 
LoggerFactory.getLogger(DynamicChefSoloToyMySqlEntityLiveTest.class);
-    
-    // test here just so Eclipse IDE picks it up
-    @Override @Test(groups="Live")
-    public void testMySqlOnProvisioningLocation() throws Exception {
-        super.testMySqlOnProvisioningLocation();
-    }
-    
-    @Override
-    protected Entity createMysql() {
-        Entity mysql = 
app.createAndManageChild(DynamicToyMySqlEntityChef.specSolo());
-        log.debug("created "+mysql);
-        return mysql;
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/64c2b2e5/software/base/src/test/java/brooklyn/entity/chef/mysql/DynamicToyMySqlEntityChef.java
----------------------------------------------------------------------
diff --git 
a/software/base/src/test/java/brooklyn/entity/chef/mysql/DynamicToyMySqlEntityChef.java
 
b/software/base/src/test/java/brooklyn/entity/chef/mysql/DynamicToyMySqlEntityChef.java
deleted file mode 100644
index b9069be..0000000
--- 
a/software/base/src/test/java/brooklyn/entity/chef/mysql/DynamicToyMySqlEntityChef.java
+++ /dev/null
@@ -1,82 +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.entity.chef.mysql;
-
-import org.apache.brooklyn.api.entity.Entity;
-import org.apache.brooklyn.api.entity.EntitySpec;
-import org.apache.brooklyn.util.collections.MutableMap;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import brooklyn.entity.chef.ChefConfig;
-import brooklyn.entity.chef.ChefConfigs;
-import brooklyn.entity.chef.ChefEntity;
-
-/** Builds up a MySql entity via chef using specs only */
-public class DynamicToyMySqlEntityChef implements ChefConfig {
-
-    private static final Logger log = 
LoggerFactory.getLogger(DynamicToyMySqlEntityChef.class);
-
-    protected static EntitySpec<? extends Entity> specBase() {
-        EntitySpec<ChefEntity> spec = EntitySpec.create(ChefEntity.class);
-        
-        ChefConfigs.addToLaunchRunList(spec, "mysql::server");
-        spec.configure(PID_FILE, "/var/run/mysqld/mysql*.pid");
-        // init.d service name is sometimes mysql, sometimes mysqld, depending 
ubuntu/centos
-        // we use pid file above instead, but this (with the right name) could 
be used:
-//        spec.configure(SERVICE_NAME, "mysql");
-        
-        // chef mysql fails on first run but works on second if switching 
between server and solo modes
-        spec.configure(ChefConfig.CHEF_RUN_CONVERGE_TWICE, true);
-
-        // only used for solo, but safely ignored for knife
-        ChefConfigs.addToCookbooksFromGithub(spec, "mysql", "build-essential", 
"openssl");
-        // we always need dependent cookbooks set, and mysql requires password 
set
-        // (TODO for knife we might wish to prefer things from the server)
-        ChefConfigs.addLaunchAttributes(spec, MutableMap.of("mysql",  
-                MutableMap.of()
-                .add("server_root_password", "MyPassword")
-                .add("server_debian_password", "MyPassword")
-                .add("server_repl_password", "MyPassword")
-            ));
-        
-        return spec;
-    }
-
-    public static EntitySpec<? extends Entity> spec() {
-        EntitySpec<? extends Entity> spec = specBase();
-        log.debug("Created entity spec for MySql: "+spec);
-        return spec;
-    }
-
-    public static EntitySpec<? extends Entity> specSolo() {
-        EntitySpec<? extends Entity> spec = specBase();
-        spec.configure(ChefConfig.CHEF_MODE, ChefConfig.ChefModes.SOLO);
-        log.debug("Created entity spec for MySql: "+spec);
-        return spec;
-    }
-
-    public static EntitySpec<? extends Entity> specKnife() {
-        EntitySpec<? extends Entity> spec = specBase();
-        spec.configure(ChefConfig.CHEF_MODE, ChefConfig.ChefModes.KNIFE);
-        log.debug("Created entity spec for MySql: "+spec);
-        return spec;
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/64c2b2e5/software/base/src/test/java/brooklyn/entity/chef/mysql/TypedToyMySqlEntityChef.java
----------------------------------------------------------------------
diff --git 
a/software/base/src/test/java/brooklyn/entity/chef/mysql/TypedToyMySqlEntityChef.java
 
b/software/base/src/test/java/brooklyn/entity/chef/mysql/TypedToyMySqlEntityChef.java
deleted file mode 100644
index ba428d2..0000000
--- 
a/software/base/src/test/java/brooklyn/entity/chef/mysql/TypedToyMySqlEntityChef.java
+++ /dev/null
@@ -1,56 +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.entity.chef.mysql;
-
-import org.apache.brooklyn.util.git.GithubUrls;
-
-import brooklyn.entity.chef.ChefConfig;
-import brooklyn.entity.chef.ChefEntityImpl;
-
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableSet;
-
-/** Illustrates how to define an entity using Java as a Java class, extending 
ChefEntityImpl */
-public class TypedToyMySqlEntityChef extends ChefEntityImpl {
-
-    @Override
-    public void init() {
-        super.init();
-
-        String password = "p4ssw0rd";
-        
-        setConfig(CHEF_COOKBOOK_PRIMARY_NAME, "mysql");
-        setConfig(CHEF_COOKBOOK_URLS, ImmutableMap.of(
-            "mysql", GithubUrls.tgz("opscode-cookbooks", "mysql", "v4.0.12"),
-            "openssl", GithubUrls.tgz("opscode-cookbooks", "openssl", 
"v1.1.0"),
-            "mysql", GithubUrls.tgz("opscode-cookbooks", "build-essential", 
"v1.4.4")));
-        
-        setConfig(CHEF_LAUNCH_RUN_LIST, ImmutableSet.of("mysql::server"));
-        setConfig(CHEF_LAUNCH_ATTRIBUTES, ImmutableMap.<String,Object>of(
-            "mysql", ImmutableMap.of(
-                "server_root_password", password,
-                "server_repl_password", password,
-                "server_debian_password", password)));
-        
-        setConfig(ChefConfig.PID_FILE, "/var/run/mysqld/mysqld.pid");
-        
-        setConfig(CHEF_MODE, ChefModes.SOLO);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/64c2b2e5/software/base/src/test/java/brooklyn/entity/driver/MockSshDriver.java
----------------------------------------------------------------------
diff --git 
a/software/base/src/test/java/brooklyn/entity/driver/MockSshDriver.java 
b/software/base/src/test/java/brooklyn/entity/driver/MockSshDriver.java
deleted file mode 100644
index 15c0aec..0000000
--- a/software/base/src/test/java/brooklyn/entity/driver/MockSshDriver.java
+++ /dev/null
@@ -1,74 +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.entity.driver;
-
-import org.apache.brooklyn.api.internal.EntityLocal;
-import org.apache.brooklyn.api.location.Location;
-
-import brooklyn.entity.basic.SoftwareProcessDriver;
-
-import org.apache.brooklyn.location.basic.SshMachineLocation;
-
-public class MockSshDriver implements SoftwareProcessDriver {
-
-    public int numCallsToRunApp = 0;
-    private final EntityLocal entity;
-    private final SshMachineLocation machine;
-
-    public MockSshDriver(EntityLocal entity, SshMachineLocation machine) {
-        this.entity = entity;
-        this.machine = machine;
-    }
-    
-    @Override
-    public void start() {
-        numCallsToRunApp++;
-    }
-
-    @Override
-    public boolean isRunning() {
-        return numCallsToRunApp>0;
-    }
-
-    @Override
-    public EntityLocal getEntity() {
-        return entity;
-    }
-
-    @Override
-    public Location getLocation() {
-        return machine;
-    }
-
-    @Override
-    public void rebind() {
-    }
-
-    @Override
-    public void stop() {
-    }
-
-    @Override
-    public void restart() {
-    }
-    
-    @Override
-    public void kill() {
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/64c2b2e5/software/base/src/test/java/brooklyn/entity/group/DynamicClusterWithAvailabilityZonesMultiLocationTest.java
----------------------------------------------------------------------
diff --git 
a/software/base/src/test/java/brooklyn/entity/group/DynamicClusterWithAvailabilityZonesMultiLocationTest.java
 
b/software/base/src/test/java/brooklyn/entity/group/DynamicClusterWithAvailabilityZonesMultiLocationTest.java
deleted file mode 100644
index 9361cf7..0000000
--- 
a/software/base/src/test/java/brooklyn/entity/group/DynamicClusterWithAvailabilityZonesMultiLocationTest.java
+++ /dev/null
@@ -1,117 +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.entity.group;
-
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertNull;
-
-import java.util.List;
-
-import org.apache.brooklyn.api.entity.Entity;
-import org.apache.brooklyn.api.entity.EntitySpec;
-import org.apache.brooklyn.api.internal.EntityLocal;
-import org.apache.brooklyn.api.location.Location;
-import org.apache.brooklyn.api.location.LocationSpec;
-import org.apache.brooklyn.api.location.MachineLocation;
-import org.apache.brooklyn.api.location.MachineProvisioningLocation;
-import org.apache.brooklyn.core.test.BrooklynAppUnitTestSupport;
-import org.apache.brooklyn.entity.core.EntityPredicates;
-import org.apache.brooklyn.entity.group.DynamicCluster;
-import 
org.apache.brooklyn.entity.group.DynamicClusterWithAvailabilityZonesTest;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import brooklyn.entity.basic.EmptySoftwareProcess;
-import brooklyn.entity.basic.SoftwareProcess;
-
-import org.apache.brooklyn.location.basic.LocalhostMachineProvisioningLocation;
-import org.apache.brooklyn.location.basic.MultiLocation;
-import org.apache.brooklyn.test.Asserts;
-
-import com.google.common.base.Predicate;
-import com.google.common.base.Predicates;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
-
-/**
- * Uses {@link SoftwareProcess}, so test can't be in core project.
- * 
- * Different from {@link DynamicClusterWithAvailabilityZonesTest} in the use 
of {@link MultiLocation}.
- * However, the difference is important: the {@link SoftwareProcess} entity 
has two locations
- * (the {@link MachineProvisioningLocation} and the {@link MachineLocation}, 
which was previously
- * causing a failure - now fixed and tested here.
- */
-public class DynamicClusterWithAvailabilityZonesMultiLocationTest extends 
BrooklynAppUnitTestSupport {
-    
-    private DynamicCluster cluster;
-    
-    private LocalhostMachineProvisioningLocation subLoc1;
-    private LocalhostMachineProvisioningLocation subLoc2;
-    private MultiLocation<?> multiLoc;
-    
-    @BeforeMethod(alwaysRun=true)
-    @Override
-    public void setUp() throws Exception {
-        super.setUp();
-        cluster = 
app.createAndManageChild(EntitySpec.create(DynamicCluster.class)
-                .configure(DynamicCluster.ENABLE_AVAILABILITY_ZONES, true)
-                .configure(DynamicCluster.INITIAL_SIZE, 0)
-                .configure(DynamicCluster.MEMBER_SPEC, 
EntitySpec.create(EmptySoftwareProcess.class)));
-        
-        subLoc1 = 
app.newLocalhostProvisioningLocation(ImmutableMap.of("displayName", "loc1"));
-        subLoc2 = 
app.newLocalhostProvisioningLocation(ImmutableMap.of("displayName", "loc2"));
-        multiLoc = 
mgmt.getLocationManager().createLocation(LocationSpec.create(MultiLocation.class)
-                .configure(MultiLocation.SUB_LOCATIONS, 
ImmutableList.<MachineProvisioningLocation<?>>of(subLoc1, subLoc2)));
-    }
-
-    @Test
-    public void testReplacesEntityInSameZone() throws Exception {
-        
((EntityLocal)cluster).config().set(DynamicCluster.ENABLE_AVAILABILITY_ZONES, 
true);
-        cluster.start(ImmutableList.of(multiLoc));
-        
-        cluster.resize(4);
-        List<String> locsUsed = 
getLocationNames(getLocationsOf(cluster.getMembers(), 
Predicates.instanceOf(MachineProvisioningLocation.class)));
-        Asserts.assertEqualsIgnoringOrder(locsUsed, ImmutableList.of("loc1", 
"loc1", "loc2", "loc2"));
-
-        String idToRemove = Iterables.getFirst(cluster.getMembers(), 
null).getId();
-        String idAdded = cluster.replaceMember(idToRemove);
-        locsUsed = getLocationNames(getLocationsOf(cluster.getMembers(), 
Predicates.instanceOf(MachineProvisioningLocation.class)));
-        Asserts.assertEqualsIgnoringOrder(locsUsed, ImmutableList.of("loc1", 
"loc1", "loc2", "loc2"));
-        assertNull(Iterables.find(cluster.getMembers(), 
EntityPredicates.idEqualTo(idToRemove), null));
-        assertNotNull(Iterables.find(cluster.getMembers(), 
EntityPredicates.idEqualTo(idAdded), null));
-    }
-    
-    protected List<Location> getLocationsOf(Iterable<? extends Entity> 
entities, Predicate<? super Location> filter) {
-        List<Location> result = Lists.newArrayList();
-        for (Entity entity : entities) {
-            Iterables.addAll(result, Iterables.filter(entity.getLocations(), 
filter));
-        }
-        return result;
-    }
-
-    protected List<String> getLocationNames(Iterable<? extends Location> locs) 
{
-        List<String> result = Lists.newArrayList();
-        for (Location subLoc : locs) {
-            result.add(subLoc.getDisplayName());
-        }
-        return result;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/64c2b2e5/software/base/src/test/java/brooklyn/entity/java/EntityPollingTest.java
----------------------------------------------------------------------
diff --git 
a/software/base/src/test/java/brooklyn/entity/java/EntityPollingTest.java 
b/software/base/src/test/java/brooklyn/entity/java/EntityPollingTest.java
deleted file mode 100644
index 0168a0f..0000000
--- a/software/base/src/test/java/brooklyn/entity/java/EntityPollingTest.java
+++ /dev/null
@@ -1,206 +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.entity.java;
-
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-
-import org.apache.brooklyn.api.entity.EntitySpec;
-import org.apache.brooklyn.api.location.MachineLocation;
-import org.apache.brooklyn.core.test.entity.TestApplication;
-import org.apache.brooklyn.entity.core.Entities;
-import org.apache.brooklyn.sensor.core.BasicAttributeSensor;
-import org.apache.brooklyn.test.EntityTestUtils;
-import org.apache.brooklyn.util.collections.MutableMap;
-import org.apache.brooklyn.util.exceptions.Exceptions;
-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.basic.SoftwareProcess;
-import brooklyn.entity.java.UsesJmx.JmxAgentModes;
-import brooklyn.event.feed.jmx.JmxAttributePollConfig;
-import brooklyn.event.feed.jmx.JmxFeed;
-
-import org.apache.brooklyn.location.basic.SshMachineLocation;
-
-import brooklyn.test.JmxService;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-
-public class EntityPollingTest {
-
-    private static final Logger LOG = 
LoggerFactory.getLogger(EntityPollingTest.class);
-
-    private JmxService jmxService;
-    private TestApplication app;
-    private SoftwareProcess entity;
-    
-    private static final BasicAttributeSensor<String> stringAttribute = new 
BasicAttributeSensor<String>(
-            String.class, "brooklyn.test.stringAttribute", "Brooklyn testing 
int attribute");
-    private String objectName = "Brooklyn:type=MyTestMBean,name=myname";
-    
-    private static final ObjectName jmxObjectName;
-    static {
-        try {
-            jmxObjectName = new 
ObjectName("Brooklyn:type=MyTestMBean,name=myname");
-        } catch (MalformedObjectNameException e) {
-            throw Exceptions.propagate(e);
-        }
-    }
-
-    private static final String attributeName = "myattrib";
-
-    public static class SubVanillaJavaApp extends VanillaJavaAppImpl {
-        private JmxFeed feed;
-        
-        @Override protected void connectSensors() {
-            super.connectSensors();
-   
-            // Add a sensor that we can explicitly set in jmx
-            feed = JmxFeed.builder()
-                .entity(this)
-                .pollAttribute(new 
JmxAttributePollConfig<String>(stringAttribute)
-                    .objectName(jmxObjectName)
-                    .attributeName(attributeName))
-                .build();
-        }
-
-        @Override
-        public void disconnectSensors() {
-            super.disconnectSensors();
-            if (feed != null) feed.stop();
-        }
-        
-        @SuppressWarnings({ "rawtypes", "unchecked" })
-        @Override
-        public Class getDriverInterface() {
-            return null;
-        }
-
-        @Override
-        public VanillaJavaAppSshDriver newDriver(MachineLocation loc) {
-            return new VanillaJavaAppSshDriver(this, (SshMachineLocation)loc) {
-                @Override public void install() {
-                    // no-op
-                }
-                @Override public void customize() {
-                    // no-op
-                }
-                @Override public void launch() {
-                    // no-op
-                }
-                @Override public boolean isRunning() {
-                    return true;
-                }
-                @Override public void stop() {
-                    // no-op
-                }
-                @Override public void kill() {
-                    // no-op
-                }
-            };
-        }
-    };        
-
-    @BeforeMethod(alwaysRun=true)
-    public void setUp() {
-        app = TestApplication.Factory.newManagedInstanceForTests();
-        
-        /*
-         * Create an entity, using real entity code, but that swaps out the 
external process
-         * for a JmxService that we can control in the test.        
-         */
-        entity = 
app.createAndManageChild(EntitySpec.create(SoftwareProcess.class).impl(SubVanillaJavaApp.class)
-                .configure("rmiRegistryPort", 40123)
-                .configure("mxbeanStatsEnabled", false)
-                .configure(UsesJmx.JMX_AGENT_MODE, 
JmxAgentModes.JMX_RMI_CUSTOM_AGENT));
-    }
-
-    @AfterMethod(alwaysRun=true)
-    public void tearDown() throws Exception {
-        if (app != null) Entities.destroyAll(app.getManagementContext());
-        if (jmxService != null) jmxService.shutdown();
-    }
-
-    // Tests that the happy path works
-    @Test(groups="Integration")
-    public void testSimpleConnection() throws Exception {
-        jmxService = new JmxService("localhost", 40123);
-        jmxService.registerMBean(ImmutableMap.of(attributeName, "myval"), 
objectName);
-
-        app.start(ImmutableList.of(new 
SshMachineLocation(MutableMap.of("address", "localhost"))));
-        
-        // Starts with value defined when registering...
-        EntityTestUtils.assertAttributeEqualsEventually(entity, 
stringAttribute, "myval");
-    }
-
-    // Test that connect will keep retrying (e.g. start script returns before 
the JMX server is up)
-    @Test(groups="Integration")
-    public void testEntityWithDelayedJmxStartupWillKeepRetrying() {
-        // In 2 seconds time, we'll start the JMX server
-        Thread t = new Thread(new Runnable() {
-            public void run() {
-                try {
-                    Thread.sleep(2000);
-                    jmxService = new JmxService("localhost", 40123);
-                    jmxService.registerMBean(ImmutableMap.of(attributeName, 
"myval"), objectName);
-                } catch (Exception e) {
-                    LOG.error("Error in 
testEntityWithDelayedJmxStartupWillKeepRetrying", e);
-                    throw Exceptions.propagate(e);
-                }
-            }});
-
-        try {
-            t.start();
-            app.start(ImmutableList.of(new 
SshMachineLocation(MutableMap.of("address", "localhost"))));
-
-            EntityTestUtils.assertAttributeEqualsEventually(entity, 
stringAttribute, "myval");
-            
-        } finally {
-            t.interrupt();
-        }
-    }
-    
-    @Test(groups="Integration")
-    public void testJmxConnectionGoesDownRequiringReconnect() throws Exception 
{
-        jmxService = new JmxService("localhost", 40123);
-        jmxService.registerMBean(ImmutableMap.of(attributeName, "myval"), 
objectName);
-
-        app.start(ImmutableList.of(new 
SshMachineLocation(MutableMap.of("address", "localhost"))));
-        
-        EntityTestUtils.assertAttributeEqualsEventually(entity, 
stringAttribute, "myval");
-        
-        // Shutdown the MBeanServer - simulates network failure so can't 
connect
-        jmxService.shutdown();
-        
-        // TODO Want a better way of determining that the entity is down; 
ideally should have 
-        // sensor for entity-down that's wired up to a JMX attribute?
-        Thread.sleep(5000);
-
-        // Restart MBeanServer, and set attribute to different value; expect 
it to be polled again
-        jmxService = new JmxService("localhost", 40123);
-        jmxService.registerMBean(ImmutableMap.of(attributeName, "myval2"), 
objectName);
-        
-        EntityTestUtils.assertAttributeEqualsEventually(entity, 
stringAttribute, "myval2");
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/64c2b2e5/software/base/src/test/java/brooklyn/entity/java/ExampleVanillaMain.java
----------------------------------------------------------------------
diff --git 
a/software/base/src/test/java/brooklyn/entity/java/ExampleVanillaMain.java 
b/software/base/src/test/java/brooklyn/entity/java/ExampleVanillaMain.java
deleted file mode 100644
index 65c3903..0000000
--- a/software/base/src/test/java/brooklyn/entity/java/ExampleVanillaMain.java
+++ /dev/null
@@ -1,26 +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.entity.java;
-
-public class ExampleVanillaMain {
-    public static void main(String[] args) throws Exception {
-        System.out.println("In VanillaJavaExampleMain.main");
-        Thread.sleep(100*1000);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/64c2b2e5/software/base/src/test/java/brooklyn/entity/java/ExampleVanillaMainCpuHungry.java
----------------------------------------------------------------------
diff --git 
a/software/base/src/test/java/brooklyn/entity/java/ExampleVanillaMainCpuHungry.java
 
b/software/base/src/test/java/brooklyn/entity/java/ExampleVanillaMainCpuHungry.java
deleted file mode 100644
index fe2179d..0000000
--- 
a/software/base/src/test/java/brooklyn/entity/java/ExampleVanillaMainCpuHungry.java
+++ /dev/null
@@ -1,41 +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.entity.java;
-
-public class ExampleVanillaMainCpuHungry {
-    private static final int MAX_TIME_MILLIS = 100*1000;
-    private static final int CALCULATIONS_PER_CYCLE = 100000;
-    private static final int SLEEP_PER_CYCLE_MILLIS = 1;
-    
-    public static void main(String[] args) throws Exception {
-        System.out.println("In ExampleVanillaMainCpuHungry.main");
-        long startTime = System.currentTimeMillis();
-        long count = 0;
-        double total = 0;
-        do {
-            for (int i = 0; i < CALCULATIONS_PER_CYCLE; i++) {
-                total += Math.sqrt(Math.random());
-                count++;
-            }
-            Thread.sleep(SLEEP_PER_CYCLE_MILLIS);
-        } while ((System.currentTimeMillis() - startTime) < MAX_TIME_MILLIS);
-        
-        System.out.println("Did "+count+" random square roots, took 
"+(System.currentTimeMillis()-startTime)+"ms; total = "+total);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/64c2b2e5/software/base/src/test/java/brooklyn/entity/java/JavaOptsTest.java
----------------------------------------------------------------------
diff --git a/software/base/src/test/java/brooklyn/entity/java/JavaOptsTest.java 
b/software/base/src/test/java/brooklyn/entity/java/JavaOptsTest.java
deleted file mode 100644
index 958f126..0000000
--- a/software/base/src/test/java/brooklyn/entity/java/JavaOptsTest.java
+++ /dev/null
@@ -1,357 +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.entity.java;
-
-import static org.testng.Assert.fail;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.brooklyn.api.entity.EntitySpec;
-import org.apache.brooklyn.api.location.LocationSpec;
-import org.apache.brooklyn.api.location.MachineLocation;
-import org.apache.brooklyn.core.test.BrooklynAppUnitTestSupport;
-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.location.basic.SshMachineLocation;
-import org.apache.brooklyn.util.collections.MutableList;
-import org.apache.brooklyn.util.collections.MutableMap;
-import org.apache.brooklyn.util.collections.MutableSet;
-import org.apache.brooklyn.util.core.internal.ssh.RecordingSshTool;
-import org.apache.brooklyn.util.core.internal.ssh.SshTool;
-import org.apache.brooklyn.util.core.internal.ssh.RecordingSshTool.ExecCmd;
-import org.apache.brooklyn.util.jmx.jmxmp.JmxmpAgent;
-import org.apache.brooklyn.util.text.Strings;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.MapDifference.ValueDifference;
-import com.google.common.collect.Maps;
-
-@SuppressWarnings({ "rawtypes", "unchecked" })
-public class JavaOptsTest extends BrooklynAppUnitTestSupport {
-
-    // TODO Test setting classpath; but this works by customize() copying all 
the artifacts into /lib/*
-    // so that we can simply set this on the classpath...
-    
-    private static final Logger log = 
LoggerFactory.getLogger(JavaOptsTest.class);
-    
-    private SshMachineLocation loc;
-    
-    @BeforeMethod(alwaysRun=true)
-    @Override
-    public void setUp() throws Exception {
-        RecordingSshTool.execScriptCmds.clear();
-        super.setUp();
-        loc = 
mgmt.getLocationManager().createLocation(LocationSpec.create(SshMachineLocation.class)
-                .configure("address", "localhost")
-                .configure(SshTool.PROP_TOOL_CLASS, 
RecordingSshTool.class.getName()));
-    }
-    
-    @AfterMethod(alwaysRun=true)
-    @Override
-    public void tearDown() throws Exception {
-        super.tearDown();
-        RecordingSshTool.execScriptCmds.clear();
-    }
-    
-    @Test
-    public void testSimpleLaunchesJavaProcess() {
-        VanillaJavaApp javaProcess = 
app.createAndManageChild(EntitySpec.create(VanillaJavaApp.class)
-            .configure("main", "my.Main").configure("useJmx", false));
-        app.start(ImmutableList.of(loc));
-        
-        String runDir = javaProcess.getRunDir();
-        Map<String,String> expectedEnvs = ImmutableMap.<String,String>of();
-        List<String> expectedCmds = ImmutableList.of(String.format("java 
$JAVA_OPTS -cp \"%1$s/lib\" my.Main  >> %1$s/console 2>&1 </dev/null &", 
runDir));
-        
-        assertHasExpectedCmds(expectedCmds, expectedEnvs);
-    }
-    
-    @Test
-    public void testPassesJavaArgs() {
-        VanillaJavaApp javaProcess = 
app.createAndManageChild(EntitySpec.create(VanillaJavaApp.class)
-            .configure("main", "my.Main").configure("useJmx", 
false).configure("args", ImmutableList.of("a1", "a2")));
-        app.start(ImmutableList.of(loc));
-        
-        String runDir = javaProcess.getRunDir();
-        Map<String,String> expectedEnvs = ImmutableMap.<String,String>of();
-        List<String> expectedCmds = ImmutableList.of(String.format("java 
$JAVA_OPTS -cp \"%1$s/lib\" my.Main \"a1\" \"a2\" >> %1$s/console 2>&1 
</dev/null &", runDir));
-        
-        assertHasExpectedCmds(expectedCmds, expectedEnvs);
-    }
-    
-    @Test
-    public void testPassesJavaOpts() {
-        VanillaJavaApp javaProcess = 
app.createAndManageChild(EntitySpec.create(VanillaJavaApp.class)
-            .configure("main", "my.Main").configure("useJmx", 
false).configure("javaOpts", ImmutableList.of("-abc")));
-        app.start(ImmutableList.of(loc));
-        
-        String runDir = javaProcess.getRunDir();
-        String defaultJavaOpts = "-Xms128m -Xmx512m -XX:MaxPermSize=512m";
-        String expectedJavaOpts = defaultJavaOpts+" -abc";
-        Map<String,String> expectedEnvs = 
ImmutableMap.<String,String>of("JAVA_OPTS", expectedJavaOpts);
-        List<String> expectedCmds = ImmutableList.of(String.format("java 
$JAVA_OPTS -cp \"%1$s/lib\" my.Main  >> %1$s/console 2>&1 </dev/null &", 
runDir));
-        
-        assertHasExpectedCmds(expectedCmds, expectedEnvs);
-    }
-
-    @Test
-    public void testPassesJavaSysProps() {
-        VanillaJavaApp javaProcess = 
app.createAndManageChild(EntitySpec.create(VanillaJavaApp.class)
-            .configure("main", "my.Main").configure("useJmx", 
false).configure("javaSysProps", ImmutableMap.of("mykey", "myval")));
-
-        app.start(ImmutableList.of(loc));
-        
-        String runDir = javaProcess.getRunDir();
-        String defaultJavaOpts = "-Xms128m -Xmx512m -XX:MaxPermSize=512m";
-        String expectedJavaOpts = defaultJavaOpts+" -Dmykey=myval";
-        Map<String,String> expectedEnvs = 
ImmutableMap.<String,String>of("JAVA_OPTS", expectedJavaOpts);
-        List<String> expectedCmds = ImmutableList.of(String.format("java 
$JAVA_OPTS -cp \"%1$s/lib\" my.Main  >> %1$s/console 2>&1 </dev/null &", 
runDir));
-        
-        assertHasExpectedCmds(expectedCmds, expectedEnvs);
-    }
-    
-    @Test
-    public void testPassesJavaOptsOverridingDefaults() {
-        VanillaJavaApp javaProcess = 
app.createAndManageChild(EntitySpec.create(VanillaJavaApp.class)
-            .configure("main", "my.Main").configure("useJmx", 
false).configure("javaOpts", ImmutableList.of("-Xmx567m", 
"-XX:MaxPermSize=567m")));
-        app.start(ImmutableList.of(loc));
-        
-        String runDir = javaProcess.getRunDir();
-        Object expectedJavaOpts = MutableSet.of("-Xms128m", "-Xmx567m", 
"-XX:MaxPermSize=567m");
-        Map<String,Object> expectedEnvs = 
ImmutableMap.<String,Object>of("JAVA_OPTS", expectedJavaOpts);
-        List<String> expectedCmds = ImmutableList.of(String.format("java 
$JAVA_OPTS -cp \"%1$s/lib\" my.Main  >> %1$s/console 2>&1 </dev/null &", 
runDir));
-
-        assertHasExpectedCmds(expectedCmds, expectedEnvs);
-    }
-    
-    public static class TestingJavaOptsVanillaJavaAppImpl extends 
VanillaJavaAppImpl {
-        @Override public VanillaJavaAppSshDriver newDriver(MachineLocation 
loc) {
-            return new VanillaJavaAppSshDriver(this, (SshMachineLocation)loc) {
-                @Override protected List<String> getCustomJavaConfigOptions() {
-                    return MutableList.<String>builder()
-                        .addAll(super.getCustomJavaConfigOptions())
-                        .add("-server")
-                        .build();
-                };
-            };
-        }
-    }
-    
-    @Test
-    public void testPassesJavaOptsObeyingMutualExclusions() {
-        VanillaJavaApp javaProcess = 
app.createAndManageChild(EntitySpec.create(VanillaJavaApp.class, 
TestingJavaOptsVanillaJavaAppImpl.class)
-            .configure("main", "my.Main").configure("useJmx", 
false).configure("javaOpts", ImmutableList.of("-client")));
-        app.start(ImmutableList.of(loc));
-        
-        String runDir = javaProcess.getRunDir();
-        String defaultJavaOpts = "-Xms128m -Xmx512m -XX:MaxPermSize=512m";
-        String expectedJavaOpts = defaultJavaOpts+" -client";
-        Map<String,String> expectedEnvs = 
ImmutableMap.<String,String>of("JAVA_OPTS", expectedJavaOpts);
-        List<String> expectedCmds = ImmutableList.of(String.format("java 
$JAVA_OPTS -cp \"%1$s/lib\" my.Main  >> %1$s/console 2>&1 </dev/null &", 
runDir));
-        
-        assertHasExpectedCmds(expectedCmds, expectedEnvs);
-    }
-    
-    /**
-     * Asserts that one of the scripts executed had these commands, and these 
environment variables.
-     * There could be other commands in between though.
-     */
-    private void assertHasExpectedCmds(List<String> expectedCmds, 
Map<String,?> expectedEnvs) {
-        if (RecordingSshTool.execScriptCmds.isEmpty())
-            fail("No commands recorded");
-        
-        for (ExecCmd cmd : RecordingSshTool.execScriptCmds) {
-            // TODO Check expectedCmds in-order
-            
-            // check if expectedEnv is a set, then the string value contains 
all elements in the set
-            Map<Object, ValueDifference<Object>> difference = 
Maps.<Object,Object>difference(cmd.env, expectedEnvs).entriesDiffering();
-            boolean same = difference.isEmpty();
-            if (!same) {
-                Set<Object> differingKeys = new 
LinkedHashSet<Object>(difference.keySet());
-                Iterator<Object> ki = differingKeys.iterator();
-                while (ki.hasNext()) {
-                    Object key = ki.next();
-                    Object expectationHere = expectedEnvs.get(key);
-                    Object valueHere = cmd.env.get(key);
-                    if (valueHere==null) break;
-                    
-                    if (expectationHere instanceof Set) {
-                        Set mutableExpectationHere = new 
LinkedHashSet(((Set)expectationHere));
-                        Iterator si = ((Set)mutableExpectationHere).iterator();
-                        while (si.hasNext()) {
-                            Object oneExpectationHere = si.next();
-                            if 
(valueHere.toString().contains(Strings.toString(oneExpectationHere)))
-                                si.remove();
-                            else break;
-                        }
-                        if (mutableExpectationHere.isEmpty())
-                            differingKeys.remove(key);
-                        else
-                            // not the same
-                            break;
-                    } else {
-                        // not the same
-                        break;
-                    }
-                }
-                if (differingKeys.isEmpty())
-                    same = true;
-            }
-            
-            if (cmd.commands.containsAll(expectedCmds) && same) {
-                return;
-            }
-        }
-        
-        for (ExecCmd cmd : RecordingSshTool.execScriptCmds) {
-            log.info("Command:");
-            log.info("\tEnv:");
-            for (Map.Entry<?,?> entry : cmd.env.entrySet()) {
-                log.info("\t\t"+entry.getKey()+" = "+entry.getValue());
-            }
-            log.info("\tCmds:");
-            for (String c : cmd.commands) {
-                log.info("\t\t"+c);
-            }
-        }
-        
-        fail("Cmd not present: expected="+expectedCmds+"/"+expectedEnvs+"; 
actual="+RecordingSshTool.execScriptCmds);
-    }
-
-    public static class TestingNoSensorsVanillaJavaAppImpl extends 
VanillaJavaAppImpl {
-        protected void connectSensors() {
-            /* nothing here */
-            setAttribute(SERVICE_UP, true);
-        }
-    }
-    
-    private void assertJmxWithPropsHasPhrases(Map props,
-            List<String> expectedPhrases,
-            List<String> forbiddenPhrases) {
-        if (!props.containsKey("main")) props.put("main", "my.Main");
-        @SuppressWarnings({ "unused" })
-        VanillaJavaApp javaProcess = 
app.createAndManageChild(EntitySpec.create(VanillaJavaApp.class, 
TestingNoSensorsVanillaJavaAppImpl.class)
-            .configure(props));
-        app.start(ImmutableList.of(loc));
-        
-        List<String> phrases = new ArrayList<String>(expectedPhrases);
-        Set<String> forbiddenPhrasesFound = new LinkedHashSet<String>();
-        for (ExecCmd cmd : RecordingSshTool.execScriptCmds) {
-            String biggun = ""+cmd.env+" "+cmd.commands;
-            Iterator<String> pi = phrases.iterator();
-            while (pi.hasNext()) {
-                String phrase = pi.next();
-                if (biggun.contains(phrase)) pi.remove();
-            }
-            if (forbiddenPhrases!=null)
-                for (String p: forbiddenPhrases)
-                    if (biggun.contains(p)) forbiddenPhrasesFound.add(p);
-        }
-        
-        if (!phrases.isEmpty()) {
-            log.warn("Missing phrases in commands: "+phrases+"\nCOMMANDS: 
"+RecordingSshTool.execScriptCmds);
-            fail("Missing phrases in commands: "+phrases);
-        }
-        if (!forbiddenPhrasesFound.isEmpty()) {
-            log.warn("Forbidden phrases found in commands: 
"+forbiddenPhrasesFound+"\nCOMMANDS: "+RecordingSshTool.execScriptCmds);
-            fail("Forbidden phrases found in commands: 
"+forbiddenPhrasesFound);
-        }
-    }
-    
-    private static final List<String> EXPECTED_BASIC_JMX_OPTS = Arrays.asList(
-            "-Dcom.sun.management.jmxremote",
-            "-Dcom.sun.management.jmxremote.ssl=false",
-            "-Dcom.sun.management.jmxremote.authenticate=false"
-        );
-
-    private static final List<String> FORBIDDEN_BASIC_JMX_OPTS = Arrays.asList(
-            "-Dcom.sun.management.jmxremote.ssl=true",
-            
-            // often breaks things, as this is an advertised hostname usually;
-            // it typically listens on all interfaces anyway
-            "-Djava.rmi.server.hostname=0.0.0.0"
-        );
-
-    @Test
-    public void testBasicJmxFromFlag() {
-        assertJmxWithPropsHasPhrases(
-                MutableMap.builder().
-                put("useJmx", true).
-                build(), 
-            EXPECTED_BASIC_JMX_OPTS,
-            FORBIDDEN_BASIC_JMX_OPTS);
-    }
-
-    @Test
-    public void testBasicJmxFromConfig() {
-        assertJmxWithPropsHasPhrases(
-                MutableMap.builder().
-                put(UsesJmx.USE_JMX, true).
-                build(), 
-            EXPECTED_BASIC_JMX_OPTS,
-            FORBIDDEN_BASIC_JMX_OPTS);
-    }
-
-    @Test
-    public void testBasicJmxConfigFromDefault() {
-        assertJmxWithPropsHasPhrases(
-                MutableMap.builder().
-                build(), 
-            EXPECTED_BASIC_JMX_OPTS,
-            FORBIDDEN_BASIC_JMX_OPTS);
-    }
-    
-    @Test
-    public void testSecureJmxConfigFromDefault() {
-        final List<String> EXPECTED_SECURE_JMX_OPTS = Arrays.asList(
-                "-Dcom.sun.management.jmxremote",
-                "-Dbrooklyn.jmxmp.port=31009",
-                "-Dcom.sun.management.jmxremote.ssl=true",
-                "-D"+JmxmpAgent.AUTHENTICATE_CLIENTS_PROPERTY+"=true",
-                "keyStore", "/jmx-keystore",
-                "trustStore", "/jmx-truststore",
-                "-javaagent", "brooklyn-jmxmp-agent"
-            );
-
-        final List<String> FORBIDDEN_SECURE_JMX_OPTS = Arrays.asList(
-                "-Dcom.sun.management.jmxremote.authenticate=true",
-                "-Dcom.sun.management.jmxremote.ssl=false",
-                // hostname isn't forbidden -- but it is generally not used now
-                "-Djava.rmi.server.hostname="
-            );
-        
-        assertJmxWithPropsHasPhrases(
-                MutableMap.builder()
-                        .put(UsesJmx.JMX_SSL_ENABLED, true)
-                        .put(UsesJmx.JMX_PORT, 31009)
-                        .build(), 
-                EXPECTED_SECURE_JMX_OPTS,
-                FORBIDDEN_SECURE_JMX_OPTS);
-    }
-}

Reply via email to