Repository: incubator-brooklyn Updated Branches: refs/heads/master df4eb8a7f -> 2013f2fb2
Tidy BrooklynLauncherRebindCatalogTest Stop the BrooklynLaunchers that were created during tests (as discussed in PR #716) Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/40c39756 Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/40c39756 Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/40c39756 Branch: refs/heads/master Commit: 40c39756e5fba56b7606cb95b151791e09825821 Parents: 3559b5d Author: Aled Sage <[email protected]> Authored: Thu Jul 23 22:46:46 2015 -0700 Committer: Aled Sage <[email protected]> Committed: Thu Jul 23 22:46:46 2015 -0700 ---------------------------------------------------------------------- .../BrooklynLauncherRebindCatalogTest.java | 30 ++++++++++++++------ 1 file changed, 22 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/40c39756/usage/launcher/src/test/java/brooklyn/launcher/BrooklynLauncherRebindCatalogTest.java ---------------------------------------------------------------------- diff --git a/usage/launcher/src/test/java/brooklyn/launcher/BrooklynLauncherRebindCatalogTest.java b/usage/launcher/src/test/java/brooklyn/launcher/BrooklynLauncherRebindCatalogTest.java index 8cf5354..70ce776 100644 --- a/usage/launcher/src/test/java/brooklyn/launcher/BrooklynLauncherRebindCatalogTest.java +++ b/usage/launcher/src/test/java/brooklyn/launcher/BrooklynLauncherRebindCatalogTest.java @@ -19,13 +19,20 @@ package brooklyn.launcher; import java.io.File; -import java.util.Collection; +import java.util.List; import javax.annotation.Nullable; import org.testng.Assert; +import org.testng.annotations.AfterMethod; import org.testng.annotations.Test; +import com.google.common.base.Function; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Iterables; +import com.google.common.collect.Lists; +import com.google.common.io.Files; + import brooklyn.catalog.BrooklynCatalog; import brooklyn.catalog.CatalogItem; import brooklyn.catalog.internal.CatalogInitialization; @@ -34,11 +41,6 @@ import brooklyn.test.entity.LocalManagementContextForTests; import brooklyn.util.ResourceUtils; import brooklyn.util.os.Os; -import com.google.common.base.Function; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Iterables; -import com.google.common.io.Files; - public class BrooklynLauncherRebindCatalogTest { private static final String TEST_VERSION = "test-version"; @@ -47,13 +49,25 @@ public class BrooklynLauncherRebindCatalogTest { private static final Iterable<String> EXPECTED_DEFAULT_IDS = ImmutableSet.of("one:" + TEST_VERSION, "two:" + TEST_VERSION); private static final Iterable<String> EXPECTED_ADDED_IDS = ImmutableSet.of("three:" + TEST_VERSION, "four:" + TEST_VERSION); + private List<BrooklynLauncher> launchers = Lists.newCopyOnWriteArrayList(); + + @AfterMethod(alwaysRun=true) + public void tearDown() throws Exception { + for (BrooklynLauncher launcher : launchers) { + launcher.terminate(); + } + launchers.clear(); + } + private BrooklynLauncher newLauncherForTests(String persistenceDir) { CatalogInitialization catalogInitialization = new CatalogInitialization(CATALOG_INITIAL, false, null, false); BrooklynLauncher launcher = BrooklynLauncher.newInstance() .brooklynProperties(LocalManagementContextForTests.builder(true).buildProperties()) .catalogInitialization(catalogInitialization) .persistMode(PersistMode.AUTO) - .persistenceDir(persistenceDir); + .persistenceDir(persistenceDir) + .webconsole(false); + launchers.add(launcher); return launcher; } @@ -70,7 +84,7 @@ public class BrooklynLauncherRebindCatalogTest { catalog.deleteCatalogItem("one", TEST_VERSION); catalog.deleteCatalogItem("two", TEST_VERSION); - Assert.assertEquals(((Collection) catalog.getCatalogItems()).size(), 0); + Assert.assertEquals(Iterables.size(catalog.getCatalogItems()), 0); catalog.addItems(new ResourceUtils(this).getResourceAsString(CATALOG_ADDITIONS));
