Return-Path: X-Original-To: apmail-brooklyn-commits-archive@minotaur.apache.org Delivered-To: apmail-brooklyn-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 93EDE17E0F for ; Tue, 14 Oct 2014 10:05:21 +0000 (UTC) Received: (qmail 51007 invoked by uid 500); 14 Oct 2014 10:05:21 -0000 Delivered-To: apmail-brooklyn-commits-archive@brooklyn.apache.org Received: (qmail 50984 invoked by uid 500); 14 Oct 2014 10:05:21 -0000 Mailing-List: contact commits-help@brooklyn.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@brooklyn.incubator.apache.org Delivered-To: mailing list commits@brooklyn.incubator.apache.org Received: (qmail 50975 invoked by uid 99); 14 Oct 2014 10:05:21 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 14 Oct 2014 10:05:21 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO mail.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with SMTP; Tue, 14 Oct 2014 10:04:57 +0000 Received: (qmail 49275 invoked by uid 99); 14 Oct 2014 10:04:52 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 14 Oct 2014 10:04:52 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 2CCE7915FBC; Tue, 14 Oct 2014 10:04:52 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: richard@apache.org To: commits@brooklyn.incubator.apache.org Date: Tue, 14 Oct 2014 10:05:03 -0000 Message-Id: In-Reply-To: <639b39df2d094d2597b0301448995719@git.apache.org> References: <639b39df2d094d2597b0301448995719@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [13/16] git commit: Elastic search test tidy: extend BrooklynAppLiveTestSupport X-Virus-Checked: Checked by ClamAV on apache.org Elastic search test tidy: extend BrooklynAppLiveTestSupport - for ElasticSearchClusterIntegrationTest - for Jboss6ServerIntegrationTest - Split ControlledDynamicWebAppClusterTest to separate the integration tests, and have that extend BrooklynAppLiveTestSupport (because I need my local scriptHeader to get the right Java version). Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/8d7685d8 Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/8d7685d8 Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/8d7685d8 Branch: refs/heads/master Commit: 8d7685d8b0e0f66ce91366e6bde9f6c73bdeb19f Parents: a78edf2 Author: Aled Sage Authored: Mon Oct 13 21:34:41 2014 +0100 Committer: Aled Sage Committed: Mon Oct 13 21:34:41 2014 +0100 ---------------------------------------------------------------------- .../ElasticSearchClusterIntegrationTest.java | 19 +- ...lledDynamicWebAppClusterIntegrationTest.java | 172 +++++++++++++++++++ .../ControlledDynamicWebAppClusterTest.java | 126 +------------- .../jboss/Jboss6ServerIntegrationTest.java | 17 +- 4 files changed, 185 insertions(+), 149 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/8d7685d8/software/nosql/src/test/java/brooklyn/entity/nosql/elasticsearch/ElasticSearchClusterIntegrationTest.java ---------------------------------------------------------------------- diff --git a/software/nosql/src/test/java/brooklyn/entity/nosql/elasticsearch/ElasticSearchClusterIntegrationTest.java b/software/nosql/src/test/java/brooklyn/entity/nosql/elasticsearch/ElasticSearchClusterIntegrationTest.java index 62d490c..efb17d6 100644 --- a/software/nosql/src/test/java/brooklyn/entity/nosql/elasticsearch/ElasticSearchClusterIntegrationTest.java +++ b/software/nosql/src/test/java/brooklyn/entity/nosql/elasticsearch/ElasticSearchClusterIntegrationTest.java @@ -25,45 +25,36 @@ import java.net.URISyntaxException; import org.apache.http.client.methods.HttpGet; import org.bouncycastle.util.Strings; -import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; +import brooklyn.entity.BrooklynAppLiveTestSupport; import brooklyn.entity.Entity; -import brooklyn.entity.basic.ApplicationBuilder; import brooklyn.entity.basic.Attributes; -import brooklyn.entity.basic.Entities; import brooklyn.entity.group.DynamicCluster; import brooklyn.entity.proxying.EntitySpec; import brooklyn.entity.trait.Startable; import brooklyn.event.feed.http.HttpValueFunctions; import brooklyn.location.Location; -import brooklyn.location.basic.LocalhostMachineProvisioningLocation; import brooklyn.test.EntityTestUtils; -import brooklyn.test.entity.TestApplication; import brooklyn.util.http.HttpTool; import brooklyn.util.http.HttpToolResponse; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; -public class ElasticSearchClusterIntegrationTest { +public class ElasticSearchClusterIntegrationTest extends BrooklynAppLiveTestSupport { + + // FIXME Exception in thread "main" java.lang.UnsupportedClassVersionError: org/elasticsearch/bootstrap/Elasticsearch : Unsupported major.minor version 51.0 - protected TestApplication app; protected Location testLocation; protected ElasticSearchCluster elasticSearchCluster; @BeforeMethod(alwaysRun = true) public void setup() throws Exception { - app = ApplicationBuilder.newManagedApp(TestApplication.class); - testLocation = new LocalhostMachineProvisioningLocation(); + testLocation = app.newLocalhostProvisioningLocation(); } - @AfterMethod(alwaysRun = true) - public void shutdown() { - Entities.destroyAll(app.getManagementContext()); - } - @Test(groups = {"Integration"}) public void testStartupAndShutdown() { elasticSearchCluster = app.createAndManageChild(EntitySpec.create(ElasticSearchCluster.class) http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/8d7685d8/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 new file mode 100644 index 0000000..46a097a --- /dev/null +++ b/software/webapp/src/test/java/brooklyn/entity/webapp/ControlledDynamicWebAppClusterIntegrationTest.java @@ -0,0 +1,172 @@ +/* + * 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.net.URL; +import java.util.List; +import java.util.concurrent.Callable; + +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.BasicConfigurableEntityFactory; +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.ControlledDynamicWebAppClusterTest.RecordingSensorEventListener; +import brooklyn.entity.webapp.jboss.JBoss7Server; +import brooklyn.entity.webapp.tomcat.TomcatServer; +import brooklyn.location.basic.LocalhostMachineProvisioningLocation; +import brooklyn.test.Asserts; +import brooklyn.test.EntityTestUtils; +import brooklyn.test.HttpTestUtils; +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 URL warUrl; + private LocalhostMachineProvisioningLocation loc; + private List locs; + + @BeforeMethod(alwaysRun=true) + public void setUp() throws Exception { + super.setUp(); + String warPath = "hello-world.war"; + warUrl = getClass().getClassLoader().getResource(warPath); + + loc = app.newLocalhostProvisioningLocation(); + locs = ImmutableList.of(loc); + } + + @Test(groups="Integration") + public void testConfiguresController() { + ControlledDynamicWebAppCluster cluster = app.createAndManageChild(EntitySpec.create(ControlledDynamicWebAppCluster.class) + .configure("initialSize", 1) + .configure("memberSpec", EntitySpec.create(JBoss7Server.class).configure("war", warUrl.toString()))); + 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(JBoss7Server.class).configure("war", warUrl.toString()))); + 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(JBoss7Server.class) + .configure(JBoss7Server.ROOT_WAR, warUrl.toString())) + .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("factory", new BasicConfigurableEntityFactory(TestJavaWebAppEntity.class))); + + EntityTestUtils.assertAttributeEqualsEventually(cluster, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.STOPPED); + + RecordingSensorEventListener listener = new RecordingSensorEventListener(true); + app.subscribe(cluster, Attributes.SERVICE_STATE_ACTUAL, listener); + app.start(locs); + + Asserts.eventually(Suppliers.ofInstance(listener.getValues()), CollectionFunctionals.sizeEquals(2)); + assertEquals(listener.getValues(), ImmutableList.of(Lifecycle.STARTING, Lifecycle.RUNNING), "vals="+listener.getValues()); + listener.getValues().clear(); + + app.stop(); + EntityTestUtils.assertAttributeEqualsEventually(cluster, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.STOPPED); + Asserts.eventually(Suppliers.ofInstance(listener.getValues()), CollectionFunctionals.sizeEquals(2)); + assertEquals(listener.getValues(), ImmutableList.of(Lifecycle.STOPPING, Lifecycle.STOPPED), "vals="+listener.getValues()); + } + + @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, "classpath://hello-world.war")) + .configure("initialSize", 1) + .configure(AbstractController.SERVICE_UP_URL_PATH, "hello/redirectAbsolute") + ); + app.start(locs); + + final NginxController nginxController = (NginxController) cluster.getController(); + Asserts.succeedsEventually(new Callable() { + @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/8d7685d8/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 index f80d10c..041616f 100644 --- a/software/webapp/src/test/java/brooklyn/entity/webapp/ControlledDynamicWebAppClusterTest.java +++ b/software/webapp/src/test/java/brooklyn/entity/webapp/ControlledDynamicWebAppClusterTest.java @@ -19,73 +19,52 @@ package brooklyn.entity.webapp; import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; import java.net.URL; import java.util.List; -import java.util.concurrent.Callable; 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.Attributes; +import brooklyn.entity.BrooklynAppUnitTestSupport; import brooklyn.entity.basic.BasicConfigurableEntityFactory; import brooklyn.entity.basic.Entities; import brooklyn.entity.basic.Lifecycle; import brooklyn.entity.proxy.AbstractController; import brooklyn.entity.proxy.LoadBalancer; import brooklyn.entity.proxy.TrackingAbstractController; -import brooklyn.entity.proxy.nginx.NginxController; import brooklyn.entity.proxying.EntitySpec; import brooklyn.entity.webapp.jboss.JBoss7Server; -import brooklyn.entity.webapp.tomcat.TomcatServer; import brooklyn.event.SensorEvent; import brooklyn.event.SensorEventListener; import brooklyn.location.basic.LocalhostMachineProvisioningLocation; import brooklyn.test.Asserts; import brooklyn.test.EntityTestUtils; -import brooklyn.test.HttpTestUtils; -import brooklyn.test.entity.TestApplication; import brooklyn.test.entity.TestJavaWebAppEntity; -import brooklyn.util.collections.CollectionFunctionals; -import brooklyn.util.collections.MutableMap; -import brooklyn.util.guava.Functionals; -import com.google.common.base.Suppliers; import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; -public class ControlledDynamicWebAppClusterTest { +public class ControlledDynamicWebAppClusterTest extends BrooklynAppUnitTestSupport { private static final Logger log = LoggerFactory.getLogger(ControlledDynamicWebAppClusterTest.class); - private static final int TIMEOUT_MS = 10*1000; - private URL warUrl; - private TestApplication app; private LocalhostMachineProvisioningLocation loc; private List locs; @BeforeMethod(alwaysRun=true) public void setUp() throws Exception { + super.setUp(); String warPath = "hello-world.war"; warUrl = getClass().getClassLoader().getResource(warPath); - app = TestApplication.Factory.newManagedInstanceForTests(); - loc = new LocalhostMachineProvisioningLocation(); + loc = app.newLocalhostProvisioningLocation(); locs = ImmutableList.of(loc); } - @AfterMethod(alwaysRun=true) - public void tearDown() throws Exception { - if (app != null) Entities.destroyAll(app.getManagementContext()); - } - @Test public void testUsesCustomController() { AbstractController controller = app.createAndManageChild(EntitySpec.create(TrackingAbstractController.class).displayName("mycustom")); @@ -122,18 +101,6 @@ public class ControlledDynamicWebAppClusterTest { EntityTestUtils.assertAttributeEquals(controller, AbstractController.SERVICE_UP, false); } - @Test(groups="Integration") - public void testConfiguresController() { - ControlledDynamicWebAppCluster cluster = app.createAndManageChild(EntitySpec.create(ControlledDynamicWebAppCluster.class) - .configure("initialSize", 1) - .configure("memberSpec", EntitySpec.create(JBoss7Server.class).configure("war", warUrl.toString()))); - app.start(locs); - - String url = cluster.getController().getAttribute(NginxController.ROOT_URL); - HttpTestUtils.assertHttpStatusCodeEventuallyEquals(url, 200); - HttpTestUtils.assertContentEventuallyContainsText(url, "Hello"); - } - @Test public void testSetsInitialSize() { ControlledDynamicWebAppCluster cluster = app.createAndManageChild(EntitySpec.create(ControlledDynamicWebAppCluster.class) @@ -146,25 +113,6 @@ public class ControlledDynamicWebAppClusterTest { assertEquals(Iterables.size(webservers), 2, "webservers="+webservers); } - @Test(groups="Integration") - public void testSetsToplevelHostnameFromController() { - ControlledDynamicWebAppCluster cluster = app.createAndManageChild(EntitySpec.create(ControlledDynamicWebAppCluster.class) - .configure("initialSize", 1) - .configure("memberSpec", EntitySpec.create(JBoss7Server.class).configure("war", warUrl.toString()))); - 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 public void testUsesCustomWebClusterSpec() { ControlledDynamicWebAppCluster cluster = app.createAndManageChild(EntitySpec.create(ControlledDynamicWebAppCluster.class) @@ -177,72 +125,6 @@ public class ControlledDynamicWebAppClusterTest { assertEquals(cluster.getCluster().getDisplayName(), "mydisplayname"); } - @Test(groups="Integration") - public void testCustomWebClusterSpecGetsMemberSpec() { - ControlledDynamicWebAppCluster cluster = app.createAndManageChild(EntitySpec.create(ControlledDynamicWebAppCluster.class) - .configure("initialSize", 1) - .configure(ControlledDynamicWebAppCluster.MEMBER_SPEC, EntitySpec.create(JBoss7Server.class) - .configure(JBoss7Server.ROOT_WAR, warUrl.toString())) - .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("factory", new BasicConfigurableEntityFactory(TestJavaWebAppEntity.class))); - - EntityTestUtils.assertAttributeEqualsEventually(cluster, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.STOPPED); - - RecordingSensorEventListener listener = new RecordingSensorEventListener(true); - app.subscribe(cluster, Attributes.SERVICE_STATE_ACTUAL, listener); - app.start(locs); - - Asserts.eventually(Suppliers.ofInstance(listener.getValues()), CollectionFunctionals.sizeEquals(2)); - assertEquals(listener.getValues(), ImmutableList.of(Lifecycle.STARTING, Lifecycle.RUNNING), "vals="+listener.getValues()); - listener.getValues().clear(); - - app.stop(); - EntityTestUtils.assertAttributeEqualsEventually(cluster, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.STOPPED); - Asserts.eventually(Suppliers.ofInstance(listener.getValues()), CollectionFunctionals.sizeEquals(2)); - assertEquals(listener.getValues(), ImmutableList.of(Lifecycle.STOPPING, Lifecycle.STOPPED), "vals="+listener.getValues()); - } - - @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, "classpath://hello-world.war")) - .configure("initialSize", 1) - .configure(AbstractController.SERVICE_UP_URL_PATH, "hello/redirectAbsolute") - ); - app.start(locs); - - final NginxController nginxController = (NginxController) cluster.getController(); - Asserts.succeedsEventually(new Callable() { - @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(); - } - public static class RecordingSensorEventListener implements SensorEventListener { private final List> events = Lists.newCopyOnWriteArrayList(); private final List values = Lists.newCopyOnWriteArrayList(); http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/8d7685d8/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/Jboss6ServerIntegrationTest.java ---------------------------------------------------------------------- diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/Jboss6ServerIntegrationTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/Jboss6ServerIntegrationTest.java index 2fd2a7a..b2056dd 100644 --- a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/Jboss6ServerIntegrationTest.java +++ b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/Jboss6ServerIntegrationTest.java @@ -23,45 +23,36 @@ import static org.testng.Assert.assertNotNull; import java.net.URL; -import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import brooklyn.entity.basic.ApplicationBuilder; -import brooklyn.entity.basic.Entities; +import brooklyn.entity.BrooklynAppLiveTestSupport; import brooklyn.entity.java.UsesJmx; import brooklyn.entity.proxying.EntitySpec; import brooklyn.location.basic.LocalhostMachineProvisioningLocation; import brooklyn.test.Asserts; import brooklyn.test.HttpTestUtils; -import brooklyn.test.entity.TestApplication; import com.google.common.collect.ImmutableList; /** * TODO re-write this like WebAppIntegrationTest, rather than being jboss6 specific. */ -public class Jboss6ServerIntegrationTest { +public class Jboss6ServerIntegrationTest extends BrooklynAppLiveTestSupport { // Port increment for JBoss 6. public static final int PORT_INCREMENT = 400; private URL warUrl; private LocalhostMachineProvisioningLocation localhostProvisioningLocation; - private TestApplication app; @BeforeMethod(alwaysRun=true) public void setUp() throws Exception { + super.setUp(); String warPath = "hello-world.war"; warUrl = getClass().getClassLoader().getResource(warPath); - localhostProvisioningLocation = new LocalhostMachineProvisioningLocation(); - app = ApplicationBuilder.newManagedApp(TestApplication.class); - } - - @AfterMethod(alwaysRun=true) - public void tearDown() throws Exception { - if (app != null) Entities.destroyAll(app.getManagementContext()); + localhostProvisioningLocation = app.newLocalhostProvisioningLocation(); } @Test(groups = "Integration")