brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hadr...@apache.org
Subject [6/6] incubator-brooklyn git commit: This closes #803
Date Sat, 08 Aug 2015 02:19:11 GMT
This closes #803


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

Branch: refs/heads/master
Commit: 2ed62d61bac4b704842064ad2d6956e2a9fecf4f
Parents: 83acab2 9e04407
Author: Hadrian Zbarcea <hadrian@apache.org>
Authored: Fri Aug 7 21:32:39 2015 -0400
Committer: Hadrian Zbarcea <hadrian@apache.org>
Committed: Fri Aug 7 21:32:39 2015 -0400

----------------------------------------------------------------------
 ...stomAggregatingEnricherDeprecatedTest.groovy |   2 +-
 .../enricher/CustomAggregatingEnricherTest.java |   2 +-
 .../java/brooklyn/enricher/EnrichersTest.java   |   4 +-
 ...SensorPropagatingEnricherDeprecatedTest.java |   2 +-
 .../enricher/SensorPropagatingEnricherTest.java |   2 +-
 .../TransformingEnricherDeprecatedTest.groovy   |   2 +-
 .../enricher/TransformingEnricherTest.java      |   2 +-
 .../entity/EntityPreManagementTest.java         |   2 +-
 .../brooklyn/entity/basic/DataEntityTest.java   |   2 +-
 .../basic/DependentConfigurationTest.java       |   2 +-
 .../entity/basic/PolicyRegistrationTest.java    |   2 +-
 .../entity/basic/ServiceStateLogicTest.java     |   2 +-
 .../entity/effector/EffectorBasicTest.java      |   2 +-
 .../entity/group/DynamicClusterTest.java        |   4 +-
 .../entity/group/DynamicFabricTest.java         |   2 +-
 .../entity/group/GroupPickUpEntitiesTest.java   |   2 +-
 .../entity/rebind/RebindEnricherTest.java       |   2 +-
 .../entity/rebind/RebindEntityTest.java         |   4 +-
 .../brooklyn/entity/rebind/RebindFeedTest.java  |   2 +-
 .../entity/rebind/RebindFeedWithHaTest.java     |   2 +-
 .../event/feed/function/FunctionFeedTest.java   |   2 +-
 .../feed/http/HttpFeedIntegrationTest.java      |   2 +-
 .../feed/shell/ShellFeedIntegrationTest.java    |   2 +-
 .../event/feed/ssh/SshFeedIntegrationTest.java  |   2 +-
 .../WindowsPerformanceCounterFeedLiveTest.java  |   2 +-
 .../WindowsPerformanceCounterFeedTest.java      |   2 +-
 .../SshMachineLocationPerformanceTest.java      |   2 +-
 .../brooklyn/management/ha/HotStandbyTest.java  |   2 +-
 .../EntityPersistencePerformanceTest.java       |   2 +-
 ...lusterDatabaseExampleAppIntegrationTest.java |   7 +-
 .../os/AdvertiseWinrmLoginPolicyTest.java       |   2 +-
 .../policy/os/CreateUserPolicyLiveTest.java     |   2 +-
 .../policy/os/CreateUserPolicyTest.java         |   2 +-
 .../enricher/HttpLatencyDetectorTest.java       |   2 +-
 .../brooklyn/enricher/RebindEnricherTest.java   |   2 +-
 .../autoscaling/AutoScalerPolicyRebindTest.java |   2 +-
 .../policy/ha/ServiceFailureDetectorTest.java   |   2 +-
 .../brooklyn/policy/ha/ServiceReplacerTest.java |   2 +-
 ...ctSoftwareProcessRestartIntegrationTest.java |   2 +-
 .../basic/SoftwareProcessEntityRebindTest.java  |   2 +-
 .../entity/basic/SoftwareProcessEntityTest.java |   2 +-
 ...ftwareProcessAndChildrenIntegrationTest.java |   2 +-
 .../basic/lifecycle/ScriptHelperTest.java       |   2 +-
 .../BrooklynClusterIntegrationTest.java         |   2 +-
 .../BrooklynNodeIntegrationTest.java            |   4 +-
 .../brooklynnode/SelectMasterEffectorTest.java  |   2 +-
 .../brooklyn/entity/java/EntityPollingTest.java |   2 +-
 .../entity/java/VanillaJavaAppRebindTest.java   |   2 +-
 .../entity/machine/MachineEntityRebindTest.java |   2 +-
 .../entity/pool/AbstractServerPoolTest.java     |   2 +-
 .../brooklyn/entity/pool/ServerPoolTest.java    |   2 +-
 .../entity/software/StaticSensorTest.java       |   2 +-
 .../software/http/HttpRequestSensorTest.java    |   2 +-
 .../mysql/AbstractToyMySqlEntityTest.java       |   2 +-
 .../software/ssh/SshCommandIntegrationTest.java |   2 +-
 .../brooklyn/event/feed/jmx/JmxFeedTest.java    |   4 +-
 .../brooklyn/event/feed/jmx/JmxHelperTest.java  |   2 +-
 .../event/feed/jmx/RebindJmxFeedTest.java       |   2 +-
 .../basic/MachineDetailsEc2LiveTest.java        |   2 +-
 .../MachineDetailsGoogleComputeLiveTest.java    |   2 +-
 .../crate/CrateNodeIntegrationTest.java         |   2 +-
 .../PostgreSqlRebindIntegrationTest.java        |   2 +-
 .../messaging/activemq/ActiveMQEc2LiveTest.java |   2 +-
 .../activemq/ActiveMQGoogleComputeLiveTest.java |   4 +-
 .../activemq/ActiveMQIntegrationTest.java       |   2 +-
 .../messaging/kafka/KafkaIntegrationTest.java   |   2 +-
 .../entity/messaging/qpid/QpidEc2LiveTest.java  |   2 +-
 .../messaging/qpid/QpidIntegrationTest.java     |   4 +-
 .../messaging/rabbit/RabbitEc2LiveTest.java     |   2 +-
 .../messaging/rabbit/RabbitIntegrationTest.java |   2 +-
 .../storm/StormAbstractCloudLiveTest.java       |   2 +-
 .../messaging/storm/StormEc2LiveTest.java       |   2 +-
 .../zookeeper/ZooKeeperEc2LiveTest.java         |   2 +-
 .../zookeeper/ZooKeeperEnsembleLiveTest.java    |   4 +-
 .../monitoring/monit/MonitIntegrationTest.java  |   2 +-
 .../bind/BindDnsServerIntegrationTest.java      |   2 +-
 .../network/bind/BindDnsServerLiveTest.java     |   2 +-
 .../CassandraDatacenterIntegrationTest.java     |   2 +-
 .../cassandra/CassandraDatacenterLiveTest.java  |   2 +-
 ...assandraDatacenterRebindIntegrationTest.java |   2 +-
 .../cassandra/CassandraDatacenterTest.java      |   2 +-
 .../nosql/cassandra/CassandraFabricTest.java    |   2 +-
 .../cassandra/CassandraNodeEc2LiveTest.java     |   2 +-
 .../cassandra/CassandraNodeIntegrationTest.java |   4 +-
 .../nosql/cassandra/CassandraNodeLiveTest.java  |   2 +-
 .../CouchbaseSyncGatewayEc2LiveTest.java        |   2 +-
 .../nosql/couchdb/CouchDBClusterLiveTest.java   |   2 +-
 .../nosql/couchdb/CouchDBNodeEc2LiveTest.java   |   2 +-
 .../couchdb/CouchDBNodeIntegrationTest.java     |   2 +-
 .../nosql/couchdb/CouchDBNodeLiveTest.java      |   2 +-
 .../ElasticSearchClusterIntegrationTest.java    |   2 +-
 .../ElasticSearchNodeIntegrationTest.java       |   2 +-
 .../nosql/mongodb/MongoDBEc2LiveTest.java       |   4 +-
 .../nosql/mongodb/MongoDBIntegrationTest.java   |   2 +-
 .../mongodb/MongoDBRebindIntegrationTest.java   |   2 +-
 .../nosql/mongodb/MongoDBSoftLayerLiveTest.java |   2 +-
 .../MongoDBConfigServerIntegrationTest.java     |   2 +-
 ...MongoDBShardedDeploymentIntegrationTest.java |   2 +-
 .../redis/RedisClusterIntegrationTest.java      |   2 +-
 .../entity/nosql/redis/RedisEc2LiveTest.java    |   2 +-
 .../nosql/redis/RedisIntegrationTest.java       |   2 +-
 .../nosql/riak/RiakClusterEc2LiveTest.java      |   2 +-
 .../entity/nosql/riak/RiakNodeEc2LiveTest.java  |   2 +-
 .../riak/RiakNodeGoogleComputeLiveTest.java     |   2 +-
 .../nosql/riak/RiakNodeIntegrationTest.java     |   2 +-
 .../nosql/riak/RiakNodeSoftlayerLiveTest.java   |   2 +-
 .../nosql/solr/SolrServerEc2LiveTest.java       |   2 +-
 .../nosql/solr/SolrServerIntegrationTest.java   |   2 +-
 .../entity/nosql/solr/SolrServerLiveTest.java   |   2 +-
 .../osgi/karaf/KarafContainerEc2LiveTest.java   |   2 +-
 .../entity/osgi/karaf/KarafContainerTest.java   |   2 +-
 .../entity/dns/AbstractGeoDnsServiceTest.java   |   2 +-
 .../nginx/NginxClusterIntegrationTest.java      |   4 +-
 .../entity/proxy/nginx/NginxEc2LiveTest.java    |   4 +-
 .../nginx/NginxHttpsSslIntegrationTest.java     |   2 +-
 .../proxy/nginx/NginxIntegrationTest.java       |  10 +-
 .../proxy/nginx/NginxRebindIntegrationTest.java |  11 +-
 .../nginx/NginxRebindWithHaIntegrationTest.java |   4 +-
 .../nginx/NginxUrlMappingIntegrationTest.java   |   3 +-
 .../proxy/nginx/NginxWebClusterEc2LiveTest.java |   2 +-
 .../AbstractWebAppFixtureIntegrationTest.java   |   9 +-
 ...lledDynamicWebAppClusterIntegrationTest.java |   5 +-
 .../ControlledDynamicWebAppClusterTest.java     |   2 +-
 .../entity/webapp/DynamicWebAppClusterTest.java |   2 +-
 .../entity/webapp/DynamicWebAppFabricTest.java  |   2 +-
 ...ElasticJavaWebAppServiceIntegrationTest.java |   2 +-
 .../webapp/TomcatAutoScalerPolicyTest.java      |   2 +-
 .../webapp/WebAppConcurrentDeployTest.java      |   4 +-
 .../webapp/WebAppLiveIntegrationTest.groovy     |   4 +-
 ...namicWebAppClusterRebindIntegrationTest.java |   8 +-
 ...namicWebAppClusterRebindIntegrationTest.java |   8 +-
 .../jboss/JBoss6ServerAwsEc2LiveTest.java       |   2 +-
 ...Boss6ServerNonInheritingIntegrationTest.java |   2 +-
 .../jboss/JBoss7ServerAwsEc2LiveTest.java       |   2 +-
 .../jboss/JBoss7ServerDockerLiveTest.java       |   5 +-
 ...Boss7ServerNonInheritingIntegrationTest.java |   4 +-
 .../JBoss7ServerRebindingIntegrationTest.java   |   6 +-
 .../Jboss7ServerGoogleComputeLiveTest.java      |   2 +-
 .../webapp/nodejs/NodeJsWebAppEc2LiveTest.java  |   2 +-
 .../NodeJsWebAppFixtureIntegrationTest.java     |   6 +-
 .../nodejs/NodeJsWebAppSoftlayerLiveTest.java   |   2 +-
 .../webapp/tomcat/Tomcat8ServerEc2LiveTest.java |   3 +-
 .../tomcat/Tomcat8ServerSoftlayerLiveTest.java  |   3 +-
 .../webapp/tomcat/TomcatServerEc2LiveTest.java  |   2 +-
 .../tomcat/TomcatServerSoftlayerLiveTest.java   |   2 +-
 .../EnrichersSlightlySimplerYamlTest.java       |   2 +-
 .../brooklyn/JavaWebAppsIntegrationTest.java    |   3 +-
 .../brooklyn/ReloadBrooklynPropertiesTest.java  |   2 +-
 .../brooklyn/VanillaBashNetcatYamlTest.java     |   2 +-
 .../BrooklynJavascriptGuiLauncherTest.java      |   2 +-
 .../BrooklynEntityMirrorIntegrationTest.java    |   4 +-
 .../brooklynnode/BrooklynNodeRestTest.java      |   4 +-
 .../brooklyn/launcher/BrooklynLauncherTest.java |   2 +-
 .../brooklyn/launcher/WebAppRunnerTest.java     |   2 +-
 .../blueprints/AbstractBlueprintTest.java       |   2 +-
 .../SoftlayerObtainPrivateLiveTest.java         |   2 +-
 .../org/apache/brooklyn/qa/load/LoadTest.java   |   3 +-
 .../rest/client/BrooklynApiRestClientTest.java  |   2 +-
 .../brooklynnode/DeployBlueprintTest.java       |   2 +-
 .../rest/BrooklynRestApiLauncherTest.java       |   2 +-
 .../rest/resources/ApplicationResourceTest.java |   2 +-
 .../rest/resources/EntityResourceTest.java      |   2 +-
 .../SensorResourceIntegrationTest.java          |   2 +-
 .../rest/resources/SensorResourceTest.java      |   2 +-
 .../ServerResourceIntegrationTest.java          |   2 +-
 .../rest/resources/ServerShutdownTest.java      |   2 +-
 .../java/brooklyn/test/EntityTestUtils.java     | 180 ------
 .../main/java/brooklyn/test/HttpTestUtils.java  | 391 --------------
 .../java/brooklyn/test/NetworkingTestUtils.java |  68 ---
 .../brooklyn/test/PerformanceTestUtils.java     |  99 ----
 .../main/java/brooklyn/test/TestUtils.groovy    | 540 ------------------
 .../brooklyn/test/TrustingSslSocketFactory.java | 134 -----
 .../main/java/brooklyn/test/WebAppMonitor.java  | 213 --------
 .../apache/brooklyn/test/EntityTestUtils.java   | 181 +++++++
 .../org/apache/brooklyn/test/HttpTestUtils.java | 392 ++++++++++++++
 .../brooklyn/test/NetworkingTestUtils.java      |  69 +++
 .../brooklyn/test/PerformanceTestUtils.java     |  99 ++++
 .../org/apache/brooklyn/test/TestUtils.groovy   | 541 +++++++++++++++++++
 .../brooklyn/test/TrustingSslSocketFactory.java | 134 +++++
 .../org/apache/brooklyn/test/WebAppMonitor.java | 214 ++++++++
 180 files changed, 1855 insertions(+), 1828 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/2ed62d61/usage/launcher/src/test/java/org/apache/brooklyn/entity/brooklynnode/BrooklynEntityMirrorIntegrationTest.java
