brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aleds...@apache.org
Subject [1/3] brooklyn-server git commit: Allow custom mgmt properties in unit test support
Date Fri, 18 Mar 2016 23:18:53 GMT
Repository: brooklyn-server
Updated Branches:
  refs/heads/master d0590884f -> 3767000c6


Allow custom mgmt properties in unit test support


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/18403d0d
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/18403d0d
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/18403d0d

Branch: refs/heads/master
Commit: 18403d0d39e3ff13a6a0c469bb0b1c5e95f2a1c2
Parents: f8476be
Author: Sam Corbett <sam.corbett@cloudsoftcorp.com>
Authored: Tue Mar 15 12:08:11 2016 +0000
Committer: Sam Corbett <sam.corbett@cloudsoftcorp.com>
Committed: Tue Mar 15 12:30:39 2016 +0000

----------------------------------------------------------------------
 .../core/test/BrooklynMgmtUnitTestSupport.java  | 12 +++++++-
 .../usage/ApplicationUsageTrackingTest.java     | 31 ++------------------
 2 files changed, 14 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/18403d0d/core/src/test/java/org/apache/brooklyn/core/test/BrooklynMgmtUnitTestSupport.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/test/BrooklynMgmtUnitTestSupport.java
b/core/src/test/java/org/apache/brooklyn/core/test/BrooklynMgmtUnitTestSupport.java
index 9742bce..ee2ab79 100644
--- a/core/src/test/java/org/apache/brooklyn/core/test/BrooklynMgmtUnitTestSupport.java
+++ b/core/src/test/java/org/apache/brooklyn/core/test/BrooklynMgmtUnitTestSupport.java
@@ -19,6 +19,7 @@
 package org.apache.brooklyn.core.test;
 
 import org.apache.brooklyn.core.entity.Entities;
+import org.apache.brooklyn.core.internal.BrooklynProperties;
 import org.apache.brooklyn.core.mgmt.internal.ManagementContextInternal;
 import org.apache.brooklyn.core.test.entity.LocalManagementContextForTests;
 import org.slf4j.Logger;
@@ -40,7 +41,12 @@ public class BrooklynMgmtUnitTestSupport {
     @BeforeMethod(alwaysRun=true)
     public void setUp() throws Exception {
         if (mgmt == null) {
-            mgmt = LocalManagementContextForTests.newInstance();
+            BrooklynProperties brooklynProperties = getBrooklynProperties();
+            if (brooklynProperties != null) {
+                mgmt = LocalManagementContextForTests.newInstance(brooklynProperties);
+            } else {
+                mgmt = LocalManagementContextForTests.newInstance();
+            }
         }
     }
 
@@ -58,4 +64,8 @@ public class BrooklynMgmtUnitTestSupport {
         }
     }
 
+    protected BrooklynProperties getBrooklynProperties() {
+        return null;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/18403d0d/software/base/src/test/java/org/apache/brooklyn/entity/software/base/test/core/mgmt/usage/ApplicationUsageTrackingTest.java
----------------------------------------------------------------------
diff --git a/software/base/src/test/java/org/apache/brooklyn/entity/software/base/test/core/mgmt/usage/ApplicationUsageTrackingTest.java
b/software/base/src/test/java/org/apache/brooklyn/entity/software/base/test/core/mgmt/usage/ApplicationUsageTrackingTest.java
index 6f11431..9fc5a0f 100644
--- a/software/base/src/test/java/org/apache/brooklyn/entity/software/base/test/core/mgmt/usage/ApplicationUsageTrackingTest.java
+++ b/software/base/src/test/java/org/apache/brooklyn/entity/software/base/test/core/mgmt/usage/ApplicationUsageTrackingTest.java
@@ -29,21 +29,17 @@ import java.util.Set;
 
 import org.apache.brooklyn.api.entity.Application;
 import org.apache.brooklyn.api.location.Location;
-import org.apache.brooklyn.core.entity.Entities;
 import org.apache.brooklyn.core.entity.lifecycle.Lifecycle;
-import org.apache.brooklyn.core.mgmt.internal.ManagementContextInternal;
-import org.apache.brooklyn.core.mgmt.usage.UsageListener.ApplicationMetadata;
 import org.apache.brooklyn.core.mgmt.usage.ApplicationUsage;
 import org.apache.brooklyn.core.mgmt.usage.ApplicationUsage.ApplicationEvent;
+import org.apache.brooklyn.core.mgmt.usage.UsageListener.ApplicationMetadata;
 import org.apache.brooklyn.core.objs.proxy.EntityProxy;
-import org.apache.brooklyn.core.test.entity.LocalManagementContextForTests;
+import org.apache.brooklyn.core.test.BrooklynMgmtUnitTestSupport;
 import org.apache.brooklyn.core.test.entity.TestApplication;
 import org.apache.brooklyn.test.Asserts;
 import org.apache.brooklyn.util.time.Time;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
 import com.google.common.base.Predicates;
@@ -51,32 +47,11 @@ import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Iterables;
 
-public class ApplicationUsageTrackingTest {
+public class ApplicationUsageTrackingTest extends BrooklynMgmtUnitTestSupport {
 
     private static final Logger LOG = LoggerFactory.getLogger(ApplicationUsageTrackingTest.class);
 
     protected TestApplication app;
-    protected ManagementContextInternal mgmt;
-
-    protected boolean shouldSkipOnBoxBaseDirResolution() {
-        return true;
-    }
-
-    @BeforeMethod(alwaysRun=true)
-    public void setUp() throws Exception {
-        mgmt = LocalManagementContextForTests.newInstance();
-    }
-
-    @AfterMethod(alwaysRun=true)
-    public void tearDown() throws Exception {
-        try {
-            if (mgmt != null) Entities.destroyAll(mgmt);
-        } catch (Throwable t) {
-            LOG.error("Caught exception in tearDown method", t);
-        } finally {
-            mgmt = null;
-        }
-    }
 
     @Test
     public void testUsageInitiallyEmpty() {


Mime
View raw message