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 40A1A18924 for ; Thu, 13 Aug 2015 13:54:56 +0000 (UTC) Received: (qmail 62931 invoked by uid 500); 13 Aug 2015 13:54:43 -0000 Delivered-To: apmail-brooklyn-commits-archive@brooklyn.apache.org Received: (qmail 62908 invoked by uid 500); 13 Aug 2015 13:54:43 -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 62899 invoked by uid 99); 13 Aug 2015 13:54:43 -0000 Received: from Unknown (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 13 Aug 2015 13:54:43 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id C4A8ADD5E8 for ; Thu, 13 Aug 2015 13:54:42 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 4.301 X-Spam-Level: **** X-Spam-Status: No, score=4.301 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RDNS_NONE=2.5, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-us-east.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id 3M45QDFF2WcM for ; Thu, 13 Aug 2015 13:54:09 +0000 (UTC) Received: from spamd4-us-west.apache.org (unknown [209.188.14.142]) by mx1-us-east.apache.org (ASF Mail Server at mx1-us-east.apache.org) with ESMTP id 586AC44062 for ; Wed, 12 Aug 2015 16:58:36 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id EF29EC1320 for ; Wed, 12 Aug 2015 16:58:35 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org Received: from mx1-us-east.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id uiVyw1xX4LPB for ; Wed, 12 Aug 2015 16:56:26 +0000 (UTC) Received: from spamd1-us-west.apache.org (unknown [209.188.14.142]) by mx1-us-east.apache.org (ASF Mail Server at mx1-us-east.apache.org) with ESMTP id E5D9642D0B for ; Wed, 12 Aug 2015 16:49:14 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 9C52DDCA58 for ; Wed, 12 Aug 2015 16:49:14 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org Received: from mx1-eu-west.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id 6n8rx1J2Dmp7 for ; Wed, 12 Aug 2015 16:48:47 +0000 (UTC) Received: from spamd1-us-west.apache.org (unknown [209.188.14.142]) by mx1-eu-west.apache.org (ASF Mail Server at mx1-eu-west.apache.org) with ESMTP id 6191534BEC for ; Wed, 12 Aug 2015 16:43:22 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id B6B65DCA5F for ; Wed, 12 Aug 2015 16:43:21 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org Received: from mx1-us-west.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id 193Caow4uztq for ; Wed, 12 Aug 2015 16:42:33 +0000 (UTC) Received: from spamd4-us-west.apache.org (unknown [209.188.14.142]) by mx1-us-west.apache.org (ASF Mail Server at mx1-us-west.apache.org) with ESMTP id 69ECA26777 for ; Wed, 12 Aug 2015 16:13:30 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 29DDEC12DC for ; Wed, 12 Aug 2015 16:13:30 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org Received: from mx1-us-east.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id pKBDCgNU36iP for ; Wed, 12 Aug 2015 16:11:25 +0000 (UTC) Received: from spamd1-us-west.apache.org (unknown [209.188.14.142]) by mx1-us-east.apache.org (ASF Mail Server at mx1-us-east.apache.org) with ESMTP id EEFA242BF5 for ; Wed, 12 Aug 2015 16:01:49 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id A50EADC9FA for ; Wed, 12 Aug 2015 16:01:49 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org Received: from mx1-us-east.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id YYnAuZ7xSFGx for ; Wed, 12 Aug 2015 16:01:33 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-us-east.apache.org (ASF Mail Server at mx1-us-east.apache.org) with SMTP id 2B78342BF5 for ; Wed, 12 Aug 2015 15:55:21 +0000 (UTC) Received: (qmail 66339 invoked by uid 99); 12 Aug 2015 15:55:20 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 12 Aug 2015 15:55:20 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id CC943E05D6; Wed, 12 Aug 2015 15:55:20 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: aledsage@apache.org To: commits@brooklyn.incubator.apache.org Date: Wed, 12 Aug 2015 15:55:49 -0000 Message-Id: <4a450fda025c47409c149f5e34b64e25@git.apache.org> In-Reply-To: <86a4cb0cc0ac4b3c8aa5cd4b2a09ae2e@git.apache.org> References: <86a4cb0cc0ac4b3c8aa5cd4b2a09ae2e@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [31/35] incubator-brooklyn git commit: Renaming brooklyn.test.entity.* http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0d702c5b/core/src/test/java/brooklyn/management/entitlement/AcmeEntitlementManagerTestFixture.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/brooklyn/management/entitlement/AcmeEntitlementManagerTestFixture.java b/core/src/test/java/brooklyn/management/entitlement/AcmeEntitlementManagerTestFixture.java index 1e64590..8d2fa39 100644 --- a/core/src/test/java/brooklyn/management/entitlement/AcmeEntitlementManagerTestFixture.java +++ b/core/src/test/java/brooklyn/management/entitlement/AcmeEntitlementManagerTestFixture.java @@ -22,6 +22,7 @@ import java.io.IOException; import java.net.URI; import org.apache.brooklyn.management.ManagementContext; +import org.apache.brooklyn.test.entity.LocalManagementContextForTests; import org.testng.Assert; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; @@ -41,7 +42,6 @@ import brooklyn.management.entitlement.NotEntitledException; import brooklyn.management.entitlement.WebEntitlementContext; import brooklyn.management.entitlement.Entitlements.EntityAndItem; import brooklyn.management.entitlement.Entitlements.StringAndArgument; -import brooklyn.test.entity.LocalManagementContextForTests; import brooklyn.util.config.ConfigBag; import brooklyn.util.exceptions.Exceptions; http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0d702c5b/core/src/test/java/brooklyn/management/entitlement/EntitlementsTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/brooklyn/management/entitlement/EntitlementsTest.java b/core/src/test/java/brooklyn/management/entitlement/EntitlementsTest.java index 174e150..95e7c6c 100644 --- a/core/src/test/java/brooklyn/management/entitlement/EntitlementsTest.java +++ b/core/src/test/java/brooklyn/management/entitlement/EntitlementsTest.java @@ -23,6 +23,7 @@ import static org.testng.Assert.assertTrue; import org.apache.brooklyn.management.ManagementContext; import org.apache.brooklyn.management.entitlement.EntitlementManager; +import org.apache.brooklyn.test.entity.LocalManagementContextForTests; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @@ -35,7 +36,6 @@ import brooklyn.entity.basic.Entities; import brooklyn.entity.proxying.EntitySpec; import brooklyn.management.entitlement.Entitlements.EntityAndItem; import brooklyn.management.entitlement.Entitlements.StringAndArgument; -import brooklyn.test.entity.LocalManagementContextForTests; @Test public class EntitlementsTest { http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0d702c5b/core/src/test/java/brooklyn/management/entitlement/EntityEntitlementTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/brooklyn/management/entitlement/EntityEntitlementTest.java b/core/src/test/java/brooklyn/management/entitlement/EntityEntitlementTest.java index 1f253e6..2a7d41f 100644 --- a/core/src/test/java/brooklyn/management/entitlement/EntityEntitlementTest.java +++ b/core/src/test/java/brooklyn/management/entitlement/EntityEntitlementTest.java @@ -19,6 +19,7 @@ package brooklyn.management.entitlement; import org.apache.brooklyn.management.ManagementContext; +import org.apache.brooklyn.test.entity.LocalManagementContextForTests; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.testng.Assert; @@ -37,7 +38,6 @@ import brooklyn.location.Location; import brooklyn.management.entitlement.Entitlements.EntityAndItem; import brooklyn.management.entitlement.Entitlements.StringAndArgument; import brooklyn.management.internal.LocalManagementContext; -import brooklyn.test.entity.LocalManagementContextForTests; import brooklyn.util.config.ConfigBag; import brooklyn.util.exceptions.Exceptions; http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0d702c5b/core/src/test/java/brooklyn/management/ha/HighAvailabilityManagerInMemoryTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/brooklyn/management/ha/HighAvailabilityManagerInMemoryTest.java b/core/src/test/java/brooklyn/management/ha/HighAvailabilityManagerInMemoryTest.java index 1a0cf4b..5018e7d 100644 --- a/core/src/test/java/brooklyn/management/ha/HighAvailabilityManagerInMemoryTest.java +++ b/core/src/test/java/brooklyn/management/ha/HighAvailabilityManagerInMemoryTest.java @@ -22,6 +22,8 @@ import java.util.Collection; import java.util.List; import org.apache.brooklyn.management.ha.HighAvailabilityMode; +import org.apache.brooklyn.test.entity.TestApplication; +import org.apache.brooklyn.test.entity.TestEntity; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.testng.Assert; @@ -37,8 +39,6 @@ import brooklyn.location.NoMachinesAvailableException; import brooklyn.location.basic.LocalhostMachineProvisioningLocation; import brooklyn.location.basic.SshMachineLocation; import brooklyn.management.internal.LocalManagementContext; -import brooklyn.test.entity.TestApplication; -import brooklyn.test.entity.TestEntity; import brooklyn.util.collections.MutableList; import com.google.common.collect.Iterables; http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0d702c5b/core/src/test/java/brooklyn/management/ha/HighAvailabilityManagerSplitBrainTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/brooklyn/management/ha/HighAvailabilityManagerSplitBrainTest.java b/core/src/test/java/brooklyn/management/ha/HighAvailabilityManagerSplitBrainTest.java index a6275cc..1d33672 100644 --- a/core/src/test/java/brooklyn/management/ha/HighAvailabilityManagerSplitBrainTest.java +++ b/core/src/test/java/brooklyn/management/ha/HighAvailabilityManagerSplitBrainTest.java @@ -32,6 +32,8 @@ import org.apache.brooklyn.management.ha.ManagementNodeState; import org.apache.brooklyn.management.ha.ManagementNodeSyncRecord; import org.apache.brooklyn.management.ha.ManagementPlaneSyncRecord; import org.apache.brooklyn.management.ha.ManagementPlaneSyncRecordPersister; +import org.apache.brooklyn.test.entity.LocalManagementContextForTests; +import org.apache.brooklyn.test.entity.TestApplication; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.testng.annotations.AfterMethod; @@ -52,8 +54,6 @@ import brooklyn.location.Location; import brooklyn.management.ha.TestEntityFailingRebind.RebindException; import brooklyn.management.internal.ManagementContextInternal; import brooklyn.test.Asserts; -import brooklyn.test.entity.LocalManagementContextForTests; -import brooklyn.test.entity.TestApplication; import brooklyn.util.collections.MutableList; import brooklyn.util.collections.MutableMap; import brooklyn.util.exceptions.Exceptions; http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0d702c5b/core/src/test/java/brooklyn/management/ha/HighAvailabilityManagerTestFixture.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/brooklyn/management/ha/HighAvailabilityManagerTestFixture.java b/core/src/test/java/brooklyn/management/ha/HighAvailabilityManagerTestFixture.java index 69f5b09..7f35f16 100644 --- a/core/src/test/java/brooklyn/management/ha/HighAvailabilityManagerTestFixture.java +++ b/core/src/test/java/brooklyn/management/ha/HighAvailabilityManagerTestFixture.java @@ -32,6 +32,7 @@ import org.apache.brooklyn.management.ha.ManagementNodeState; import org.apache.brooklyn.management.ha.ManagementNodeSyncRecord; import org.apache.brooklyn.management.ha.ManagementPlaneSyncRecord; import org.apache.brooklyn.management.ha.ManagementPlaneSyncRecordPersister; +import org.apache.brooklyn.test.entity.LocalManagementContextForTests; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.testng.annotations.AfterMethod; @@ -49,7 +50,6 @@ import brooklyn.entity.rebind.plane.dto.BasicManagementNodeSyncRecord.Builder; import brooklyn.management.ha.HighAvailabilityManagerImpl.PromotionListener; import brooklyn.management.internal.ManagementContextInternal; import brooklyn.test.Asserts; -import brooklyn.test.entity.LocalManagementContextForTests; import brooklyn.util.time.Duration; import com.google.common.base.Ticker; http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0d702c5b/core/src/test/java/brooklyn/management/ha/HotStandbyTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/brooklyn/management/ha/HotStandbyTest.java b/core/src/test/java/brooklyn/management/ha/HotStandbyTest.java index 096fcf7..02949c9 100644 --- a/core/src/test/java/brooklyn/management/ha/HotStandbyTest.java +++ b/core/src/test/java/brooklyn/management/ha/HotStandbyTest.java @@ -33,6 +33,9 @@ import org.apache.brooklyn.management.ha.HighAvailabilityMode; import org.apache.brooklyn.management.ha.ManagementNodeState; import org.apache.brooklyn.management.ha.ManagementPlaneSyncRecordPersister; import org.apache.brooklyn.test.EntityTestUtils; +import org.apache.brooklyn.test.entity.LocalManagementContextForTests; +import org.apache.brooklyn.test.entity.TestApplication; +import org.apache.brooklyn.test.entity.TestEntity; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.testng.Assert; @@ -60,9 +63,6 @@ import brooklyn.location.LocationSpec; import brooklyn.location.basic.LocalhostMachineProvisioningLocation.LocalhostMachine; import brooklyn.management.internal.AbstractManagementContext; import brooklyn.management.internal.ManagementContextInternal; -import brooklyn.test.entity.LocalManagementContextForTests; -import brooklyn.test.entity.TestApplication; -import brooklyn.test.entity.TestEntity; import brooklyn.util.collections.MutableList; import brooklyn.util.collections.MutableMap; import brooklyn.util.javalang.JavaClassNames; http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0d702c5b/core/src/test/java/brooklyn/management/ha/TestEntityFailingRebind.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/brooklyn/management/ha/TestEntityFailingRebind.java b/core/src/test/java/brooklyn/management/ha/TestEntityFailingRebind.java index a077b0d..a8cfced 100644 --- a/core/src/test/java/brooklyn/management/ha/TestEntityFailingRebind.java +++ b/core/src/test/java/brooklyn/management/ha/TestEntityFailingRebind.java @@ -18,11 +18,10 @@ */ package brooklyn.management.ha; +import org.apache.brooklyn.test.entity.TestApplicationImpl; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import brooklyn.test.entity.TestApplicationImpl; - public class TestEntityFailingRebind extends TestApplicationImpl { private static final Logger LOG = LoggerFactory.getLogger(TestEntityFailingRebind.class); http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0d702c5b/core/src/test/java/brooklyn/management/ha/WarmStandbyTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/brooklyn/management/ha/WarmStandbyTest.java b/core/src/test/java/brooklyn/management/ha/WarmStandbyTest.java index ad59a4b..428047d 100644 --- a/core/src/test/java/brooklyn/management/ha/WarmStandbyTest.java +++ b/core/src/test/java/brooklyn/management/ha/WarmStandbyTest.java @@ -27,6 +27,8 @@ import java.util.Map; import org.apache.brooklyn.management.ha.HighAvailabilityMode; import org.apache.brooklyn.management.ha.ManagementNodeState; import org.apache.brooklyn.management.ha.ManagementPlaneSyncRecordPersister; +import org.apache.brooklyn.test.entity.LocalManagementContextForTests; +import org.apache.brooklyn.test.entity.TestApplication; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.testng.annotations.AfterMethod; @@ -42,8 +44,6 @@ import brooklyn.entity.rebind.persister.PersistMode; import brooklyn.entity.rebind.persister.PersistenceObjectStore; import brooklyn.location.Location; import brooklyn.management.internal.ManagementContextInternal; -import brooklyn.test.entity.LocalManagementContextForTests; -import brooklyn.test.entity.TestApplication; import brooklyn.util.collections.MutableList; import brooklyn.util.collections.MutableMap; import brooklyn.util.time.Duration; http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0d702c5b/core/src/test/java/brooklyn/management/internal/AccessManagerTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/brooklyn/management/internal/AccessManagerTest.java b/core/src/test/java/brooklyn/management/internal/AccessManagerTest.java index e67400c..7eec459 100644 --- a/core/src/test/java/brooklyn/management/internal/AccessManagerTest.java +++ b/core/src/test/java/brooklyn/management/internal/AccessManagerTest.java @@ -23,6 +23,9 @@ import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertTrue; import static org.testng.Assert.fail; +import org.apache.brooklyn.test.entity.LocalManagementContextForTests; +import org.apache.brooklyn.test.entity.TestApplication; +import org.apache.brooklyn.test.entity.TestEntity; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @@ -33,9 +36,6 @@ import brooklyn.entity.proxying.EntitySpec; import brooklyn.location.Location; import brooklyn.location.LocationSpec; import brooklyn.location.basic.SimulatedLocation; -import brooklyn.test.entity.LocalManagementContextForTests; -import brooklyn.test.entity.TestApplication; -import brooklyn.test.entity.TestEntity; import brooklyn.util.exceptions.Exceptions; import com.google.common.collect.ImmutableSet; http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0d702c5b/core/src/test/java/brooklyn/management/internal/EntityExecutionManagerTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/brooklyn/management/internal/EntityExecutionManagerTest.java b/core/src/test/java/brooklyn/management/internal/EntityExecutionManagerTest.java index 28d5779..581ae84 100644 --- a/core/src/test/java/brooklyn/management/internal/EntityExecutionManagerTest.java +++ b/core/src/test/java/brooklyn/management/internal/EntityExecutionManagerTest.java @@ -32,6 +32,9 @@ import java.util.concurrent.Semaphore; import org.apache.brooklyn.management.ExecutionManager; import org.apache.brooklyn.management.Task; +import org.apache.brooklyn.test.entity.LocalManagementContextForTests; +import org.apache.brooklyn.test.entity.TestApplication; +import org.apache.brooklyn.test.entity.TestEntity; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.testng.Assert; @@ -49,9 +52,6 @@ import brooklyn.entity.basic.EntityInternal; import brooklyn.entity.proxying.EntitySpec; import brooklyn.event.basic.BasicAttributeSensor; import brooklyn.test.Asserts; -import brooklyn.test.entity.LocalManagementContextForTests; -import brooklyn.test.entity.TestApplication; -import brooklyn.test.entity.TestEntity; import brooklyn.util.collections.MutableMap; import brooklyn.util.javalang.JavaClassNames; import brooklyn.util.repeat.Repeater; http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0d702c5b/core/src/test/java/brooklyn/management/internal/LocalManagementContextTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/brooklyn/management/internal/LocalManagementContextTest.java b/core/src/test/java/brooklyn/management/internal/LocalManagementContextTest.java index eacf666..c19355a 100644 --- a/core/src/test/java/brooklyn/management/internal/LocalManagementContextTest.java +++ b/core/src/test/java/brooklyn/management/internal/LocalManagementContextTest.java @@ -26,6 +26,7 @@ import java.io.IOException; import java.util.concurrent.atomic.AtomicInteger; import org.apache.brooklyn.management.ManagementContext.PropertiesReloadListener; +import org.apache.brooklyn.test.entity.LocalManagementContextForTests; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @@ -33,7 +34,6 @@ import org.testng.annotations.Test; import brooklyn.config.BrooklynProperties; import brooklyn.config.BrooklynProperties.Factory.Builder; import brooklyn.location.Location; -import brooklyn.test.entity.LocalManagementContextForTests; import brooklyn.util.os.Os; import com.google.common.base.Charsets; http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0d702c5b/core/src/test/java/brooklyn/management/internal/LocalSubscriptionManagerTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/brooklyn/management/internal/LocalSubscriptionManagerTest.java b/core/src/test/java/brooklyn/management/internal/LocalSubscriptionManagerTest.java index a03838d..841ba73 100644 --- a/core/src/test/java/brooklyn/management/internal/LocalSubscriptionManagerTest.java +++ b/core/src/test/java/brooklyn/management/internal/LocalSubscriptionManagerTest.java @@ -29,6 +29,7 @@ import java.util.concurrent.atomic.AtomicReference; import org.apache.brooklyn.management.SubscriptionHandle; import org.apache.brooklyn.management.SubscriptionManager; +import org.apache.brooklyn.test.entity.TestEntity; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @@ -39,7 +40,6 @@ import brooklyn.entity.basic.Entities; import brooklyn.entity.proxying.EntitySpec; import brooklyn.event.SensorEvent; import brooklyn.event.SensorEventListener; -import brooklyn.test.entity.TestEntity; /** * testing the {@link SubscriptionManager} and associated classes. http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0d702c5b/core/src/test/java/brooklyn/management/osgi/OsgiPathTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/brooklyn/management/osgi/OsgiPathTest.java b/core/src/test/java/brooklyn/management/osgi/OsgiPathTest.java index f4ac674..829b281 100644 --- a/core/src/test/java/brooklyn/management/osgi/OsgiPathTest.java +++ b/core/src/test/java/brooklyn/management/osgi/OsgiPathTest.java @@ -21,6 +21,7 @@ package brooklyn.management.osgi; import java.io.File; import java.io.IOException; +import org.apache.brooklyn.test.entity.LocalManagementContextForTests; import org.osgi.framework.BundleException; import org.testng.Assert; import org.testng.annotations.AfterMethod; @@ -31,7 +32,6 @@ import brooklyn.config.BrooklynServerConfig; import brooklyn.config.BrooklynServerPaths; import brooklyn.entity.basic.Entities; import brooklyn.management.internal.LocalManagementContext; -import brooklyn.test.entity.LocalManagementContextForTests; import brooklyn.util.os.Os; import brooklyn.util.text.Identifiers; http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0d702c5b/core/src/test/java/brooklyn/management/osgi/OsgiVersionMoreEntityTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/brooklyn/management/osgi/OsgiVersionMoreEntityTest.java b/core/src/test/java/brooklyn/management/osgi/OsgiVersionMoreEntityTest.java index 02327c7..da7dd08 100644 --- a/core/src/test/java/brooklyn/management/osgi/OsgiVersionMoreEntityTest.java +++ b/core/src/test/java/brooklyn/management/osgi/OsgiVersionMoreEntityTest.java @@ -54,9 +54,9 @@ import org.apache.brooklyn.management.ManagementContext; import org.apache.brooklyn.management.classloading.BrooklynClassLoadingContext; import org.apache.brooklyn.policy.PolicySpec; import org.apache.brooklyn.test.TestResourceUnavailableException; +import org.apache.brooklyn.test.entity.LocalManagementContextForTests; +import org.apache.brooklyn.test.entity.TestApplication; -import brooklyn.test.entity.LocalManagementContextForTests; -import brooklyn.test.entity.TestApplication; import brooklyn.util.guava.Maybe; import brooklyn.util.os.Os; import brooklyn.util.osgi.Osgis; http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0d702c5b/core/src/test/java/brooklyn/policy/basic/PolicyConfigTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/brooklyn/policy/basic/PolicyConfigTest.java b/core/src/test/java/brooklyn/policy/basic/PolicyConfigTest.java index c601e09..b68781d 100644 --- a/core/src/test/java/brooklyn/policy/basic/PolicyConfigTest.java +++ b/core/src/test/java/brooklyn/policy/basic/PolicyConfigTest.java @@ -25,13 +25,13 @@ import static org.testng.Assert.fail; import java.util.concurrent.Callable; import java.util.concurrent.CountDownLatch; +import org.apache.brooklyn.test.entity.TestEntity; import org.testng.annotations.Test; import brooklyn.entity.BrooklynAppUnitTestSupport; import brooklyn.event.basic.BasicConfigKey; import brooklyn.event.basic.DependentConfiguration; import brooklyn.policy.basic.BasicPolicyTest.MyPolicy; -import brooklyn.test.entity.TestEntity; import brooklyn.util.collections.MutableMap; import brooklyn.util.exceptions.Exceptions; http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0d702c5b/core/src/test/java/brooklyn/policy/basic/PolicySubscriptionTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/brooklyn/policy/basic/PolicySubscriptionTest.java b/core/src/test/java/brooklyn/policy/basic/PolicySubscriptionTest.java index 6952396..9bee29d 100644 --- a/core/src/test/java/brooklyn/policy/basic/PolicySubscriptionTest.java +++ b/core/src/test/java/brooklyn/policy/basic/PolicySubscriptionTest.java @@ -27,12 +27,12 @@ import brooklyn.entity.BrooklynAppUnitTestSupport; import org.apache.brooklyn.entity.basic.RecordingSensorEventListener; import org.apache.brooklyn.management.SubscriptionHandle; +import org.apache.brooklyn.test.entity.TestEntity; import brooklyn.entity.proxying.EntitySpec; import brooklyn.event.basic.BasicSensorEvent; import brooklyn.location.basic.SimulatedLocation; import brooklyn.test.Asserts; -import brooklyn.test.entity.TestEntity; import com.google.common.collect.ImmutableList; http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0d702c5b/core/src/test/java/brooklyn/qa/longevity/EntityCleanupLongevityTestFixture.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/brooklyn/qa/longevity/EntityCleanupLongevityTestFixture.java b/core/src/test/java/brooklyn/qa/longevity/EntityCleanupLongevityTestFixture.java index cdc7b7c..8247a84 100644 --- a/core/src/test/java/brooklyn/qa/longevity/EntityCleanupLongevityTestFixture.java +++ b/core/src/test/java/brooklyn/qa/longevity/EntityCleanupLongevityTestFixture.java @@ -22,6 +22,9 @@ import java.util.Set; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.TimeUnit; +import org.apache.brooklyn.test.entity.LocalManagementContextForTests; +import org.apache.brooklyn.test.entity.TestApplication; +import org.apache.brooklyn.test.entity.TestEntity; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.testng.Assert; @@ -41,9 +44,6 @@ import brooklyn.location.basic.SimulatedLocation; import brooklyn.management.internal.AbstractManagementContext; import brooklyn.management.internal.LocalManagementContext; import brooklyn.management.internal.ManagementContextInternal; -import brooklyn.test.entity.LocalManagementContextForTests; -import brooklyn.test.entity.TestApplication; -import brooklyn.test.entity.TestEntity; import brooklyn.util.task.BasicExecutionManager; import brooklyn.util.task.TaskScheduler; import brooklyn.util.text.Strings; http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0d702c5b/core/src/test/java/brooklyn/qa/performance/AbstractPerformanceTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/brooklyn/qa/performance/AbstractPerformanceTest.java b/core/src/test/java/brooklyn/qa/performance/AbstractPerformanceTest.java index f3595e5..bd4ceee 100644 --- a/core/src/test/java/brooklyn/qa/performance/AbstractPerformanceTest.java +++ b/core/src/test/java/brooklyn/qa/performance/AbstractPerformanceTest.java @@ -23,6 +23,7 @@ import static org.testng.Assert.assertTrue; import java.util.concurrent.TimeUnit; import org.apache.brooklyn.management.ManagementContext; +import org.apache.brooklyn.test.entity.TestApplication; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.testng.annotations.AfterMethod; @@ -31,7 +32,6 @@ import org.testng.annotations.BeforeMethod; import brooklyn.entity.basic.ApplicationBuilder; import brooklyn.entity.basic.Entities; import brooklyn.location.basic.SimulatedLocation; -import brooklyn.test.entity.TestApplication; import brooklyn.util.internal.DoubleSystemProperty; import com.google.common.base.Stopwatch; http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0d702c5b/core/src/test/java/brooklyn/qa/performance/EntityPerformanceTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/brooklyn/qa/performance/EntityPerformanceTest.java b/core/src/test/java/brooklyn/qa/performance/EntityPerformanceTest.java index dab9afd..33eb1b7 100644 --- a/core/src/test/java/brooklyn/qa/performance/EntityPerformanceTest.java +++ b/core/src/test/java/brooklyn/qa/performance/EntityPerformanceTest.java @@ -24,6 +24,7 @@ import java.util.List; import java.util.concurrent.atomic.AtomicInteger; import org.apache.brooklyn.management.Task; +import org.apache.brooklyn.test.entity.TestEntity; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @@ -32,7 +33,6 @@ import brooklyn.entity.proxying.EntitySpec; import brooklyn.event.SensorEvent; import brooklyn.event.SensorEventListener; import brooklyn.test.Asserts; -import brooklyn.test.entity.TestEntity; import brooklyn.util.collections.MutableMap; import brooklyn.util.exceptions.Exceptions; http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0d702c5b/core/src/test/java/brooklyn/qa/performance/EntityPersistencePerformanceTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/brooklyn/qa/performance/EntityPersistencePerformanceTest.java b/core/src/test/java/brooklyn/qa/performance/EntityPersistencePerformanceTest.java index ffccb3a..09a574c 100644 --- a/core/src/test/java/brooklyn/qa/performance/EntityPersistencePerformanceTest.java +++ b/core/src/test/java/brooklyn/qa/performance/EntityPersistencePerformanceTest.java @@ -25,13 +25,13 @@ import java.util.concurrent.TimeUnit; import org.apache.brooklyn.policy.Policy; import org.apache.brooklyn.policy.PolicySpec; import org.apache.brooklyn.test.PerformanceTestUtils; +import org.apache.brooklyn.test.entity.TestEntity; import org.testng.annotations.Test; import brooklyn.entity.proxying.EntitySpec; import brooklyn.entity.rebind.RebindTestFixtureWithApp; import brooklyn.location.LocationSpec; import brooklyn.location.basic.SimulatedLocation; -import brooklyn.test.entity.TestEntity; import brooklyn.test.policy.TestPolicy; import brooklyn.util.repeat.Repeater; import brooklyn.util.time.Duration; http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0d702c5b/core/src/test/java/brooklyn/qa/performance/SubscriptionPerformanceTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/brooklyn/qa/performance/SubscriptionPerformanceTest.java b/core/src/test/java/brooklyn/qa/performance/SubscriptionPerformanceTest.java index 57f3361..b805987 100644 --- a/core/src/test/java/brooklyn/qa/performance/SubscriptionPerformanceTest.java +++ b/core/src/test/java/brooklyn/qa/performance/SubscriptionPerformanceTest.java @@ -27,13 +27,13 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; import org.apache.brooklyn.management.SubscriptionManager; +import org.apache.brooklyn.test.entity.TestEntity; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import brooklyn.entity.proxying.EntitySpec; import brooklyn.event.SensorEvent; import brooklyn.event.SensorEventListener; -import brooklyn.test.entity.TestEntity; import brooklyn.util.collections.MutableMap; import brooklyn.util.exceptions.Exceptions; http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0d702c5b/core/src/test/java/brooklyn/test/entity/BlockingEntity.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/brooklyn/test/entity/BlockingEntity.java b/core/src/test/java/brooklyn/test/entity/BlockingEntity.java deleted file mode 100644 index dbaafcb..0000000 --- a/core/src/test/java/brooklyn/test/entity/BlockingEntity.java +++ /dev/null @@ -1,45 +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.test.entity; - -import java.util.concurrent.CountDownLatch; - -import brooklyn.config.ConfigKey; -import brooklyn.entity.proxying.ImplementedBy; -import brooklyn.event.basic.BasicConfigKey; -import brooklyn.util.flags.SetFromFlag; - -/** - * Mock entity that blocks on startup via the {@link CountDownLatch} argument. - */ -@ImplementedBy(BlockingEntityImpl.class) -public interface BlockingEntity extends TestEntity { - - @SetFromFlag("startupLatch") - public static final ConfigKey STARTUP_LATCH = new BasicConfigKey(CountDownLatch.class, "test.startupLatch", "Latch that blocks startup"); - - @SetFromFlag("shutdownLatch") - public static final ConfigKey SHUTDOWN_LATCH = new BasicConfigKey(CountDownLatch.class, "test.shutdownLatch", "Latch that blocks shutdown"); - - @SetFromFlag("executingStartupNotificationLatch") - public static final ConfigKey EXECUTING_STARTUP_NOTIFICATION_LATCH = new BasicConfigKey(CountDownLatch.class, "test.executingStartupNotificationLatch", ""); - - @SetFromFlag("executingShutdownNotificationLatch") - public static final ConfigKey EXECUTING_SHUTDOWN_NOTIFICATION_LATCH = new BasicConfigKey(CountDownLatch.class, "test.executingShutdownNotificationLatch", ""); -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0d702c5b/core/src/test/java/brooklyn/test/entity/BlockingEntityImpl.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/brooklyn/test/entity/BlockingEntityImpl.java b/core/src/test/java/brooklyn/test/entity/BlockingEntityImpl.java deleted file mode 100644 index 040b433..0000000 --- a/core/src/test/java/brooklyn/test/entity/BlockingEntityImpl.java +++ /dev/null @@ -1,59 +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.test.entity; - -import java.util.Collection; -import java.util.concurrent.CountDownLatch; - -import brooklyn.location.Location; - -import com.google.common.base.Throwables; - -/** - * Mock entity that blocks on startup via the {@link CountDownLatch} argument. - */ -public class BlockingEntityImpl extends TestEntityImpl implements BlockingEntity { - - public BlockingEntityImpl() { - } - - @Override - public void start(Collection locs) { - try { - if (getConfig(EXECUTING_STARTUP_NOTIFICATION_LATCH) != null) getConfig(EXECUTING_STARTUP_NOTIFICATION_LATCH).countDown(); - if (getConfig(STARTUP_LATCH) != null) getConfig(STARTUP_LATCH).await(); - super.start(locs); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - throw Throwables.propagate(e); - } - } - - @Override - public void stop() { - try { - if (getConfig(EXECUTING_SHUTDOWN_NOTIFICATION_LATCH) != null) getConfig(EXECUTING_SHUTDOWN_NOTIFICATION_LATCH).countDown(); - if (getConfig(SHUTDOWN_LATCH) != null) getConfig(SHUTDOWN_LATCH).await(); - super.stop(); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - throw Throwables.propagate(e); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0d702c5b/core/src/test/java/brooklyn/test/entity/LocalManagementContextForTests.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/brooklyn/test/entity/LocalManagementContextForTests.java b/core/src/test/java/brooklyn/test/entity/LocalManagementContextForTests.java deleted file mode 100644 index 28b6914..0000000 --- a/core/src/test/java/brooklyn/test/entity/LocalManagementContextForTests.java +++ /dev/null @@ -1,157 +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.test.entity; - -import brooklyn.config.BrooklynProperties; -import brooklyn.config.BrooklynServerConfig; -import brooklyn.config.ConfigKey; -import brooklyn.management.internal.LocalManagementContext; -import brooklyn.management.internal.ManagementContextInternal; - -/** management context which allows disabling common time-consuming tasks. - * most instances have: - *
  • empty properties - *
  • no catalog - *
  • persistence off - *
  • osgi off - *

    - * the constructor, {@link #newInstance()}, and {@link #builder(boolean)} (with true) return the above; - * the constructor and the builder allow custom properties to be set, - * and the builder allows individual items to be turned back on. - */ -public class LocalManagementContextForTests extends LocalManagementContext { - - protected LocalManagementContextForTests(BrooklynProperties brooklynProperties, boolean minimal) { - super(builder(minimal).useProperties(brooklynProperties).buildProperties()); - } - - public LocalManagementContextForTests() { - this(null); - } - - public LocalManagementContextForTests(BrooklynProperties brooklynProperties) { - this(brooklynProperties, true); - } - - private static BrooklynProperties emptyIfNull(BrooklynProperties bp) { - if (bp!=null) return bp; - return BrooklynProperties.Factory.newEmpty(); - } - - public static BrooklynProperties setEmptyCatalogAsDefault(BrooklynProperties brooklynProperties) { - if (brooklynProperties==null) return null; - brooklynProperties.putIfAbsent(BrooklynServerConfig.BROOKLYN_CATALOG_URL, ManagementContextInternal.EMPTY_CATALOG_URL); - return brooklynProperties; - } - - public static BrooklynProperties disableOsgi(BrooklynProperties brooklynProperties) { - if (brooklynProperties==null) return null; - setFailingIfConflicting(brooklynProperties, BrooklynServerConfig.USE_OSGI, false); - return brooklynProperties; - } - - @SuppressWarnings("deprecation") - public static BrooklynProperties disablePersistenceBackups(BrooklynProperties brooklynProperties) { - if (brooklynProperties==null) return null; - setFailingIfConflicting(brooklynProperties, BrooklynServerConfig.PERSISTENCE_BACKUPS_REQUIRED_ON_DEMOTION, false); - setFailingIfConflicting(brooklynProperties, BrooklynServerConfig.PERSISTENCE_BACKUPS_REQUIRED_ON_PROMOTION, false); - setFailingIfConflicting(brooklynProperties, BrooklynServerConfig.PERSISTENCE_BACKUPS_REQUIRED, false); - return brooklynProperties; - } - - private static void setFailingIfConflicting(BrooklynProperties brooklynProperties, ConfigKey key, T value) { - Object old = brooklynProperties.put(key, value); - if (old != null && !old.equals(value)) { - throw new IllegalStateException("Cannot change value for '" + key + "' from " + old + " to " + value); - } - } - - public static class Builder { - boolean disablePersistenceBackups = false; - boolean disableOsgi = false; - boolean emptyCatalog = false; - BrooklynProperties properties = null; - - public Builder disablePersistenceBackups() { return disablePersistenceBackups(true); } - public Builder disableOsgi() { return disableOsgi(true); } - public Builder emptyCatalog() { return emptyCatalog(true); } - - public Builder disablePersistenceBackups(boolean disablePersistenceBackups) { this.disablePersistenceBackups = disablePersistenceBackups; return this; } - public Builder disableOsgi(boolean disableOsgi) { this.disableOsgi = disableOsgi; return this; } - public Builder emptyCatalog(boolean emptyCatalog) { this.emptyCatalog = emptyCatalog; return this; } - - // for use in the outer class's constructor - private Builder minimal(boolean really) { - if (really) minimal(); - return this; - } - - public Builder minimal() { - disablePersistenceBackups(); - disableOsgi(); - emptyCatalog(); - properties = null; - return this; - } - - public Builder useProperties(BrooklynProperties properties) { - if (this.properties!=null && properties!=null) - throw new IllegalStateException("Cannot set multiple properties"); - this.properties = properties; - return this; - } - - public BrooklynProperties buildProperties() { - BrooklynProperties result = emptyIfNull(properties); - if (disablePersistenceBackups) LocalManagementContextForTests.disablePersistenceBackups(result); - if (disableOsgi) LocalManagementContextForTests.disableOsgi(result); - if (emptyCatalog) LocalManagementContextForTests.setEmptyCatalogAsDefault(result); - return result; - } - - public LocalManagementContext build() { - return new LocalManagementContextForTests(buildProperties(), false); - } - public Builder useDefaultProperties() { - properties = BrooklynProperties.Factory.newDefault(); - return this; - } - } - - /** Create a new builder, defaulting to empty properties, and with the parameter determining whether - * by default to disable common things disabled in tests (and the caller can re-enable selected ones individually) - * or (if false) leaving everything enabled (so the caller turns things off) */ - public static Builder builder(boolean minimal) { return new Builder().minimal(minimal); } - - /** Creates a new minimal instance */ - public static LocalManagementContext newInstance() { - return builder(true).build(); - } - - /** Creates a new minimal instance with the given properties then installed. */ - public static LocalManagementContext newInstance(BrooklynProperties properties) { - return builder(true).useProperties(properties).build(); - } - - /** Creates a new minimal instance with OSGi then enabled. */ - public static LocalManagementContext newInstanceWithOsgi() { - return builder(true).disableOsgi(false).build(); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0d702c5b/core/src/test/java/brooklyn/test/entity/NoopStartable.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/brooklyn/test/entity/NoopStartable.java b/core/src/test/java/brooklyn/test/entity/NoopStartable.java deleted file mode 100644 index b700d2e..0000000 --- a/core/src/test/java/brooklyn/test/entity/NoopStartable.java +++ /dev/null @@ -1,29 +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.test.entity; - -import java.util.Collection; - -import brooklyn.entity.trait.Startable; - -public class NoopStartable implements Startable { - public void start(Collection loc) {} - public void stop() {} - public void restart() {} -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0d702c5b/core/src/test/java/brooklyn/test/entity/TestApplication.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/brooklyn/test/entity/TestApplication.java b/core/src/test/java/brooklyn/test/entity/TestApplication.java deleted file mode 100644 index 441359a..0000000 --- a/core/src/test/java/brooklyn/test/entity/TestApplication.java +++ /dev/null @@ -1,60 +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.test.entity; - -import java.util.Map; - -import org.apache.brooklyn.management.ManagementContext; - -import brooklyn.entity.Entity; -import brooklyn.entity.basic.ApplicationBuilder; -import brooklyn.entity.basic.EntityInternal; -import brooklyn.entity.basic.StartableApplication; -import brooklyn.entity.proxying.EntitySpec; -import brooklyn.entity.proxying.ImplementedBy; -import brooklyn.event.AttributeSensor; -import brooklyn.event.basic.Sensors; -import brooklyn.location.basic.LocalhostMachineProvisioningLocation; -import brooklyn.location.basic.SimulatedLocation; - -/** - * Mock application for testing. - */ -//TODO Don't want to extend EntityLocal/EntityInternal, but tests want to call things like app.setAttribute -@ImplementedBy(TestApplicationImpl.class) -public interface TestApplication extends StartableApplication, EntityInternal { - - public static final AttributeSensor MY_ATTRIBUTE = Sensors.newStringSensor("test.myattribute", "Test attribute sensor"); - - public T createAndManageChild(EntitySpec spec); - - public SimulatedLocation newSimulatedLocation(); - public LocalhostMachineProvisioningLocation newLocalhostProvisioningLocation(); - public LocalhostMachineProvisioningLocation newLocalhostProvisioningLocation(Map flags); - - public static class Factory { - public static TestApplication newManagedInstanceForTests(ManagementContext mgmt) { - return ApplicationBuilder.newManagedApp(TestApplication.class, mgmt); - } - public static TestApplication newManagedInstanceForTests() { - return newManagedInstanceForTests(new LocalManagementContextForTests()); - } - } - -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0d702c5b/core/src/test/java/brooklyn/test/entity/TestApplicationImpl.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/brooklyn/test/entity/TestApplicationImpl.java b/core/src/test/java/brooklyn/test/entity/TestApplicationImpl.java deleted file mode 100644 index 584c51c..0000000 --- a/core/src/test/java/brooklyn/test/entity/TestApplicationImpl.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package brooklyn.test.entity; - -import java.util.Map; - -import org.apache.brooklyn.management.SubscriptionHandle; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import brooklyn.entity.Entity; -import brooklyn.entity.Group; -import brooklyn.entity.basic.AbstractApplication; -import brooklyn.entity.proxying.EntitySpec; -import brooklyn.event.Sensor; -import brooklyn.event.SensorEventListener; -import brooklyn.location.LocationSpec; -import brooklyn.location.basic.LocalhostMachineProvisioningLocation; -import brooklyn.location.basic.SimulatedLocation; -import brooklyn.util.logging.LoggingSetup; - -/** - * Mock application for testing. - */ -public class TestApplicationImpl extends AbstractApplication implements TestApplication { - private static final Logger LOG = LoggerFactory.getLogger(TestApplication.class); - - static { - // our tests should redirect the j.u.l logging messages to logback - LoggingSetup.installJavaUtilLoggingBridge(); - } - - public TestApplicationImpl() { - super(); - } - - public TestApplicationImpl(Map flags) { - super(flags); - } - - @Override - public T createAndManageChild(EntitySpec spec) { - if (!getManagementSupport().isDeployed()) throw new IllegalStateException("Entity "+this+" not managed"); - T child = addChild(spec); - getEntityManager().manage(child); - return child; - } - - @Override - public SubscriptionHandle subscribeToMembers(Group parent, Sensor sensor, SensorEventListener listener) { - return getSubscriptionContext().subscribeToMembers(parent, sensor, listener); - } - - @Override - public String toString() { - String id = getId(); - return "Application["+id.substring(Math.max(0, id.length()-8))+"]"; - } - - @Override - public SimulatedLocation newSimulatedLocation() { - return getManagementContext().getLocationManager().createLocation(LocationSpec.create(SimulatedLocation.class)); - } - - @Override - public LocalhostMachineProvisioningLocation newLocalhostProvisioningLocation() { - return (LocalhostMachineProvisioningLocation) getManagementContext().getLocationRegistry().resolve("localhost"); - } - - @Override - public LocalhostMachineProvisioningLocation newLocalhostProvisioningLocation(Map flags) { - return (LocalhostMachineProvisioningLocation) getManagementContext().getLocationManager().createLocation( - LocationSpec.create(LocalhostMachineProvisioningLocation.class).configure(flags)); - } - - @Override - protected void logApplicationLifecycle(String message) { - // for tests, log this at debug so we see test info more - LOG.debug(message+" application "+this); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0d702c5b/core/src/test/java/brooklyn/test/entity/TestApplicationNoEnrichersImpl.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/brooklyn/test/entity/TestApplicationNoEnrichersImpl.java b/core/src/test/java/brooklyn/test/entity/TestApplicationNoEnrichersImpl.java deleted file mode 100644 index a56fbcb..0000000 --- a/core/src/test/java/brooklyn/test/entity/TestApplicationNoEnrichersImpl.java +++ /dev/null @@ -1,29 +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.test.entity; - - -/** - * Mock application for testing. - */ -public class TestApplicationNoEnrichersImpl extends TestApplicationImpl { - - protected void initEnrichers() { /* none */ } - -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0d702c5b/core/src/test/java/brooklyn/test/entity/TestCluster.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/brooklyn/test/entity/TestCluster.java b/core/src/test/java/brooklyn/test/entity/TestCluster.java deleted file mode 100644 index ec02178..0000000 --- a/core/src/test/java/brooklyn/test/entity/TestCluster.java +++ /dev/null @@ -1,30 +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.test.entity; - -import brooklyn.entity.basic.EntityLocal; -import brooklyn.entity.group.DynamicCluster; -import brooklyn.entity.proxying.ImplementedBy; - -/** -* Mock cluster entity for testing. -*/ -@ImplementedBy(TestClusterImpl.class) -public interface TestCluster extends DynamicCluster, EntityLocal { -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0d702c5b/core/src/test/java/brooklyn/test/entity/TestClusterImpl.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/brooklyn/test/entity/TestClusterImpl.java b/core/src/test/java/brooklyn/test/entity/TestClusterImpl.java deleted file mode 100644 index 3663520..0000000 --- a/core/src/test/java/brooklyn/test/entity/TestClusterImpl.java +++ /dev/null @@ -1,65 +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.test.entity; - -import brooklyn.entity.basic.QuorumCheck.QuorumChecks; -import brooklyn.entity.group.DynamicClusterImpl; -import brooklyn.entity.trait.Startable; - -/** -* Mock cluster entity for testing. -*/ -public class TestClusterImpl extends DynamicClusterImpl implements TestCluster { - private volatile int size; - - public TestClusterImpl() { - } - - @Override - public void init() { - super.init(); - size = getConfig(INITIAL_SIZE); - setAttribute(Startable.SERVICE_UP, true); - } - - @Override - protected void initEnrichers() { - // say this is up if it has no children - setConfig(UP_QUORUM_CHECK, QuorumChecks.atLeastOneUnlessEmpty()); - - super.initEnrichers(); - } - - @Override - public Integer resize(Integer desiredSize) { - this.size = desiredSize; - return size; - } - - @Override - public void stop() { - size = 0; - super.stop(); - } - - @Override - public Integer getCurrentSize() { - return size; - } -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0d702c5b/core/src/test/java/brooklyn/test/entity/TestEntity.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/brooklyn/test/entity/TestEntity.java b/core/src/test/java/brooklyn/test/entity/TestEntity.java deleted file mode 100644 index c3ca9c2..0000000 --- a/core/src/test/java/brooklyn/test/entity/TestEntity.java +++ /dev/null @@ -1,113 +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.test.entity; - -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.atomic.AtomicInteger; - -import org.testng.collections.Lists; -import org.testng.internal.annotations.Sets; - -import com.google.common.reflect.TypeToken; - -import brooklyn.config.ConfigKey; -import brooklyn.entity.Entity; -import brooklyn.entity.annotation.Effector; -import brooklyn.entity.annotation.EffectorParam; -import brooklyn.entity.basic.Attributes; -import brooklyn.entity.basic.ConfigKeys; -import brooklyn.entity.basic.EntityInternal; -import brooklyn.entity.basic.EntityLocal; -import brooklyn.entity.basic.Lifecycle; -import brooklyn.entity.basic.MethodEffector; -import brooklyn.entity.proxying.EntitySpec; -import brooklyn.entity.proxying.ImplementedBy; -import brooklyn.entity.trait.Startable; -import brooklyn.event.AttributeSensor; -import brooklyn.event.basic.BasicConfigKey; -import brooklyn.event.basic.BasicNotificationSensor; -import brooklyn.event.basic.ListConfigKey; -import brooklyn.event.basic.MapConfigKey; -import brooklyn.event.basic.Sensors; -import brooklyn.event.basic.SetConfigKey; -import brooklyn.util.collections.MutableMap; -import brooklyn.util.flags.SetFromFlag; - -/** - * Mock entity for testing. - */ -//FIXME Don't want to extend EntityLocal, but tests call things like entity.subscribe(); how to deal with that elegantly? -@ImplementedBy(TestEntityImpl.class) -public interface TestEntity extends Entity, Startable, EntityLocal, EntityInternal { - - @SetFromFlag("confName") - public static final ConfigKey CONF_NAME = ConfigKeys.newStringConfigKey("test.confName", "Configuration key, my name", "defaultval"); - public static final BasicConfigKey CONF_MAP_PLAIN = new BasicConfigKey(Map.class, "test.confMapPlain", "Configuration key that's a plain map", MutableMap.of()); - public static final BasicConfigKey CONF_LIST_PLAIN = new BasicConfigKey(List.class, "test.confListPlain", "Configuration key that's a plain list", Lists.newArrayList()); - public static final BasicConfigKey CONF_SET_PLAIN = new BasicConfigKey(Set.class, "test.confSetPlain", "Configuration key that's a plain set", Sets.newHashSet()); - public static final MapConfigKey CONF_MAP_THING = new MapConfigKey(String.class, "test.confMapThing", "Configuration key that's a map thing"); - public static final MapConfigKey CONF_MAP_THING_OBJECT = new MapConfigKey(Object.class, "test.confMapThing.obj", "Configuration key that's a map thing with objects"); - public static final ListConfigKey CONF_LIST_THING = new ListConfigKey(String.class, "test.confListThing", "Configuration key that's a list thing"); - public static final ListConfigKey CONF_LIST_OBJ_THING = new ListConfigKey(Object.class, "test.confListObjThing", "Configuration key that's a list thing, of objects"); - public static final SetConfigKey CONF_SET_THING = new SetConfigKey(String.class, "test.confSetThing", "Configuration key that's a set thing"); - public static final SetConfigKey CONF_SET_OBJ_THING = new SetConfigKey(Object.class, "test.confSetObjThing", "Configuration key that's a set thing, of objects"); - public static final BasicConfigKey CONF_OBJECT = new BasicConfigKey(Object.class, "test.confObject", "Configuration key that's an object"); - public static final ConfigKey> CHILD_SPEC = ConfigKeys.newConfigKey(new TypeToken>() {}, "test.childSpec", "Spec to be used for creating children"); - - public static final AttributeSensor SEQUENCE = Sensors.newIntegerSensor("test.sequence", "Test Sequence"); - public static final AttributeSensor NAME = Sensors.newStringSensor("test.name", "Test name"); - public static final BasicNotificationSensor MY_NOTIF = new BasicNotificationSensor(Integer.class, "test.myNotif", "Test notification"); - - public static final AttributeSensor SERVICE_STATE_ACTUAL = Attributes.SERVICE_STATE_ACTUAL; - @Deprecated - public static final AttributeSensor SERVICE_STATE = Attributes.SERVICE_STATE_ACTUAL; - - public static final MethodEffector MY_EFFECTOR = new MethodEffector(TestEntity.class, "myEffector"); - public static final MethodEffector IDENTITY_EFFECTOR = new MethodEffector(TestEntity.class, "identityEffector"); - - public boolean isLegacyConstruction(); - - @Effector(description="an example of a no-arg effector") - public void myEffector(); - - @Effector(description="returns the arg passed in") - public Object identityEffector(@EffectorParam(name="arg", description="val to return") Object arg); - - public AtomicInteger getCounter(); - - public int getCount(); - - public Map getConstructorProperties(); - - public Map getConfigureProperties(); - - public int getSequenceValue(); - - public void setSequenceValue(int value); - - public T createChild(EntitySpec spec); - - public T createAndManageChild(EntitySpec spec); - - public Entity createAndManageChildFromConfig(); - - public List getCallHistory(); -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0d702c5b/core/src/test/java/brooklyn/test/entity/TestEntityImpl.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/brooklyn/test/entity/TestEntityImpl.java b/core/src/test/java/brooklyn/test/entity/TestEntityImpl.java deleted file mode 100644 index 1fd3d57..0000000 --- a/core/src/test/java/brooklyn/test/entity/TestEntityImpl.java +++ /dev/null @@ -1,186 +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.test.entity; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.concurrent.atomic.AtomicInteger; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import brooklyn.entity.Entity; -import brooklyn.entity.basic.AbstractEntity; -import brooklyn.entity.basic.Lifecycle; -import brooklyn.entity.basic.ServiceStateLogic; -import brooklyn.entity.proxying.EntitySpec; -import brooklyn.location.Location; -import brooklyn.util.collections.MutableMap; - -import com.google.common.collect.Lists; - -/** - * Mock entity for testing. - */ -public class TestEntityImpl extends AbstractEntity implements TestEntity { - private static final Logger LOG = LoggerFactory.getLogger(TestEntityImpl.class); - - protected int sequenceValue = 0; - protected AtomicInteger counter = new AtomicInteger(0); - protected Map constructorProperties; - protected Map configureProperties; - protected List callHistory = Collections.synchronizedList(Lists.newArrayList()); - - public TestEntityImpl() { - super(); - } - public TestEntityImpl(Map properties) { - this(properties, null); - } - public TestEntityImpl(Entity parent) { - this(MutableMap.of(), parent); - } - public TestEntityImpl(Map properties, Entity parent) { - super(properties, parent); - this.constructorProperties = properties; - } - - public AbstractEntity configure(Map flags) { - this.configureProperties = flags; - return super.configure(flags); - } - - @Override // made public for testing - public boolean isLegacyConstruction() { - return super.isLegacyConstruction(); - } - - @Override - public void myEffector() { - if (LOG.isTraceEnabled()) LOG.trace("In myEffector for {}", this); - callHistory.add("myEffector"); - } - - @Override - public Object identityEffector(Object arg) { - if (LOG.isTraceEnabled()) LOG.trace("In identityEffector for {}", this); - callHistory.add("identityEffector"); - return checkNotNull(arg, "arg"); - } - - @Override - public AtomicInteger getCounter() { - return counter; - } - - @Override - public int getCount() { - return counter.get(); - } - - @Override - public Map getConstructorProperties() { - return constructorProperties; - } - - @Override - public Map getConfigureProperties() { - return configureProperties; - } - - @Override - public synchronized int getSequenceValue() { - return sequenceValue; - } - - @Override - public synchronized void setSequenceValue(int value) { - sequenceValue = value; - setAttribute(SEQUENCE, value); - } - - @Override - public void start(Collection locs) { - LOG.trace("Starting {}", this); - callHistory.add("start"); - ServiceStateLogic.setExpectedState(this, Lifecycle.STARTING); - counter.incrementAndGet(); - addLocations(locs); - setAttribute(SERVICE_UP, true); - ServiceStateLogic.setExpectedState(this, Lifecycle.RUNNING); - } - - @Override - public void stop() { - LOG.trace("Stopping {}", this); - callHistory.add("stop"); - ServiceStateLogic.setExpectedState(this, Lifecycle.STOPPING); - counter.decrementAndGet(); - setAttribute(SERVICE_UP, false); - ServiceStateLogic.setExpectedState(this, Lifecycle.STOPPED); - } - - @Override - public void restart() { - LOG.trace("Restarting {}", this); - callHistory.add("restart"); - } - - /** - * TODO Rename to addChild - */ - @Override - public T createChild(EntitySpec spec) { - return addChild(spec); - } - - @Override - public T createAndManageChild(EntitySpec spec) { - if (!getManagementSupport().isDeployed()) throw new IllegalStateException("Entity "+this+" not managed"); - T child = createChild(spec); - getEntityManager().manage(child); - return child; - } - - @Override - public Entity createAndManageChildFromConfig() { - return createAndManageChild(checkNotNull(getConfig(CHILD_SPEC), "childSpec")); - } - -// @Override -// public String toString() { -// String id = getId(); -// return getEntityType().getSimpleName()+"["+id.substring(Math.max(0, id.length()-8))+"]"; -// } - - @Override - public List getCallHistory() { - return callHistory; - } - - public static class TestEntityWithoutEnrichers extends TestEntityImpl { - @Override - protected void initEnrichers() {} - } - -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0d702c5b/core/src/test/java/brooklyn/test/entity/TestEntityNoEnrichersImpl.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/brooklyn/test/entity/TestEntityNoEnrichersImpl.java b/core/src/test/java/brooklyn/test/entity/TestEntityNoEnrichersImpl.java deleted file mode 100644 index 66ef7ae..0000000 --- a/core/src/test/java/brooklyn/test/entity/TestEntityNoEnrichersImpl.java +++ /dev/null @@ -1,32 +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.test.entity; - - -/** - * Mock entity for testing. - */ -public class TestEntityNoEnrichersImpl extends TestEntityImpl { - - @Override - protected void initEnrichers() { - // no enrichers here, so we can test the explicit enrichers we set - } - -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0d702c5b/core/src/test/java/brooklyn/test/entity/TestEntityTransientCopyImpl.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/brooklyn/test/entity/TestEntityTransientCopyImpl.java b/core/src/test/java/brooklyn/test/entity/TestEntityTransientCopyImpl.java deleted file mode 100644 index a5987ee..0000000 --- a/core/src/test/java/brooklyn/test/entity/TestEntityTransientCopyImpl.java +++ /dev/null @@ -1,28 +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.test.entity; - -import brooklyn.entity.basic.EntityTransientCopyInternal; - -/** - * Entity to give compilation errors if {@link EntityTransientCopyInternal} methods are not aligned - * with Entity methods. (Everything in that interface should be on EntityInternal, and if not, we want to know!) - */ -public class TestEntityTransientCopyImpl extends TestEntityImpl implements EntityTransientCopyInternal { -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0d702c5b/core/src/test/java/brooklyn/util/ssh/BashCommandsIntegrationTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/brooklyn/util/ssh/BashCommandsIntegrationTest.java b/core/src/test/java/brooklyn/util/ssh/BashCommandsIntegrationTest.java index d8ee99f..593de3d 100644 --- a/core/src/test/java/brooklyn/util/ssh/BashCommandsIntegrationTest.java +++ b/core/src/test/java/brooklyn/util/ssh/BashCommandsIntegrationTest.java @@ -34,6 +34,7 @@ import java.util.Collection; import java.util.List; import org.apache.brooklyn.management.ManagementContext; +import org.apache.brooklyn.test.entity.LocalManagementContextForTests; import org.apache.commons.io.FileUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -45,7 +46,6 @@ import org.testng.annotations.Test; import brooklyn.entity.basic.Entities; import brooklyn.location.basic.LocalhostMachineProvisioningLocation; import brooklyn.location.basic.SshMachineLocation; -import brooklyn.test.entity.LocalManagementContextForTests; import brooklyn.util.javalang.JavaClassNames; import brooklyn.util.net.Networking; import brooklyn.util.os.Os; http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0d702c5b/core/src/test/java/brooklyn/util/task/TasksTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/brooklyn/util/task/TasksTest.java b/core/src/test/java/brooklyn/util/task/TasksTest.java index a1439fb..18a4392 100644 --- a/core/src/test/java/brooklyn/util/task/TasksTest.java +++ b/core/src/test/java/brooklyn/util/task/TasksTest.java @@ -28,14 +28,14 @@ import java.util.concurrent.Callable; import org.apache.brooklyn.management.ExecutionContext; import org.apache.brooklyn.management.Task; +import org.apache.brooklyn.test.entity.TestApplication; +import org.apache.brooklyn.test.entity.TestEntity; import org.testng.Assert; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import brooklyn.entity.BrooklynAppUnitTestSupport; import brooklyn.entity.basic.EntityFunctions; -import brooklyn.test.entity.TestApplication; -import brooklyn.test.entity.TestEntity; import brooklyn.util.guava.Functionals; import brooklyn.util.repeat.Repeater; import brooklyn.util.time.Duration; http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0d702c5b/core/src/test/java/brooklyn/util/text/TemplateProcessorTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/brooklyn/util/text/TemplateProcessorTest.java b/core/src/test/java/brooklyn/util/text/TemplateProcessorTest.java index 030e8c6..c021261 100644 --- a/core/src/test/java/brooklyn/util/text/TemplateProcessorTest.java +++ b/core/src/test/java/brooklyn/util/text/TemplateProcessorTest.java @@ -20,6 +20,8 @@ package brooklyn.util.text; import static org.testng.Assert.assertEquals; +import org.apache.brooklyn.test.entity.TestApplication; +import org.apache.brooklyn.test.entity.TestEntity; import org.testng.Assert; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; @@ -30,8 +32,6 @@ import brooklyn.entity.proxying.EntitySpec; import brooklyn.event.basic.DependentConfiguration; import brooklyn.management.internal.ManagementContextInternal; import brooklyn.test.FixedLocaleTest; -import brooklyn.test.entity.TestApplication; -import brooklyn.test.entity.TestEntity; import com.google.common.collect.ImmutableMap; http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0d702c5b/core/src/test/java/org/apache/brooklyn/test/entity/BlockingEntity.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/test/entity/BlockingEntity.java b/core/src/test/java/org/apache/brooklyn/test/entity/BlockingEntity.java new file mode 100644 index 0000000..4c365ab --- /dev/null +++ b/core/src/test/java/org/apache/brooklyn/test/entity/BlockingEntity.java @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.brooklyn.test.entity; + +import java.util.concurrent.CountDownLatch; + +import brooklyn.config.ConfigKey; +import brooklyn.entity.proxying.ImplementedBy; +import brooklyn.event.basic.BasicConfigKey; +import brooklyn.util.flags.SetFromFlag; + +/** + * Mock entity that blocks on startup via the {@link CountDownLatch} argument. + */ +@ImplementedBy(BlockingEntityImpl.class) +public interface BlockingEntity extends TestEntity { + + @SetFromFlag("startupLatch") + public static final ConfigKey STARTUP_LATCH = new BasicConfigKey(CountDownLatch.class, "test.startupLatch", "Latch that blocks startup"); + + @SetFromFlag("shutdownLatch") + public static final ConfigKey SHUTDOWN_LATCH = new BasicConfigKey(CountDownLatch.class, "test.shutdownLatch", "Latch that blocks shutdown"); + + @SetFromFlag("executingStartupNotificationLatch") + public static final ConfigKey EXECUTING_STARTUP_NOTIFICATION_LATCH = new BasicConfigKey(CountDownLatch.class, "test.executingStartupNotificationLatch", ""); + + @SetFromFlag("executingShutdownNotificationLatch") + public static final ConfigKey EXECUTING_SHUTDOWN_NOTIFICATION_LATCH = new BasicConfigKey(CountDownLatch.class, "test.executingShutdownNotificationLatch", ""); +} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0d702c5b/core/src/test/java/org/apache/brooklyn/test/entity/BlockingEntityImpl.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/test/entity/BlockingEntityImpl.java b/core/src/test/java/org/apache/brooklyn/test/entity/BlockingEntityImpl.java new file mode 100644 index 0000000..cd94a22 --- /dev/null +++ b/core/src/test/java/org/apache/brooklyn/test/entity/BlockingEntityImpl.java @@ -0,0 +1,59 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.brooklyn.test.entity; + +import java.util.Collection; +import java.util.concurrent.CountDownLatch; + +import brooklyn.location.Location; + +import com.google.common.base.Throwables; + +/** + * Mock entity that blocks on startup via the {@link CountDownLatch} argument. + */ +public class BlockingEntityImpl extends TestEntityImpl implements BlockingEntity { + + public BlockingEntityImpl() { + } + + @Override + public void start(Collection locs) { + try { + if (getConfig(EXECUTING_STARTUP_NOTIFICATION_LATCH) != null) getConfig(EXECUTING_STARTUP_NOTIFICATION_LATCH).countDown(); + if (getConfig(STARTUP_LATCH) != null) getConfig(STARTUP_LATCH).await(); + super.start(locs); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw Throwables.propagate(e); + } + } + + @Override + public void stop() { + try { + if (getConfig(EXECUTING_SHUTDOWN_NOTIFICATION_LATCH) != null) getConfig(EXECUTING_SHUTDOWN_NOTIFICATION_LATCH).countDown(); + if (getConfig(SHUTDOWN_LATCH) != null) getConfig(SHUTDOWN_LATCH).await(); + super.stop(); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw Throwables.propagate(e); + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0d702c5b/core/src/test/java/org/apache/brooklyn/test/entity/LocalManagementContextForTests.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/brooklyn/test/entity/LocalManagementContextForTests.java b/core/src/test/java/org/apache/brooklyn/test/entity/LocalManagementContextForTests.java new file mode 100644 index 0000000..775f1a3 --- /dev/null +++ b/core/src/test/java/org/apache/brooklyn/test/entity/LocalManagementContextForTests.java @@ -0,0 +1,157 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.brooklyn.test.entity; + +import brooklyn.config.BrooklynProperties; +import brooklyn.config.BrooklynServerConfig; +import brooklyn.config.ConfigKey; +import brooklyn.management.internal.LocalManagementContext; +import brooklyn.management.internal.ManagementContextInternal; + +/** management context which allows disabling common time-consuming tasks. + * most instances have: + *
  • empty properties + *
  • no catalog + *
  • persistence off + *
  • osgi off + *

    + * the constructor, {@link #newInstance()}, and {@link #builder(boolean)} (with true) return the above; + * the constructor and the builder allow custom properties to be set, + * and the builder allows individual items to be turned back on. + */ +public class LocalManagementContextForTests extends LocalManagementContext { + + protected LocalManagementContextForTests(BrooklynProperties brooklynProperties, boolean minimal) { + super(builder(minimal).useProperties(brooklynProperties).buildProperties()); + } + + public LocalManagementContextForTests() { + this(null); + } + + public LocalManagementContextForTests(BrooklynProperties brooklynProperties) { + this(brooklynProperties, true); + } + + private static BrooklynProperties emptyIfNull(BrooklynProperties bp) { + if (bp!=null) return bp; + return BrooklynProperties.Factory.newEmpty(); + } + + public static BrooklynProperties setEmptyCatalogAsDefault(BrooklynProperties brooklynProperties) { + if (brooklynProperties==null) return null; + brooklynProperties.putIfAbsent(BrooklynServerConfig.BROOKLYN_CATALOG_URL, ManagementContextInternal.EMPTY_CATALOG_URL); + return brooklynProperties; + } + + public static BrooklynProperties disableOsgi(BrooklynProperties brooklynProperties) { + if (brooklynProperties==null) return null; + setFailingIfConflicting(brooklynProperties, BrooklynServerConfig.USE_OSGI, false); + return brooklynProperties; + } + + @SuppressWarnings("deprecation") + public static BrooklynProperties disablePersistenceBackups(BrooklynProperties brooklynProperties) { + if (brooklynProperties==null) return null; + setFailingIfConflicting(brooklynProperties, BrooklynServerConfig.PERSISTENCE_BACKUPS_REQUIRED_ON_DEMOTION, false); + setFailingIfConflicting(brooklynProperties, BrooklynServerConfig.PERSISTENCE_BACKUPS_REQUIRED_ON_PROMOTION, false); + setFailingIfConflicting(brooklynProperties, BrooklynServerConfig.PERSISTENCE_BACKUPS_REQUIRED, false); + return brooklynProperties; + } + + private static void setFailingIfConflicting(BrooklynProperties brooklynProperties, ConfigKey key, T value) { + Object old = brooklynProperties.put(key, value); + if (old != null && !old.equals(value)) { + throw new IllegalStateException("Cannot change value for '" + key + "' from " + old + " to " + value); + } + } + + public static class Builder { + boolean disablePersistenceBackups = false; + boolean disableOsgi = false; + boolean emptyCatalog = false; + BrooklynProperties properties = null; + + public Builder disablePersistenceBackups() { return disablePersistenceBackups(true); } + public Builder disableOsgi() { return disableOsgi(true); } + public Builder emptyCatalog() { return emptyCatalog(true); } + + public Builder disablePersistenceBackups(boolean disablePersistenceBackups) { this.disablePersistenceBackups = disablePersistenceBackups; return this; } + public Builder disableOsgi(boolean disableOsgi) { this.disableOsgi = disableOsgi; return this; } + public Builder emptyCatalog(boolean emptyCatalog) { this.emptyCatalog = emptyCatalog; return this; } + + // for use in the outer class's constructor + private Builder minimal(boolean really) { + if (really) minimal(); + return this; + } + + public Builder minimal() { + disablePersistenceBackups(); + disableOsgi(); + emptyCatalog(); + properties = null; + return this; + } + + public Builder useProperties(BrooklynProperties properties) { + if (this.properties!=null && properties!=null) + throw new IllegalStateException("Cannot set multiple properties"); + this.properties = properties; + return this; + } + + public BrooklynProperties buildProperties() { + BrooklynProperties result = emptyIfNull(properties); + if (disablePersistenceBackups) LocalManagementContextForTests.disablePersistenceBackups(result); + if (disableOsgi) LocalManagementContextForTests.disableOsgi(result); + if (emptyCatalog) LocalManagementContextForTests.setEmptyCatalogAsDefault(result); + return result; + } + + public LocalManagementContext build() { + return new LocalManagementContextForTests(buildProperties(), false); + } + public Builder useDefaultProperties() { + properties = BrooklynProperties.Factory.newDefault(); + return this; + } + } + + /** Create a new builder, defaulting to empty properties, and with the parameter determining whether + * by default to disable common things disabled in tests (and the caller can re-enable selected ones individually) + * or (if false) leaving everything enabled (so the caller turns things off) */ + public static Builder builder(boolean minimal) { return new Builder().minimal(minimal); } + + /** Creates a new minimal instance */ + public static LocalManagementContext newInstance() { + return builder(true).build(); + } + + /** Creates a new minimal instance with the given properties then installed. */ + public static LocalManagementContext newInstance(BrooklynProperties properties) { + return builder(true).useProperties(properties).build(); + } + + /** Creates a new minimal instance with OSGi then enabled. */ + public static LocalManagementContext newInstanceWithOsgi() { + return builder(true).disableOsgi(false).build(); + } + +}