----------------------------------------------------------------------
diff --cc usage/launcher/src/test/java/org/apache/brooklyn/entity/brooklynnode/BrooklynEntityMirrorIntegrationTest.java
index f42c574,0000000..d66dc53
mode 100644,000000..100644
--- a/usage/launcher/src/test/java/org/apache/brooklyn/entity/brooklynnode/BrooklynEntityMirrorIntegrationTest.java
+++ b/usage/launcher/src/test/java/org/apache/brooklyn/entity/brooklynnode/BrooklynEntityMirrorIntegrationTest.java
@@@ -1,180 -1,0 +1,180 @@@
 +/*
 + * Licensed to the Apache Software Foundation (ASF) under one
 + * or more contributor license agreements.  See the NOTICE file
 + * distributed with this work for additional information
 + * regarding copyright ownership.  The ASF licenses this file
 + * to you under the Apache License, Version 2.0 (the
 + * "License"); you may not use this file except in compliance
 + * with the License.  You may obtain a copy of the License at
 + *
 + *     http://www.apache.org/licenses/LICENSE-2.0
 + *
 + * Unless required by applicable law or agreed to in writing,
 + * software distributed under the License is distributed on an
 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 + * KIND, either express or implied.  See the License for the
 + * specific language governing permissions and limitations
 + * under the License.
 + */
 +package org.apache.brooklyn.entity.brooklynnode;
 +
 +import static org.testng.Assert.assertFalse;
 +import static org.testng.Assert.assertTrue;
 +
