brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aleds...@apache.org
Subject [09/35] incubator-brooklyn git commit: [BROOKLYN-162] package rename to org.apache.brooklyn: software/webapp
Date Wed, 12 Aug 2015 15:55:27 GMT
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/77dff880/software/webapp/src/test/java/brooklyn/entity/proxy/nginx/NginxWebClusterEc2LiveTest.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/brooklyn/entity/proxy/nginx/NginxWebClusterEc2LiveTest.java b/software/webapp/src/test/java/brooklyn/entity/proxy/nginx/NginxWebClusterEc2LiveTest.java
deleted file mode 100644
index 3646155..0000000
--- a/software/webapp/src/test/java/brooklyn/entity/proxy/nginx/NginxWebClusterEc2LiveTest.java
+++ /dev/null
@@ -1,115 +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.proxy.nginx;
-
-import static org.testng.Assert.assertNotNull;
-
-import java.net.URL;
-
-import org.apache.brooklyn.management.ManagementContext;
-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.BeforeMethod;
-import org.testng.annotations.Test;
-
-import brooklyn.entity.Entity;
-import brooklyn.entity.basic.ApplicationBuilder;
-import brooklyn.entity.basic.Entities;
-import brooklyn.entity.group.DynamicCluster;
-import brooklyn.entity.proxying.EntitySpec;
-import brooklyn.entity.webapp.JavaWebAppService;
-import brooklyn.entity.webapp.WebAppService;
-import brooklyn.entity.webapp.jboss.JBoss7Server;
-import brooklyn.location.Location;
-import brooklyn.location.MachineLocation;
-import brooklyn.location.basic.Machines;
-import brooklyn.test.Asserts;
-import brooklyn.test.entity.TestApplication;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-
-/**
- * Test Nginx proxying a cluster of JBoss7Server entities on AWS for ENGR-1689.
- *
- * This test is a proof-of-concept for the Brooklyn demo application, with each
- * service running on a separate Amazon EC2 instance.
- */
-public class NginxWebClusterEc2LiveTest {
-    private static final Logger LOG = LoggerFactory.getLogger(NginxWebClusterEc2LiveTest.class);
-    
-    private TestApplication app;
-    private NginxController nginx;
-    private DynamicCluster cluster;
-    private Location loc;
-
-    @BeforeMethod(alwaysRun = true)
-    public void setUp() {
-        ManagementContext managementContext = Entities.newManagementContext(
-                ImmutableMap.of("brooklyn.location.jclouds.aws-ec2.image-id", "us-east-1/ami-2342a94a"));
-        
-        loc = managementContext.getLocationRegistry().resolve("aws-ec2:us-east-1");
-        app = ApplicationBuilder.newManagedApp(TestApplication.class, managementContext);
-    }
-
-    @AfterMethod(alwaysRun = true)
-    public void shutdown() {
-        if (app != null) Entities.destroyAll(app.getManagementContext());
-    }
-
-    @Test(groups = "Live")
-    public void testProvisionAwsCluster() {
-        String warName = "/hello-world.war";
-        TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), warName);
-        URL war = getClass().getResource(warName);
-        assertNotNull(war, "Unable to locate resource "+warName);
-        
-        cluster = app.createAndManageChild(EntitySpec.create(DynamicCluster.class)
-                .configure(DynamicCluster.MEMBER_SPEC, EntitySpec.create(JBoss7Server.class))
-                .configure("initialSize", 2)
-                .configure("httpPort", 8080)
-                .configure(JavaWebAppService.ROOT_WAR, war.getPath()));
-        
-        nginx = app.createAndManageChild(EntitySpec.create(NginxController.class)
-                .configure("cluster", cluster)
-                .configure("domain", "localhost")
-                .configure("port", 8000)
-                .configure("portNumberSensor", WebAppService.HTTP_PORT));
-
-        app.start(ImmutableList.of(loc));
-        
-        Asserts.succeedsEventually(new Runnable() {
-            public void run() {
-                // Nginx URL is available
-                MachineLocation machine = Machines.findUniqueMachineLocation(nginx.getLocations()).get();
-                String url = "http://" + machine.getAddress().getHostName() + ":" + nginx.getAttribute(NginxController.PROXY_HTTP_PORT) + "/swf-booking-mvc";
-                HttpTestUtils.assertHttpStatusCodeEquals(url, 200);
-    
-                // Web-app URL is available
-                for (Entity member : cluster.getMembers()) {
-                    HttpTestUtils.assertHttpStatusCodeEquals(member.getAttribute(JavaWebAppService.ROOT_URL) + "swf-booking-mvc", 200);
-                }
-            }});
-
-        nginx.stop();
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/77dff880/software/webapp/src/test/java/brooklyn/entity/webapp/AbstractWebAppFixtureIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/AbstractWebAppFixtureIntegrationTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/AbstractWebAppFixtureIntegrationTest.java
deleted file mode 100644
index 5ff4d0b..0000000
--- a/software/webapp/src/test/java/brooklyn/entity/webapp/AbstractWebAppFixtureIntegrationTest.java
+++ /dev/null
@@ -1,502 +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.webapp;
-
-import static org.apache.brooklyn.test.HttpTestUtils.connectToUrl;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertTrue;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.net.URLConnection;
-import java.security.KeyStore;
-import java.security.cert.Certificate;
-import java.util.List;
-import java.util.concurrent.Callable;
-import java.util.concurrent.CopyOnWriteArrayList;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import brooklyn.entity.basic.SoftwareProcessDriver;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
-
-import brooklyn.config.BrooklynProperties;
-import brooklyn.entity.Application;
-import brooklyn.entity.Entity;
-import brooklyn.entity.basic.ApplicationBuilder;
-import brooklyn.entity.basic.Entities;
-import brooklyn.entity.basic.EntityInternal;
-import brooklyn.entity.basic.EntityLocal;
-import brooklyn.entity.basic.SoftwareProcess;
-import brooklyn.entity.drivers.DriverDependentEntity;
-import brooklyn.entity.trait.Startable;
-import brooklyn.event.SensorEvent;
-import brooklyn.event.SensorEventListener;
-import brooklyn.location.LocationSpec;
-import brooklyn.location.basic.LocalhostMachineProvisioningLocation;
-import brooklyn.test.Asserts;
-
-import org.apache.brooklyn.management.ManagementContext;
-import org.apache.brooklyn.management.SubscriptionContext;
-import org.apache.brooklyn.management.SubscriptionHandle;
-import org.apache.brooklyn.test.EntityTestUtils;
-import org.apache.brooklyn.test.HttpTestUtils;
-import org.apache.brooklyn.test.TestResourceUnavailableException;
-
-import brooklyn.test.entity.LocalManagementContextForTests;
-import brooklyn.test.entity.TestApplication;
-import brooklyn.util.collections.MutableMap;
-import brooklyn.util.crypto.FluentKeySigner;
-import brooklyn.util.crypto.SecureKeys;
-import brooklyn.util.net.Urls;
-import brooklyn.util.stream.Streams;
-import brooklyn.util.time.Time;
-
-import com.google.common.base.Stopwatch;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Lists;
-
-/**
- * Test fixture for implementations of JavaWebApp, checking start up and shutdown, 
- * post request and error count metrics and deploy wars, etc.
- */
-public abstract class AbstractWebAppFixtureIntegrationTest {
-    
-    private static final Logger log = LoggerFactory.getLogger(AbstractWebAppFixtureIntegrationTest.class);
-    
-    // Don't use 8080 since that is commonly used by testing software
-    public static final String DEFAULT_HTTP_PORT = "7880+";
-    
-    // Port increment for JBoss 6.
-    public static final int PORT_INCREMENT = 400;
-
-    // The parent application entity for these tests
-    protected ManagementContext mgmt;
-    protected List<TestApplication> applications = Lists.newArrayList();
-    protected SoftwareProcess entity;
-    protected LocalhostMachineProvisioningLocation loc;
-
-    protected synchronized ManagementContext getMgmt() {
-        if (mgmt==null)
-            mgmt = new LocalManagementContextForTests(BrooklynProperties.Factory.newDefault());
-        return mgmt;
-    }
-    
-    @BeforeMethod(alwaysRun=true)
-    public void setUp() throws Exception {
-        loc = getMgmt().getLocationManager().createLocation(LocationSpec.create(LocalhostMachineProvisioningLocation.class));
-    }
-    
-    /*
-     * Use of @DataProvider with test methods gives surprising behaviour with @AfterMethod.
-     * Unless careful, this causes problems when trying to ensure everything is shutdown cleanly.
-     *
-     * Empirically, the rules seem to be...
-     *  - @DataProvider method is called first; it creates a bunch of cases to run 
-     *    (all sharing the same instance of WebAppIntegrationTest).
-     *  - It runs the test method for the first time with the first @DataProvider value
-     *  - It runs @AfterMethod
-     *  - It runs the test method for the second @DataProvider value
-     *  - It runs @AfterMethod
-     *  - etc...
-     *
-     * Previously shutdownApp was calling stop on each app in applications, and clearing the applications set;
-     * but then the second invocation of the method was starting an entity that was never stopped. Until recently,
-     * every test method was also terminating the entity (belt-and-braces, but also brittle for if the method threw
-     * an exception earlier). When that "extra" termination was removed, it meant the second and subsequent 
-     * entities were never being stopped.
-     *
-     * Now we rely on having the test method set the entity field, so we can find out which application instance 
-     * it is and calling stop on just that app + entity.
-     */
-    @AfterMethod(alwaysRun=true)
-    public void shutdownApp() {
-        if (entity != null) {
-            Application app = entity.getApplication();
-            if (app != null) Entities.destroy(app);
-        }
-    }
-
-    @AfterClass(alwaysRun=true)
-    public synchronized void shutdownMgmt() {
-        try {
-            if (mgmt != null) Entities.destroyAll(mgmt);
-        } finally {
-            mgmt = null;
-        }
-    }
-
-    public static File createTemporaryKeyStore(String alias, String password) throws Exception {
-        FluentKeySigner signer = new FluentKeySigner("brooklyn-test").selfsign();
-
-        KeyStore ks = SecureKeys.newKeyStore();
-        ks.setKeyEntry(
-                alias,
-                signer.getKey().getPrivate(),
-                password.toCharArray(),
-                new Certificate[]{signer.getAuthorityCertificate()});
-
-        File file = File.createTempFile("test", "keystore");
-        FileOutputStream fos = new FileOutputStream(file);
-        try {
-            ks.store(fos, password.toCharArray());
-            return file;
-        } finally {
-            Streams.closeQuietly(fos);
-        }
-    }
-
-    /** 
-     * Create a new instance of TestApplication and append it to applications list
-     * so it can be terminated suitable after each test has run.
-     * @return
-     */
-    protected TestApplication newTestApplication() {
-        TestApplication ta = ApplicationBuilder.newManagedApp(TestApplication.class, getMgmt());
-        applications.add(ta);
-        return ta;
-    }
-
-    /**
-     * Provides instances of the WebAppServer to test
-     * (arrays of 1-element array arguments to some of the other methods) 
-     *
-     * NB annotation must be placed on concrete impl method
-     * 
-     * TODO combine the data provider here with live integration test
-     * @see WebAppLiveIntegrationTest#basicEntities()
-     */
-    @DataProvider(name = "basicEntities")
-    public abstract Object[][] basicEntities();
-
-    /**
-     * Checks an entity can start, set SERVICE_UP to true and shutdown again.
-     */
-    @Test(groups = "Integration", dataProvider = "basicEntities")
-    public void canStartAndStop(final SoftwareProcess entity) {
-        this.entity = entity;
-        log.info("test=canStartAndStop; entity="+entity+"; app="+entity.getApplication());
-        
-        Entities.start(entity.getApplication(), ImmutableList.of(loc));
-        Asserts.succeedsEventually(MutableMap.of("timeout", 120*1000), new Runnable() {
-            public void run() {
-                assertTrue(entity.getAttribute(Startable.SERVICE_UP));
-            }});
-        
-        entity.stop();
-        assertFalse(entity.getAttribute(Startable.SERVICE_UP));
-    }
-    
-    /**
-     * Checks an entity can start, set SERVICE_UP to true and shutdown again.
-     */
-    @Test(groups = "Integration", dataProvider = "basicEntities")
-    public void testReportsServiceDownWhenKilled(final SoftwareProcess entity) throws Exception {
-        this.entity = entity;
-        log.info("test=testReportsServiceDownWithKilled; entity="+entity+"; app="+entity.getApplication());
-        
-        Entities.start(entity.getApplication(), ImmutableList.of(loc));
-        EntityTestUtils.assertAttributeEqualsEventually(MutableMap.of("timeout", 120*1000), entity, Startable.SERVICE_UP, true);
-
-        // Stop the underlying entity, but without our entity instance being told!
-        killEntityBehindBack(entity);
-        log.info("Killed {} behind mgmt's back, waiting for service up false in mgmt context", entity);
-        
-        EntityTestUtils.assertAttributeEqualsEventually(entity, Startable.SERVICE_UP, false);
-        
-        log.info("success getting service up false in primary mgmt universe");
-    }
-    
-    /**
-     * Stop the given underlying entity, but without our entity instance being told!
-     */
-    protected void killEntityBehindBack(Entity tokill) throws Exception {
-        ((SoftwareProcessDriver)((DriverDependentEntity<?>) Entities.deproxy(entity)).getDriver()).stop();
-        // old method of doing this did some dodgy legacy rebind and failed due to too many dangling refs; above is better in any case
-        // but TODO we should have some rebind tests for these!
-    }
-    
-    /**
-     * Checks that an entity correctly sets request and error count metrics by
-     * connecting to a non-existent URL several times.
-     */
-    @Test(groups = "Integration", dataProvider = "basicEntities")
-    public void publishesRequestAndErrorCountMetrics(final SoftwareProcess entity) throws Exception {
-        this.entity = entity;
-        log.info("test=publishesRequestAndErrorCountMetrics; entity="+entity+"; app="+entity.getApplication());
-        
-        Entities.start(entity.getApplication(), ImmutableList.of(loc));
-        
-        Asserts.succeedsEventually(MutableMap.of("timeout", 10*1000), new Runnable() {
-            public void run() {
-                assertTrue(entity.getAttribute(SoftwareProcess.SERVICE_UP));
-            }});
-        
-        String url = entity.getAttribute(WebAppService.ROOT_URL) + "does_not_exist";
-        
-        final int n = 10;
-        for (int i = 0; i < n; i++) {
-            URLConnection connection = HttpTestUtils.connectToUrl(url);
-            int status = ((HttpURLConnection) connection).getResponseCode();
-            log.info("connection to {} gives {}", url, status);
-        }
-        
-        Asserts.succeedsEventually(MutableMap.of("timeout", 20*1000), new Runnable() {
-            public void run() {
-                Integer requestCount = entity.getAttribute(WebAppService.REQUEST_COUNT);
-                Integer errorCount = entity.getAttribute(WebAppService.ERROR_COUNT);
-                log.info("req={}, err={}", requestCount, errorCount);
-                
-                assertNotNull(errorCount, "errorCount not set yet ("+errorCount+")");
-    
-                // AS 7 seems to take a very long time to report error counts,
-                // hence not using ==.  >= in case error pages include a favicon, etc.
-                assertEquals(errorCount, (Integer)n);
-                assertTrue(requestCount >= errorCount);
-            }});
-    }
-    
-    /**
-     * Checks an entity publishes correct requests/second figures and that these figures
-     * fall to zero after a period of no activity.
-     */
-    @Test(groups = "Integration", dataProvider = "basicEntities")
-    public void publishesRequestsPerSecondMetric(final SoftwareProcess entity) throws Exception {
-        this.entity = entity;
-        log.info("test=publishesRequestsPerSecondMetric; entity="+entity+"; app="+entity.getApplication());
-        
-        Entities.start(entity.getApplication(), ImmutableList.of(loc));
-
-        log.info("Entity "+entity+" started");
-        
-        try {
-            // reqs/sec initially zero
-            log.info("Waiting for initial avg-requests to be zero...");
-            Asserts.succeedsEventually(MutableMap.of("timeout", 20*1000), new Runnable() {
-                public void run() {
-                    Double activityValue = entity.getAttribute(WebAppService.REQUESTS_PER_SECOND_IN_WINDOW);
-                    assertNotNull(activityValue, "activity not set yet "+activityValue+")");
-                    assertEquals(activityValue.doubleValue(), 0.0d, 0.000001d);
-                }});
-            
-            // apply workload on 1 per sec; reqs/sec should update
-            Asserts.succeedsEventually(MutableMap.of("timeout", 30*1000), new Callable<Void>() {
-                public Void call() throws Exception {
-                    String url = entity.getAttribute(WebAppService.ROOT_URL) + "does_not_exist";
-                    final int desiredMsgsPerSec = 10;
-                    
-                    Stopwatch stopwatch = Stopwatch.createStarted();
-                    final AtomicInteger reqsSent = new AtomicInteger();
-                    final Integer preRequestCount = entity.getAttribute(WebAppService.REQUEST_COUNT);
-                    
-                    // need to maintain n requests per second for the duration of the window size
-                    log.info("Applying load for "+WebAppServiceMethods.DEFAULT_WINDOW_DURATION);
-                    while (stopwatch.elapsed(TimeUnit.MILLISECONDS) < WebAppServiceMethods.DEFAULT_WINDOW_DURATION.toMilliseconds()) {
-                        long preReqsTime = stopwatch.elapsed(TimeUnit.MILLISECONDS);
-                        for (int i = 0; i < desiredMsgsPerSec; i++) { connectToUrl(url); }
-                        Time.sleep(1000 - (stopwatch.elapsed(TimeUnit.MILLISECONDS)-preReqsTime));
-                        reqsSent.addAndGet(desiredMsgsPerSec);
-                    }
-    
-                    Asserts.succeedsEventually(MutableMap.of("timeout", 4000), new Runnable() {
-                        public void run() {
-                            Double avgReqs = entity.getAttribute(WebAppService.REQUESTS_PER_SECOND_IN_WINDOW);
-                            Integer requestCount = entity.getAttribute(WebAppService.REQUEST_COUNT);
-                            
-                            log.info("avg-requests="+avgReqs+"; total-requests="+requestCount);
-                            assertEquals(avgReqs.doubleValue(), (double)desiredMsgsPerSec, 3.0d);
-                            assertEquals(requestCount.intValue(), preRequestCount+reqsSent.get());
-                        }});
-                    
-                    return null;
-                }});
-            
-            // After suitable delay, expect to again get zero msgs/sec
-            log.info("Waiting for avg-requests to drop to zero, for "+WebAppServiceMethods.DEFAULT_WINDOW_DURATION);
-            Thread.sleep(WebAppServiceMethods.DEFAULT_WINDOW_DURATION.toMilliseconds());
-            
-            Asserts.succeedsEventually(MutableMap.of("timeout", 10*1000), new Runnable() {
-                public void run() {
-                    Double avgReqs = entity.getAttribute(WebAppService.REQUESTS_PER_SECOND_IN_WINDOW);
-                    assertNotNull(avgReqs);
-                    assertEquals(avgReqs.doubleValue(), 0.0d, 0.00001d);
-                }});
-        } finally {
-            entity.stop();
-        }
-    }
-
-    /**
-     * Tests that we get consecutive events with zero workrate, and with suitably small timestamps between them.
-     */
-    @Test(groups = "Integration", dataProvider = "basicEntities")
-    @SuppressWarnings("rawtypes")
-    public void publishesZeroRequestsPerSecondMetricRepeatedly(final SoftwareProcess entity) {
-        this.entity = entity;
-        log.info("test=publishesZeroRequestsPerSecondMetricRepeatedly; entity="+entity+"; app="+entity.getApplication());
-        
-        final int MAX_INTERVAL_BETWEEN_EVENTS = 4000; // TomcatServerImpl publishes events every 3000ms so this should be enough overhead
-        final int NUM_CONSECUTIVE_EVENTS = 3;
-
-        Entities.start(entity.getApplication(), ImmutableList.of(loc));
-        
-        SubscriptionHandle subscriptionHandle = null;
-        SubscriptionContext subContext = ((EntityInternal)entity).getSubscriptionContext();
-
-        try {
-            final List<SensorEvent> events = new CopyOnWriteArrayList<SensorEvent>();
-            subscriptionHandle = subContext.subscribe(entity, WebAppService.REQUESTS_PER_SECOND_IN_WINDOW, new SensorEventListener<Double>() {
-                public void onEvent(SensorEvent<Double> event) {
-                    log.info("publishesRequestsPerSecondMetricRepeatedly.onEvent: {}", event);
-                    events.add(event);
-                }});
-            
-            
-            Asserts.succeedsEventually(new Runnable() {
-                public void run() {
-                    assertTrue(events.size() > NUM_CONSECUTIVE_EVENTS, "events "+events.size()+" > "+NUM_CONSECUTIVE_EVENTS);
-                    long eventTime = 0;
-                    
-                    for (SensorEvent event : events.subList(events.size()-NUM_CONSECUTIVE_EVENTS, events.size())) {
-                        assertEquals(event.getSource(), entity);
-                        assertEquals(event.getSensor(), WebAppService.REQUESTS_PER_SECOND_IN_WINDOW);
-                        assertEquals(event.getValue(), 0.0d);
-                        if (eventTime > 0) assertTrue(event.getTimestamp()-eventTime < MAX_INTERVAL_BETWEEN_EVENTS,
-                            "events at "+eventTime+" and "+event.getTimestamp()+" exceeded maximum allowable interval "+MAX_INTERVAL_BETWEEN_EVENTS);
-                        eventTime = event.getTimestamp();
-                    }
-                }});
-        } finally {
-            if (subscriptionHandle != null) subContext.unsubscribe(subscriptionHandle);
-            entity.stop();
-        }
-    }
-
-    /**
-     * Twins the entities given by basicEntities() with links to WAR files
-     * they should be able to deploy.  Correct deployment can be checked by
-     * pinging the given URL.
-     *
-     * Everything can deploy hello world. Some subclasses deploy add'l apps.
-     * We're using the simplest hello-world (with no URL mapping) because JBoss 6 does not
-     * support URL mappings.
-     */
-    @DataProvider(name = "entitiesWithWarAndURL")
-    public Object[][] entitiesWithWar() {
-        TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), "/hello-world-no-mapping.war");
-        List<Object[]> result = Lists.newArrayList();
-        
-        for (Object[] entity : basicEntities()) {
-            result.add(new Object[] {
-                    entity[0],
-                    "hello-world-no-mapping.war",
-                    "hello-world-no-mapping/",
-                    "" // no sub-page path
-                    });
-        }
-        
-        return result.toArray(new Object[][] {});
-    }
-
-    /**
-     * Tests given entity can deploy the given war.  Checks given httpURL to confirm success.
-     */
-    @Test(groups = "Integration", dataProvider = "entitiesWithWarAndURL")
-    public void initialRootWarDeployments(final SoftwareProcess entity, final String war, 
-            final String urlSubPathToWebApp, final String urlSubPathToPageToQuery) {
-        this.entity = entity;
-        log.info("test=initialRootWarDeployments; entity="+entity+"; app="+entity.getApplication());
-        
-        URL resource = getClass().getClassLoader().getResource(war);
-        assertNotNull(resource);
-        
-        ((EntityLocal)entity).setConfig(JavaWebAppService.ROOT_WAR, resource.toString());
-        Entities.start(entity.getApplication(), ImmutableList.of(loc));
-        
-        //tomcat may need a while to unpack everything
-        Asserts.succeedsEventually(MutableMap.of("timeout", 60*1000), new Runnable() {
-            public void run() {
-                // TODO get this URL from a WAR file entity
-                HttpTestUtils.assertHttpStatusCodeEquals(Urls.mergePaths(entity.getAttribute(WebAppService.ROOT_URL), urlSubPathToPageToQuery), 200);
-                
-                assertEquals(entity.getAttribute(JavaWebAppSoftwareProcess.DEPLOYED_WARS), ImmutableSet.of("/"));
-            }});
-    }
-    
-    @Test(groups = "Integration", dataProvider = "entitiesWithWarAndURL")
-    public void initialNamedWarDeployments(final SoftwareProcess entity, final String war, 
-            final String urlSubPathToWebApp, final String urlSubPathToPageToQuery) {
-        this.entity = entity;
-        log.info("test=initialNamedWarDeployments; entity="+entity+"; app="+entity.getApplication());
-        
-        URL resource = getClass().getClassLoader().getResource(war);
-        assertNotNull(resource);
-        
-        ((EntityLocal)entity).setConfig(JavaWebAppService.NAMED_WARS, ImmutableList.of(resource.toString()));
-        Entities.start(entity.getApplication(), ImmutableList.of(loc));
-
-        Asserts.succeedsEventually(MutableMap.of("timeout", 60*1000), new Runnable() {
-            public void run() {
-                // TODO get this URL from a WAR file entity
-                HttpTestUtils.assertHttpStatusCodeEquals(Urls.mergePaths(entity.getAttribute(WebAppService.ROOT_URL), urlSubPathToWebApp, urlSubPathToPageToQuery), 200);
-            }});
-    }
-    
-    @Test(groups = "Integration", dataProvider = "entitiesWithWarAndURL")
-    public void testWarDeployAndUndeploy(final JavaWebAppSoftwareProcess entity, final String war, 
-            final String urlSubPathToWebApp, final String urlSubPathToPageToQuery) {
-        this.entity = entity;
-        log.info("test=testWarDeployAndUndeploy; entity="+entity+"; app="+entity.getApplication());
-        
-        URL resource = getClass().getClassLoader().getResource(war);;
-        assertNotNull(resource);
-        
-        Entities.start(entity.getApplication(), ImmutableList.of(loc));
-        
-        // Test deploying
-        entity.deploy(resource.toString(), "myartifactname.war");
-        Asserts.succeedsEventually(MutableMap.of("timeout", 60*1000), new Runnable() {
-            public void run() {
-                // TODO get this URL from a WAR file entity
-                HttpTestUtils.assertHttpStatusCodeEquals(Urls.mergePaths(entity.getAttribute(WebAppService.ROOT_URL), "myartifactname/", urlSubPathToPageToQuery), 200);
-                assertEquals(entity.getAttribute(JavaWebAppSoftwareProcess.DEPLOYED_WARS), ImmutableSet.of("/myartifactname"));
-            }});
-        
-        // And undeploying
-        entity.undeploy("/myartifactname");
-        Asserts.succeedsEventually(MutableMap.of("timeout", 60*1000), new Runnable() {
-            public void run() {
-                // TODO get this URL from a WAR file entity
-                HttpTestUtils.assertHttpStatusCodeEquals(Urls.mergePaths(entity.getAttribute(WebAppService.ROOT_URL), "myartifactname", urlSubPathToPageToQuery), 404);
-                assertEquals(entity.getAttribute(JavaWebAppSoftwareProcess.DEPLOYED_WARS), ImmutableSet.of());
-            }});
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/77dff880/software/webapp/src/test/java/brooklyn/entity/webapp/ControlledDynamicWebAppClusterIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/ControlledDynamicWebAppClusterIntegrationTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/ControlledDynamicWebAppClusterIntegrationTest.java
deleted file mode 100644
index 4d847fc..0000000
--- a/software/webapp/src/test/java/brooklyn/entity/webapp/ControlledDynamicWebAppClusterIntegrationTest.java
+++ /dev/null
@@ -1,182 +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.webapp;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
-
-import java.util.List;
-import java.util.concurrent.Callable;
-
-import org.apache.brooklyn.test.EntityTestUtils;
-import org.apache.brooklyn.test.HttpTestUtils;
-import org.apache.brooklyn.test.TestResourceUnavailableException;
-import org.apache.brooklyn.entity.basic.RecordingSensorEventListener;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import brooklyn.entity.BrooklynAppLiveTestSupport;
-import brooklyn.entity.Entity;
-import brooklyn.entity.basic.Attributes;
-import brooklyn.entity.basic.Lifecycle;
-import brooklyn.entity.proxy.AbstractController;
-import brooklyn.entity.proxy.LoadBalancer;
-import brooklyn.entity.proxy.nginx.NginxController;
-import brooklyn.entity.proxying.EntitySpec;
-import brooklyn.entity.webapp.tomcat.TomcatServer;
-import brooklyn.location.basic.LocalhostMachineProvisioningLocation;
-import brooklyn.test.Asserts;
-import brooklyn.test.entity.TestJavaWebAppEntity;
-import brooklyn.util.collections.CollectionFunctionals;
-import brooklyn.util.collections.MutableMap;
-
-import com.google.common.base.Suppliers;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
-
-public class ControlledDynamicWebAppClusterIntegrationTest extends BrooklynAppLiveTestSupport {
-    private static final Logger log = LoggerFactory.getLogger(ControlledDynamicWebAppClusterIntegrationTest.class);
-
-    private static final int TIMEOUT_MS = 10*1000;
-    
-    private LocalhostMachineProvisioningLocation loc;
-    private List<LocalhostMachineProvisioningLocation> locs;
-    
-    @BeforeMethod(alwaysRun=true)
-    public void setUp() throws Exception {
-        super.setUp();
-
-        loc = app.newLocalhostProvisioningLocation();
-        locs = ImmutableList.of(loc);
-    }
-
-    public String getTestWar() {
-        TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), "/hello-world.war");
-        return "classpath://hello-world.war";
-    }
-    
-    @Test(groups="Integration")
-    public void testPropogateHttpPorts() {
-        ControlledDynamicWebAppCluster cluster = app.createAndManageChild(EntitySpec.create(ControlledDynamicWebAppCluster.class)
-                .configure("initialSize", 1));
-        app.start(locs);
-
-        EntityTestUtils.assertAttributeEventuallyNonNull(cluster, LoadBalancer.PROXY_HTTP_PORT);
-        EntityTestUtils.assertAttributeEventuallyNonNull(cluster, LoadBalancer.PROXY_HTTPS_PORT);
-    }
-    
-    @Test(groups="Integration")
-    public void testConfiguresController() {
-        ControlledDynamicWebAppCluster cluster = app.createAndManageChild(EntitySpec.create(ControlledDynamicWebAppCluster.class)
-                .configure("initialSize", 1)
-                .configure("memberSpec", EntitySpec.create(TomcatServer.class).configure("war", getTestWar())));
-        app.start(locs);
-
-        String url = cluster.getController().getAttribute(NginxController.ROOT_URL);
-        HttpTestUtils.assertHttpStatusCodeEventuallyEquals(url, 200);
-        HttpTestUtils.assertContentEventuallyContainsText(url, "Hello");
-    }
-    
-    @Test(groups="Integration")
-    public void testSetsToplevelHostnameFromController() {
-        ControlledDynamicWebAppCluster cluster = app.createAndManageChild(EntitySpec.create(ControlledDynamicWebAppCluster.class)
-                .configure("initialSize", 1)
-                .configure("memberSpec", EntitySpec.create(TomcatServer.class).configure("war", getTestWar())));
-        app.start(locs);
-
-        String expectedHostname = cluster.getController().getAttribute(LoadBalancer.HOSTNAME);
-        String expectedRootUrl = cluster.getController().getAttribute(LoadBalancer.ROOT_URL);
-        boolean expectedServiceUp = true;
-        
-        assertNotNull(expectedHostname);
-        assertNotNull(expectedRootUrl);
-        
-        EntityTestUtils.assertAttributeEqualsEventually(MutableMap.of("timeout", TIMEOUT_MS), cluster, ControlledDynamicWebAppCluster.HOSTNAME, expectedHostname);
-        EntityTestUtils.assertAttributeEqualsEventually(MutableMap.of("timeout", TIMEOUT_MS), cluster, ControlledDynamicWebAppCluster.ROOT_URL, expectedRootUrl);
-        EntityTestUtils.assertAttributeEqualsEventually(MutableMap.of("timeout", TIMEOUT_MS), cluster, ControlledDynamicWebAppCluster.SERVICE_UP, expectedServiceUp);
-    }
-    
-    @Test(groups="Integration")
-    public void testCustomWebClusterSpecGetsMemberSpec() {
-        ControlledDynamicWebAppCluster cluster = app.createAndManageChild(EntitySpec.create(ControlledDynamicWebAppCluster.class)
-                .configure("initialSize", 1)
-                .configure(ControlledDynamicWebAppCluster.MEMBER_SPEC, EntitySpec.create(TomcatServer.class)
-                        .configure(TomcatServer.ROOT_WAR, getTestWar()))
-                .configure(ControlledDynamicWebAppCluster.WEB_CLUSTER_SPEC, EntitySpec.create(DynamicWebAppCluster.class)
-                        .displayName("mydisplayname")));
-        app.start(locs);
-
-        String url = cluster.getController().getAttribute(NginxController.ROOT_URL);
-        HttpTestUtils.assertContentEventuallyContainsText(url, "Hello");
-
-        // and make sure it really was using our custom spec
-        assertEquals(cluster.getCluster().getDisplayName(), "mydisplayname");
-    }
-    
-    // Needs to be integration test because still using nginx controller; could pass in mock controller
-    @Test(groups="Integration")
-    public void testSetsServiceLifecycle() {
-        ControlledDynamicWebAppCluster cluster = app.createAndManageChild( EntitySpec.create(ControlledDynamicWebAppCluster.class)
-                .configure("initialSize", 1)
-                .configure(ControlledDynamicWebAppCluster.MEMBER_SPEC, EntitySpec.create(TestJavaWebAppEntity.class)) );
-        
-        EntityTestUtils.assertAttributeEqualsEventually(cluster, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.STOPPED);
-        
-        RecordingSensorEventListener<Lifecycle> listener = new RecordingSensorEventListener<Lifecycle>(true);
-        app.subscribe(cluster, Attributes.SERVICE_STATE_ACTUAL, listener);
-        app.start(locs);
-        
-        Asserts.eventually(Suppliers.ofInstance(listener.getEventValues()), CollectionFunctionals.sizeEquals(2));
-        assertEquals(listener.getEventValues(), ImmutableList.of(Lifecycle.STARTING, Lifecycle.RUNNING), "vals="+listener.getEventValues());
-        listener.clearEvents();
-        
-        app.stop();
-        EntityTestUtils.assertAttributeEqualsEventually(cluster, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.STOPPED);
-        Asserts.eventually(Suppliers.ofInstance(listener), CollectionFunctionals.sizeEquals(2));
-        assertEquals(listener.getEventValues(), ImmutableList.of(Lifecycle.STOPPING, Lifecycle.STOPPED), "vals="+listener.getEventValues());
-    }
-    
-    @Test(groups="Integration")
-    public void testTomcatAbsoluteRedirect() {
-        final ControlledDynamicWebAppCluster cluster = app.createAndManageChild(EntitySpec.create(ControlledDynamicWebAppCluster.class)
-            .configure(ControlledDynamicWebAppCluster.MEMBER_SPEC, EntitySpec.create(TomcatServer.class)
-            .configure(TomcatServer.ROOT_WAR, getTestWar()))
-            .configure("initialSize", 1)
-            .configure(AbstractController.SERVICE_UP_URL_PATH, "hello/redirectAbsolute")
-        );
-        app.start(locs);
-
-        final NginxController nginxController = (NginxController) cluster.getController();
-        Asserts.succeedsEventually(new Callable<Boolean>() {
-            @Override
-            public Boolean call() throws Exception {
-                return nginxController.getServerPoolAddresses().size() == 1;
-            }
-        });
-        
-        Entity tomcatServer = Iterables.getOnlyElement(cluster.getCluster().getMembers());
-        EntityTestUtils.assertAttributeEqualsEventually(tomcatServer, Attributes.SERVICE_UP, true);
-        
-        EntityTestUtils.assertAttributeEqualsContinually(nginxController, Attributes.SERVICE_UP, true);
-        
-        app.stop();
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/77dff880/software/webapp/src/test/java/brooklyn/entity/webapp/ControlledDynamicWebAppClusterTest.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/ControlledDynamicWebAppClusterTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/ControlledDynamicWebAppClusterTest.java
deleted file mode 100644
index d841f1b..0000000
--- a/software/webapp/src/test/java/brooklyn/entity/webapp/ControlledDynamicWebAppClusterTest.java
+++ /dev/null
@@ -1,211 +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.webapp;
-
-import static org.testng.Assert.assertEquals;
-
-import java.util.List;
-
-import org.apache.brooklyn.test.EntityTestUtils;
-import org.apache.brooklyn.test.TestResourceUnavailableException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import brooklyn.entity.BrooklynAppUnitTestSupport;
-import brooklyn.entity.Group;
-import brooklyn.entity.basic.Attributes;
-import brooklyn.entity.basic.BasicGroup;
-import brooklyn.entity.basic.Entities;
-import brooklyn.entity.basic.Lifecycle;
-import brooklyn.entity.basic.SoftwareProcess;
-import brooklyn.entity.proxy.AbstractController;
-import brooklyn.entity.proxy.LoadBalancer;
-import brooklyn.entity.proxy.TrackingAbstractController;
-import brooklyn.entity.proxying.EntitySpec;
-import brooklyn.entity.webapp.jboss.JBoss7Server;
-import brooklyn.location.basic.LocalhostMachineProvisioningLocation;
-import brooklyn.test.Asserts;
-import brooklyn.test.entity.TestJavaWebAppEntity;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Iterables;
-
-public class ControlledDynamicWebAppClusterTest extends BrooklynAppUnitTestSupport {
-    private static final Logger log = LoggerFactory.getLogger(ControlledDynamicWebAppClusterTest.class);
-
-    private LocalhostMachineProvisioningLocation loc;
-    private List<LocalhostMachineProvisioningLocation> locs;
-    
-    @BeforeMethod(alwaysRun=true)
-    public void setUp() throws Exception {
-        super.setUp();
-
-        loc = app.newLocalhostProvisioningLocation();
-        locs = ImmutableList.of(loc);
-    }
-
-    public String getTestWar() {
-        TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), "/hello-world.war");
-        return "classpath://hello-world.war";
-    }
-
-    @Test
-    public void testUsesCustomController() {
-        AbstractController controller = app.createAndManageChild(EntitySpec.create(TrackingAbstractController.class).displayName("mycustom"));
-
-        ControlledDynamicWebAppCluster cluster = app.createAndManageChild(EntitySpec.create(ControlledDynamicWebAppCluster.class)
-                .configure("initialSize", 0)
-                .configure(ControlledDynamicWebAppCluster.CONTROLLER, controller)
-                .configure("memberSpec", EntitySpec.create(JBoss7Server.class).configure("war", getTestWar())));
-        app.start(locs);
-
-        EntityTestUtils.assertAttributeEqualsEventually(controller, AbstractController.SERVICE_UP, true);
-        assertEquals(cluster.getController(), controller);
-
-        // Stopping cluster should not stop controller (because it didn't create it)
-        cluster.stop();
-        EntityTestUtils.assertAttributeEquals(controller, AbstractController.SERVICE_UP, true);
-    }
-    
-    @Test
-    public void testUsesCustomControlledGroup() {
-        TestJavaWebAppEntity webServer = app.createAndManageChild(EntitySpec.create(TestJavaWebAppEntity.class));
-        webServer.setAttribute(Attributes.SUBNET_HOSTNAME, "myhostname");
-        webServer.setAttribute(Attributes.HTTP_PORT, 1234);
-        
-        TrackingAbstractController controller = app.createAndManageChild(EntitySpec.create(TrackingAbstractController.class));
-        Group controlledGroup = app.createAndManageChild(EntitySpec.create(BasicGroup.class));
-        controlledGroup.addMember(webServer);
-        
-        ControlledDynamicWebAppCluster cluster = app.createAndManageChild(EntitySpec.create(ControlledDynamicWebAppCluster.class)
-                .configure("initialSize", 0)
-                .configure(ControlledDynamicWebAppCluster.CONTROLLER, controller)
-                .configure(ControlledDynamicWebAppCluster.CONTROLLED_GROUP, controlledGroup)
-                .configure("memberSpec", EntitySpec.create(JBoss7Server.class).configure("war", getTestWar())));
-        app.start(locs);
-
-        assertEquals(controller.getUpdates(), ImmutableList.of(ImmutableSet.of("myhostname:1234")));
-    }
-    
-    @Test
-    public void testUsesCustomControllerSpec() {
-        EntitySpec<TrackingAbstractController> controllerSpec = EntitySpec.create(TrackingAbstractController.class).displayName("mycustom");
-        ControlledDynamicWebAppCluster cluster = app.createAndManageChild(EntitySpec.create(ControlledDynamicWebAppCluster.class)
-                .configure("initialSize", 0)
-                .configure(ControlledDynamicWebAppCluster.CONTROLLER_SPEC, controllerSpec)
-                .configure("memberSpec", EntitySpec.create(JBoss7Server.class).configure("war", getTestWar())));
-        app.start(locs);
-        LoadBalancer controller = cluster.getController();
-        
-        EntityTestUtils.assertAttributeEqualsEventually(controller, AbstractController.SERVICE_UP, true);
-        assertEquals(controller.getDisplayName(), "mycustom");
-
-        // Stopping cluster should stop the controller (because it created it)
-        cluster.stop();
-        EntityTestUtils.assertAttributeEquals(controller, AbstractController.SERVICE_UP, false);
-    }
-    
-    @Test
-    public void testTheTestJavaWebApp() {
-        SoftwareProcess n = app.createAndManageChild(EntitySpec.create(TestJavaWebAppEntity.class));
-        app.start(locs);
-
-        EntityTestUtils.assertAttributeEqualsEventually(n, AbstractController.SERVICE_UP, true);
-        
-        app.stop();
-        EntityTestUtils.assertAttributeEqualsEventually(n, AbstractController.SERVICE_UP, false);
-    }
-    
-    @Test
-    public void testSetsInitialSize() {
-        ControlledDynamicWebAppCluster cluster = app.createAndManageChild(EntitySpec.create(ControlledDynamicWebAppCluster.class)
-                .configure("initialSize", 2)
-                .configure(ControlledDynamicWebAppCluster.CONTROLLER_SPEC, EntitySpec.create(TrackingAbstractController.class))
-                .configure(ControlledDynamicWebAppCluster.MEMBER_SPEC, EntitySpec.create(TestJavaWebAppEntity.class)) );
-        app.start(locs);
-
-        Iterable<TestJavaWebAppEntity> webservers = Iterables.filter(cluster.getCluster().getMembers(), TestJavaWebAppEntity.class);
-        assertEquals(Iterables.size(webservers), 2, "webservers="+webservers);
-    }
-    
-    @Test
-    public void testUsesCustomWebClusterSpec() {
-        ControlledDynamicWebAppCluster cluster = app.createAndManageChild(EntitySpec.create(ControlledDynamicWebAppCluster.class)
-                .configure("initialSize", 0)
-                .configure(ControlledDynamicWebAppCluster.CONTROLLER_SPEC, EntitySpec.create(TrackingAbstractController.class))
-                .configure(ControlledDynamicWebAppCluster.WEB_CLUSTER_SPEC, EntitySpec.create(DynamicWebAppCluster.class)
-                        .displayName("mydisplayname")));
-        app.start(locs);
-
-        assertEquals(cluster.getCluster().getDisplayName(), "mydisplayname");
-    }
-
-    @Test
-    public void testMembersReflectChildClusterMembers() {
-        final ControlledDynamicWebAppCluster cluster = app.createAndManageChild(EntitySpec.create(ControlledDynamicWebAppCluster.class)
-                .configure("initialSize", 1)
-                .configure(ControlledDynamicWebAppCluster.CONTROLLER_SPEC, EntitySpec.create(TrackingAbstractController.class))
-                .configure(ControlledDynamicWebAppCluster.MEMBER_SPEC, EntitySpec.create(TestJavaWebAppEntity.class)) );
-        app.start(locs);
-        final DynamicWebAppCluster childCluster = cluster.getCluster();
-        
-        // Expect initial member(s) to be the same
-        assertEquals(childCluster.getMembers().size(), 1);
-        Asserts.succeedsEventually(new Runnable() {
-            @Override public void run() {
-                Asserts.assertEqualsIgnoringOrder(childCluster.getMembers(), cluster.getMembers());
-            }});
-        
-        // After resize up, same members
-        cluster.resize(2);
-        assertEquals(childCluster.getMembers().size(), 2);
-        Asserts.succeedsEventually(new Runnable() {
-            @Override public void run() {
-                Asserts.assertEqualsIgnoringOrder(childCluster.getMembers(), cluster.getMembers());
-            }});
-        
-        // After resize down, same members
-        cluster.resize(1);
-        assertEquals(childCluster.getMembers().size(), 1);
-        Asserts.succeedsEventually(new Runnable() {
-            @Override public void run() {
-                Asserts.assertEqualsIgnoringOrder(childCluster.getMembers(), cluster.getMembers());
-            }});
-    }
-    
-    @Test
-    public void testStopOnChildUnmanaged() {
-        final ControlledDynamicWebAppCluster cluster = app.createAndManageChild(EntitySpec.create(ControlledDynamicWebAppCluster.class)
-                .configure("initialSize", 1)
-                .configure(ControlledDynamicWebAppCluster.CONTROLLER_SPEC, EntitySpec.create(TrackingAbstractController.class))
-                .configure(ControlledDynamicWebAppCluster.MEMBER_SPEC, EntitySpec.create(TestJavaWebAppEntity.class)) );
-        app.start(locs);
-        final DynamicWebAppCluster childCluster = cluster.getCluster();
-        LoadBalancer controller = cluster.getController();
-        
-        Entities.unmanage(childCluster);
-        Entities.unmanage(controller);
-        
-        cluster.stop();
-        EntityTestUtils.assertAttributeEquals(cluster, ControlledDynamicWebAppCluster.SERVICE_STATE_ACTUAL, Lifecycle.STOPPED);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/77dff880/software/webapp/src/test/java/brooklyn/entity/webapp/DynamicWebAppClusterTest.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/DynamicWebAppClusterTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/DynamicWebAppClusterTest.java
deleted file mode 100644
index df5a582..0000000
--- a/software/webapp/src/test/java/brooklyn/entity/webapp/DynamicWebAppClusterTest.java
+++ /dev/null
@@ -1,131 +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.webapp;
-
-import static org.testng.Assert.assertEquals;
-
-import org.apache.brooklyn.test.EntityTestUtils;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import brooklyn.entity.Entity;
-import brooklyn.entity.basic.Attributes;
-import brooklyn.entity.basic.Entities;
-import brooklyn.entity.basic.EntityLocal;
-import brooklyn.entity.proxying.EntitySpec;
-import brooklyn.entity.trait.Startable;
-import brooklyn.location.basic.SimulatedLocation;
-import brooklyn.test.entity.TestApplication;
-import brooklyn.test.entity.TestJavaWebAppEntity;
-import brooklyn.util.collections.MutableMap;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Iterables;
-
-public class DynamicWebAppClusterTest {
-    
-    private static final int SHORT_WAIT_MS = 250;
-    
-    private TestApplication app;
-    private SimulatedLocation loc;
-    
-    @BeforeMethod(alwaysRun=true)
-    public void setUp() throws Exception {
-        app = TestApplication.Factory.newManagedInstanceForTests();
-        loc = app.newSimulatedLocation();
-    }
-    
-    @AfterMethod(alwaysRun=true)
-    public void tearDown() throws Exception {
-        if (app != null) Entities.destroyAll(app.getManagementContext());
-    }
-
-    @Test
-    public void testTestJavaWebAppEntityStarts() throws Exception {
-        Entity test = app.createAndManageChild(EntitySpec.create(TestJavaWebAppEntity.class));
-        test.invoke(Startable.START, ImmutableMap.of("locations", ImmutableList.of(loc))).get();
-        
-        EntityTestUtils.assertAttributeEqualsEventually(test, Attributes.SERVICE_UP, true);
-    }
-    
-    @Test
-    public void testRequestCountAggregation() throws Exception {
-        final DynamicWebAppCluster cluster = app.createAndManageChild(EntitySpec.create(DynamicWebAppCluster.class)
-                .configure("initialSize", 2)
-                .configure(ControlledDynamicWebAppCluster.MEMBER_SPEC, EntitySpec.create(TestJavaWebAppEntity.class)) );
-        
-        app.start(ImmutableList.of(loc));
-        
-        for (Entity member : cluster.getMembers()) {
-            ((TestJavaWebAppEntity)member).spoofRequest();
-        }
-        EntityTestUtils.assertAttributeEqualsEventually(cluster, DynamicWebAppCluster.REQUEST_COUNT, 2);
-        
-        for (Entity member : cluster.getMembers()) {
-            for (int i = 0; i < 2; i++) {
-                ((TestJavaWebAppEntity)member).spoofRequest();
-            }
-        }
-        EntityTestUtils.assertAttributeEqualsEventually(cluster, DynamicWebAppCluster.REQUEST_COUNT_PER_NODE, 3d);
-    }
-    
-    @Test
-    public void testSetsServiceUpIfMemberIsUp() throws Exception {
-        DynamicWebAppCluster cluster = app.createAndManageChild(EntitySpec.create(DynamicWebAppCluster.class)
-                .configure("initialSize", 1)
-                .configure(ControlledDynamicWebAppCluster.MEMBER_SPEC, EntitySpec.create(TestJavaWebAppEntity.class)) );
-    
-        app.start(ImmutableList.of(loc));
-        
-        // Should initially be true (now that TestJavaWebAppEntity sets true) 
-        EntityTestUtils.assertAttributeEqualsEventually(cluster, DynamicWebAppCluster.SERVICE_UP, true);
-        
-        // When child is !service_up, should report false
-        ((EntityLocal)Iterables.get(cluster.getMembers(), 0)).setAttribute(Startable.SERVICE_UP, false);
-        EntityTestUtils.assertAttributeEqualsEventually(cluster, DynamicWebAppCluster.SERVICE_UP, false);
-        EntityTestUtils.assertAttributeEqualsContinually(MutableMap.of("timeout", SHORT_WAIT_MS), cluster, DynamicWebAppCluster.SERVICE_UP, false);
-        
-        cluster.resize(2);
-        
-        // When one of the two children is service_up, should report true
-        EntityTestUtils.assertAttributeEqualsEventually(cluster, DynamicWebAppCluster.SERVICE_UP, true);
-
-        // And if that serviceUp child goes away, should again report false
-        Entities.unmanage(Iterables.get(cluster.getMembers(), 1));
-        ((EntityLocal)Iterables.get(cluster.getMembers(), 0)).setAttribute(Startable.SERVICE_UP, false);
-        
-        EntityTestUtils.assertAttributeEqualsEventually(cluster, DynamicWebAppCluster.SERVICE_UP, false);
-    }
-    
-    @Test
-    public void testPropertiesToChildren() throws Exception {
-        DynamicWebAppCluster cluster = app.createAndManageChild(EntitySpec.create(DynamicWebAppCluster.class)
-            .configure(ControlledDynamicWebAppCluster.MEMBER_SPEC, EntitySpec.create(TestJavaWebAppEntity.class)
-                .configure("a", 1))
-            .configure(DynamicWebAppCluster.CUSTOM_CHILD_FLAGS, ImmutableMap.of("b", 2)));
-
-        app.start(ImmutableList.of(loc));
-        
-        TestJavaWebAppEntity we = (TestJavaWebAppEntity) Iterables.getOnlyElement(cluster.getMembers());
-        assertEquals(we.getA(), 1);
-        assertEquals(we.getB(), 2);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/77dff880/software/webapp/src/test/java/brooklyn/entity/webapp/DynamicWebAppFabricTest.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/DynamicWebAppFabricTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/DynamicWebAppFabricTest.java
deleted file mode 100644
index b47bfdd..0000000
--- a/software/webapp/src/test/java/brooklyn/entity/webapp/DynamicWebAppFabricTest.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.webapp;
-
-import java.util.List;
-
-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 org.testng.annotations.Test;
-
-import brooklyn.entity.Entity;
-import brooklyn.entity.basic.DynamicGroup;
-import brooklyn.entity.basic.Entities;
-import brooklyn.entity.basic.EntityInternal;
-import brooklyn.entity.basic.EntityLocal;
-import brooklyn.entity.proxying.EntitySpec;
-import brooklyn.entity.trait.Changeable;
-import brooklyn.location.basic.SimulatedLocation;
-import brooklyn.test.entity.TestApplication;
-import brooklyn.test.entity.TestJavaWebAppEntity;
-import brooklyn.util.collections.MutableMap;
-
-import com.google.common.collect.ImmutableList;
-
-/**
- * TODO clarify test purpose
- */
-public class DynamicWebAppFabricTest {
-    private static final Logger log = LoggerFactory.getLogger(DynamicWebAppFabricTest.class);
-
-    private static final long TIMEOUT_MS = 10*1000;
-    
-    private TestApplication app;
-    private SimulatedLocation loc1;
-    private SimulatedLocation loc2;
-    private List<SimulatedLocation> locs;
-    
-    @BeforeMethod(alwaysRun=true)
-    public void setUp() throws Exception {
-        app = TestApplication.Factory.newManagedInstanceForTests();
-        loc1 = app.newSimulatedLocation();
-        loc2 = app.newSimulatedLocation();
-        locs = ImmutableList.of(loc1, loc2);
-    }
-    
-    @AfterMethod(alwaysRun=true)
-    public void tearDown() throws Exception {
-        if (app != null) Entities.destroyAll(app.getManagementContext());
-    }
-
-    @Test
-    public void testRequestCountAggregation() {
-        DynamicWebAppFabric fabric = app.createAndManageChild(EntitySpec.create(DynamicWebAppFabric.class)
-                .configure(DynamicWebAppFabric.MEMBER_SPEC, EntitySpec.create(TestJavaWebAppEntity.class)) );
-        
-        app.start(locs);
-        for (Entity member : fabric.getChildren()) {
-            ((EntityLocal)member).setAttribute(Changeable.GROUP_SIZE, 1);
-        }
-        
-        for (Entity member : fabric.getChildren()) {
-            ((EntityInternal)member).setAttribute(DynamicGroup.GROUP_SIZE, 1);
-            ((TestJavaWebAppEntity)member).spoofRequest();
-        }
-        EntityTestUtils.assertAttributeEqualsEventually(MutableMap.of("timeout", TIMEOUT_MS), fabric, DynamicWebAppFabric.REQUEST_COUNT, 2);
-        
-        // Note this is time-sensitive: need to do the next two sends before the previous one has dropped out
-        // of the time-window.
-        for (Entity member : fabric.getChildren()) {
-            for (int i = 0; i < 2; i++) {
-                ((TestJavaWebAppEntity)member).spoofRequest();
-            }
-        }
-        EntityTestUtils.assertAttributeEqualsEventually(MutableMap.of("timeout", TIMEOUT_MS), fabric, DynamicWebAppFabric.REQUEST_COUNT_PER_NODE, 3d);
-    }
-    
-    @Test
-    public void testRequestCountAggregationOverClusters() {
-        DynamicWebAppFabric fabric = app.createAndManageChild(EntitySpec.create(DynamicWebAppFabric.class)
-                .configure(DynamicWebAppFabric.MEMBER_SPEC, 
-                    EntitySpec.create(DynamicWebAppCluster.class)
-                        .configure("initialSize", 2)
-                        .configure(ControlledDynamicWebAppCluster.MEMBER_SPEC, EntitySpec.create(TestJavaWebAppEntity.class)) ));
-
-        app.start(locs);
-        
-        for (Entity cluster : fabric.getChildren()) {
-            for (Entity node : ((DynamicWebAppCluster)cluster).getMembers()) {
-                ((TestJavaWebAppEntity)node).spoofRequest();
-            }
-        }
-        EntityTestUtils.assertAttributeEqualsEventually(MutableMap.of("timeout", TIMEOUT_MS), fabric, DynamicWebAppFabric.REQUEST_COUNT, 4);
-        
-        // Note this is time-sensitive: need to do the next two sends before the previous one has dropped out
-        // of the time-window.
-        for (Entity cluster : fabric.getChildren()) {
-            for (Entity node : ((DynamicWebAppCluster)cluster).getMembers()) {
-                for (int i = 0; i < 2; i++) {
-                    ((TestJavaWebAppEntity)node).spoofRequest();
-                }
-            }
-        }
-        EntityTestUtils.assertAttributeEqualsEventually(MutableMap.of("timeout", TIMEOUT_MS), fabric, DynamicWebAppFabric.REQUEST_COUNT_PER_NODE, 3d);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/77dff880/software/webapp/src/test/java/brooklyn/entity/webapp/ElasticCustomLocationTest.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/ElasticCustomLocationTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/ElasticCustomLocationTest.java
deleted file mode 100644
index 5e24035..0000000
--- a/software/webapp/src/test/java/brooklyn/entity/webapp/ElasticCustomLocationTest.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.webapp;
-
-import java.util.Map;
-
-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.BasicConfigurableEntityFactory;
-import brooklyn.entity.basic.ConfigurableEntityFactory;
-import brooklyn.entity.basic.Entities;
-import brooklyn.entity.webapp.ElasticJavaWebAppService.ElasticJavaWebAppServiceAwareLocation;
-import brooklyn.location.basic.SimulatedLocation;
-import brooklyn.test.entity.TestApplication;
-import brooklyn.test.entity.TestEntityImpl;
-import brooklyn.util.collections.MutableMap;
-
-import com.google.common.collect.ImmutableList;
-
-public class ElasticCustomLocationTest {
-
-    public static class MockWebServiceLocation extends SimulatedLocation implements ElasticJavaWebAppServiceAwareLocation {
-        public MockWebServiceLocation() {
-        }
-        
-        @Override
-        public ConfigurableEntityFactory<ElasticJavaWebAppService> newWebClusterFactory() {
-            return new BasicConfigurableEntityFactory(MockWebService.class);
-        }
-    }
-    
-    public static class MockWebService extends TestEntityImpl implements ElasticJavaWebAppService {
-        public MockWebService() {
-        } 
-        // TODO Used by asicConfigurableEntityFactory.newEntity2, via MockWebServiceLocation.newWebClusterFactory
-        public MockWebService(Map flags, Entity parent) {
-            super(flags, parent);
-        } 
-    }
-
-    private TestApplication app;
-    
-    @BeforeMethod(alwaysRun=true)
-    public void setUp() throws Exception {
-        app = ApplicationBuilder.newManagedApp(TestApplication.class);
-    }
-
-    @AfterMethod(alwaysRun=true)
-    public void tearDown() throws Exception {
-        if (app != null) Entities.destroyAll(app.getManagementContext());
-    }
-
-    @Test
-    public void testElasticClusterCreatesTestEntity() {
-        MockWebServiceLocation l = new MockWebServiceLocation();
-        app.setConfig(MockWebService.ROOT_WAR, "WAR0");
-        app.setConfig(MockWebService.NAMED_WARS, ImmutableList.of("ignore://WARn"));
-        
-        ElasticJavaWebAppService svc = 
-            new ElasticJavaWebAppService.Factory().newFactoryForLocation(l).newEntity(MutableMap.of("war", "WAR1"), app);
-        Entities.manage(svc);
-        
-        Assert.assertTrue(svc instanceof MockWebService, "expected MockWebService, got "+svc);
-        //check config has been set correctly, where overridden, and where inherited
-        Assert.assertEquals(svc.getConfig(MockWebService.ROOT_WAR), "WAR1");
-        Assert.assertEquals(svc.getConfig(MockWebService.NAMED_WARS), ImmutableList.of("ignore://WARn"));
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/77dff880/software/webapp/src/test/java/brooklyn/entity/webapp/ElasticJavaWebAppServiceIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/ElasticJavaWebAppServiceIntegrationTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/ElasticJavaWebAppServiceIntegrationTest.java
deleted file mode 100644
index 69711c5..0000000
--- a/software/webapp/src/test/java/brooklyn/entity/webapp/ElasticJavaWebAppServiceIntegrationTest.java
+++ /dev/null
@@ -1,69 +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.webapp;
-
-import org.apache.brooklyn.test.HttpTestUtils;
-import org.apache.brooklyn.test.TestResourceUnavailableException;
-import org.testng.Assert;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import brooklyn.entity.basic.Entities;
-import brooklyn.location.basic.LocalhostMachineProvisioningLocation;
-import brooklyn.test.entity.TestApplication;
-import brooklyn.util.collections.MutableMap;
-
-import com.google.common.collect.ImmutableList;
-
-public class ElasticJavaWebAppServiceIntegrationTest {
-
-    private LocalhostMachineProvisioningLocation loc;
-    private TestApplication app;
-    
-    @BeforeMethod(alwaysRun=true)
-    public void setUp() throws Exception {
-        app = TestApplication.Factory.newManagedInstanceForTests();
-        loc = app.newLocalhostProvisioningLocation();
-    }
-
-    @AfterMethod(alwaysRun=true)
-    public void tearDown() throws Exception {
-        if (app != null) Entities.destroyAll(app.getManagementContext());
-    }
-
-    public String getTestWar() {
-        TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), "/hello-world.war");
-        return "classpath://hello-world.war";
-    }
-
-    @SuppressWarnings("deprecation")
-    @Test(groups = "Integration")
-    // TODO a new approach to what ElasticJavaWebAppService.Factory does, giving a different entity depending on location!
-    public void testLegacyFactory() {
-        ElasticJavaWebAppService svc =
-            new ElasticJavaWebAppService.Factory().newEntity(MutableMap.of("war", getTestWar()), app);
-        Entities.manage(svc);
-        app.start(ImmutableList.of(loc));
-        
-        String url = svc.getAttribute(ElasticJavaWebAppService.ROOT_URL);
-        Assert.assertNotNull(url);
-        HttpTestUtils.assertContentEventuallyContainsText(url, "Hello");
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/77dff880/software/webapp/src/test/java/brooklyn/entity/webapp/FilenameToWebContextMapperTest.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/FilenameToWebContextMapperTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/FilenameToWebContextMapperTest.java
deleted file mode 100644
index 421bca0..0000000
--- a/software/webapp/src/test/java/brooklyn/entity/webapp/FilenameToWebContextMapperTest.java
+++ /dev/null
@@ -1,85 +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.webapp;
-
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-@Test
-public class FilenameToWebContextMapperTest {
-
-//    *   either ROOT.WAR or /       denotes root context
-//    * <p>
-//    *   anything of form  FOO.?AR  (ending .?AR) is copied with that name (unless copying not necessary)
-//    *                              and is expected to be served from /FOO
-//    * <p>
-//    *   anything of form  /FOO     (with leading slash) is expected to be served from /FOO
-//    *                              (and is copied as FOO.WAR)
-//    * <p>
-//    *   anything of form  FOO      (without a dot) is expected to be served from /FOO
-//    *                              (and is copied as FOO.WAR)
-//    * <p>                            
-//    *   otherwise <i>please note</i> behaviour may vary on different appservers;
-//    *   e.g. FOO.FOO would probably be ignored on appservers which expect a file copied across (usually),
-//    *   but served as /FOO.FOO on systems that take a deployment context.
-
-    FilenameToWebContextMapper m = new FilenameToWebContextMapper();
-    
-    private void assertMapping(String input, String context, String filename) {
-        Assert.assertEquals(m.convertDeploymentTargetNameToContext(input), context);
-        Assert.assertEquals(m.convertDeploymentTargetNameToFilename(input), filename);
-    }
-    
-    public void testRootNames() {
-        assertMapping("/", "/", "ROOT.war");
-        assertMapping("ROOT.war", "/", "ROOT.war");
-        
-        //bad ones -- some of these aren't invertible
-        assertMapping("/ROOT.war", "/ROOT.war", "ROOT.war.war");
-        assertMapping("/ROOT", "/ROOT", "ROOT.war");
-        
-        //and leave empty string alone (will cause subsequent error)
-        assertMapping("", "", "");
-    }
-
-    public void testOtherNames() {
-        assertMapping("/foo", "/foo", "foo.war");
-        assertMapping("/foo.foo", "/foo.foo", "foo.foo.war");
-        assertMapping("foo.war", "/foo", "foo.war");
-        assertMapping("foo.Ear", "/foo", "foo.Ear");
-        assertMapping("foo", "/foo", "foo.war");
-        
-        //bad ones -- some of these aren't invertible
-        assertMapping("foo.foo", "/foo.foo", "foo.foo");
-    }
-    
-    public void testInferFromUrl() {
-        Assert.assertEquals(m.findArchiveNameFromUrl("http//localhost/simple.war", false), "simple.war");
-        Assert.assertEquals(m.findArchiveNameFromUrl("http//localhost/simple.Ear?type=raw", false), "simple.Ear");
-        Assert.assertEquals(m.findArchiveNameFromUrl("http//localhost/simple.war?type=raw*other=sample.war", false), "simple.war");
-        Assert.assertEquals(m.findArchiveNameFromUrl("http//localhost/get?file=simple.war", false), "simple.war");
-        Assert.assertEquals(m.findArchiveNameFromUrl("http//localhost/get?file=simple.war&other=ignore", false), "simple.war");
-        //takes the first (but logs warning in verbose mode)
-        Assert.assertEquals(m.findArchiveNameFromUrl("http//localhost/get?file=simple.war&other=sample.war", false), "simple.war");
-        //allows hyphen
-        Assert.assertEquals(m.findArchiveNameFromUrl("http//localhost/get?file=simple-simon.war&other=sample", false), "simple-simon.war");
-        Assert.assertEquals(m.findArchiveNameFromUrl("http//localhost/get?file=simple\\simon.war&other=sample", false), "simon.war");
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/77dff880/software/webapp/src/test/java/brooklyn/entity/webapp/HttpsSslConfigTest.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/HttpsSslConfigTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/HttpsSslConfigTest.java
deleted file mode 100644
index da4b0ce..0000000
--- a/software/webapp/src/test/java/brooklyn/entity/webapp/HttpsSslConfigTest.java
+++ /dev/null
@@ -1,38 +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.webapp;
-
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-import brooklyn.util.collections.MutableMap;
-import brooklyn.util.flags.TypeCoercions;
-
-public class HttpsSslConfigTest {
-
-    @Test
-    public void testCoerce() {
-        HttpsSslConfig config = TypeCoercions.coerce(MutableMap.of("keystoreUrl", "http://foo", "keystorePassword", "b4r", "keyAlias", "baz"), 
-            HttpsSslConfig.class);
-        Assert.assertEquals(config.getKeystoreUrl(), "http://foo");
-        Assert.assertEquals(config.getKeystorePassword(), "b4r");
-        Assert.assertEquals(config.getKeyAlias(), "baz");
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/77dff880/software/webapp/src/test/java/brooklyn/entity/webapp/TomcatAutoScalerPolicyTest.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/TomcatAutoScalerPolicyTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/TomcatAutoScalerPolicyTest.java
deleted file mode 100644
index cd38dfe..0000000
--- a/software/webapp/src/test/java/brooklyn/entity/webapp/TomcatAutoScalerPolicyTest.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.webapp;
-
-import static org.apache.brooklyn.test.HttpTestUtils.connectToUrl;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
-
-import org.apache.brooklyn.management.ManagementContext;
-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.Entities;
-import brooklyn.entity.proxying.EntitySpec;
-import brooklyn.entity.webapp.tomcat.TomcatServer;
-import brooklyn.entity.webapp.tomcat.TomcatServerImpl;
-import brooklyn.location.LocationSpec;
-import brooklyn.location.basic.LocalhostMachineProvisioningLocation;
-import brooklyn.policy.autoscaling.AutoScalerPolicy;
-import brooklyn.test.Asserts;
-import brooklyn.test.entity.TestApplication;
-import brooklyn.util.collections.MutableMap;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
-
-public class TomcatAutoScalerPolicyTest {
-
-    @SuppressWarnings("unused")
-    private static final Logger LOG = LoggerFactory.getLogger(TomcatAutoScalerPolicyTest.class);
-
-    // TODO Test is time-sensitive: we send two web-requests in rapid succession, and expect the average workrate to
-    // be 2 msgs/sec; we then expect resizing to kick-in.
-    // P speculate that... if for some reason things are running slow (e.g. GC during that one second), then brooklyn 
-    // may not report the 2 msgs/sec.
-
-    private LocalhostMachineProvisioningLocation loc;
-    private TestApplication app;
-    private ManagementContext managementContext;
-    
-    @BeforeMethod(alwaysRun=true)
-    public void setUp() throws Exception {
-        app = TestApplication.Factory.newManagedInstanceForTests();
-        managementContext = app.getManagementContext();
-        loc = managementContext.getLocationManager().createLocation(LocationSpec.create(LocalhostMachineProvisioningLocation.class)
-                .configure("name", "london"));
-    }
-    
-    @AfterMethod(alwaysRun=true)
-    public void tearDown() throws Exception {
-        if (app != null) Entities.destroyAll(app.getManagementContext());
-    }
-    
-    @Test(groups="Integration")
-    public void testWithTomcatServers() throws Exception {
-        /*
-         * One DynamicWebAppClster with auto-scaler policy
-         * AutoScaler listening to DynamicWebAppCluster.TOTAL_REQS
-         * AutoScaler minSize 1
-         * AutoScaler upper metric 1
-         * AutoScaler lower metric 0
-         * .. send one request
-         * wait til auto-scaling complete
-         * assert cluster size 2
-         */
-
-        final DynamicWebAppCluster cluster = app.createAndManageChild(EntitySpec.create(DynamicWebAppCluster.class)
-                .configure(DynamicWebAppCluster.INITIAL_SIZE, 1)
-                .configure(DynamicWebAppCluster.MEMBER_SPEC, EntitySpec.create(TomcatServer.class)));
-
-        final AutoScalerPolicy policy = AutoScalerPolicy.builder()
-                .metric(DynamicWebAppCluster.REQUEST_COUNT_PER_NODE)
-                .metricRange(0, 1)
-                .minPoolSize(1)
-                .build();
-        cluster.addPolicy(policy);
-        
-        app.start(ImmutableList.of(loc));
-        
-        assertEquals(cluster.getCurrentSize(), (Integer)1);
-        
-        // Scaling based on *total requests* processed, rather than the requests per second.
-        // So just hit it with 2 requests.
-        // Alternatively could hit each tomcat server's URL twice per second; but that's less deterministic.
-        TomcatServer tc = (TomcatServer) Iterables.getOnlyElement(cluster.getMembers());
-        for (int i = 0; i < 2; i++) {
-            connectToUrl(tc.getAttribute(TomcatServerImpl.ROOT_URL));
-        }
-        
-        // We'll scale to two members as soon as the policy detects it.
-        // But the second member won't count in the requests-per-node until it has started up.
-        // Expect to see (if we polled at convenient times):
-        //  - zero requests per node (because haven't yet retrieved over JMX the metric)
-        //  - two requests per node, with one member
-        //  - two requests per node, with two members (one of whom is still starting up, so doesn't count)
-        //  - one request per node (i.e. two divided across the two active members)
-        Asserts.succeedsEventually(MutableMap.of("timeout", 5*60*1000), new Runnable() {
-            @Override public void run() {
-                String err = "policy="+policy.isRunning()+"; size="+cluster.getCurrentSize()+"; reqCountPerNode="+cluster.getAttribute(DynamicWebAppCluster.REQUEST_COUNT_PER_NODE);
-                assertTrue(policy.isRunning(), "err="+err);
-                assertEquals(cluster.getCurrentSize(), (Integer)2, "err="+err);
-                assertEquals(cluster.getAttribute(DynamicWebAppCluster.REQUEST_COUNT_PER_NODE), 1.0d, "err="+err);
-            }});
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/77dff880/software/webapp/src/test/java/brooklyn/entity/webapp/WebAppConcurrentDeployTest.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/WebAppConcurrentDeployTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/WebAppConcurrentDeployTest.java
deleted file mode 100644
index 328971c..0000000
--- a/software/webapp/src/test/java/brooklyn/entity/webapp/WebAppConcurrentDeployTest.java
+++ /dev/null
@@ -1,105 +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.webapp;
-
-import static org.testng.Assert.assertEquals;
-
-import java.net.URI;
-import java.util.Collection;
-
-import org.apache.http.client.HttpClient;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
-
-import brooklyn.entity.BrooklynAppUnitTestSupport;
-import brooklyn.entity.basic.Attributes;
-import brooklyn.entity.basic.BrooklynConfigKeys;
-import brooklyn.entity.proxying.EntitySpec;
-import brooklyn.entity.webapp.jboss.JBoss7Server;
-import brooklyn.entity.webapp.tomcat.TomcatServer;
-import brooklyn.location.Location;
-import brooklyn.location.LocationSpec;
-import brooklyn.location.basic.LocalhostMachineProvisioningLocation;
-import brooklyn.test.Asserts;
-
-import org.apache.brooklyn.management.Task;
-import org.apache.brooklyn.test.EntityTestUtils;
-import org.apache.brooklyn.test.TestResourceUnavailableException;
-
-import brooklyn.util.collections.MutableList;
-import brooklyn.util.collections.MutableMap;
-import brooklyn.util.http.HttpTool;
-import brooklyn.util.http.HttpToolResponse;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-
-public class WebAppConcurrentDeployTest extends BrooklynAppUnitTestSupport {
-    private Location loc;
-    
-    @Override
-    @BeforeMethod(alwaysRun=true)
-    public void setUp() throws Exception {
-        super.setUp();
-        app.config().set(BrooklynConfigKeys.SKIP_ON_BOX_BASE_DIR_RESOLUTION, false);
-//      tested on  loc = mgmt.getLocationRegistry().resolve("byon:(hosts=\"hostname\")");
-        loc = mgmt.getLocationManager().createLocation(LocationSpec.create(LocalhostMachineProvisioningLocation.class));
-    }
-    
-    @DataProvider(name = "basicEntities")
-    public Object[][] basicEntities() {
-        return new Object[][]{
-            {EntitySpec.create(TomcatServer.class)},
-            // Hot Deploy not enabled?
-            // {EntitySpec.create(JBoss6Server.class)},
-            {EntitySpec.create(JBoss7Server.class)},
-        };
-    }
-
-    @Test(groups = "Live", dataProvider="basicEntities")
-    public void testConcurrentDeploys(EntitySpec<? extends JavaWebAppSoftwareProcess> webServerSpec) throws Exception {
-        JavaWebAppSoftwareProcess server = app.createAndManageChild(webServerSpec);
-        app.start(ImmutableList.of(loc));
-        EntityTestUtils.assertAttributeEqualsEventually(server, Attributes.SERVICE_UP, Boolean.TRUE);
-        Collection<Task<Void>> deploys = MutableList.of();
-        for (int i = 0; i < 5; i++) {
-            deploys.add(server.invoke(TomcatServer.DEPLOY, MutableMap.of("url", getTestWar(), "targetName", "/")));
-        }
-        for(Task<Void> t : deploys) {
-            t.getUnchecked();
-        }
-
-        final HttpClient client = HttpTool.httpClientBuilder().build();
-        final URI warUrl = URI.create(server.getAttribute(JavaWebAppSoftwareProcess.ROOT_URL));
-        Asserts.succeedsEventually(new Runnable() {
-            @Override
-            public void run() {
-                HttpToolResponse resp = HttpTool.httpGet(client, warUrl, ImmutableMap.<String,String>of());
-                assertEquals(resp.getResponseCode(), 200);
-            }
-        });
-    }
-    
-    public String getTestWar() {
-        TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), "/hello-world.war");
-        return "classpath://hello-world.war";
-    }
-
-}









Mime
View raw message