You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by he...@apache.org on 2016/02/01 18:51:56 UTC

[12/50] [abbrv] brooklyn-ui git commit: fix java web tests so they clean up mgmt context

fix java web tests so they clean up mgmt context


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/commit/3fefde1d
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/tree/3fefde1d
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/diff/3fefde1d

Branch: refs/heads/0.6.0
Commit: 3fefde1dbe6af7db727a9a1b6290aebe5197b552
Parents: 59889ae
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Authored: Fri Sep 13 16:23:24 2013 +0100
Committer: Alex Heneveld <al...@cloudsoftcorp.com>
Committed: Fri Sep 13 16:23:24 2013 +0100

----------------------------------------------------------------------
 .../jsgui/BrooklynJavascriptGuiLauncherTest.java     | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/3fefde1d/usage/jsgui/src/test/java/brooklyn/rest/jsgui/BrooklynJavascriptGuiLauncherTest.java
----------------------------------------------------------------------
diff --git a/usage/jsgui/src/test/java/brooklyn/rest/jsgui/BrooklynJavascriptGuiLauncherTest.java b/usage/jsgui/src/test/java/brooklyn/rest/jsgui/BrooklynJavascriptGuiLauncherTest.java
index e751aee..429212f 100644
--- a/usage/jsgui/src/test/java/brooklyn/rest/jsgui/BrooklynJavascriptGuiLauncherTest.java
+++ b/usage/jsgui/src/test/java/brooklyn/rest/jsgui/BrooklynJavascriptGuiLauncherTest.java
@@ -1,9 +1,13 @@
 package brooklyn.rest.jsgui;
 
 import org.eclipse.jetty.server.Server;
-import org.testng.annotations.AfterTest;
+import org.eclipse.jetty.server.handler.ContextHandler;
+import org.testng.annotations.AfterMethod;
 import org.testng.annotations.Test;
 
+import brooklyn.config.BrooklynServiceAttributes;
+import brooklyn.entity.basic.Entities;
+import brooklyn.management.ManagementContext;
 import brooklyn.rest.BrooklynRestApiLauncherTest;
 import brooklyn.test.HttpTestUtils;
 
@@ -12,10 +16,12 @@ public class BrooklynJavascriptGuiLauncherTest {
 
     Server server = null;
     
-    @AfterTest
+    @AfterMethod(alwaysRun=true)
     public void stopServer() throws Exception {
         if (server!=null) {
+            ManagementContext mgmt = getManagementContextFromJettyServerAttributes(server);
             server.stop();
+            if (mgmt!=null) Entities.destroyAll(mgmt);
             server = null;
         }
     }
@@ -40,4 +46,9 @@ public class BrooklynJavascriptGuiLauncherTest {
         HttpTestUtils.assertContentContainsText(rootUrl+path, text);
     }
 
+    public static ManagementContext getManagementContextFromJettyServerAttributes(Server server) {
+        ManagementContext mgmt = (ManagementContext) ((ContextHandler)server.getHandler()).getAttribute(BrooklynServiceAttributes.BROOKLYN_MANAGEMENT_CONTEXT);
+        return mgmt;
+    }
+
 }