++import org.apache.brooklyn.test.EntityTestUtils;
++import org.apache.brooklyn.test.HttpTestUtils;
 +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.Entity;
 +import brooklyn.entity.basic.ApplicationBuilder;
 +import brooklyn.entity.basic.Entities;
 +import brooklyn.entity.basic.EntityInternal;
 +import brooklyn.entity.brooklynnode.BrooklynEntityMirror;
 +import brooklyn.entity.proxying.EntitySpec;
 +import org.apache.brooklyn.launcher.BrooklynWebServer;
 +import brooklyn.management.ManagementContext;
 +import brooklyn.management.ha.HighAvailabilityMode;
 +import brooklyn.rest.filter.BrooklynPropertiesSecurityFilter;
 +import brooklyn.test.Asserts;
- import brooklyn.test.EntityTestUtils;
- import brooklyn.test.HttpTestUtils;
 +import brooklyn.test.entity.LocalManagementContextForTests;
 +import brooklyn.test.entity.TestApplication;
 +import brooklyn.util.exceptions.Exceptions;
 +import brooklyn.util.time.Duration;
 +
 +/**
 + * Test for EntityMirror, launching an in-memory server and ensuring we can mirror.
 + * Here so that we can access the REST server.
 + * <p>
 + * May require <code>-Dbrooklyn.localhost.address=127.0.0.1</code> so that the console which binds to localhost is addressible.
 + * (That and the time it takes to run are the only reasons this is Integration.)
 + */
 +@Test
 +public class BrooklynEntityMirrorIntegrationTest {
 +
 +    private static final Logger log = LoggerFactory.getLogger(BrooklynEntityMirrorIntegrationTest.class);
 +    
 +    private BrooklynWebServer server;
 +    private TestApplication serverApp;
 +    private ManagementContext serverMgmt;
 +    
 +    private TestApplication localApp;
 +    private ManagementContext localMgmt;
 +
 +    @BeforeMethod(alwaysRun=true)
 +    public void setUp() throws Exception {
 +        localApp = TestApplication.Factory.newManagedInstanceForTests();
 +        localMgmt = localApp.getManagementContext();
 +    }
 +
 +    @AfterMethod(alwaysRun=true)
 +    public void tearDown() throws Exception {
 +        if (serverMgmt!=null) Entities.destroyAll(serverMgmt);
 +        if (server!=null) server.stop();
 +        if (localMgmt!=null) Entities.destroyAll(localMgmt);
 +        
 +        serverMgmt = null;
 +    }
 +
 +    
 +    protected void setUpServer() {
 +        setUpServer(new LocalManagementContextForTests(), false);
 +    }
 +    protected void setUpServer(ManagementContext mgmt, boolean useSecurityFilter) {
 +        try {
 +            if (serverMgmt!=null) throw new IllegalStateException("server already set up");
 +            
 +            serverMgmt = mgmt;
 +            server = new BrooklynWebServer(mgmt);
 +            if (useSecurityFilter) server.setSecurityFilter(BrooklynPropertiesSecurityFilter.class);
 +            server.start();
 +            
 +            serverMgmt.getHighAvailabilityManager().disabled();
 +            serverApp = ApplicationBuilder.newManagedApp(TestApplication.class, serverMgmt);
 +            
 +            ((LocalManagementContextForTests)serverMgmt).noteStartupComplete();
 +        } catch (Exception e) {
 +            throw Exceptions.propagate(e);
 +        }
 +    }
 +
 +    protected String getBaseUri() {
 +        return server.getRootUrl();
 +    }
 +    
 +    @Test(groups="Integration")
 +    public void testServiceMirroring() throws Exception {
 +        setUpServer();
 +        
 +        String catalogItemId = "test-catalog-item:1.0";
 +        String catalogItemIdGA = "test-catalog-item:1.0-GA";
 +        serverApp.setAttribute(TestApplication.MY_ATTRIBUTE, "austria");
 +        serverApp.setCatalogItemId(catalogItemId);
 +
 +        String serviceId = serverApp.getId();
 +        Entity mirror = localApp.addChild(EntitySpec.create(BrooklynEntityMirror.class)
 +            .configure(BrooklynEntityMirror.POLL_PERIOD, Duration.millis(100))
 +            .configure(BrooklynEntityMirror.MIRRORED_ENTITY_ID, serviceId)
 +            .configure(BrooklynEntityMirror.MIRRORED_ENTITY_URL, 
 +                getBaseUri()+"/v1/applications/"+serviceId+"/entities/"+serviceId)
 +        );
 +
 +        EntityTestUtils.assertAttributeEqualsEventually(mirror, TestApplication.MY_ATTRIBUTE, "austria");
 +        EntityTestUtils.assertAttributeEqualsEventually(mirror, BrooklynEntityMirror.MIRROR_CATALOG_ITEM_ID, catalogItemId);
 +        assertTrue(mirror.getAttribute(BrooklynEntityMirror.MIRROR_SUMMARY) != null, "entity summary is null");
 +        log.info("Sensors mirrored are: "+((EntityInternal)mirror).getAllAttributes());
 +        
 +        serverApp.setAttribute(TestApplication.MY_ATTRIBUTE, "bermuda");
 +        serverApp.setCatalogItemId(catalogItemIdGA);
 +        EntityTestUtils.assertAttributeEqualsEventually(mirror, TestApplication.MY_ATTRIBUTE, "bermuda");
 +        EntityTestUtils.assertAttributeEqualsEventually(mirror, BrooklynEntityMirror.MIRROR_CATALOG_ITEM_ID, catalogItemIdGA);
 +
 +        serverApp.stop();
 +        assertUnmanagedEventually(mirror);
 +    }
 +
 +    @Test(groups="Integration")
 +    public void testServiceMirroringHttps() throws Exception {
 +        LocalManagementContextForTests mgmtHttps = new LocalManagementContextForTests();
 +        mgmtHttps.getBrooklynProperties().put("brooklyn.webconsole.security.https.required", true);
 +        mgmtHttps.getBrooklynProperties().put("brooklyn.webconsole.security.users", "admin");
 +        mgmtHttps.getBrooklynProperties().put("brooklyn.webconsole.security.user.admin.password", "P5ssW0rd");
 +
 +        setUpServer(mgmtHttps, true);
 +        Assert.assertTrue(getBaseUri().startsWith("https:"), "URL is not https: "+getBaseUri());
 +        // check auth is required
 +        HttpTestUtils.assertHttpStatusCodeEquals(getBaseUri(), 401);
 +        
 +        serverApp.setAttribute(TestApplication.MY_ATTRIBUTE, "austria");
 +
 +        String serviceId = serverApp.getId();
 +        Entity mirror = localApp.addChild(EntitySpec.create(BrooklynEntityMirror.class)
 +            .configure(BrooklynEntityMirror.POLL_PERIOD, Duration.millis(100))
 +            .configure(BrooklynEntityMirror.MANAGEMENT_USER, "admin")
 +            .configure(BrooklynEntityMirror.MANAGEMENT_PASSWORD, "P5ssW0rd")
 +            .configure(BrooklynEntityMirror.MIRRORED_ENTITY_ID, serviceId)
 +            .configure(BrooklynEntityMirror.MIRRORED_ENTITY_URL, 
 +                getBaseUri()+"/v1/applications/"+serviceId+"/entities/"+serviceId)
 +        );
 +
 +        EntityTestUtils.assertAttributeEqualsEventually(mirror, TestApplication.MY_ATTRIBUTE, "austria");
 +        log.info("Sensors mirrored are: "+((EntityInternal)mirror).getAllAttributes());
 +        
 +        serverApp.setAttribute(TestApplication.MY_ATTRIBUTE, "bermuda");
 +        EntityTestUtils.assertAttributeEqualsEventually(mirror, TestApplication.MY_ATTRIBUTE, "bermuda");
 +
 +        serverApp.stop();
 +        assertUnmanagedEventually(mirror);
 +    }
 +
 +    private static void assertUnmanagedEventually(final Entity entity) {
 +        Asserts.succeedsEventually(new Runnable() {
 +            @Override public void run() {
 +                assertFalse(Entities.isManaged(entity));
 +            }});
 +    }
 +}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/2ed62d61/usage/launcher/src/test/java/org/apache/brooklyn/entity/brooklynnode/BrooklynNodeRestTest.java
