@Test public void testLocationEntityConfigurationWithWrongTypeAndNoDefault() throws Exception { Map<String, EntitySpec<?>> map = ImmutableMap.<String, EntitySpec<?>>builder() .put("OtherLocation", EntitySpec.create(TestEntity.class).configure(TestEntity.CONF_NAME, "Other")) .build(); entity = app.addChild(EntitySpec.create(LocationEntity.class) .configure(LocationEntity.LOCATION_ENTITY_SPEC_MAP, map)); app.start(ImmutableList.of(loc1)); assertTrue(entity.getChildren().isEmpty()); EntityAsserts.assertAttributeEqualsEventually(entity, LocationEntity.LOCATION_TYPE, "SimulatedLocation"); EntityAsserts.assertAttributeEqualsEventually(entity, LocationEntity.LOCATION_ENTITY, null); EntityAsserts.assertEntityHealthy(entity); }
@Test public void testLocationEntityConfigurationWithDefault() throws Exception { Map<String, EntitySpec<?>> map = ImmutableMap.<String, EntitySpec<?>>builder() .put("default", EntitySpec.create(TestEntity.class).configure(TestEntity.CONF_NAME, "Default")) .build(); entity = app.addChild(EntitySpec.create(LocationEntity.class) .configure(LocationEntity.LOCATION_ENTITY_SPEC_MAP, map)); app.start(ImmutableList.of(loc1)); assertEquals(entity.getChildren().size(), 1); Entity child = Iterables.getOnlyElement(entity.getChildren()); assertTrue(child instanceof TestEntity); EntityAsserts.assertAttributeEqualsEventually(entity, LocationEntity.LOCATION_TYPE, "SimulatedLocation"); EntityAsserts.assertAttributeEqualsEventually(entity, LocationEntity.LOCATION_ENTITY, child); EntityAsserts.assertConfigEquals(child, TestEntity.CONF_NAME, "Default"); EntityAsserts.assertEntityHealthy(child); EntityAsserts.assertEntityHealthy(entity); }
@Test public void testLocationEntityConfigurationWithWrongTypeAndDefault() throws Exception { Map<String, EntitySpec<?>> map = ImmutableMap.<String, EntitySpec<?>>builder() .put("OtherLocation", EntitySpec.create(TestEntity.class).configure(TestEntity.CONF_NAME, "Other")) .put("default", EntitySpec.create(TestEntity.class).configure(TestEntity.CONF_NAME, "Default")) .build(); entity = app.addChild(EntitySpec.create(LocationEntity.class) .configure(LocationEntity.LOCATION_ENTITY_SPEC_MAP, map)); app.start(ImmutableList.of(loc1)); assertEquals(entity.getChildren().size(), 1); Entity child = Iterables.getOnlyElement(entity.getChildren()); assertTrue(child instanceof TestEntity); EntityAsserts.assertAttributeEqualsEventually(entity, LocationEntity.LOCATION_TYPE, "SimulatedLocation"); EntityAsserts.assertAttributeEqualsEventually(entity, LocationEntity.LOCATION_ENTITY, child); EntityAsserts.assertConfigEquals(child, TestEntity.CONF_NAME, "Default"); EntityAsserts.assertEntityHealthy(child); EntityAsserts.assertEntityHealthy(entity); }
@Test public void testLocationEntityConfigurationWithType() throws Exception { Map<String, EntitySpec<?>> map = ImmutableMap.<String, EntitySpec<?>>builder() .put("OtherLocation", EntitySpec.create(TestEntity.class).configure(TestEntity.CONF_NAME, "Other")) .put("SimulatedLocation", EntitySpec.create(TestEntity.class).configure(TestEntity.CONF_NAME, "Simulated")) .put("default", EntitySpec.create(TestEntity.class).configure(TestEntity.CONF_NAME, "Default")) .build(); entity = app.addChild(EntitySpec.create(LocationEntity.class) .configure(LocationEntity.LOCATION_ENTITY_SPEC_MAP, map)); app.start(ImmutableList.of(loc1)); assertEquals(entity.getChildren().size(), 1); Entity child = Iterables.getOnlyElement(entity.getChildren()); assertTrue(child instanceof TestEntity); EntityAsserts.assertAttributeEqualsEventually(entity, LocationEntity.LOCATION_TYPE, "SimulatedLocation"); EntityAsserts.assertAttributeEqualsEventually(entity, LocationEntity.LOCATION_ENTITY, child); EntityAsserts.assertConfigEquals(child, TestEntity.CONF_NAME, "Simulated"); EntityAsserts.assertEntityHealthy(child); EntityAsserts.assertEntityHealthy(entity); }
@Test public void testLocationEntityConfigurationWithCountry() throws Exception { Map<String, EntitySpec<?>> map = ImmutableMap.<String, EntitySpec<?>>builder() .put("UK", EntitySpec.create(TestEntity.class).configure(TestEntity.CONF_NAME, "United Kingdom")) .put("DE", EntitySpec.create(TestEntity.class).configure(TestEntity.CONF_NAME, "Germany")) .put("default", EntitySpec.create(TestEntity.class).configure(TestEntity.CONF_NAME, "default")) .build(); entity = app.addChild(EntitySpec.create(LocationEntity.class) .configure(LocationEntity.LOCATION_ENTITY_SPEC_MAP, map)); app.start(ImmutableList.of(loc3)); assertEquals(entity.getChildren().size(), 1); Entity child = Iterables.getOnlyElement(entity.getChildren()); assertTrue(child instanceof TestEntity); EntityAsserts.assertAttributeEqualsEventually(entity, LocationEntity.LOCATION_TYPE, "SimulatedLocation"); EntityAsserts.assertAttributeEqualsEventually(entity, LocationEntity.LOCATION_COUNTRY_CODES, ImmutableSet.of("UK", "US")); EntityAsserts.assertAttributeEqualsEventually(entity, LocationEntity.LOCATION_ENTITY, child); EntityAsserts.assertConfigEquals(child, TestEntity.CONF_NAME, "United Kingdom"); EntityAsserts.assertEntityHealthy(child); EntityAsserts.assertEntityHealthy(entity); }
@Test public void testLocationEntityConfigurationWithProvider() throws Exception { Map<String, EntitySpec<?>> map = ImmutableMap.<String, EntitySpec<?>>builder() .put("cloud", EntitySpec.create(TestEntity.class).configure(TestEntity.CONF_NAME, "Cloud")) .put("other", EntitySpec.create(TestEntity.class).configure(TestEntity.CONF_NAME, "Other")) .put("default", EntitySpec.create(TestEntity.class).configure(TestEntity.CONF_NAME, "Default")) .build(); entity = app.addChild(EntitySpec.create(LocationEntity.class) .configure(LocationEntity.LOCATION_ENTITY_SPEC_MAP, map)); app.start(ImmutableList.of(loc2)); assertEquals(entity.getChildren().size(), 1); Entity child = Iterables.getOnlyElement(entity.getChildren()); assertTrue(child instanceof TestEntity); EntityAsserts.assertAttributeEqualsEventually(entity, LocationEntity.LOCATION_TYPE, "SimulatedLocation"); EntityAsserts.assertAttributeEqualsEventually(entity, LocationEntity.LOCATION_PROVIDER, "cloud"); EntityAsserts.assertAttributeEqualsEventually(entity, LocationEntity.LOCATION_ENTITY, child); EntityAsserts.assertConfigEquals(child, TestEntity.CONF_NAME, "Cloud"); EntityAsserts.assertEntityHealthy(child); EntityAsserts.assertEntityHealthy(entity); }
protected void runStartStopSequentiallyIsQuick(final ProvisioningLocation<?> loc) throws Exception { final EmptySoftwareProcess entity = app.createAndManageChild(EntitySpec.create(EmptySoftwareProcess.class) .configure(BrooklynConfigKeys.SKIP_ON_BOX_BASE_DIR_RESOLUTION, true)); executeInLimitedTime(new Callable<Void>() { @Override public Void call() { app.start(ImmutableList.of(loc)); return null; } }, Asserts.DEFAULT_LONG_TIMEOUT.toMilliseconds(), TimeUnit.MILLISECONDS); EntityAsserts.assertEntityHealthy(entity); assertEquals(entity.getAttribute(AttributesInternal.INTERNAL_PROVISIONING_TASK_STATE), null); assertEquals(entity.getAttribute(MachineLifecycleEffectorTasks.INTERNAL_PROVISIONED_MACHINE), Machines.findUniqueMachineLocation(entity.getLocations(), SshMachineLocation.class).get()); executeInLimitedTime(new Callable<Void>() { @Override public Void call() { Entities.destroy(app); return null; } }, Asserts.DEFAULT_LONG_TIMEOUT.toMilliseconds(), TimeUnit.MILLISECONDS); assertEquals(app.getAttribute(Attributes.SERVICE_STATE_ACTUAL), Lifecycle.STOPPED); assertEquals(app.getAttribute(Attributes.SERVICE_STATE_EXPECTED).getState(), Lifecycle.STOPPED); assertEquals(entity.getAttribute(AttributesInternal.INTERNAL_PROVISIONING_TASK_STATE), null); assertEquals(entity.getAttribute(MachineLifecycleEffectorTasks.INTERNAL_PROVISIONED_MACHINE), null); }