Java Code Examples for org.apache.brooklyn.core.test.entity.TestApplication#stop()
The following examples show how to use
org.apache.brooklyn.core.test.entity.TestApplication#stop() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ServerPoolTest.java From brooklyn-server with Apache License 2.0 | 6 votes |
@Test public void testDeployReleaseDeploy() { TestApplication app = createAppWithChildren(getInitialPoolSize()); TestApplication app2 = createAppWithChildren(1); app.start(ImmutableList.of(pool.getDynamicLocation())); EntityAsserts.assertAttributeEqualsEventually(app, Attributes.SERVICE_UP, true); assertAvailableCountEventuallyEquals(0); assertNoMachinesAvailableForApp(app2); app.stop(); assertFalse(app.getAttribute(Attributes.SERVICE_UP)); assertAvailableCountEventuallyEquals(getInitialPoolSize()); app2.start(ImmutableList.of(pool.getDynamicLocation())); EntityAsserts.assertAttributeEqualsEventually(app2, Attributes.SERVICE_UP, true); assertAvailableCountEventuallyEquals(getInitialPoolSize() - 1); assertClaimedCountEventuallyEquals(1); }
Example 2
Source File: AbstractApplicationLegacyTest.java From brooklyn-server with Apache License 2.0 | 6 votes |
@Test(groups="Integration") // Implicit creation is deprecaed and can be removed, plus the test is slow public void testStartAndStopUnmanagedAppAutomanagesTheAppAndChildren() throws Exception { // deliberately unmanaged TestApplication app2 = new TestApplicationImpl(); TestEntity child = new TestEntityImpl(app2); assertFalse(Entities.isManaged(app2)); assertFalse(Entities.isManaged(child)); app2.invoke(AbstractApplication.START, ImmutableMap.of("locations", locs)).get(); extraMgmtContexts.add(app2.getManagementContext()); assertTrue(Entities.isManaged(app2)); assertTrue(Entities.isManaged(child)); assertEquals(child.getCallHistory(), ImmutableList.of("start")); assertNull(mgmt.getEntityManager().getEntity(app2.getId()), "app2 shouldn't be managed by mgmt"); assertNull(mgmt.getEntityManager().getEntity(child.getId()), "child shouldn't be managed by mgmt"); assertNotEquals(mgmt, app2.getManagementContext(), "managing app2 creates a new management context"); assertEquals(app2.getManagementContext().getEntityManager().getEntity(app2.getId()), app2); assertEquals(app2.getManagementContext().getEntityManager().getEntity(child.getId()), child); app2.stop(); assertEquals(child.getCallHistory(), ImmutableList.of("start", "stop")); assertFalse(Entities.isManaged(child)); assertFalse(Entities.isManaged(app2)); }
Example 3
Source File: UsageResourceTest.java From brooklyn-server with Apache License 2.0 | 5 votes |
@Test public void testListMachinesUsageForApp() throws Exception { Location location = getManagementContext().getLocationManager().createLocation(LocationSpec.create(DynamicLocalhostMachineProvisioningLocation.class)); TestApplication app = getManagementContext().getEntityManager().createEntity(EntitySpec.create(TestApplication.class)); SoftwareProcessEntityTest.MyService entity = app.createAndManageChild(org.apache.brooklyn.api.entity.EntitySpec.create(SoftwareProcessEntityTest.MyService.class)); String appId = app.getId(); Calendar preStart = new GregorianCalendar(); app.start(ImmutableList.of(location)); Calendar postStart = new GregorianCalendar(); Location machine = Iterables.getOnlyElement(entity.getLocations()); // For running machine Response response = client().path("/usage/machines").query("application", appId).get(); assertEquals(response.getStatus(), Response.Status.OK.getStatusCode()); Iterable<UsageStatistics> usages = response.readEntity(new GenericType<List<UsageStatistics>>() {}); UsageStatistics usage = Iterables.getOnlyElement(usages); assertMachineUsage(usage, app.getId(), machine.getId(), ImmutableList.of(Status.ACCEPTED), roundDown(preStart), postStart); // Stop the machine Calendar preStop = new GregorianCalendar(); app.stop(); Calendar postStop = new GregorianCalendar(); // Deleted machine still returned, if in time range response = client().path("/usage/machines").query("application", appId).get(); assertEquals(response.getStatus(), Response.Status.OK.getStatusCode()); usages = response.readEntity(new GenericType<List<UsageStatistics>>() {}); usage = Iterables.getOnlyElement(usages); assertMachineUsage(usage, app.getId(), machine.getId(), ImmutableList.of(Status.ACCEPTED, Status.DESTROYED), roundDown(preStart), postStop); assertMachineUsage(ImmutableList.copyOf(usage.getStatistics()).subList(1,2), appId, machine.getId(), ImmutableList.of(Status.DESTROYED), roundDown(preStop), postStop); // Terminated machines ignored if terminated since start-time long futureTime = postStop.getTime().getTime()+1; waitForFuture(futureTime); response = client().path("/usage/applications").query("start", futureTime).get(); assertEquals(response.getStatus(), Response.Status.OK.getStatusCode()); usages = response.readEntity(new GenericType<List<UsageStatistics>>() {}); assertTrue(Iterables.isEmpty(usages), "usages="+usages); }