----------------------------------------------------------------------
diff --cc usage/launcher/src/test/java/org/apache/brooklyn/entity/brooklynnode/BrooklynNodeRestTest.java
index 4a630de,0000000..8ffd465
mode 100644,000000..100644
--- a/usage/launcher/src/test/java/org/apache/brooklyn/entity/brooklynnode/BrooklynNodeRestTest.java
+++ b/usage/launcher/src/test/java/org/apache/brooklyn/entity/brooklynnode/BrooklynNodeRestTest.java
@@@ -1,149 -1,0 +1,149 @@@
 +/*
 + * Licensed to the Apache Software Foundation (ASF) under one
 + * or more contributor license agreements.  See the NOTICE file
 + * distributed with this work for additional information
 + * regarding copyright ownership.  The ASF licenses this file
 + * to you under the Apache License, Version 2.0 (the
 + * "License"); you may not use this file except in compliance
 + * with the License.  You may obtain a copy of the License at
 + *
 + *     http://www.apache.org/licenses/LICENSE-2.0
 + *
 + * Unless required by applicable law or agreed to in writing,
 + * software distributed under the License is distributed on an
 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 + * KIND, either express or implied.  See the License for the
 + * specific language governing permissions and limitations
 + * under the License.
 + */
 +package org.apache.brooklyn.entity.brooklynnode;
 +
 +import java.net.URI;
 +import java.util.concurrent.Callable;
 +
++import org.apache.brooklyn.test.EntityTestUtils;
++import org.apache.brooklyn.test.HttpTestUtils;
 +import org.apache.http.client.HttpClient;
 +import org.slf4j.Logger;
 +import org.slf4j.LoggerFactory;
 +import org.testng.Assert;
 +import org.testng.annotations.Test;
 +
 +import brooklyn.entity.Application;
 +import brooklyn.entity.basic.ApplicationBuilder;
 +import brooklyn.entity.basic.Attributes;
 +import brooklyn.entity.basic.Entities;
 +import brooklyn.entity.basic.EntityInternal;
 +import brooklyn.entity.brooklynnode.BrooklynEntityMirror;
 +import brooklyn.entity.brooklynnode.BrooklynNode;
 +import brooklyn.entity.brooklynnode.SameBrooklynNodeImpl;
 +import brooklyn.entity.proxying.EntitySpec;
 +import brooklyn.event.basic.BasicConfigKey;
 +import org.apache.brooklyn.launcher.SimpleYamlLauncherForTests;
 +import org.apache.brooklyn.launcher.camp.SimpleYamlLauncher;
 +import brooklyn.location.Location;
 +import brooklyn.management.Task;
- import brooklyn.test.EntityTestUtils;
- import brooklyn.test.HttpTestUtils;
 +import brooklyn.test.entity.TestApplication;
 +import brooklyn.test.entity.TestEntity;
 +import brooklyn.util.collections.Jsonya;
 +import brooklyn.util.collections.MutableMap;
 +import brooklyn.util.collections.MutableSet;
 +import brooklyn.util.config.ConfigBag;
 +import brooklyn.util.http.HttpTool;
 +import brooklyn.util.http.HttpToolResponse;
 +import brooklyn.util.net.Urls;
 +import brooklyn.util.repeat.Repeater;
 +import brooklyn.util.time.Duration;
 +
 +import com.google.common.collect.Iterables;
 +
 +/** REST-accessible extension of {@link BrooklynNodeTest} */
 +public class BrooklynNodeRestTest {
 +
 +    private static final Logger log = LoggerFactory.getLogger(BrooklynNodeRestTest.class);
 +    
 +    // takes a while when run on its own, because initializing war and making some requests;
 +    // but there are no waits (beyond 10ms), the delay is all classloading;
 +    // and this tests a lot of things, REST API, Brooklyn Node, yaml deployment,
 +    // so feels worth it to have as a unit test
 +    // FIXME[BROOKLYN-43]: Test fails if security is configured in brooklyn.properties.
 +    @Test(groups = "WIP")
 +    public void testBrooklynNodeRestDeployAndMirror() {
 +        final SimpleYamlLauncher l = new SimpleYamlLauncherForTests();
 +        try {
 +            TestApplication app = ApplicationBuilder.newManagedApp(TestApplication.class, l.getManagementContext());
 +
 +            BrooklynNode bn = app.createAndManageChild(EntitySpec.create(BrooklynNode.class, SameBrooklynNodeImpl.class));
 +            bn.start(MutableSet.<Location>of());
 +            
 +            URI uri = bn.getAttribute(BrooklynNode.WEB_CONSOLE_URI);
 +            Assert.assertNotNull(uri);
 +            EntityTestUtils.assertAttributeEqualsEventually(bn, Attributes.SERVICE_UP, true);
 +            log.info("Created BrooklynNode: "+bn);
 +
 +            // deploy
 +            Task<?> t = bn.invoke(BrooklynNode.DEPLOY_BLUEPRINT, ConfigBag.newInstance()
 +                .configure(BrooklynNode.DeployBlueprintEffector.BLUEPRINT_TYPE, TestApplication.class.getName())
 +                .configure(BrooklynNode.DeployBlueprintEffector.BLUEPRINT_CONFIG, MutableMap.<String,Object>of("x", 1, "y", "Y"))
 +                .getAllConfig());
 +            log.info("Deployment result: "+t.getUnchecked());
 +            
 +            MutableSet<Application> apps = MutableSet.copyOf( l.getManagementContext().getApplications() );
 +            Assert.assertEquals(apps.size(), 2);
 +            apps.remove(app);
 +            
 +            Application newApp = Iterables.getOnlyElement(apps);
 +            Entities.dumpInfo(newApp);
 +            
 +            Assert.assertEquals(newApp.getConfig(new BasicConfigKey<Integer>(Integer.class, "x")), (Integer)1);
 +            
 +            // check mirror
 +            String newAppId = newApp.getId();
 +            BrooklynEntityMirror mirror = app.createAndManageChild(EntitySpec.create(BrooklynEntityMirror.class)
 +                .configure(BrooklynEntityMirror.MIRRORED_ENTITY_URL, 
 +                    Urls.mergePaths(uri.toString(), "/v1/applications/"+newAppId+"/entities/"+newAppId))
 +                .configure(BrooklynEntityMirror.MIRRORED_ENTITY_ID, newAppId)
 +                .configure(BrooklynEntityMirror.POLL_PERIOD, Duration.millis(10)));
 +            
 +            Entities.dumpInfo(mirror);
 +            
 +            EntityTestUtils.assertAttributeEqualsEventually(mirror, Attributes.SERVICE_UP, true);
 +            
 +            ((EntityInternal)newApp).setAttribute(TestEntity.NAME, "foo");
 +            EntityTestUtils.assertAttributeEqualsEventually(mirror, TestEntity.NAME, "foo");
 +            log.info("Mirror successfully validated");
 +            
 +            // also try deploying by invoking deploy through json
 +            // (catch issues when effector params are map)
 +            HttpClient client = HttpTool.httpClientBuilder().build();
 +            HttpToolResponse result = HttpTool.httpPost(client, URI.create(Urls.mergePaths(uri.toString(), "/v1/applications/"+app.getId()+"/entities/"+bn.getId()
 +                    +"/effectors/deployBlueprint")), 
 +                MutableMap.of(com.google.common.net.HttpHeaders.CONTENT_TYPE, "application/json"), 
 +                Jsonya.newInstance()
 +                    .put("blueprintType", TestApplication.class.getName())
 +                    .put("blueprintConfig", MutableMap.of(TestEntity.CONF_NAME.getName(), "foo"))
 +                .toString().getBytes());
 +            log.info("Deploy effector invoked, result: "+result);
 +            HttpTestUtils.assertHealthyStatusCode( result.getResponseCode() );
 +            
 +            Repeater.create().every(Duration.millis(10)).until(new Callable<Boolean>() {
 +                @Override
 +                public Boolean call() throws Exception {
 +                    return l.getManagementContext().getApplications().size() == 3;
 +                }
 +            }).limitTimeTo(Duration.TEN_SECONDS).runRequiringTrue();
 +            
 +            apps = MutableSet.copyOf( l.getManagementContext().getApplications() );
 +            apps.removeAll( MutableSet.of(app, newApp) );
 +            Application newApp2 = Iterables.getOnlyElement(apps);
 +            Entities.dumpInfo(newApp2);
 +            
 +            EntityTestUtils.assertAttributeEqualsEventually(newApp2, Attributes.SERVICE_UP, true);
 +            Assert.assertEquals(newApp2.getConfig(TestEntity.CONF_NAME), "foo");
 +            
 +        } finally {
 +            l.destroyAll();
 +        }
 +        log.info("DONE");
 +    }
 +}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/2ed62d61/usage/launcher/src/test/java/org/apache/brooklyn/launcher/BrooklynLauncherTest.java
