Repository: brooklyn-server Updated Branches: refs/heads/master 37308909a -> e25832b26
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/52f9ebdd/software/base/src/test/java/org/apache/brooklyn/entity/software/base/SoftwareProcessSshDriverIntegrationTest.java ---------------------------------------------------------------------- diff --git a/software/base/src/test/java/org/apache/brooklyn/entity/software/base/SoftwareProcessSshDriverIntegrationTest.java b/software/base/src/test/java/org/apache/brooklyn/entity/software/base/SoftwareProcessSshDriverIntegrationTest.java index fbcba68..41b588d 100644 --- a/software/base/src/test/java/org/apache/brooklyn/entity/software/base/SoftwareProcessSshDriverIntegrationTest.java +++ b/software/base/src/test/java/org/apache/brooklyn/entity/software/base/SoftwareProcessSshDriverIntegrationTest.java @@ -35,11 +35,8 @@ import org.apache.brooklyn.api.entity.EntitySpec; import org.apache.brooklyn.api.entity.ImplementedBy; import org.apache.brooklyn.api.location.LocationSpec; import org.apache.brooklyn.core.entity.BrooklynConfigKeys; -import org.apache.brooklyn.core.entity.Entities; -import org.apache.brooklyn.core.entity.factory.ApplicationBuilder; import org.apache.brooklyn.core.entity.trait.Startable; -import org.apache.brooklyn.core.mgmt.internal.LocalManagementContext; -import org.apache.brooklyn.core.test.entity.TestApplication; +import org.apache.brooklyn.core.test.BrooklynAppLiveTestSupport; import org.apache.brooklyn.location.localhost.LocalhostMachineProvisioningLocation; import org.apache.brooklyn.location.ssh.SshMachineLocation; import org.apache.brooklyn.util.collections.MutableMap; @@ -61,36 +58,40 @@ import com.google.common.io.ByteSource; import com.google.common.io.Files; -public class SoftwareProcessSshDriverIntegrationTest { +// TODO Does it really need to be a live test? When converting from ApplicationBuilder, preserved +// existing behaviour of using the live BrooklynProperties. +public class SoftwareProcessSshDriverIntegrationTest extends BrooklynAppLiveTestSupport { - private LocalManagementContext managementContext; private LocalhostMachineProvisioningLocation localhost; private SshMachineLocation machine127; - private TestApplication app; private File tempDataDir; @BeforeMethod(alwaysRun=true) + @Override public void setUp() throws Exception { + super.setUp(); tempDataDir = Files.createTempDir(); - managementContext = new LocalManagementContext(); - localhost = managementContext.getLocationManager().createLocation(LocationSpec.create(LocalhostMachineProvisioningLocation.class)); - machine127 = managementContext.getLocationManager().createLocation(LocationSpec.create(SshMachineLocation.class) + localhost = app.newLocalhostProvisioningLocation(); + machine127 = mgmt.getLocationManager().createLocation(LocationSpec.create(SshMachineLocation.class) .configure("address", "localhost")); - app = ApplicationBuilder.newManagedApp(TestApplication.class, managementContext); } @AfterMethod(alwaysRun=true) + @Override public void tearDown() throws Exception { - if (app != null) Entities.destroyAll(app.getManagementContext()); - if (tempDataDir != null) Os.deleteRecursively(tempDataDir); + try { + super.tearDown(); + } finally { + if (tempDataDir != null) Os.deleteRecursively(tempDataDir); + } } // Integration test because requires ssh'ing (and takes about 5 seconds) // See also SoftwareProcessEntityTest.testCustomInstallDirX for a lot more mocked variants @Test(groups="Integration") public void testCanInstallMultipleVersionsOnSameMachine() throws Exception { - managementContext.getBrooklynProperties().put(BrooklynConfigKeys.ONBOX_BASE_DIR, tempDataDir.getAbsolutePath()); + mgmt.getBrooklynProperties().put(BrooklynConfigKeys.ONBOX_BASE_DIR, tempDataDir.getAbsolutePath()); MyService entity = app.createAndManageChild(EntitySpec.create(MyService.class) .configure(SoftwareProcess.SUGGESTED_VERSION, "0.1.0")); @@ -140,7 +141,7 @@ public class SoftwareProcessSshDriverIntegrationTest { @Test(groups="Integration") @Deprecated public void testMachineInCustomFromDataDir() throws Exception { - managementContext.getBrooklynProperties().put(BrooklynConfigKeys.BROOKLYN_DATA_DIR, tempDataDir.getAbsolutePath()); + mgmt.getBrooklynProperties().put(BrooklynConfigKeys.BROOKLYN_DATA_DIR, tempDataDir.getAbsolutePath()); MyService entity = app.createAndManageChild(EntitySpec.create(MyService.class)); app.start(ImmutableList.of(machine127)); http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/52f9ebdd/software/base/src/test/java/org/apache/brooklyn/entity/software/base/VanillaWindowsProcessWinrmExitStatusLiveTest.java ---------------------------------------------------------------------- diff --git a/software/base/src/test/java/org/apache/brooklyn/entity/software/base/VanillaWindowsProcessWinrmExitStatusLiveTest.java b/software/base/src/test/java/org/apache/brooklyn/entity/software/base/VanillaWindowsProcessWinrmExitStatusLiveTest.java index c6eb94c..b410449 100644 --- a/software/base/src/test/java/org/apache/brooklyn/entity/software/base/VanillaWindowsProcessWinrmExitStatusLiveTest.java +++ b/software/base/src/test/java/org/apache/brooklyn/entity/software/base/VanillaWindowsProcessWinrmExitStatusLiveTest.java @@ -26,7 +26,6 @@ import org.apache.brooklyn.core.entity.Attributes; import org.apache.brooklyn.core.entity.BrooklynConfigKeys; import org.apache.brooklyn.core.entity.Entities; import org.apache.brooklyn.core.entity.EntityAsserts; -import org.apache.brooklyn.core.entity.factory.ApplicationBuilder; import org.apache.brooklyn.core.entity.lifecycle.Lifecycle; import org.apache.brooklyn.core.internal.BrooklynProperties; import org.apache.brooklyn.core.mgmt.internal.ManagementContextInternal; @@ -83,7 +82,7 @@ public class VanillaWindowsProcessWinrmExitStatusLiveTest { public void setUp() throws Exception { EntitySpec<TestApplication> appSpec = EntitySpec.create(TestApplication.class) .configure(BrooklynConfigKeys.SKIP_ON_BOX_BASE_DIR_RESOLUTION, true); - app = ApplicationBuilder.newManagedApp(appSpec, mgmt); + app = mgmt.getEntityManager().createEntity(appSpec); } @AfterMethod(alwaysRun=true) http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/52f9ebdd/software/base/src/test/java/org/apache/brooklyn/entity/software/base/VanillaWindowsProcessWinrmStreamsLiveTest.java ---------------------------------------------------------------------- diff --git a/software/base/src/test/java/org/apache/brooklyn/entity/software/base/VanillaWindowsProcessWinrmStreamsLiveTest.java b/software/base/src/test/java/org/apache/brooklyn/entity/software/base/VanillaWindowsProcessWinrmStreamsLiveTest.java index fdc4c59..e72e67f 100644 --- a/software/base/src/test/java/org/apache/brooklyn/entity/software/base/VanillaWindowsProcessWinrmStreamsLiveTest.java +++ b/software/base/src/test/java/org/apache/brooklyn/entity/software/base/VanillaWindowsProcessWinrmStreamsLiveTest.java @@ -24,7 +24,6 @@ import org.apache.brooklyn.api.entity.EntitySpec; import org.apache.brooklyn.api.location.MachineProvisioningLocation; import org.apache.brooklyn.core.entity.BrooklynConfigKeys; import org.apache.brooklyn.core.entity.Entities; -import org.apache.brooklyn.core.entity.factory.ApplicationBuilder; import org.apache.brooklyn.core.test.entity.TestApplication; import org.apache.brooklyn.entity.software.base.test.location.WindowsTestFixture; import org.apache.brooklyn.location.winrm.WinRmMachineLocation; @@ -70,7 +69,7 @@ public class VanillaWindowsProcessWinrmStreamsLiveTest extends AbstractSoftwareP @BeforeMethod(alwaysRun = true) @Override public void setUp() throws Exception { - app = ApplicationBuilder.newManagedApp(TestApplication.class, mgmt); + app = mgmt.getEntityManager().createEntity(EntitySpec.create(TestApplication.class)); } @AfterMethod(alwaysRun = true) http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/52f9ebdd/software/base/src/test/java/org/apache/brooklyn/entity/software/base/lifecycle/SoftwareProcessDriverCopyResourcesTest.java ---------------------------------------------------------------------- diff --git a/software/base/src/test/java/org/apache/brooklyn/entity/software/base/lifecycle/SoftwareProcessDriverCopyResourcesTest.java b/software/base/src/test/java/org/apache/brooklyn/entity/software/base/lifecycle/SoftwareProcessDriverCopyResourcesTest.java index b16b54b..b54e5c0 100644 --- a/software/base/src/test/java/org/apache/brooklyn/entity/software/base/lifecycle/SoftwareProcessDriverCopyResourcesTest.java +++ b/software/base/src/test/java/org/apache/brooklyn/entity/software/base/lifecycle/SoftwareProcessDriverCopyResourcesTest.java @@ -31,15 +31,10 @@ import org.apache.brooklyn.api.entity.EntitySpec; import org.apache.brooklyn.api.location.Location; import org.apache.brooklyn.api.sensor.AttributeSensor; import org.apache.brooklyn.core.config.MapConfigKey; -import org.apache.brooklyn.core.entity.Entities; -import org.apache.brooklyn.core.entity.factory.ApplicationBuilder; -import org.apache.brooklyn.core.mgmt.internal.LocalManagementContext; -import org.apache.brooklyn.core.test.entity.LocalManagementContextForTests; -import org.apache.brooklyn.core.test.entity.TestApplication; +import org.apache.brooklyn.core.test.BrooklynAppUnitTestSupport; import org.apache.brooklyn.entity.software.base.EmptySoftwareProcess; import org.apache.brooklyn.entity.software.base.SoftwareProcess; import org.apache.brooklyn.entity.software.base.VanillaSoftwareProcess; -import org.apache.brooklyn.location.localhost.LocalhostMachineProvisioningLocation; import org.apache.brooklyn.util.os.Os; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; @@ -50,25 +45,22 @@ import com.google.common.collect.ImmutableMap; import com.google.common.io.Files; @Test(groups="Integration") -public class SoftwareProcessDriverCopyResourcesTest { +public class SoftwareProcessDriverCopyResourcesTest extends BrooklynAppUnitTestSupport { File installDir; File runDir; File sourceFileDir; File sourceTemplateDir; - private LocalManagementContext managementContext; - private TestApplication app; - private Location location; private static final String TEST_CONTENT_FILE = "testing123"; private static final String TEST_CONTENT_TEMPLATE = "id=${entity.id}"; @BeforeMethod(alwaysRun = true) - public void setUp() { - managementContext = new LocalManagementContextForTests(); - app = ApplicationBuilder.newManagedApp(TestApplication.class, managementContext); + @Override + public void setUp() throws Exception { + super.setUp(); sourceFileDir = Os.newTempDir(getClass().getSimpleName()); sourceTemplateDir = Os.newTempDir(getClass().getSimpleName()); @@ -76,7 +68,7 @@ public class SoftwareProcessDriverCopyResourcesTest { installDir = Os.newTempDir(getClass().getSimpleName()); runDir = Os.newTempDir(getClass().getSimpleName()); - location = new LocalhostMachineProvisioningLocation(); + location = app.newLocalhostProvisioningLocation(); } @Test @@ -131,13 +123,14 @@ public class SoftwareProcessDriverCopyResourcesTest { } @AfterMethod(alwaysRun = true) - public void tearDown() { - app.stop(); - if (managementContext != null) Entities.destroyAll(managementContext); - app = null; - Os.deleteRecursively(sourceFileDir); - Os.deleteRecursively(sourceTemplateDir); - Os.deleteRecursively(installDir); - Os.deleteRecursively(runDir); + public void tearDown() throws Exception { + try { + super.tearDown(); + } finally { + Os.deleteRecursively(sourceFileDir); + Os.deleteRecursively(sourceTemplateDir); + Os.deleteRecursively(installDir); + Os.deleteRecursively(runDir); + } } }
