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/01/15 00:54:24 UTC
[10/24] incubator-brooklyn git commit: moved new QA classes to
correct location
moved new QA classes to correct location
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/be6612cf
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/be6612cf
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/be6612cf
Branch: refs/heads/master
Commit: be6612cf409bc498e67c734397520e5c8d4d812f
Parents: e2392c3
Author: Graeme-Miller <gr...@cloudsoftcorp.com>
Authored: Thu Jan 14 13:44:51 2016 +0000
Committer: Graeme-Miller <gr...@cloudsoftcorp.com>
Committed: Thu Jan 14 13:44:51 2016 +0000
----------------------------------------------------------------------
...infrastructuredeploymenttestcase-entity.yaml | 11 +
.../entities/loopovergroupmembers-entity.yaml | 6 +
.../InfrastructureDeploymentTestCaseTest.java | 267 +++++++++++++++++
.../LoopOverGroupMembersTestCaseTest.java | 286 +++++++++++++++++++
.../framework/entity/TestInfrastructure.java | 31 ++
.../entity/TestInfrastructureImpl.java | 46 +++
...infrastructuredeploymenttestcase-entity.yaml | 11 -
.../entities/loopovergroupmembers-entity.yaml | 6 -
.../InfrastructureDeploymentTestCaseTest.java | 267 -----------------
.../LoopOverGroupMembersTestCaseTest.java | 286 -------------------
.../framework/entity/TestInfrastructure.java | 31 --
.../entity/TestInfrastructureImpl.java | 46 ---
12 files changed, 647 insertions(+), 647 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/be6612cf/brooklyn-docs/guide/yaml/example_yaml/entities/infrastructuredeploymenttestcase-entity.yaml
----------------------------------------------------------------------
diff --git a/brooklyn-docs/guide/yaml/example_yaml/entities/infrastructuredeploymenttestcase-entity.yaml b/brooklyn-docs/guide/yaml/example_yaml/entities/infrastructuredeploymenttestcase-entity.yaml
new file mode 100644
index 0000000..6b344da
--- /dev/null
+++ b/brooklyn-docs/guide/yaml/example_yaml/entities/infrastructuredeploymenttestcase-entity.yaml
@@ -0,0 +1,11 @@
+- type: org.apache.brooklyn.test.framework.InfrastructureDeploymentTestCase
+ brooklyn.config:
+ infrastructure.deployment.location.sensor: entity.dynamicLocation
+ infrastructure.deployment.spec:
+ $brooklyn:entitySpec:
+ - type: docker-cloud-calico
+ ...
+ infrastructure.deployment.entity.specs:
+ - $brooklyn:entitySpec:
+ type: org.apache.brooklyn.entity.software.base.VanillaSoftwareProcess
+ ...
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/be6612cf/brooklyn-docs/guide/yaml/example_yaml/entities/loopovergroupmembers-entity.yaml
----------------------------------------------------------------------
diff --git a/brooklyn-docs/guide/yaml/example_yaml/entities/loopovergroupmembers-entity.yaml b/brooklyn-docs/guide/yaml/example_yaml/entities/loopovergroupmembers-entity.yaml
new file mode 100644
index 0000000..e97ab4c
--- /dev/null
+++ b/brooklyn-docs/guide/yaml/example_yaml/entities/loopovergroupmembers-entity.yaml
@@ -0,0 +1,6 @@
+- type: org.apache.brooklyn.test.framework.LoopOverGroupMembersTestCase
+ target: $brooklyn:component("infrastructure").component("child", "DockerHosts")
+ testSpec:
+ $brooklyn:entitySpec:
+ type: org.apache.brooklyn.test.framework.TestSensor
+ ...
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/be6612cf/brooklyn-server/test-framework/src/test/java/org/apache/brooklyn/test/framework/InfrastructureDeploymentTestCaseTest.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/test-framework/src/test/java/org/apache/brooklyn/test/framework/InfrastructureDeploymentTestCaseTest.java b/brooklyn-server/test-framework/src/test/java/org/apache/brooklyn/test/framework/InfrastructureDeploymentTestCaseTest.java
new file mode 100644
index 0000000..fa0e864
--- /dev/null
+++ b/brooklyn-server/test-framework/src/test/java/org/apache/brooklyn/test/framework/InfrastructureDeploymentTestCaseTest.java
@@ -0,0 +1,267 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.brooklyn.test.framework;
+
+import static org.apache.brooklyn.core.entity.trait.Startable.SERVICE_UP;
+import static org.apache.brooklyn.test.Asserts.fail;
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.util.Collection;
+import java.util.List;
+
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.reflect.TypeToken;
+
+import org.apache.brooklyn.api.entity.Entity;
+import org.apache.brooklyn.api.entity.EntitySpec;
+import org.apache.brooklyn.api.entity.ImplementedBy;
+import org.apache.brooklyn.api.location.Location;
+import org.apache.brooklyn.api.location.LocationSpec;
+import org.apache.brooklyn.api.mgmt.ManagementContext;
+import org.apache.brooklyn.core.config.ConfigKeys;
+import org.apache.brooklyn.core.entity.Entities;
+import org.apache.brooklyn.core.sensor.AttributeSensorAndConfigKey;
+import org.apache.brooklyn.core.test.entity.TestApplication;
+import org.apache.brooklyn.entity.software.base.EmptySoftwareProcess;
+import org.apache.brooklyn.entity.software.base.SoftwareProcess;
+import org.apache.brooklyn.entity.stock.BasicApplication;
+import org.apache.brooklyn.location.localhost.LocalhostMachineProvisioningLocation;
+import org.apache.brooklyn.test.framework.entity.TestInfrastructure;
+import org.apache.brooklyn.util.exceptions.Exceptions;
+import org.apache.brooklyn.util.text.Identifiers;
+
+/**
+ * @author Graeme Miller on 27/10/2015.
+ */
+public class InfrastructureDeploymentTestCaseTest {
+
+ private TestApplication app;
+ private ManagementContext managementContext;
+ private LocalhostMachineProvisioningLocation loc;
+ private LocalhostMachineProvisioningLocation infrastructureLoc;
+ private String LOC_NAME = "location";
+ private String INFRASTRUCTURE_LOC_NAME = "Infrastructure location";
+
+ private static final AttributeSensorAndConfigKey<Location, Location> DEPLOYMENT_LOCATION_SENSOR =
+ ConfigKeys.newSensorAndConfigKey(
+ new TypeToken<Location>() {
+ },
+ "deploymentLocationSensor", "The location to deploy to");
+
+ @BeforeMethod
+ public void setup() {
+ app = TestApplication.Factory.newManagedInstanceForTests();
+ managementContext = app.getManagementContext();
+
+ loc = managementContext.getLocationManager()
+ .createLocation(LocationSpec.create(LocalhostMachineProvisioningLocation.class)
+ .configure("name", LOC_NAME));
+
+ infrastructureLoc = managementContext.getLocationManager()
+ .createLocation(LocationSpec.create(LocalhostMachineProvisioningLocation.class)
+ .configure("name", INFRASTRUCTURE_LOC_NAME));
+ }
+
+ @AfterMethod(alwaysRun = true)
+ public void tearDown() throws Exception {
+ if (app != null) Entities.destroyAll(app.getManagementContext());
+ }
+
+ @Test
+ public void testVanilla() {
+ EntitySpec<TestInfrastructure> infrastructureSpec = EntitySpec.create(TestInfrastructure.class);
+ infrastructureSpec.configure(DEPLOYMENT_LOCATION_SENSOR, infrastructureLoc);
+
+ List<EntitySpec<? extends SoftwareProcess>> testSpecs = ImmutableList.<EntitySpec<? extends SoftwareProcess>>of(EntitySpec.create(EmptySoftwareProcess.class));
+
+ InfrastructureDeploymentTestCase infrastructureDeploymentTestCase = app.createAndManageChild(EntitySpec.create(InfrastructureDeploymentTestCase.class));
+ infrastructureDeploymentTestCase.config().set(InfrastructureDeploymentTestCase.INFRASTRUCTURE_SPEC, infrastructureSpec);
+ infrastructureDeploymentTestCase.config().set(InfrastructureDeploymentTestCase.ENTITY_SPEC_TO_DEPLOY, testSpecs);
+ infrastructureDeploymentTestCase.config().set(InfrastructureDeploymentTestCase.DEPLOYMENT_LOCATION_SENSOR_NAME, DEPLOYMENT_LOCATION_SENSOR.getName());
+
+ app.start(ImmutableList.of(loc));
+
+ assertThat(infrastructureDeploymentTestCase.sensors().get(SERVICE_UP)).isTrue();
+ assertThat(infrastructureDeploymentTestCase.getChildren().size()).isEqualTo(2);
+
+ boolean seenInfrastructure = false;
+ boolean seenEntity = false;
+
+ for (Entity entity : infrastructureDeploymentTestCase.getChildren()) {
+ if (entity instanceof BasicApplication) {
+ assertThat(entity.getLocations().size()).isEqualTo(1);
+ assertThat(entity.getLocations().iterator().next().getDisplayName()).isEqualTo(LOC_NAME);
+ assertThat(entity.sensors().get(SERVICE_UP)).isTrue();
+
+ seenInfrastructure = true;
+ } else if (entity instanceof EmptySoftwareProcess) {
+ assertThat(entity.getLocations().size()).isEqualTo(1);
+ assertThat(entity.getLocations().iterator().next().getDisplayName()).isEqualTo(INFRASTRUCTURE_LOC_NAME);
+ assertThat(entity.sensors().get(SERVICE_UP)).isTrue();
+
+ seenEntity = true;
+ } else {
+ fail("Unknown child of InfrastructureDeploymentTestCase");
+ }
+ }
+
+ assertThat(seenInfrastructure).isTrue();
+ assertThat(seenEntity).isTrue();
+ }
+
+ @Test
+ public void testMultipleSpec() {
+ EntitySpec<TestInfrastructure> infrastructureSpec = EntitySpec.create(TestInfrastructure.class);
+ infrastructureSpec.configure(DEPLOYMENT_LOCATION_SENSOR, infrastructureLoc);
+
+ List<EntitySpec<? extends SoftwareProcess>> testSpecs = ImmutableList.<EntitySpec<? extends SoftwareProcess>>of
+ (EntitySpec.create(EmptySoftwareProcess.class),
+ (EntitySpec.create(EmptySoftwareProcess.class)));
+
+ InfrastructureDeploymentTestCase infrastructureDeploymentTestCase = app.createAndManageChild(EntitySpec.create(InfrastructureDeploymentTestCase.class));
+ infrastructureDeploymentTestCase.config().set(InfrastructureDeploymentTestCase.INFRASTRUCTURE_SPEC, infrastructureSpec);
+ infrastructureDeploymentTestCase.config().set(InfrastructureDeploymentTestCase.ENTITY_SPEC_TO_DEPLOY, testSpecs);
+ infrastructureDeploymentTestCase.config().set(InfrastructureDeploymentTestCase.DEPLOYMENT_LOCATION_SENSOR_NAME, DEPLOYMENT_LOCATION_SENSOR.getName());
+
+ app.start(ImmutableList.of(loc));
+
+ assertThat(infrastructureDeploymentTestCase.sensors().get(SERVICE_UP)).isTrue();
+ assertThat(infrastructureDeploymentTestCase.getChildren().size()).isEqualTo(3);
+
+ boolean seenInfrastructure = false;
+ int entitiesSeen = 0;
+
+ for (Entity entity : infrastructureDeploymentTestCase.getChildren()) {
+ if (entity instanceof BasicApplication) {
+ assertThat(entity.getLocations().size()).isEqualTo(1);
+ assertThat(entity.getLocations().iterator().next().getDisplayName()).isEqualTo(LOC_NAME);
+ assertThat(entity.sensors().get(SERVICE_UP)).isTrue();
+
+ seenInfrastructure = true;
+ } else if (entity instanceof EmptySoftwareProcess) {
+ assertThat(entity.getLocations().size()).isEqualTo(1);
+ assertThat(entity.getLocations().iterator().next().getDisplayName()).isEqualTo(INFRASTRUCTURE_LOC_NAME);
+ assertThat(entity.sensors().get(SERVICE_UP)).isTrue();
+
+ entitiesSeen++;
+ } else {
+ fail("Unknown child of InfrastructureDeploymentTestCase");
+ }
+ }
+
+ assertThat(seenInfrastructure).isTrue();
+ assertThat(entitiesSeen).isEqualTo(2);
+ }
+
+ @Test
+ public void testNoInfrastructureSpec() {
+ List<EntitySpec<? extends SoftwareProcess>> testSpecs = ImmutableList.<EntitySpec<? extends SoftwareProcess>>of(EntitySpec.create(EmptySoftwareProcess.class));
+
+ InfrastructureDeploymentTestCase infrastructureDeploymentTestCase = app.createAndManageChild(EntitySpec.create(InfrastructureDeploymentTestCase.class));
+ infrastructureDeploymentTestCase.config().set(InfrastructureDeploymentTestCase.ENTITY_SPEC_TO_DEPLOY, testSpecs);
+ infrastructureDeploymentTestCase.config().set(InfrastructureDeploymentTestCase.DEPLOYMENT_LOCATION_SENSOR_NAME, DEPLOYMENT_LOCATION_SENSOR.getName());
+
+ try {
+ app.start(ImmutableList.of(app.newSimulatedLocation()));
+ fail("Should have thrown execption");
+ } catch (Throwable throwable) {
+ Throwable firstInteresting = Exceptions.getFirstInteresting(throwable);
+ assertThat(firstInteresting).isNotNull();
+ assertThat(throwable).isNotNull();
+ assertThat(firstInteresting).isInstanceOf(IllegalArgumentException.class);
+ }
+
+ assertThat(infrastructureDeploymentTestCase.sensors().get(SERVICE_UP)).isFalse();
+ }
+
+ @Test
+ public void testNoEntitySpec() {
+ EntitySpec<TestInfrastructure> infrastructureSpec = EntitySpec.create(TestInfrastructure.class);
+ infrastructureSpec.configure(DEPLOYMENT_LOCATION_SENSOR, infrastructureLoc);
+
+ InfrastructureDeploymentTestCase infrastructureDeploymentTestCase = app.createAndManageChild(EntitySpec.create(InfrastructureDeploymentTestCase.class));
+ infrastructureDeploymentTestCase.config().set(InfrastructureDeploymentTestCase.INFRASTRUCTURE_SPEC, infrastructureSpec);
+ infrastructureDeploymentTestCase.config().set(InfrastructureDeploymentTestCase.DEPLOYMENT_LOCATION_SENSOR_NAME, DEPLOYMENT_LOCATION_SENSOR.getName());
+
+ try {
+ app.start(ImmutableList.of(app.newSimulatedLocation()));
+ fail("Should have thrown execption");
+ } catch (Throwable throwable) {
+ Throwable firstInteresting = Exceptions.getFirstInteresting(throwable);
+ assertThat(firstInteresting).isNotNull();
+ assertThat(throwable).isNotNull();
+ assertThat(firstInteresting).isInstanceOf(IllegalArgumentException.class);
+ }
+
+ assertThat(infrastructureDeploymentTestCase.sensors().get(SERVICE_UP)).isFalse();
+ }
+
+ @Test
+ public void testNoDeploymentLocation() {
+ EntitySpec<TestInfrastructure> infrastructureSpec = EntitySpec.create(TestInfrastructure.class);
+ infrastructureSpec.configure(DEPLOYMENT_LOCATION_SENSOR, infrastructureLoc);
+
+ List<EntitySpec<? extends SoftwareProcess>> testSpecs = ImmutableList.<EntitySpec<? extends SoftwareProcess>>of(EntitySpec.create(EmptySoftwareProcess.class));
+
+ InfrastructureDeploymentTestCase infrastructureDeploymentTestCase = app.createAndManageChild(EntitySpec.create(InfrastructureDeploymentTestCase.class));
+ infrastructureDeploymentTestCase.config().set(InfrastructureDeploymentTestCase.INFRASTRUCTURE_SPEC, infrastructureSpec);
+ infrastructureDeploymentTestCase.config().set(InfrastructureDeploymentTestCase.ENTITY_SPEC_TO_DEPLOY, testSpecs);
+
+ try {
+ app.start(ImmutableList.of(app.newSimulatedLocation()));
+ fail("Should have thrown execption");
+ } catch (Throwable throwable) {
+ Throwable firstInteresting = Exceptions.getFirstInteresting(throwable);
+ assertThat(firstInteresting).isNotNull();
+ assertThat(throwable).isNotNull();
+ assertThat(firstInteresting).isInstanceOf(IllegalArgumentException.class);
+ }
+
+ assertThat(infrastructureDeploymentTestCase.sensors().get(SERVICE_UP)).isFalse();
+ }
+
+ @Test
+ public void testInfrastrucutreHasNoLocation() {
+ EntitySpec<TestInfrastructure> infrastructureSpec = EntitySpec.create(TestInfrastructure.class);
+
+ List<EntitySpec<? extends SoftwareProcess>> testSpecs = ImmutableList.<EntitySpec<? extends SoftwareProcess>>of(EntitySpec.create(EmptySoftwareProcess.class));
+
+ InfrastructureDeploymentTestCase infrastructureDeploymentTestCase = app.createAndManageChild(EntitySpec.create(InfrastructureDeploymentTestCase.class));
+ infrastructureDeploymentTestCase.config().set(InfrastructureDeploymentTestCase.INFRASTRUCTURE_SPEC, infrastructureSpec);
+ infrastructureDeploymentTestCase.config().set(InfrastructureDeploymentTestCase.ENTITY_SPEC_TO_DEPLOY, testSpecs);
+ infrastructureDeploymentTestCase.config().set(InfrastructureDeploymentTestCase.DEPLOYMENT_LOCATION_SENSOR_NAME, DEPLOYMENT_LOCATION_SENSOR.getName());
+
+ try {
+ app.start(ImmutableList.of(app.newSimulatedLocation()));
+ fail("Should have thrown execption");
+ } catch (Throwable throwable) {
+ Throwable firstInteresting = Exceptions.getFirstInteresting(throwable);
+ assertThat(firstInteresting).isNotNull();
+ assertThat(throwable).isNotNull();
+ assertThat(firstInteresting).isInstanceOf(IllegalArgumentException.class);
+ }
+
+ assertThat(infrastructureDeploymentTestCase.sensors().get(SERVICE_UP)).isFalse();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/be6612cf/brooklyn-server/test-framework/src/test/java/org/apache/brooklyn/test/framework/LoopOverGroupMembersTestCaseTest.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/test-framework/src/test/java/org/apache/brooklyn/test/framework/LoopOverGroupMembersTestCaseTest.java b/brooklyn-server/test-framework/src/test/java/org/apache/brooklyn/test/framework/LoopOverGroupMembersTestCaseTest.java
new file mode 100644
index 0000000..39c85c5
--- /dev/null
+++ b/brooklyn-server/test-framework/src/test/java/org/apache/brooklyn/test/framework/LoopOverGroupMembersTestCaseTest.java
@@ -0,0 +1,286 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.brooklyn.test.framework;
+
+import static org.apache.brooklyn.core.entity.trait.Startable.SERVICE_UP;
+import static org.apache.brooklyn.test.Asserts.fail;
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+
+import org.apache.brooklyn.api.entity.Entity;
+import org.apache.brooklyn.api.entity.EntitySpec;
+import org.apache.brooklyn.api.entity.Group;
+import org.apache.brooklyn.api.location.LocationSpec;
+import org.apache.brooklyn.api.mgmt.ManagementContext;
+import org.apache.brooklyn.core.config.ConfigKeys;
+import org.apache.brooklyn.core.entity.Entities;
+import org.apache.brooklyn.core.sensor.AttributeSensorAndConfigKey;
+import org.apache.brooklyn.core.test.entity.TestApplication;
+import org.apache.brooklyn.entity.group.DynamicGroup;
+import org.apache.brooklyn.entity.software.base.EmptySoftwareProcess;
+import org.apache.brooklyn.location.localhost.LocalhostMachineProvisioningLocation;
+import org.apache.brooklyn.util.collections.MutableSet;
+import org.apache.brooklyn.util.exceptions.Exceptions;
+import org.apache.brooklyn.util.text.Identifiers;
+
+/**
+ * @author Graeme Miller on 27/10/2015.
+ */
+public class LoopOverGroupMembersTestCaseTest {
+
+ private TestApplication app;
+ private Group testGroup;
+ private ManagementContext managementContext;
+ private LocalhostMachineProvisioningLocation loc;
+ private String testId;
+ private final String SENSOR_VAL = "Hello World!";
+
+ private static final AttributeSensorAndConfigKey<String, String> STRING_SENSOR = ConfigKeys.newSensorAndConfigKey(String.class, "string-sensor", "String Sensor");
+
+ @BeforeMethod
+ public void setup() {
+ testId = Identifiers.makeRandomId(8);
+ app = TestApplication.Factory.newManagedInstanceForTests();
+ managementContext = app.getManagementContext();
+
+ loc = managementContext.getLocationManager()
+ .createLocation(LocationSpec.create(LocalhostMachineProvisioningLocation.class)
+ .configure("name", testId));
+
+ testGroup = app.createAndManageChild(EntitySpec.create(DynamicGroup.class));
+ }
+
+ @AfterMethod(alwaysRun = true)
+ public void tearDown() throws Exception {
+ if (app != null) Entities.destroyAll(app.getManagementContext());
+ }
+
+ @Test
+ public void testOneChildWhichPasses() {
+ EmptySoftwareProcess emptySoftwareProcess = addEmptySoftwareProcessToGroup();
+ EntitySpec<TestSensor> testSpec = createPassingTestSensorSpec();
+
+ LoopOverGroupMembersTestCase loopOverGroupMembersTestCase = app.createAndManageChild(EntitySpec.create(LoopOverGroupMembersTestCase.class));
+ loopOverGroupMembersTestCase.config().set(LoopOverGroupMembersTestCase.TEST_SPEC, testSpec);
+ loopOverGroupMembersTestCase.config().set(LoopOverGroupMembersTestCase.TARGET_ENTITY, testGroup);
+
+ app.start(ImmutableList.of(app.newSimulatedLocation()));
+
+ assertThat(loopOverGroupMembersTestCase.getChildren().size()).isEqualTo(1);
+ assertThat(loopOverGroupMembersTestCase.sensors().get(SERVICE_UP)).isTrue();
+
+ Entity loopChildEntity = loopOverGroupMembersTestCase.getChildren().iterator().next();
+ assertThat(loopChildEntity).isInstanceOf(TestSensor.class);
+ assertThat(loopChildEntity.sensors().get(SERVICE_UP)).isTrue();
+ assertThat(loopChildEntity.config().get(LoopOverGroupMembersTestCase.TARGET_ENTITY)).isEqualTo(emptySoftwareProcess);
+ }
+
+ @Test
+ public void testMultipleChildrenWhichPass() {
+ Set<EmptySoftwareProcess> emptySoftwareProcesses = addMultipleEmptySoftwareProcessesToGroup(4);
+ EntitySpec<TestSensor> testSpec = createPassingTestSensorSpec();
+
+ LoopOverGroupMembersTestCase loopOverGroupMembersTestCase = app.createAndManageChild(EntitySpec.create(LoopOverGroupMembersTestCase.class));
+ loopOverGroupMembersTestCase.config().set(LoopOverGroupMembersTestCase.TEST_SPEC, testSpec);
+ loopOverGroupMembersTestCase.config().set(LoopOverGroupMembersTestCase.TARGET_ENTITY, testGroup);
+
+ app.start(ImmutableList.of(app.newSimulatedLocation()));
+
+ assertThat(loopOverGroupMembersTestCase.getChildren().size()).isEqualTo(4);
+ assertThat(loopOverGroupMembersTestCase.sensors().get(SERVICE_UP)).isTrue();
+
+ for (Entity loopChildEntity : loopOverGroupMembersTestCase.getChildren()) {
+ assertThat(loopChildEntity).isInstanceOf(TestSensor.class);
+ assertThat(loopChildEntity.sensors().get(SERVICE_UP)).isTrue();
+ assertThat(emptySoftwareProcesses.contains(loopChildEntity.config().get(LoopOverGroupMembersTestCase.TARGET_ENTITY))).isTrue();
+ emptySoftwareProcesses.remove(loopChildEntity.config().get(LoopOverGroupMembersTestCase.TARGET_ENTITY));
+ }
+ }
+
+ @Test
+ public void testMultipleChildrenWhichAllFail() {
+ Set<EmptySoftwareProcess> emptySoftwareProcesses = addMultipleEmptySoftwareProcessesToGroup(4);
+ EntitySpec<TestSensor> testSpec = createFailingTestSensorSpec();
+
+ LoopOverGroupMembersTestCase loopOverGroupMembersTestCase = app.createAndManageChild(EntitySpec.create(LoopOverGroupMembersTestCase.class));
+ loopOverGroupMembersTestCase.config().set(LoopOverGroupMembersTestCase.TEST_SPEC, testSpec);
+ loopOverGroupMembersTestCase.config().set(LoopOverGroupMembersTestCase.TARGET_ENTITY, testGroup);
+
+ app.start(ImmutableList.of(app.newSimulatedLocation()));
+
+ assertThat(loopOverGroupMembersTestCase.getChildren().size()).isEqualTo(4);
+ assertThat(loopOverGroupMembersTestCase.sensors().get(SERVICE_UP)).isFalse();
+
+ for (Entity loopChildEntity : loopOverGroupMembersTestCase.getChildren()) {
+ assertThat(loopChildEntity).isInstanceOf(TestSensor.class);
+ assertThat(loopChildEntity.sensors().get(SERVICE_UP)).isFalse();
+ assertThat(emptySoftwareProcesses.contains(loopChildEntity.config().get(LoopOverGroupMembersTestCase.TARGET_ENTITY))).isTrue();
+ emptySoftwareProcesses.remove(loopChildEntity.config().get(LoopOverGroupMembersTestCase.TARGET_ENTITY));
+ }
+ }
+
+ @Test
+ public void testMultipleChildrenOneOfWhichFails() {
+ Set<EmptySoftwareProcess> emptySoftwareProcesses = addMultipleEmptySoftwareProcessesToGroup(3);
+ EntitySpec<TestSensor> testSpec = createPassingTestSensorSpec();
+
+ EmptySoftwareProcess failingProcess = testGroup.addMemberChild(EntitySpec.create(EmptySoftwareProcess.class));
+ failingProcess.sensors().set(STRING_SENSOR, "THIS STRING WILL CAUSE SENSOR TEST TO FAIL");
+
+ LoopOverGroupMembersTestCase loopOverGroupMembersTestCase = app.createAndManageChild(EntitySpec.create(LoopOverGroupMembersTestCase.class));
+ loopOverGroupMembersTestCase.config().set(LoopOverGroupMembersTestCase.TEST_SPEC, testSpec);
+ loopOverGroupMembersTestCase.config().set(LoopOverGroupMembersTestCase.TARGET_ENTITY, testGroup);
+
+ app.start(ImmutableList.of(app.newSimulatedLocation()));
+
+ assertThat(loopOverGroupMembersTestCase.getChildren().size()).isEqualTo(4);
+ assertThat(loopOverGroupMembersTestCase.sensors().get(SERVICE_UP)).isFalse();
+
+ for (Entity loopChildEntity : loopOverGroupMembersTestCase.getChildren()) {
+ assertThat(loopChildEntity).isInstanceOf(TestSensor.class);
+
+ Entity targetedEntity = loopChildEntity.config().get(LoopOverGroupMembersTestCase.TARGET_ENTITY);
+
+ if (targetedEntity.equals(failingProcess)) {
+ assertThat(loopChildEntity.sensors().get(SERVICE_UP)).isFalse();
+ } else if (emptySoftwareProcesses.contains(targetedEntity)) {
+ assertThat(loopChildEntity.sensors().get(SERVICE_UP)).isTrue();
+ emptySoftwareProcesses.remove(targetedEntity);
+ } else {
+ fail("Targeted entity not recognized");
+ }
+ }
+ }
+
+ @Test
+ public void testOneChildWhichFails() {
+ EmptySoftwareProcess emptySoftwareProcess = addEmptySoftwareProcessToGroup();
+ EntitySpec<TestSensor> testSpec = createFailingTestSensorSpec();
+
+ LoopOverGroupMembersTestCase loopOverGroupMembersTestCase = app.createAndManageChild(EntitySpec.create(LoopOverGroupMembersTestCase.class));
+ loopOverGroupMembersTestCase.config().set(LoopOverGroupMembersTestCase.TEST_SPEC, testSpec);
+ loopOverGroupMembersTestCase.config().set(LoopOverGroupMembersTestCase.TARGET_ENTITY, testGroup);
+
+ app.start(ImmutableList.of(app.newSimulatedLocation()));
+
+ assertThat(loopOverGroupMembersTestCase.getChildren().size()).isEqualTo(1);
+ assertThat(loopOverGroupMembersTestCase.sensors().get(SERVICE_UP)).isFalse();
+
+ Entity loopChildEntity = loopOverGroupMembersTestCase.getChildren().iterator().next();
+ assertThat(loopChildEntity).isInstanceOf(TestSensor.class);
+ assertThat(loopChildEntity.sensors().get(SERVICE_UP)).isFalse();
+ assertThat(loopChildEntity.config().get(LoopOverGroupMembersTestCase.TARGET_ENTITY)).isEqualTo(emptySoftwareProcess);
+ }
+
+ //negative
+ // without test spec
+ // without target + taget id
+ // not a group
+
+ @Test
+ public void testNoTarget() {
+ EmptySoftwareProcess emptySoftwareProcess = addEmptySoftwareProcessToGroup();
+ EntitySpec<TestSensor> testSpec = createFailingTestSensorSpec();
+
+ LoopOverGroupMembersTestCase loopOverGroupMembersTestCase = app.createAndManageChild(EntitySpec.create(LoopOverGroupMembersTestCase.class));
+ loopOverGroupMembersTestCase.config().set(LoopOverGroupMembersTestCase.TEST_SPEC, testSpec);
+
+ app.start(ImmutableList.of(app.newSimulatedLocation()));
+
+ assertThat(loopOverGroupMembersTestCase.getChildren().size()).isEqualTo(0);
+ assertThat(loopOverGroupMembersTestCase.sensors().get(SERVICE_UP)).isFalse();
+ }
+
+ @Test
+ public void testNotTargetingGroup() {
+ EmptySoftwareProcess emptySoftwareProcess = addEmptySoftwareProcessToGroup();
+ EntitySpec<TestSensor> testSpec = createFailingTestSensorSpec();
+
+ LoopOverGroupMembersTestCase loopOverGroupMembersTestCase = app.createAndManageChild(EntitySpec.create(LoopOverGroupMembersTestCase.class));
+ loopOverGroupMembersTestCase.config().set(LoopOverGroupMembersTestCase.TEST_SPEC, testSpec);
+ loopOverGroupMembersTestCase.config().set(LoopOverGroupMembersTestCase.TARGET_ENTITY, app);
+
+ app.start(ImmutableList.of(app.newSimulatedLocation()));
+
+ assertThat(loopOverGroupMembersTestCase.getChildren().size()).isEqualTo(0);
+ assertThat(loopOverGroupMembersTestCase.sensors().get(SERVICE_UP)).isFalse();
+ }
+
+ @Test
+ public void testNoSpec() {
+ EmptySoftwareProcess emptySoftwareProcess = addEmptySoftwareProcessToGroup();
+ EntitySpec<TestSensor> testSpec = createFailingTestSensorSpec();
+
+ LoopOverGroupMembersTestCase loopOverGroupMembersTestCase = app.createAndManageChild(EntitySpec.create(LoopOverGroupMembersTestCase.class));
+ loopOverGroupMembersTestCase.config().set(LoopOverGroupMembersTestCase.TARGET_ENTITY, testGroup);
+
+ app.start(ImmutableList.of(app.newSimulatedLocation()));
+
+ assertThat(loopOverGroupMembersTestCase.getChildren().size()).isEqualTo(0);
+ assertThat(loopOverGroupMembersTestCase.sensors().get(SERVICE_UP)).isFalse();
+ }
+
+ //UTILITY METHODS
+ private EntitySpec<TestSensor> createFailingTestSensorSpec() {
+ List<Map<String, Object>> assertions = ImmutableList.<Map<String, Object>>of(
+ ImmutableMap.<String, Object>of(TestFrameworkAssertions.EQUAL_TO, "THIS IS THE WRONG STRING")
+ );
+
+ return EntitySpec.create(TestSensor.class)
+ .configure(TestSensor.SENSOR_NAME, STRING_SENSOR.getName())
+ .configure(TestSensor.ASSERTIONS, assertions);
+ }
+
+ private EntitySpec<TestSensor> createPassingTestSensorSpec() {
+ List<Map<String, Object>> assertions = ImmutableList.<Map<String, Object>>of(
+ ImmutableMap.<String, Object>of(TestFrameworkAssertions.EQUAL_TO, SENSOR_VAL)
+ );
+
+ return EntitySpec.create(TestSensor.class)
+ .configure(TestSensor.SENSOR_NAME, STRING_SENSOR.getName())
+ .configure(TestSensor.ASSERTIONS, assertions);
+ }
+
+ private Set<EmptySoftwareProcess> addMultipleEmptySoftwareProcessesToGroup(int number) {
+ MutableSet<EmptySoftwareProcess> softwareProcesses = MutableSet.<EmptySoftwareProcess>of();
+ for (int i = 0; i < number; i++) {
+ softwareProcesses.add(addEmptySoftwareProcessToGroup());
+ }
+
+ return softwareProcesses;
+ }
+
+ private EmptySoftwareProcess addEmptySoftwareProcessToGroup() {
+ EmptySoftwareProcess emptySoftwareProcess = testGroup.addMemberChild(EntitySpec.create(EmptySoftwareProcess.class));
+ emptySoftwareProcess.sensors().set(STRING_SENSOR, SENSOR_VAL);
+ return emptySoftwareProcess;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/be6612cf/brooklyn-server/test-framework/src/test/java/org/apache/brooklyn/test/framework/entity/TestInfrastructure.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/test-framework/src/test/java/org/apache/brooklyn/test/framework/entity/TestInfrastructure.java b/brooklyn-server/test-framework/src/test/java/org/apache/brooklyn/test/framework/entity/TestInfrastructure.java
new file mode 100644
index 0000000..abcd679
--- /dev/null
+++ b/brooklyn-server/test-framework/src/test/java/org/apache/brooklyn/test/framework/entity/TestInfrastructure.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.brooklyn.test.framework.entity;
+
+import org.apache.brooklyn.api.entity.ImplementedBy;
+import org.apache.brooklyn.entity.stock.BasicApplication;
+
+/**
+ * Created by graememiller on 17/12/2015.
+ */
+
+@ImplementedBy(TestInfrastructureImpl.class)
+public interface TestInfrastructure extends BasicApplication {
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/be6612cf/brooklyn-server/test-framework/src/test/java/org/apache/brooklyn/test/framework/entity/TestInfrastructureImpl.java
----------------------------------------------------------------------
diff --git a/brooklyn-server/test-framework/src/test/java/org/apache/brooklyn/test/framework/entity/TestInfrastructureImpl.java b/brooklyn-server/test-framework/src/test/java/org/apache/brooklyn/test/framework/entity/TestInfrastructureImpl.java
new file mode 100644
index 0000000..6ec0638
--- /dev/null
+++ b/brooklyn-server/test-framework/src/test/java/org/apache/brooklyn/test/framework/entity/TestInfrastructureImpl.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.brooklyn.test.framework.entity;
+
+import java.util.Collection;
+
+import com.google.common.reflect.TypeToken;
+
+import org.apache.brooklyn.api.location.Location;
+import org.apache.brooklyn.core.config.ConfigKeys;
+import org.apache.brooklyn.core.sensor.AttributeSensorAndConfigKey;
+import org.apache.brooklyn.entity.stock.BasicApplicationImpl;
+
+/**
+ * Created by graememiller on 17/12/2015.
+ */
+public class TestInfrastructureImpl extends BasicApplicationImpl implements TestInfrastructure {
+
+ private final AttributeSensorAndConfigKey<Location, Location> DEPLOYMENT_LOCATION = ConfigKeys.newSensorAndConfigKey(
+ new TypeToken<Location>() {
+ },
+ "deploymentLocationSensor", "The location to deploy to");
+
+ @Override
+ public void postStart(Collection<? extends Location> locations) {
+ super.postStart(locations);
+ sensors().set(DEPLOYMENT_LOCATION, config().get(DEPLOYMENT_LOCATION));
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/be6612cf/docs/guide/yaml/test/example_yaml/entities/infrastructuredeploymenttestcase-entity.yaml
----------------------------------------------------------------------
diff --git a/docs/guide/yaml/test/example_yaml/entities/infrastructuredeploymenttestcase-entity.yaml b/docs/guide/yaml/test/example_yaml/entities/infrastructuredeploymenttestcase-entity.yaml
deleted file mode 100644
index 6b344da..0000000
--- a/docs/guide/yaml/test/example_yaml/entities/infrastructuredeploymenttestcase-entity.yaml
+++ /dev/null
@@ -1,11 +0,0 @@
-- type: org.apache.brooklyn.test.framework.InfrastructureDeploymentTestCase
- brooklyn.config:
- infrastructure.deployment.location.sensor: entity.dynamicLocation
- infrastructure.deployment.spec:
- $brooklyn:entitySpec:
- - type: docker-cloud-calico
- ...
- infrastructure.deployment.entity.specs:
- - $brooklyn:entitySpec:
- type: org.apache.brooklyn.entity.software.base.VanillaSoftwareProcess
- ...
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/be6612cf/docs/guide/yaml/test/example_yaml/entities/loopovergroupmembers-entity.yaml
----------------------------------------------------------------------
diff --git a/docs/guide/yaml/test/example_yaml/entities/loopovergroupmembers-entity.yaml b/docs/guide/yaml/test/example_yaml/entities/loopovergroupmembers-entity.yaml
deleted file mode 100644
index e97ab4c..0000000
--- a/docs/guide/yaml/test/example_yaml/entities/loopovergroupmembers-entity.yaml
+++ /dev/null
@@ -1,6 +0,0 @@
-- type: org.apache.brooklyn.test.framework.LoopOverGroupMembersTestCase
- target: $brooklyn:component("infrastructure").component("child", "DockerHosts")
- testSpec:
- $brooklyn:entitySpec:
- type: org.apache.brooklyn.test.framework.TestSensor
- ...
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/be6612cf/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/InfrastructureDeploymentTestCaseTest.java
----------------------------------------------------------------------
diff --git a/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/InfrastructureDeploymentTestCaseTest.java b/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/InfrastructureDeploymentTestCaseTest.java
deleted file mode 100644
index fa0e864..0000000
--- a/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/InfrastructureDeploymentTestCaseTest.java
+++ /dev/null
@@ -1,267 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.brooklyn.test.framework;
-
-import static org.apache.brooklyn.core.entity.trait.Startable.SERVICE_UP;
-import static org.apache.brooklyn.test.Asserts.fail;
-import static org.assertj.core.api.Assertions.assertThat;
-
-import java.util.Collection;
-import java.util.List;
-
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.reflect.TypeToken;
-
-import org.apache.brooklyn.api.entity.Entity;
-import org.apache.brooklyn.api.entity.EntitySpec;
-import org.apache.brooklyn.api.entity.ImplementedBy;
-import org.apache.brooklyn.api.location.Location;
-import org.apache.brooklyn.api.location.LocationSpec;
-import org.apache.brooklyn.api.mgmt.ManagementContext;
-import org.apache.brooklyn.core.config.ConfigKeys;
-import org.apache.brooklyn.core.entity.Entities;
-import org.apache.brooklyn.core.sensor.AttributeSensorAndConfigKey;
-import org.apache.brooklyn.core.test.entity.TestApplication;
-import org.apache.brooklyn.entity.software.base.EmptySoftwareProcess;
-import org.apache.brooklyn.entity.software.base.SoftwareProcess;
-import org.apache.brooklyn.entity.stock.BasicApplication;
-import org.apache.brooklyn.location.localhost.LocalhostMachineProvisioningLocation;
-import org.apache.brooklyn.test.framework.entity.TestInfrastructure;
-import org.apache.brooklyn.util.exceptions.Exceptions;
-import org.apache.brooklyn.util.text.Identifiers;
-
-/**
- * @author Graeme Miller on 27/10/2015.
- */
-public class InfrastructureDeploymentTestCaseTest {
-
- private TestApplication app;
- private ManagementContext managementContext;
- private LocalhostMachineProvisioningLocation loc;
- private LocalhostMachineProvisioningLocation infrastructureLoc;
- private String LOC_NAME = "location";
- private String INFRASTRUCTURE_LOC_NAME = "Infrastructure location";
-
- private static final AttributeSensorAndConfigKey<Location, Location> DEPLOYMENT_LOCATION_SENSOR =
- ConfigKeys.newSensorAndConfigKey(
- new TypeToken<Location>() {
- },
- "deploymentLocationSensor", "The location to deploy to");
-
- @BeforeMethod
- public void setup() {
- app = TestApplication.Factory.newManagedInstanceForTests();
- managementContext = app.getManagementContext();
-
- loc = managementContext.getLocationManager()
- .createLocation(LocationSpec.create(LocalhostMachineProvisioningLocation.class)
- .configure("name", LOC_NAME));
-
- infrastructureLoc = managementContext.getLocationManager()
- .createLocation(LocationSpec.create(LocalhostMachineProvisioningLocation.class)
- .configure("name", INFRASTRUCTURE_LOC_NAME));
- }
-
- @AfterMethod(alwaysRun = true)
- public void tearDown() throws Exception {
- if (app != null) Entities.destroyAll(app.getManagementContext());
- }
-
- @Test
- public void testVanilla() {
- EntitySpec<TestInfrastructure> infrastructureSpec = EntitySpec.create(TestInfrastructure.class);
- infrastructureSpec.configure(DEPLOYMENT_LOCATION_SENSOR, infrastructureLoc);
-
- List<EntitySpec<? extends SoftwareProcess>> testSpecs = ImmutableList.<EntitySpec<? extends SoftwareProcess>>of(EntitySpec.create(EmptySoftwareProcess.class));
-
- InfrastructureDeploymentTestCase infrastructureDeploymentTestCase = app.createAndManageChild(EntitySpec.create(InfrastructureDeploymentTestCase.class));
- infrastructureDeploymentTestCase.config().set(InfrastructureDeploymentTestCase.INFRASTRUCTURE_SPEC, infrastructureSpec);
- infrastructureDeploymentTestCase.config().set(InfrastructureDeploymentTestCase.ENTITY_SPEC_TO_DEPLOY, testSpecs);
- infrastructureDeploymentTestCase.config().set(InfrastructureDeploymentTestCase.DEPLOYMENT_LOCATION_SENSOR_NAME, DEPLOYMENT_LOCATION_SENSOR.getName());
-
- app.start(ImmutableList.of(loc));
-
- assertThat(infrastructureDeploymentTestCase.sensors().get(SERVICE_UP)).isTrue();
- assertThat(infrastructureDeploymentTestCase.getChildren().size()).isEqualTo(2);
-
- boolean seenInfrastructure = false;
- boolean seenEntity = false;
-
- for (Entity entity : infrastructureDeploymentTestCase.getChildren()) {
- if (entity instanceof BasicApplication) {
- assertThat(entity.getLocations().size()).isEqualTo(1);
- assertThat(entity.getLocations().iterator().next().getDisplayName()).isEqualTo(LOC_NAME);
- assertThat(entity.sensors().get(SERVICE_UP)).isTrue();
-
- seenInfrastructure = true;
- } else if (entity instanceof EmptySoftwareProcess) {
- assertThat(entity.getLocations().size()).isEqualTo(1);
- assertThat(entity.getLocations().iterator().next().getDisplayName()).isEqualTo(INFRASTRUCTURE_LOC_NAME);
- assertThat(entity.sensors().get(SERVICE_UP)).isTrue();
-
- seenEntity = true;
- } else {
- fail("Unknown child of InfrastructureDeploymentTestCase");
- }
- }
-
- assertThat(seenInfrastructure).isTrue();
- assertThat(seenEntity).isTrue();
- }
-
- @Test
- public void testMultipleSpec() {
- EntitySpec<TestInfrastructure> infrastructureSpec = EntitySpec.create(TestInfrastructure.class);
- infrastructureSpec.configure(DEPLOYMENT_LOCATION_SENSOR, infrastructureLoc);
-
- List<EntitySpec<? extends SoftwareProcess>> testSpecs = ImmutableList.<EntitySpec<? extends SoftwareProcess>>of
- (EntitySpec.create(EmptySoftwareProcess.class),
- (EntitySpec.create(EmptySoftwareProcess.class)));
-
- InfrastructureDeploymentTestCase infrastructureDeploymentTestCase = app.createAndManageChild(EntitySpec.create(InfrastructureDeploymentTestCase.class));
- infrastructureDeploymentTestCase.config().set(InfrastructureDeploymentTestCase.INFRASTRUCTURE_SPEC, infrastructureSpec);
- infrastructureDeploymentTestCase.config().set(InfrastructureDeploymentTestCase.ENTITY_SPEC_TO_DEPLOY, testSpecs);
- infrastructureDeploymentTestCase.config().set(InfrastructureDeploymentTestCase.DEPLOYMENT_LOCATION_SENSOR_NAME, DEPLOYMENT_LOCATION_SENSOR.getName());
-
- app.start(ImmutableList.of(loc));
-
- assertThat(infrastructureDeploymentTestCase.sensors().get(SERVICE_UP)).isTrue();
- assertThat(infrastructureDeploymentTestCase.getChildren().size()).isEqualTo(3);
-
- boolean seenInfrastructure = false;
- int entitiesSeen = 0;
-
- for (Entity entity : infrastructureDeploymentTestCase.getChildren()) {
- if (entity instanceof BasicApplication) {
- assertThat(entity.getLocations().size()).isEqualTo(1);
- assertThat(entity.getLocations().iterator().next().getDisplayName()).isEqualTo(LOC_NAME);
- assertThat(entity.sensors().get(SERVICE_UP)).isTrue();
-
- seenInfrastructure = true;
- } else if (entity instanceof EmptySoftwareProcess) {
- assertThat(entity.getLocations().size()).isEqualTo(1);
- assertThat(entity.getLocations().iterator().next().getDisplayName()).isEqualTo(INFRASTRUCTURE_LOC_NAME);
- assertThat(entity.sensors().get(SERVICE_UP)).isTrue();
-
- entitiesSeen++;
- } else {
- fail("Unknown child of InfrastructureDeploymentTestCase");
- }
- }
-
- assertThat(seenInfrastructure).isTrue();
- assertThat(entitiesSeen).isEqualTo(2);
- }
-
- @Test
- public void testNoInfrastructureSpec() {
- List<EntitySpec<? extends SoftwareProcess>> testSpecs = ImmutableList.<EntitySpec<? extends SoftwareProcess>>of(EntitySpec.create(EmptySoftwareProcess.class));
-
- InfrastructureDeploymentTestCase infrastructureDeploymentTestCase = app.createAndManageChild(EntitySpec.create(InfrastructureDeploymentTestCase.class));
- infrastructureDeploymentTestCase.config().set(InfrastructureDeploymentTestCase.ENTITY_SPEC_TO_DEPLOY, testSpecs);
- infrastructureDeploymentTestCase.config().set(InfrastructureDeploymentTestCase.DEPLOYMENT_LOCATION_SENSOR_NAME, DEPLOYMENT_LOCATION_SENSOR.getName());
-
- try {
- app.start(ImmutableList.of(app.newSimulatedLocation()));
- fail("Should have thrown execption");
- } catch (Throwable throwable) {
- Throwable firstInteresting = Exceptions.getFirstInteresting(throwable);
- assertThat(firstInteresting).isNotNull();
- assertThat(throwable).isNotNull();
- assertThat(firstInteresting).isInstanceOf(IllegalArgumentException.class);
- }
-
- assertThat(infrastructureDeploymentTestCase.sensors().get(SERVICE_UP)).isFalse();
- }
-
- @Test
- public void testNoEntitySpec() {
- EntitySpec<TestInfrastructure> infrastructureSpec = EntitySpec.create(TestInfrastructure.class);
- infrastructureSpec.configure(DEPLOYMENT_LOCATION_SENSOR, infrastructureLoc);
-
- InfrastructureDeploymentTestCase infrastructureDeploymentTestCase = app.createAndManageChild(EntitySpec.create(InfrastructureDeploymentTestCase.class));
- infrastructureDeploymentTestCase.config().set(InfrastructureDeploymentTestCase.INFRASTRUCTURE_SPEC, infrastructureSpec);
- infrastructureDeploymentTestCase.config().set(InfrastructureDeploymentTestCase.DEPLOYMENT_LOCATION_SENSOR_NAME, DEPLOYMENT_LOCATION_SENSOR.getName());
-
- try {
- app.start(ImmutableList.of(app.newSimulatedLocation()));
- fail("Should have thrown execption");
- } catch (Throwable throwable) {
- Throwable firstInteresting = Exceptions.getFirstInteresting(throwable);
- assertThat(firstInteresting).isNotNull();
- assertThat(throwable).isNotNull();
- assertThat(firstInteresting).isInstanceOf(IllegalArgumentException.class);
- }
-
- assertThat(infrastructureDeploymentTestCase.sensors().get(SERVICE_UP)).isFalse();
- }
-
- @Test
- public void testNoDeploymentLocation() {
- EntitySpec<TestInfrastructure> infrastructureSpec = EntitySpec.create(TestInfrastructure.class);
- infrastructureSpec.configure(DEPLOYMENT_LOCATION_SENSOR, infrastructureLoc);
-
- List<EntitySpec<? extends SoftwareProcess>> testSpecs = ImmutableList.<EntitySpec<? extends SoftwareProcess>>of(EntitySpec.create(EmptySoftwareProcess.class));
-
- InfrastructureDeploymentTestCase infrastructureDeploymentTestCase = app.createAndManageChild(EntitySpec.create(InfrastructureDeploymentTestCase.class));
- infrastructureDeploymentTestCase.config().set(InfrastructureDeploymentTestCase.INFRASTRUCTURE_SPEC, infrastructureSpec);
- infrastructureDeploymentTestCase.config().set(InfrastructureDeploymentTestCase.ENTITY_SPEC_TO_DEPLOY, testSpecs);
-
- try {
- app.start(ImmutableList.of(app.newSimulatedLocation()));
- fail("Should have thrown execption");
- } catch (Throwable throwable) {
- Throwable firstInteresting = Exceptions.getFirstInteresting(throwable);
- assertThat(firstInteresting).isNotNull();
- assertThat(throwable).isNotNull();
- assertThat(firstInteresting).isInstanceOf(IllegalArgumentException.class);
- }
-
- assertThat(infrastructureDeploymentTestCase.sensors().get(SERVICE_UP)).isFalse();
- }
-
- @Test
- public void testInfrastrucutreHasNoLocation() {
- EntitySpec<TestInfrastructure> infrastructureSpec = EntitySpec.create(TestInfrastructure.class);
-
- List<EntitySpec<? extends SoftwareProcess>> testSpecs = ImmutableList.<EntitySpec<? extends SoftwareProcess>>of(EntitySpec.create(EmptySoftwareProcess.class));
-
- InfrastructureDeploymentTestCase infrastructureDeploymentTestCase = app.createAndManageChild(EntitySpec.create(InfrastructureDeploymentTestCase.class));
- infrastructureDeploymentTestCase.config().set(InfrastructureDeploymentTestCase.INFRASTRUCTURE_SPEC, infrastructureSpec);
- infrastructureDeploymentTestCase.config().set(InfrastructureDeploymentTestCase.ENTITY_SPEC_TO_DEPLOY, testSpecs);
- infrastructureDeploymentTestCase.config().set(InfrastructureDeploymentTestCase.DEPLOYMENT_LOCATION_SENSOR_NAME, DEPLOYMENT_LOCATION_SENSOR.getName());
-
- try {
- app.start(ImmutableList.of(app.newSimulatedLocation()));
- fail("Should have thrown execption");
- } catch (Throwable throwable) {
- Throwable firstInteresting = Exceptions.getFirstInteresting(throwable);
- assertThat(firstInteresting).isNotNull();
- assertThat(throwable).isNotNull();
- assertThat(firstInteresting).isInstanceOf(IllegalArgumentException.class);
- }
-
- assertThat(infrastructureDeploymentTestCase.sensors().get(SERVICE_UP)).isFalse();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/be6612cf/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/LoopOverGroupMembersTestCaseTest.java
----------------------------------------------------------------------
diff --git a/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/LoopOverGroupMembersTestCaseTest.java b/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/LoopOverGroupMembersTestCaseTest.java
deleted file mode 100644
index 39c85c5..0000000
--- a/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/LoopOverGroupMembersTestCaseTest.java
+++ /dev/null
@@ -1,286 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.brooklyn.test.framework;
-
-import static org.apache.brooklyn.core.entity.trait.Startable.SERVICE_UP;
-import static org.apache.brooklyn.test.Asserts.fail;
-import static org.assertj.core.api.Assertions.assertThat;
-
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-
-import org.apache.brooklyn.api.entity.Entity;
-import org.apache.brooklyn.api.entity.EntitySpec;
-import org.apache.brooklyn.api.entity.Group;
-import org.apache.brooklyn.api.location.LocationSpec;
-import org.apache.brooklyn.api.mgmt.ManagementContext;
-import org.apache.brooklyn.core.config.ConfigKeys;
-import org.apache.brooklyn.core.entity.Entities;
-import org.apache.brooklyn.core.sensor.AttributeSensorAndConfigKey;
-import org.apache.brooklyn.core.test.entity.TestApplication;
-import org.apache.brooklyn.entity.group.DynamicGroup;
-import org.apache.brooklyn.entity.software.base.EmptySoftwareProcess;
-import org.apache.brooklyn.location.localhost.LocalhostMachineProvisioningLocation;
-import org.apache.brooklyn.util.collections.MutableSet;
-import org.apache.brooklyn.util.exceptions.Exceptions;
-import org.apache.brooklyn.util.text.Identifiers;
-
-/**
- * @author Graeme Miller on 27/10/2015.
- */
-public class LoopOverGroupMembersTestCaseTest {
-
- private TestApplication app;
- private Group testGroup;
- private ManagementContext managementContext;
- private LocalhostMachineProvisioningLocation loc;
- private String testId;
- private final String SENSOR_VAL = "Hello World!";
-
- private static final AttributeSensorAndConfigKey<String, String> STRING_SENSOR = ConfigKeys.newSensorAndConfigKey(String.class, "string-sensor", "String Sensor");
-
- @BeforeMethod
- public void setup() {
- testId = Identifiers.makeRandomId(8);
- app = TestApplication.Factory.newManagedInstanceForTests();
- managementContext = app.getManagementContext();
-
- loc = managementContext.getLocationManager()
- .createLocation(LocationSpec.create(LocalhostMachineProvisioningLocation.class)
- .configure("name", testId));
-
- testGroup = app.createAndManageChild(EntitySpec.create(DynamicGroup.class));
- }
-
- @AfterMethod(alwaysRun = true)
- public void tearDown() throws Exception {
- if (app != null) Entities.destroyAll(app.getManagementContext());
- }
-
- @Test
- public void testOneChildWhichPasses() {
- EmptySoftwareProcess emptySoftwareProcess = addEmptySoftwareProcessToGroup();
- EntitySpec<TestSensor> testSpec = createPassingTestSensorSpec();
-
- LoopOverGroupMembersTestCase loopOverGroupMembersTestCase = app.createAndManageChild(EntitySpec.create(LoopOverGroupMembersTestCase.class));
- loopOverGroupMembersTestCase.config().set(LoopOverGroupMembersTestCase.TEST_SPEC, testSpec);
- loopOverGroupMembersTestCase.config().set(LoopOverGroupMembersTestCase.TARGET_ENTITY, testGroup);
-
- app.start(ImmutableList.of(app.newSimulatedLocation()));
-
- assertThat(loopOverGroupMembersTestCase.getChildren().size()).isEqualTo(1);
- assertThat(loopOverGroupMembersTestCase.sensors().get(SERVICE_UP)).isTrue();
-
- Entity loopChildEntity = loopOverGroupMembersTestCase.getChildren().iterator().next();
- assertThat(loopChildEntity).isInstanceOf(TestSensor.class);
- assertThat(loopChildEntity.sensors().get(SERVICE_UP)).isTrue();
- assertThat(loopChildEntity.config().get(LoopOverGroupMembersTestCase.TARGET_ENTITY)).isEqualTo(emptySoftwareProcess);
- }
-
- @Test
- public void testMultipleChildrenWhichPass() {
- Set<EmptySoftwareProcess> emptySoftwareProcesses = addMultipleEmptySoftwareProcessesToGroup(4);
- EntitySpec<TestSensor> testSpec = createPassingTestSensorSpec();
-
- LoopOverGroupMembersTestCase loopOverGroupMembersTestCase = app.createAndManageChild(EntitySpec.create(LoopOverGroupMembersTestCase.class));
- loopOverGroupMembersTestCase.config().set(LoopOverGroupMembersTestCase.TEST_SPEC, testSpec);
- loopOverGroupMembersTestCase.config().set(LoopOverGroupMembersTestCase.TARGET_ENTITY, testGroup);
-
- app.start(ImmutableList.of(app.newSimulatedLocation()));
-
- assertThat(loopOverGroupMembersTestCase.getChildren().size()).isEqualTo(4);
- assertThat(loopOverGroupMembersTestCase.sensors().get(SERVICE_UP)).isTrue();
-
- for (Entity loopChildEntity : loopOverGroupMembersTestCase.getChildren()) {
- assertThat(loopChildEntity).isInstanceOf(TestSensor.class);
- assertThat(loopChildEntity.sensors().get(SERVICE_UP)).isTrue();
- assertThat(emptySoftwareProcesses.contains(loopChildEntity.config().get(LoopOverGroupMembersTestCase.TARGET_ENTITY))).isTrue();
- emptySoftwareProcesses.remove(loopChildEntity.config().get(LoopOverGroupMembersTestCase.TARGET_ENTITY));
- }
- }
-
- @Test
- public void testMultipleChildrenWhichAllFail() {
- Set<EmptySoftwareProcess> emptySoftwareProcesses = addMultipleEmptySoftwareProcessesToGroup(4);
- EntitySpec<TestSensor> testSpec = createFailingTestSensorSpec();
-
- LoopOverGroupMembersTestCase loopOverGroupMembersTestCase = app.createAndManageChild(EntitySpec.create(LoopOverGroupMembersTestCase.class));
- loopOverGroupMembersTestCase.config().set(LoopOverGroupMembersTestCase.TEST_SPEC, testSpec);
- loopOverGroupMembersTestCase.config().set(LoopOverGroupMembersTestCase.TARGET_ENTITY, testGroup);
-
- app.start(ImmutableList.of(app.newSimulatedLocation()));
-
- assertThat(loopOverGroupMembersTestCase.getChildren().size()).isEqualTo(4);
- assertThat(loopOverGroupMembersTestCase.sensors().get(SERVICE_UP)).isFalse();
-
- for (Entity loopChildEntity : loopOverGroupMembersTestCase.getChildren()) {
- assertThat(loopChildEntity).isInstanceOf(TestSensor.class);
- assertThat(loopChildEntity.sensors().get(SERVICE_UP)).isFalse();
- assertThat(emptySoftwareProcesses.contains(loopChildEntity.config().get(LoopOverGroupMembersTestCase.TARGET_ENTITY))).isTrue();
- emptySoftwareProcesses.remove(loopChildEntity.config().get(LoopOverGroupMembersTestCase.TARGET_ENTITY));
- }
- }
-
- @Test
- public void testMultipleChildrenOneOfWhichFails() {
- Set<EmptySoftwareProcess> emptySoftwareProcesses = addMultipleEmptySoftwareProcessesToGroup(3);
- EntitySpec<TestSensor> testSpec = createPassingTestSensorSpec();
-
- EmptySoftwareProcess failingProcess = testGroup.addMemberChild(EntitySpec.create(EmptySoftwareProcess.class));
- failingProcess.sensors().set(STRING_SENSOR, "THIS STRING WILL CAUSE SENSOR TEST TO FAIL");
-
- LoopOverGroupMembersTestCase loopOverGroupMembersTestCase = app.createAndManageChild(EntitySpec.create(LoopOverGroupMembersTestCase.class));
- loopOverGroupMembersTestCase.config().set(LoopOverGroupMembersTestCase.TEST_SPEC, testSpec);
- loopOverGroupMembersTestCase.config().set(LoopOverGroupMembersTestCase.TARGET_ENTITY, testGroup);
-
- app.start(ImmutableList.of(app.newSimulatedLocation()));
-
- assertThat(loopOverGroupMembersTestCase.getChildren().size()).isEqualTo(4);
- assertThat(loopOverGroupMembersTestCase.sensors().get(SERVICE_UP)).isFalse();
-
- for (Entity loopChildEntity : loopOverGroupMembersTestCase.getChildren()) {
- assertThat(loopChildEntity).isInstanceOf(TestSensor.class);
-
- Entity targetedEntity = loopChildEntity.config().get(LoopOverGroupMembersTestCase.TARGET_ENTITY);
-
- if (targetedEntity.equals(failingProcess)) {
- assertThat(loopChildEntity.sensors().get(SERVICE_UP)).isFalse();
- } else if (emptySoftwareProcesses.contains(targetedEntity)) {
- assertThat(loopChildEntity.sensors().get(SERVICE_UP)).isTrue();
- emptySoftwareProcesses.remove(targetedEntity);
- } else {
- fail("Targeted entity not recognized");
- }
- }
- }
-
- @Test
- public void testOneChildWhichFails() {
- EmptySoftwareProcess emptySoftwareProcess = addEmptySoftwareProcessToGroup();
- EntitySpec<TestSensor> testSpec = createFailingTestSensorSpec();
-
- LoopOverGroupMembersTestCase loopOverGroupMembersTestCase = app.createAndManageChild(EntitySpec.create(LoopOverGroupMembersTestCase.class));
- loopOverGroupMembersTestCase.config().set(LoopOverGroupMembersTestCase.TEST_SPEC, testSpec);
- loopOverGroupMembersTestCase.config().set(LoopOverGroupMembersTestCase.TARGET_ENTITY, testGroup);
-
- app.start(ImmutableList.of(app.newSimulatedLocation()));
-
- assertThat(loopOverGroupMembersTestCase.getChildren().size()).isEqualTo(1);
- assertThat(loopOverGroupMembersTestCase.sensors().get(SERVICE_UP)).isFalse();
-
- Entity loopChildEntity = loopOverGroupMembersTestCase.getChildren().iterator().next();
- assertThat(loopChildEntity).isInstanceOf(TestSensor.class);
- assertThat(loopChildEntity.sensors().get(SERVICE_UP)).isFalse();
- assertThat(loopChildEntity.config().get(LoopOverGroupMembersTestCase.TARGET_ENTITY)).isEqualTo(emptySoftwareProcess);
- }
-
- //negative
- // without test spec
- // without target + taget id
- // not a group
-
- @Test
- public void testNoTarget() {
- EmptySoftwareProcess emptySoftwareProcess = addEmptySoftwareProcessToGroup();
- EntitySpec<TestSensor> testSpec = createFailingTestSensorSpec();
-
- LoopOverGroupMembersTestCase loopOverGroupMembersTestCase = app.createAndManageChild(EntitySpec.create(LoopOverGroupMembersTestCase.class));
- loopOverGroupMembersTestCase.config().set(LoopOverGroupMembersTestCase.TEST_SPEC, testSpec);
-
- app.start(ImmutableList.of(app.newSimulatedLocation()));
-
- assertThat(loopOverGroupMembersTestCase.getChildren().size()).isEqualTo(0);
- assertThat(loopOverGroupMembersTestCase.sensors().get(SERVICE_UP)).isFalse();
- }
-
- @Test
- public void testNotTargetingGroup() {
- EmptySoftwareProcess emptySoftwareProcess = addEmptySoftwareProcessToGroup();
- EntitySpec<TestSensor> testSpec = createFailingTestSensorSpec();
-
- LoopOverGroupMembersTestCase loopOverGroupMembersTestCase = app.createAndManageChild(EntitySpec.create(LoopOverGroupMembersTestCase.class));
- loopOverGroupMembersTestCase.config().set(LoopOverGroupMembersTestCase.TEST_SPEC, testSpec);
- loopOverGroupMembersTestCase.config().set(LoopOverGroupMembersTestCase.TARGET_ENTITY, app);
-
- app.start(ImmutableList.of(app.newSimulatedLocation()));
-
- assertThat(loopOverGroupMembersTestCase.getChildren().size()).isEqualTo(0);
- assertThat(loopOverGroupMembersTestCase.sensors().get(SERVICE_UP)).isFalse();
- }
-
- @Test
- public void testNoSpec() {
- EmptySoftwareProcess emptySoftwareProcess = addEmptySoftwareProcessToGroup();
- EntitySpec<TestSensor> testSpec = createFailingTestSensorSpec();
-
- LoopOverGroupMembersTestCase loopOverGroupMembersTestCase = app.createAndManageChild(EntitySpec.create(LoopOverGroupMembersTestCase.class));
- loopOverGroupMembersTestCase.config().set(LoopOverGroupMembersTestCase.TARGET_ENTITY, testGroup);
-
- app.start(ImmutableList.of(app.newSimulatedLocation()));
-
- assertThat(loopOverGroupMembersTestCase.getChildren().size()).isEqualTo(0);
- assertThat(loopOverGroupMembersTestCase.sensors().get(SERVICE_UP)).isFalse();
- }
-
- //UTILITY METHODS
- private EntitySpec<TestSensor> createFailingTestSensorSpec() {
- List<Map<String, Object>> assertions = ImmutableList.<Map<String, Object>>of(
- ImmutableMap.<String, Object>of(TestFrameworkAssertions.EQUAL_TO, "THIS IS THE WRONG STRING")
- );
-
- return EntitySpec.create(TestSensor.class)
- .configure(TestSensor.SENSOR_NAME, STRING_SENSOR.getName())
- .configure(TestSensor.ASSERTIONS, assertions);
- }
-
- private EntitySpec<TestSensor> createPassingTestSensorSpec() {
- List<Map<String, Object>> assertions = ImmutableList.<Map<String, Object>>of(
- ImmutableMap.<String, Object>of(TestFrameworkAssertions.EQUAL_TO, SENSOR_VAL)
- );
-
- return EntitySpec.create(TestSensor.class)
- .configure(TestSensor.SENSOR_NAME, STRING_SENSOR.getName())
- .configure(TestSensor.ASSERTIONS, assertions);
- }
-
- private Set<EmptySoftwareProcess> addMultipleEmptySoftwareProcessesToGroup(int number) {
- MutableSet<EmptySoftwareProcess> softwareProcesses = MutableSet.<EmptySoftwareProcess>of();
- for (int i = 0; i < number; i++) {
- softwareProcesses.add(addEmptySoftwareProcessToGroup());
- }
-
- return softwareProcesses;
- }
-
- private EmptySoftwareProcess addEmptySoftwareProcessToGroup() {
- EmptySoftwareProcess emptySoftwareProcess = testGroup.addMemberChild(EntitySpec.create(EmptySoftwareProcess.class));
- emptySoftwareProcess.sensors().set(STRING_SENSOR, SENSOR_VAL);
- return emptySoftwareProcess;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/be6612cf/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/entity/TestInfrastructure.java
----------------------------------------------------------------------
diff --git a/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/entity/TestInfrastructure.java b/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/entity/TestInfrastructure.java
deleted file mode 100644
index abcd679..0000000
--- a/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/entity/TestInfrastructure.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.brooklyn.test.framework.entity;
-
-import org.apache.brooklyn.api.entity.ImplementedBy;
-import org.apache.brooklyn.entity.stock.BasicApplication;
-
-/**
- * Created by graememiller on 17/12/2015.
- */
-
-@ImplementedBy(TestInfrastructureImpl.class)
-public interface TestInfrastructure extends BasicApplication {
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/be6612cf/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/entity/TestInfrastructureImpl.java
----------------------------------------------------------------------
diff --git a/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/entity/TestInfrastructureImpl.java b/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/entity/TestInfrastructureImpl.java
deleted file mode 100644
index 6ec0638..0000000
--- a/usage/test-framework/src/test/java/org/apache/brooklyn/test/framework/entity/TestInfrastructureImpl.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.brooklyn.test.framework.entity;
-
-import java.util.Collection;
-
-import com.google.common.reflect.TypeToken;
-
-import org.apache.brooklyn.api.location.Location;
-import org.apache.brooklyn.core.config.ConfigKeys;
-import org.apache.brooklyn.core.sensor.AttributeSensorAndConfigKey;
-import org.apache.brooklyn.entity.stock.BasicApplicationImpl;
-
-/**
- * Created by graememiller on 17/12/2015.
- */
-public class TestInfrastructureImpl extends BasicApplicationImpl implements TestInfrastructure {
-
- private final AttributeSensorAndConfigKey<Location, Location> DEPLOYMENT_LOCATION = ConfigKeys.newSensorAndConfigKey(
- new TypeToken<Location>() {
- },
- "deploymentLocationSensor", "The location to deploy to");
-
- @Override
- public void postStart(Collection<? extends Location> locations) {
- super.postStart(locations);
- sensors().set(DEPLOYMENT_LOCATION, config().get(DEPLOYMENT_LOCATION));
- }
-}