----------------------------------------------------------------------
diff --cc usage/launcher/src/test/java/org/apache/brooklyn/launcher/BrooklynLauncherTest.java
index df295d8,0000000..63ba561
mode 100644,000000..100644
--- a/usage/launcher/src/test/java/org/apache/brooklyn/launcher/BrooklynLauncherTest.java
+++ b/usage/launcher/src/test/java/org/apache/brooklyn/launcher/BrooklynLauncherTest.java
@@@ -1,368 -1,0 +1,368 @@@
 +/*
 + * 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.launcher;
 +
 +import org.apache.brooklyn.launcher.BrooklynLauncher;
 +import static org.testng.Assert.assertEquals;
 +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.File;
 +import java.io.IOException;
 +import java.io.StringWriter;
 +import java.io.Writer;
 +import java.net.URI;
 +import java.nio.charset.Charset;
 +import java.util.Properties;
 +
++import org.apache.brooklyn.test.HttpTestUtils;
 +import org.testng.Assert;
 +import org.testng.annotations.AfterMethod;
 +import org.testng.annotations.Test;
 +
 +import brooklyn.catalog.internal.CatalogInitialization;
 +import brooklyn.config.BrooklynProperties;
 +import brooklyn.config.BrooklynServerConfig;
 +import brooklyn.entity.Application;
 +import brooklyn.entity.basic.ApplicationBuilder;
 +import brooklyn.entity.proxying.EntitySpec;
 +import brooklyn.entity.rebind.RebindTestUtils;
 +import brooklyn.location.Location;
 +import brooklyn.location.basic.LocalhostMachineProvisioningLocation;
 +import brooklyn.management.ManagementContext;
 +import brooklyn.management.internal.LocalManagementContext;
 +import brooklyn.management.internal.ManagementContextInternal;
- import brooklyn.test.HttpTestUtils;
 +import brooklyn.test.entity.LocalManagementContextForTests;
 +import brooklyn.test.entity.TestApplication;
 +import brooklyn.test.entity.TestApplicationImpl;
 +import brooklyn.test.entity.TestEntity;
 +import brooklyn.util.exceptions.FatalRuntimeException;
 +import brooklyn.util.io.FileUtil;
 +import brooklyn.util.net.Urls;
 +import brooklyn.util.os.Os;
 +import brooklyn.util.text.StringFunctions;
 +import brooklyn.util.text.Strings;
 +
 +import com.google.api.client.util.Preconditions;
 +import com.google.common.base.Charsets;
 +import com.google.common.base.Function;
 +import com.google.common.base.Predicates;
 +import com.google.common.collect.ImmutableList;
 +import com.google.common.collect.Iterables;
 +import com.google.common.collect.Maps;
 +import com.google.common.io.Files;
 +
 +public class BrooklynLauncherTest {
 +    
 +    private BrooklynLauncher launcher;
 +    private File persistenceDir;
 +    
 +    @AfterMethod(alwaysRun=true)
 +    public void tearDown() throws Exception {
 +        if (launcher != null) launcher.terminate();
 +        if (persistenceDir != null) RebindTestUtils.deleteMementoDir(persistenceDir);
 +        launcher = null;
 +    }
 +    
 +    // Integration because takes a few seconds to start web-console
 +    @Test(groups="Integration")
 +    public void testStartsWebServerOnExpectectedPort() throws Exception {
 +        launcher = newLauncherForTests(true)
 +                .webconsolePort("10000+")
 +                .start();
 +        
 +        String webServerUrlStr = launcher.getServerDetails().getWebServerUrl();
 +        URI webServerUri = new URI(webServerUrlStr);
 +        
 +        assertEquals(launcher.getApplications(), ImmutableList.of());
 +        assertTrue(webServerUri.getPort() >= 10000 && webServerUri.getPort() < 10100, "port="+webServerUri.getPort()+"; uri="+webServerUri);
 +        HttpTestUtils.assertUrlReachable(webServerUrlStr);
 +    }
 +    
 +    // Integration because takes a few seconds to start web-console
 +    @Test(groups="Integration")
 +    public void testWebServerTempDirRespectsDataDirConfig() throws Exception {
 +        String dataDirName = ".brooklyn-foo"+Strings.makeRandomId(4);
 +        String dataDir = "~/"+dataDirName;
 +
 +        launcher = newLauncherForTests(true)
 +                .brooklynProperties(BrooklynServerConfig.MGMT_BASE_DIR, dataDir)
 +                .start();
 +        
 +        ManagementContext managementContext = launcher.getServerDetails().getManagementContext();
 +        String expectedTempDir = Os.mergePaths(Os.home(), dataDirName, "planes", managementContext.getManagementPlaneId(), managementContext.getManagementNodeId(), "jetty");
 +        
 +        File webappTempDir = launcher.getServerDetails().getWebServer().getWebappTempDir();
 +        assertEquals(webappTempDir.getAbsolutePath(), expectedTempDir);
 +    }
 +    
 +    @Test
 +    public void testCanDisableWebServerStartup() throws Exception {
 +        launcher = newLauncherForTests(true)
 +                .webconsole(false)
 +                .start();
 +        
 +        assertNull(launcher.getServerDetails().getWebServer());
 +        assertNull(launcher.getServerDetails().getWebServerUrl());
 +        Assert.assertTrue( ((ManagementContextInternal)launcher.getServerDetails().getManagementContext()).errors().isEmpty() );
 +    }
 +    
 +    @Test
 +    public void testStartsAppInstance() throws Exception {
 +        launcher = newLauncherForTests(true)
 +                .webconsole(false)
 +                .application(new TestApplicationImpl())
 +                .start();
 +        
 +        assertOnlyApp(launcher, TestApplication.class);
 +    }
 +    
 +    @Test
 +    public void testStartsAppFromSpec() throws Exception {
 +        launcher = newLauncherForTests(true)
 +                .webconsole(false)
 +                .application(EntitySpec.create(TestApplication.class))
 +                .start();
 +        
 +        assertOnlyApp(launcher, TestApplication.class);
 +    }
 +    
 +    @Test
 +    public void testStartsAppFromBuilder() throws Exception {
 +        launcher = newLauncherForTests(true)
 +                .webconsole(false)
 +                .application(new ApplicationBuilder(EntitySpec.create(TestApplication.class)) {
 +                        @Override protected void doBuild() {
 +                        }})
 +                .start();
 +        
 +        assertOnlyApp(launcher, TestApplication.class);
 +    }
 +
 +    @Test
 +    public void testStartsAppFromYAML() throws Exception {
 +        String yaml = "name: example-app\n" +
 +                "services:\n" +
 +                "- serviceType: brooklyn.test.entity.TestEntity\n" +
 +                "  name: test-app";
 +        launcher = newLauncherForTests(true)
 +                .webconsole(false)
 +                .application(yaml)
 +                .start();
 +
 +        assertEquals(launcher.getApplications().size(), 1, "apps="+launcher.getApplications());
 +        Application app = Iterables.getOnlyElement(launcher.getApplications());
 +        assertEquals(app.getChildren().size(), 1, "children=" + app.getChildren());
 +        assertTrue(Iterables.getOnlyElement(app.getChildren()) instanceof TestEntity);
 +    }
 +    
 +    @Test  // may take 2s initializing location if running this test case alone, but noise if running suite 
 +    public void testStartsAppInSuppliedLocations() throws Exception {
 +        launcher = newLauncherForTests(true)
 +                .webconsole(false)
 +                .location("localhost")
 +                .application(new ApplicationBuilder(EntitySpec.create(TestApplication.class)) {
 +                        @Override protected void doBuild() {
 +                        }})
 +                .start();
 +        
 +        Application app = Iterables.find(launcher.getApplications(), Predicates.instanceOf(TestApplication.class));
 +        assertOnlyLocation(app, LocalhostMachineProvisioningLocation.class);
 +    }
 +    
 +    @Test
 +    public void testUsesSuppliedManagementContext() throws Exception {
 +        LocalManagementContext myManagementContext = LocalManagementContextForTests.newInstance();
 +        launcher = newLauncherForTests(false)
 +                .webconsole(false)
 +                .managementContext(myManagementContext)
 +                .start();
 +        
 +        assertSame(launcher.getServerDetails().getManagementContext(), myManagementContext);
 +    }
 +    
 +    @Test
 +    public void testUsesSuppliedBrooklynProperties() throws Exception {
 +        BrooklynProperties props = LocalManagementContextForTests.builder(true).buildProperties();
 +        props.put("mykey", "myval");
 +        launcher = newLauncherForTests(false)
 +                .webconsole(false)
 +                .brooklynProperties(props)
 +                .start();
 +        
 +        assertEquals(launcher.getServerDetails().getManagementContext().getConfig().getFirst("mykey"), "myval");
 +    }
 +
 +    @Test
 +    public void testUsesSupplementaryBrooklynProperties() throws Exception {
 +        launcher = newLauncherForTests(true)
 +                .webconsole(false)
 +                .brooklynProperties("mykey", "myval")
 +                .start();
 +        
 +        assertEquals(launcher.getServerDetails().getManagementContext().getConfig().getFirst("mykey"), "myval");
 +    }
 +    
 +    @Test
 +    public void testReloadBrooklynPropertiesRestoresProgrammaticProperties() throws Exception {
 +        launcher = newLauncherForTests(true)
 +                .webconsole(false)
 +                .brooklynProperties("mykey", "myval")
 +                .start();
 +        LocalManagementContext managementContext = (LocalManagementContext)launcher.getServerDetails().getManagementContext();
 +        assertEquals(managementContext.getConfig().getFirst("mykey"), "myval");
 +        managementContext.getBrooklynProperties().put("mykey", "newval");
 +        assertEquals(managementContext.getConfig().getFirst("mykey"), "newval");
 +        managementContext.reloadBrooklynProperties();
 +        assertEquals(managementContext.getConfig().getFirst("mykey"), "myval");
 +    }
 +    
 +    @Test
 +    public void testReloadBrooklynPropertiesFromFile() throws Exception {
 +        File globalPropertiesFile = File.createTempFile("local-brooklyn-properties-test", ".properties");
 +        FileUtil.setFilePermissionsTo600(globalPropertiesFile);
 +        try {
 +            String property = "mykey=myval";
 +            Files.append(getMinimalLauncherPropertiesString()+property, globalPropertiesFile, Charsets.UTF_8);
 +            launcher = newLauncherForTests(false)
 +                    .webconsole(false)
 +                    .globalBrooklynPropertiesFile(globalPropertiesFile.getAbsolutePath())
 +                    .start();
 +            LocalManagementContext managementContext = (LocalManagementContext)launcher.getServerDetails().getManagementContext();
 +            assertEquals(managementContext.getConfig().getFirst("mykey"), "myval");
 +            property = "mykey=newval";
 +            Files.write(getMinimalLauncherPropertiesString()+property, globalPropertiesFile, Charsets.UTF_8);
 +            managementContext.reloadBrooklynProperties();
 +            assertEquals(managementContext.getConfig().getFirst("mykey"), "newval");
 +        } finally {
 +            globalPropertiesFile.delete();
 +        }
 +    }
 +
 +    @Test(groups="Integration")
 +    public void testChecksGlobalBrooklynPropertiesPermissionsX00() throws Exception {
 +        File propsFile = File.createTempFile("testChecksGlobalBrooklynPropertiesPermissionsX00", ".properties");
 +        propsFile.setReadable(true, false);
 +        try {
 +            launcher = newLauncherForTests(false)
 +                    .webconsole(false)
 +                    .globalBrooklynPropertiesFile(propsFile.getAbsolutePath())
 +                    .start();
 +
 +            Assert.fail("Should have thrown");
 +        } catch (FatalRuntimeException e) {
 +            if (!e.toString().contains("Invalid permissions for file")) throw e;
 +        } finally {
 +            propsFile.delete();
 +        }
 +    }
 +
 +    @Test(groups="Integration")
 +    public void testChecksLocalBrooklynPropertiesPermissionsX00() throws Exception {
 +        File propsFile = File.createTempFile("testChecksLocalBrooklynPropertiesPermissionsX00", ".properties");
 +        propsFile.setReadable(true, false);
 +        try {
 +            launcher = newLauncherForTests(false)
 +                    .webconsole(false)
 +                    .localBrooklynPropertiesFile(propsFile.getAbsolutePath())
 +                    .start();
 +            
 +            Assert.fail("Should have thrown");
 +        } catch (FatalRuntimeException e) {
 +            if (!e.toString().contains("Invalid permissions for file")) throw e;
 +        } finally {
 +            propsFile.delete();
 +        }
 +    }
 +
 +    @Test(groups="Integration")
 +    public void testStartsWithBrooklynPropertiesPermissionsX00() throws Exception {
 +        File globalPropsFile = File.createTempFile("testChecksLocalBrooklynPropertiesPermissionsX00_global", ".properties");
 +        Files.write(getMinimalLauncherPropertiesString()+"key_in_global=1", globalPropsFile, Charset.defaultCharset());
 +        File localPropsFile = File.createTempFile("testChecksLocalBrooklynPropertiesPermissionsX00_local", ".properties");
 +        Files.write("key_in_local=2", localPropsFile, Charset.defaultCharset());
 +        FileUtil.setFilePermissionsTo600(globalPropsFile);
 +        FileUtil.setFilePermissionsTo600(localPropsFile);
 +        try {
 +            launcher = newLauncherForTests(false)
 +                    .webconsole(false)
 +                    .localBrooklynPropertiesFile(localPropsFile.getAbsolutePath())
 +                    .globalBrooklynPropertiesFile(globalPropsFile.getAbsolutePath())
 +                    .start();
 +            assertEquals(launcher.getServerDetails().getManagementContext().getConfig().getFirst("key_in_global"), "1");
 +            assertEquals(launcher.getServerDetails().getManagementContext().getConfig().getFirst("key_in_local"), "2");
 +        } finally {
 +            globalPropsFile.delete();
 +            localPropsFile.delete();
 +        }
 +    }
 +    
 +    @Test  // takes a bit of time because starts webapp, but also tests rest api so useful
 +    public void testErrorsCaughtByApiAndRestApiWorks() throws Exception {
 +        launcher = newLauncherForTests(true)
 +                .catalogInitialization(new CatalogInitialization(null, false, null, false).addPopulationCallback(new Function<CatalogInitialization, Void>() {
 +                    @Override
 +                    public Void apply(CatalogInitialization input) {
 +                        throw new RuntimeException("deliberate-exception-for-testing");
 +                    }
 +                }))
 +                .start();
 +        // such an error should be thrown, then caught in this calling thread
 +        ManagementContext mgmt = launcher.getServerDetails().getManagementContext();
 +        Assert.assertFalse( ((ManagementContextInternal)mgmt).errors().isEmpty() );
 +        Assert.assertTrue( ((ManagementContextInternal)mgmt).errors().get(0).toString().contains("deliberate"), ""+((ManagementContextInternal)mgmt).errors() );
 +        HttpTestUtils.assertContentMatches(
 +            Urls.mergePaths(launcher.getServerDetails().getWebServerUrl(), "v1/server/up"), 
 +            "true");
 +        HttpTestUtils.assertContentMatches(
 +            Urls.mergePaths(launcher.getServerDetails().getWebServerUrl(), "v1/server/healthy"), 
 +            "false");
 +        // TODO test errors api?
 +    }
 +
 +    private BrooklynLauncher newLauncherForTests(boolean minimal) {
 +        Preconditions.checkArgument(launcher==null, "can only be used if no launcher yet");
 +        BrooklynLauncher launcher = BrooklynLauncher.newInstance();
 +        if (minimal)
 +            launcher.brooklynProperties(LocalManagementContextForTests.builder(true).buildProperties());
 +        return launcher;
 +    }
 +
 +    private String getMinimalLauncherPropertiesString() throws IOException {
 +        BrooklynProperties p1 = LocalManagementContextForTests.builder(true).buildProperties();
 +        Properties p = new Properties();
 +        p.putAll(Maps.transformValues(p1.asMapWithStringKeys(), StringFunctions.toStringFunction()));
 +        Writer w = new StringWriter();
 +        p.store(w, "test");
 +        w.close();
 +        return w.toString()+"\n";
 +    }
 +
 +    private void assertOnlyApp(BrooklynLauncher launcher, Class<? extends Application> expectedType) {
 +        assertEquals(launcher.getApplications().size(), 1, "apps="+launcher.getApplications());
 +        assertNotNull(Iterables.find(launcher.getApplications(), Predicates.instanceOf(TestApplication.class), null), "apps="+launcher.getApplications());
 +    }
 +    
 +    private void assertOnlyLocation(Application app, Class<? extends Location> expectedType) {
 +        assertEquals(app.getLocations().size(), 1, "locs="+app.getLocations());
 +        assertNotNull(Iterables.find(app.getLocations(), Predicates.instanceOf(LocalhostMachineProvisioningLocation.class), null), "locs="+app.getLocations());
 +    }
 +}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/2ed62d61/usage/launcher/src/test/java/org/apache/brooklyn/launcher/WebAppRunnerTest.java
----------------------------------------------------------------------
diff --cc usage/launcher/src/test/java/org/apache/brooklyn/launcher/WebAppRunnerTest.java
index 3aa6334,0000000..f347600
mode 100644,000000..100644
--- a/usage/launcher/src/test/java/org/apache/brooklyn/launcher/WebAppRunnerTest.java
+++ b/usage/launcher/src/test/java/org/apache/brooklyn/launcher/WebAppRunnerTest.java
@@@ -1,171 -1,0 +1,171 @@@
 +/*
 + * 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.launcher;
 +
 +import org.apache.brooklyn.launcher.BrooklynWebServer;
 +import org.apache.brooklyn.launcher.BrooklynLauncher;
 +import org.apache.brooklyn.launcher.BrooklynServerDetails;
 +import static org.testng.Assert.assertNotNull;
 +import static org.testng.Assert.fail;
 +
 +import java.util.List;
 +import java.util.Map;
 +
++import org.apache.brooklyn.test.HttpTestUtils;
 +import org.apache.brooklyn.test.TestResourceUnavailableException;
 +import org.slf4j.Logger;
 +import org.slf4j.LoggerFactory;
 +import org.testng.annotations.AfterMethod;
 +import org.testng.annotations.Test;
 +
 +import brooklyn.config.BrooklynProperties;
 +import brooklyn.entity.basic.Entities;
 +import brooklyn.management.internal.LocalManagementContext;
 +import brooklyn.management.internal.ManagementContextInternal;
- import brooklyn.test.HttpTestUtils;
 +import brooklyn.util.collections.MutableMap;
 +import brooklyn.util.net.Networking;
 +
 +import com.google.common.collect.Lists;
 +
 +
 +/**
 + * These tests require the brooklyn.war to work. (Should be placed by maven build.)
 + */
 +public class WebAppRunnerTest {
 +
 +    public static final Logger log = LoggerFactory.getLogger(WebAppRunnerTest.class);
 +            
 +    List<LocalManagementContext> managementContexts = Lists.newCopyOnWriteArrayList();
 +    
 +    @AfterMethod(alwaysRun=true)
 +    public void tearDown() throws Exception {
 +        for (LocalManagementContext managementContext : managementContexts) {
 +            Entities.destroyAll(managementContext);
 +        }
 +        managementContexts.clear();
 +    }
 +    
 +    LocalManagementContext newManagementContext(BrooklynProperties brooklynProperties) {
 +        LocalManagementContext result = new LocalManagementContext(brooklynProperties);
 +        managementContexts.add(result);
 +        return result;
 +    }
 +    
 +    @SuppressWarnings({ "unchecked", "rawtypes" })
 +    BrooklynWebServer createWebServer(Map properties) {
 +        Map bigProps = MutableMap.copyOf(properties);
 +        Map attributes = MutableMap.copyOf( (Map) bigProps.get("attributes") );
 +        bigProps.put("attributes", attributes);
 +
 +        BrooklynProperties brooklynProperties = BrooklynProperties.Factory.newEmpty();
 +        brooklynProperties.putAll(bigProps);
 +        brooklynProperties.put("brooklyn.webconsole.security.provider","brooklyn.rest.security.provider.AnyoneSecurityProvider");
 +        brooklynProperties.put("brooklyn.webconsole.security.https.required","false");
 +        return new BrooklynWebServer(bigProps, newManagementContext(brooklynProperties));
 +    }
 +    
 +    @Test
 +    public void testStartWar1() throws Exception {
 +        if (!Networking.isPortAvailable(8090))
 +            fail("Another process is using port 8090 which is required for this test.");
 +        BrooklynWebServer server = createWebServer(MutableMap.of("port", 8090));
 +        assertNotNull(server);
 +        
 +        try {
 +            server.start();
 +            assertBrooklynEventuallyAt("http://localhost:8090/");
 +        } finally {
 +            server.stop();
 +        }
 +    }
 +
 +    public static void assertBrooklynEventuallyAt(String url) {
 +        HttpTestUtils.assertContentEventuallyContainsText(url, "Brooklyn Web Console");
 +    }
 +
 +    @Test
 +    public void testStartSecondaryWar() throws Exception {
 +        TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), "/hello-world.war");
 +
 +        if (!Networking.isPortAvailable(8090))
 +            fail("Another process is using port 8090 which is required for this test.");
 +        BrooklynWebServer server = createWebServer(
 +            MutableMap.of("port", 8090, "war", "brooklyn.war", "wars", MutableMap.of("hello", "hello-world.war")) );
 +        assertNotNull(server);
 +        
 +        try {
 +            server.start();
 +
 +            assertBrooklynEventuallyAt("http://localhost:8090/");
 +            HttpTestUtils.assertContentEventuallyContainsText("http://localhost:8090/hello",
 +                "This is the home page for a sample application");
 +
 +        } finally {
 +            server.stop();
 +        }
 +    }
 +
 +    @Test
 +    public void testStartSecondaryWarAfter() throws Exception {
 +        TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), "/hello-world.war");
 +
 +        if (!Networking.isPortAvailable(8090))
 +            fail("Another process is using port 8090 which is required for this test.");
 +        BrooklynWebServer server = createWebServer(MutableMap.of("port", 8090, "war", "brooklyn.war"));
 +        assertNotNull(server);
 +        
 +        try {
 +            server.start();
 +            server.deploy("/hello", "hello-world.war");
 +
 +            assertBrooklynEventuallyAt("http://localhost:8090/");
 +            HttpTestUtils.assertContentEventuallyContainsText("http://localhost:8090/hello",
 +                "This is the home page for a sample application");
 +
 +        } finally {
 +            server.stop();
 +        }
 +    }
 +
 +    @Test
 +    public void testStartWithLauncher() throws Exception {
 +        TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), "/hello-world.war");
 +
 +        BrooklynLauncher launcher = BrooklynLauncher.newInstance()
 +                .brooklynProperties(BrooklynProperties.Factory.newEmpty())
 +                .brooklynProperties("brooklyn.webconsole.security.provider","brooklyn.rest.security.provider.AnyoneSecurityProvider")
 +                .webapp("/hello", "hello-world.war")
 +                .start();
 +        BrooklynServerDetails details = launcher.getServerDetails();
 +        
 +        try {
 +            details.getWebServer().deploy("/hello2", "hello-world.war");
 +
 +            assertBrooklynEventuallyAt(details.getWebServerUrl());
 +            HttpTestUtils.assertContentEventuallyContainsText(details.getWebServerUrl()+"hello", "This is the home page for a sample application");
 +            HttpTestUtils.assertContentEventuallyContainsText(details.getWebServerUrl()+"hello2", "This is the home page for a sample application");
 +            HttpTestUtils.assertHttpStatusCodeEventuallyEquals(details.getWebServerUrl()+"hello0", 404);
 +
 +        } finally {
 +            details.getWebServer().stop();
 +            ((ManagementContextInternal)details.getManagementContext()).terminate();
 +        }
 +    }
 +    
 +}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/2ed62d61/usage/launcher/src/test/java/org/apache/brooklyn/launcher/blueprints/AbstractBlueprintTest.java
