brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henev...@apache.org
Subject [1/2] brooklyn-server git commit: Fix LocalhostMachineProvisioningLocationTest
Date Wed, 28 Sep 2016 14:43:58 GMT
Repository: brooklyn-server
Updated Branches:
  refs/heads/master d9e4bac32 -> 15429e209


Fix LocalhostMachineProvisioningLocationTest

Use @BeforeMethod rather than @BeforeClass for test setup/teardown

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

Branch: refs/heads/master
Commit: 448c15901369e916242a9b8c26359d825137a40f
Parents: d9e4bac
Author: Aled Sage <aled.sage@gmail.com>
Authored: Wed Sep 28 12:09:03 2016 +0100
Committer: Aled Sage <aled.sage@gmail.com>
Committed: Wed Sep 28 12:09:03 2016 +0100

----------------------------------------------------------------------
 ...ocalhostMachineProvisioningLocationTest.java | 49 +++++++++-----------
 1 file changed, 22 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/448c1590/core/src/test/java/org/apache/brooklyn/location/localhost/LocalhostMachineProvisioningLocationTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/location/localhost/LocalhostMachineProvisioningLocationTest.java
b/core/src/test/java/org/apache/brooklyn/location/localhost/LocalhostMachineProvisioningLocationTest.java
index 3a2b860..e9a4dab 100644
--- a/core/src/test/java/org/apache/brooklyn/location/localhost/LocalhostMachineProvisioningLocationTest.java
+++ b/core/src/test/java/org/apache/brooklyn/location/localhost/LocalhostMachineProvisioningLocationTest.java
@@ -24,47 +24,42 @@ import static org.testng.Assert.fail;
 
 import java.net.ServerSocket;
 
-import org.apache.brooklyn.util.collections.MutableMap;
-import org.apache.brooklyn.util.net.Networking;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.Assert;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
 import org.apache.brooklyn.api.location.LocationSpec;
 import org.apache.brooklyn.api.location.MachineProvisioningLocation;
 import org.apache.brooklyn.api.location.NoMachinesAvailableException;
 import org.apache.brooklyn.api.location.PortRange;
-import org.apache.brooklyn.core.entity.Entities;
 import org.apache.brooklyn.core.location.PortRanges;
 import org.apache.brooklyn.core.location.geo.HostGeoInfo;
-import org.apache.brooklyn.core.mgmt.internal.LocalManagementContext;
-import org.apache.brooklyn.core.test.entity.LocalManagementContextForTests;
-import org.apache.brooklyn.location.localhost.LocalhostMachineProvisioningLocation;
+import org.apache.brooklyn.core.test.BrooklynMgmtUnitTestSupport;
 import org.apache.brooklyn.location.ssh.SshMachineLocation;
+import org.apache.brooklyn.util.collections.MutableMap;
+import org.apache.brooklyn.util.net.Networking;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.Assert;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
 
-public class LocalhostMachineProvisioningLocationTest {
+public class LocalhostMachineProvisioningLocationTest extends BrooklynMgmtUnitTestSupport
{
 
     private static final Logger log = LoggerFactory.getLogger(LocalhostMachineProvisioningLocationTest.class);
     
-    private LocalManagementContext mgmt;
-
-    @BeforeMethod
-    @AfterClass
-    protected void clearStatics() {
+    @BeforeMethod(alwaysRun=true)
+    @Override
+    public void setUp() throws Exception {
+        super.setUp();
         LocalhostMachineProvisioningLocation.clearStaticData();
     }
     
-    @BeforeClass
-    protected void setup() {
-        mgmt = LocalManagementContextForTests.newInstance();
-    }
-    
-    @AfterClass
-    protected void teardown() {
-        Entities.destroyAll(mgmt);
+    @AfterMethod(alwaysRun=true)
+    @Override
+    public void tearDown() throws Exception {
+        try {
+            super.tearDown();
+        } finally {
+            LocalhostMachineProvisioningLocation.clearStaticData();
+        }
     }
     
     protected LocalhostMachineProvisioningLocation newLocalhostProvisioner() {


Mime
View raw message