----------------------------------------------------------------------
diff --cc usage/launcher/src/test/java/org/apache/brooklyn/launcher/blueprints/AbstractBlueprintTest.java
index ab73cbf,0000000..3f39f91
mode 100644,000000..100644
--- a/usage/launcher/src/test/java/org/apache/brooklyn/launcher/blueprints/AbstractBlueprintTest.java
+++ b/usage/launcher/src/test/java/org/apache/brooklyn/launcher/blueprints/AbstractBlueprintTest.java
@@@ -1,202 -1,0 +1,202 @@@
 +/*
 + * 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.launcher.blueprints;
 +
 +import static org.testng.Assert.assertNotEquals;
 +
 +import java.io.File;
 +import java.io.Reader;
 +import java.io.StringReader;
 +import java.util.Collection;
 +
 +import org.apache.brooklyn.camp.brooklyn.BrooklynCampPlatformLauncherAbstract;
++import org.apache.brooklyn.test.EntityTestUtils;
 +import org.slf4j.Logger;
 +import org.slf4j.LoggerFactory;
 +import org.testng.annotations.AfterMethod;
 +import org.testng.annotations.BeforeMethod;
 +
 +import brooklyn.entity.Application;
 +import brooklyn.entity.Entity;
 +import brooklyn.entity.basic.Attributes;
 +import brooklyn.entity.basic.Entities;
 +import brooklyn.entity.basic.Lifecycle;
 +import brooklyn.entity.basic.SoftwareProcess;
 +import brooklyn.entity.rebind.RebindOptions;
 +import brooklyn.entity.rebind.RebindTestUtils;
 +import brooklyn.entity.rebind.persister.FileBasedObjectStore;
 +import org.apache.brooklyn.launcher.BrooklynLauncher;
 +import org.apache.brooklyn.launcher.SimpleYamlLauncherForTests;
 +import org.apache.brooklyn.launcher.camp.BrooklynCampPlatformLauncher;
 +import brooklyn.management.ManagementContext;
 +import brooklyn.management.internal.LocalManagementContext;
 +import brooklyn.test.Asserts;
- import brooklyn.test.EntityTestUtils;
 +import brooklyn.util.ResourceUtils;
 +import brooklyn.util.os.Os;
 +
 +public abstract class AbstractBlueprintTest {
 +
 +    private static final Logger LOG = LoggerFactory.getLogger(AbstractBlueprintTest.class);
 +    
 +    protected File mementoDir;
 +    protected ClassLoader classLoader = AbstractBlueprintTest.class.getClassLoader();
 +    
 +    protected ManagementContext mgmt;
 +    protected SimpleYamlLauncherForTests launcher;
 +    protected BrooklynLauncher viewer;
 +
 +    @BeforeMethod(alwaysRun=true)
 +    public void setUp() throws Exception {
 +        mementoDir = Os.newTempDir(getClass());
 +        mgmt = createOrigManagementContext();
 +        LOG.info("Test "+getClass()+" persisting to "+mementoDir);
 +
 +        launcher = new SimpleYamlLauncherForTests() {
 +            @Override
 +            protected BrooklynCampPlatformLauncherAbstract newPlatformLauncher() {
 +                return new BrooklynCampPlatformLauncher() {
 +                    protected ManagementContext newManagementContext() {
 +                        return AbstractBlueprintTest.this.mgmt;
 +                    }
 +                };
 +            }
 +        };
 +        viewer = BrooklynLauncher.newInstance()
 +                .managementContext(mgmt)
 +                .start();
 +    }
 +
 +    @AfterMethod(alwaysRun=true)
 +    public void tearDown() throws Exception {
 +        try {
 +            if (mgmt != null) {
 +                for (Application app: mgmt.getApplications()) {
 +                    LOG.debug("destroying app "+app+" (managed? "+Entities.isManaged(app)+"; mgmt is "+mgmt+")");
 +                    try {
 +                        Entities.destroy(app);
 +                        LOG.debug("destroyed app "+app+"; mgmt now "+mgmt);
 +                    } catch (Exception e) {
 +                        LOG.error("problems destroying app "+app, e);
 +                    }
 +                }
 +            }
 +            if (launcher != null) launcher.destroyAll();
 +            if (viewer != null) viewer.terminate();
 +            if (mgmt != null) Entities.destroyAll(mgmt);
 +            if (mementoDir != null) FileBasedObjectStore.deleteCompletely(mementoDir);
 +        } catch (Throwable t) {
 +            LOG.error("Caught exception in tearDown method", t);
 +        } finally {
 +            mgmt = null;
 +            launcher = null;
 +        }
 +    }
 +
 +    protected void runTest(String yamlFile) throws Exception {
 +        final Application app = launcher.launchAppYaml(yamlFile);
 +        
 +        assertNoFires(app);
 +        
 +        Application newApp = rebind();
 +        assertNoFires(newApp);
 +    }
 +    
 +    protected void runTest(Reader yaml) throws Exception {
 +        final Application app = launcher.launchAppYaml(yaml);
 +        
 +        assertNoFires(app);
 +        
 +        Application newApp = rebind();
 +        assertNoFires(newApp);
 +    }
 +    
 +    protected void assertNoFires(final Entity app) {
 +        EntityTestUtils.assertAttributeEqualsEventually(app, Attributes.SERVICE_UP, true);
 +        EntityTestUtils.assertAttributeEqualsEventually(app, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING);
 +        
 +        Asserts.succeedsEventually(new Runnable() {
 +            public void run() {
 +                for (Entity entity : Entities.descendants(app)) {
 +                    assertNotEquals(entity.getAttribute(Attributes.SERVICE_STATE_ACTUAL), Lifecycle.ON_FIRE);
 +                    assertNotEquals(entity.getAttribute(Attributes.SERVICE_UP), false);
 +                    
 +                    if (entity instanceof SoftwareProcess) {
 +                        EntityTestUtils.assertAttributeEquals(entity, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING);
 +                        EntityTestUtils.assertAttributeEquals(entity, Attributes.SERVICE_UP, Boolean.TRUE);
 +                    }
 +                }
 +            }});
 +    }
 +
 +    protected Reader loadYaml(String url, String location) {
 +        String yaml = 
 +                "location: "+location+"\n"+
 +                new ResourceUtils(this).getResourceAsString(url);
 +        return new StringReader(yaml);
 +    }
 +    
 +    
 +    //////////////////////////////////////////////////////////////////
 +    // FOR REBIND                                                   //
 +    // See brooklyn.entity.rebind.RebindTestFixture in core's tests //
 +    //////////////////////////////////////////////////////////////////
 +
 +    /** rebinds, and sets newApp */
 +    protected Application rebind() throws Exception {
 +        return rebind(RebindOptions.create());
 +    }
 +
 +    protected Application rebind(RebindOptions options) throws Exception {
 +        ManagementContext origMgmt = mgmt;
 +        ManagementContext newMgmt = createNewManagementContext();
 +        Collection<Application> origApps = origMgmt.getApplications();
 +        
 +        options = RebindOptions.create(options);
 +        if (options.classLoader == null) options.classLoader(classLoader);
 +        if (options.mementoDir == null) options.mementoDir(mementoDir);
 +        if (options.origManagementContext == null) options.origManagementContext(origMgmt);
 +        if (options.newManagementContext == null) options.newManagementContext(newMgmt);
 +        
 +        for (Application origApp : origApps) {
 +            RebindTestUtils.waitForPersisted(origApp);
 +        }
 +        
 +        mgmt = options.newManagementContext;
 +        Application newApp = RebindTestUtils.rebind(options);
 +        return newApp;
 +    }
 +    
 +    /** @return A started management context */
 +    protected LocalManagementContext createOrigManagementContext() {
 +        return RebindTestUtils.managementContextBuilder(mementoDir, classLoader)
 +                .persistPeriodMillis(1)
 +                .forLive(true)
 +                .emptyCatalog(true)
 +                .buildStarted();
 +    }
 +
 +    /** @return An unstarted management context */
 +    protected LocalManagementContext createNewManagementContext() {
 +        return RebindTestUtils.managementContextBuilder(mementoDir, classLoader)
 +                .persistPeriodMillis(1)
 +                .forLive(true)
 +                .emptyCatalog(true)
 +                .buildUnstarted();
 +    }
 +}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/2ed62d61/usage/qa/src/test/java/org/apache/brooklyn/qa/brooklynnode/SoftlayerObtainPrivateLiveTest.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/2ed62d61/usage/qa/src/test/java/org/apache/brooklyn/qa/load/LoadTest.java
----------------------------------------------------------------------


Mime
View raw message