Repository: brooklyn-server
Updated Branches:
  refs/heads/master 1dbe97f40 -> 975a59993


Modified InfrastructureDeploymentTestCase changing the testSpecs config to 
Startable rather than SoftwareProcess


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/ef9f48df
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/ef9f48df
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/ef9f48df

Branch: refs/heads/master
Commit: ef9f48df37470f19eb664385409fb2d074136c9c
Parents: 972854a
Author: graeme.miller <graeme.mil...@cloudsoftcorp.com>
Authored: Thu Mar 3 11:41:23 2016 +0000
Committer: graeme.miller <graeme.mil...@cloudsoftcorp.com>
Committed: Thu Mar 3 12:10:09 2016 +0000

----------------------------------------------------------------------
 .../InfrastructureDeploymentTestCase.java       |  3 +-
 .../InfrastructureDeploymentTestCaseImpl.java   |  8 ++--
 .../InfrastructureDeploymentTestCaseTest.java   | 48 +++++++++-----------
 3 files changed, 27 insertions(+), 32 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/ef9f48df/test-framework/src/main/java/org/apache/brooklyn/test/framework/InfrastructureDeploymentTestCase.java
----------------------------------------------------------------------
diff --git 
a/test-framework/src/main/java/org/apache/brooklyn/test/framework/InfrastructureDeploymentTestCase.java
 
b/test-framework/src/main/java/org/apache/brooklyn/test/framework/InfrastructureDeploymentTestCase.java
index a3ffa53..41ba1b7 100644
--- 
a/test-framework/src/main/java/org/apache/brooklyn/test/framework/InfrastructureDeploymentTestCase.java
+++ 
b/test-framework/src/main/java/org/apache/brooklyn/test/framework/InfrastructureDeploymentTestCase.java
@@ -27,6 +27,7 @@ import org.apache.brooklyn.api.entity.ImplementedBy;
 import org.apache.brooklyn.config.ConfigKey;
 import org.apache.brooklyn.core.config.ConfigKeys;
 import org.apache.brooklyn.core.entity.StartableApplication;
+import org.apache.brooklyn.core.entity.trait.Startable;
 import org.apache.brooklyn.entity.software.base.SoftwareProcess;
 
 /**
@@ -39,7 +40,7 @@ public interface InfrastructureDeploymentTestCase extends 
TargetableTestComponen
      * Entity specs to deploy. These will be deployed second, after the 
INFRASTRUCTURE_SPEC has been deployed. These specs will be deployed to the 
DEPLOYMENT_LOCATION.
      * All children will be deployed after this
      */
-    ConfigKey<List<EntitySpec<? extends SoftwareProcess>>> 
ENTITY_SPEC_TO_DEPLOY = ConfigKeys.newConfigKey(new TypeToken<List<EntitySpec<? 
extends SoftwareProcess>>>(){}, "infrastructure.deployment.entity.specs", 
"Entity specs to deploy to infrastructure");
+    ConfigKey<List<EntitySpec<? extends Startable>>> ENTITY_SPEC_TO_DEPLOY = 
ConfigKeys.newConfigKey(new TypeToken<List<EntitySpec<? extends 
Startable>>>(){}, "infrastructure.deployment.entity.specs", "Entity specs to 
deploy to infrastructure");
 
 
     /**

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/ef9f48df/test-framework/src/main/java/org/apache/brooklyn/test/framework/InfrastructureDeploymentTestCaseImpl.java
----------------------------------------------------------------------
diff --git 
a/test-framework/src/main/java/org/apache/brooklyn/test/framework/InfrastructureDeploymentTestCaseImpl.java
 
b/test-framework/src/main/java/org/apache/brooklyn/test/framework/InfrastructureDeploymentTestCaseImpl.java
index 55f3e63..13504c8 100644
--- 
a/test-framework/src/main/java/org/apache/brooklyn/test/framework/InfrastructureDeploymentTestCaseImpl.java
+++ 
b/test-framework/src/main/java/org/apache/brooklyn/test/framework/InfrastructureDeploymentTestCaseImpl.java
@@ -29,8 +29,8 @@ import org.apache.brooklyn.core.annotation.EffectorParam;
 import org.apache.brooklyn.core.entity.Attributes;
 import org.apache.brooklyn.core.entity.StartableApplication;
 import org.apache.brooklyn.core.entity.lifecycle.Lifecycle;
+import org.apache.brooklyn.core.entity.trait.Startable;
 import org.apache.brooklyn.core.sensor.Sensors;
-import org.apache.brooklyn.entity.software.base.SoftwareProcess;
 
 /**
  * Created by graememiller on 04/12/2015.
@@ -65,13 +65,13 @@ public class InfrastructureDeploymentTestCaseImpl extends 
TestCaseImpl implement
         }
 
         //Start the child entity
-        List<EntitySpec<? extends SoftwareProcess>> entitySpecsToDeploy = 
config().get(ENTITY_SPEC_TO_DEPLOY);
+        List<EntitySpec<? extends Startable>> entitySpecsToDeploy = 
config().get(ENTITY_SPEC_TO_DEPLOY);
         if (entitySpecsToDeploy == null || entitySpecsToDeploy.isEmpty()) {
             setServiceState(false, Lifecycle.ON_FIRE);
             throw new IllegalArgumentException(ENTITY_SPEC_TO_DEPLOY + " not 
configured");
         }
-        for (EntitySpec<? extends SoftwareProcess> softwareProcessEntitySpec : 
entitySpecsToDeploy) {
-            SoftwareProcess entityToDeploy = 
this.addChild(softwareProcessEntitySpec);
+        for (EntitySpec<? extends Startable> entitySpec : entitySpecsToDeploy) 
{
+            Startable entityToDeploy = this.addChild(entitySpec);
             entityToDeploy.start(ImmutableList.of(locationToDeployTo));
         }
 

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/ef9f48df/test-framework/src/test/java/org/apache/brooklyn/test/framework/InfrastructureDeploymentTestCaseTest.java
----------------------------------------------------------------------
diff --git 
a/test-framework/src/test/java/org/apache/brooklyn/test/framework/InfrastructureDeploymentTestCaseTest.java
 
b/test-framework/src/test/java/org/apache/brooklyn/test/framework/InfrastructureDeploymentTestCaseTest.java
index 2059d76..73d2854 100644
--- 
a/test-framework/src/test/java/org/apache/brooklyn/test/framework/InfrastructureDeploymentTestCaseTest.java
+++ 
b/test-framework/src/test/java/org/apache/brooklyn/test/framework/InfrastructureDeploymentTestCaseTest.java
@@ -32,10 +32,10 @@ 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.entity.StartableApplication;
+import org.apache.brooklyn.core.entity.trait.Startable;
 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.Asserts;
@@ -89,7 +89,7 @@ public class InfrastructureDeploymentTestCaseTest {
         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));
+        List<EntitySpec<? extends Startable>> testSpecs = 
ImmutableList.<EntitySpec<? extends 
Startable>>of(EntitySpec.create(BasicApplication.class));
 
         InfrastructureDeploymentTestCase infrastructureDeploymentTestCase = 
app.createAndManageChild(EntitySpec.create(InfrastructureDeploymentTestCase.class));
         
infrastructureDeploymentTestCase.config().set(InfrastructureDeploymentTestCase.INFRASTRUCTURE_SPEC,
 infrastructureSpec);
@@ -105,17 +105,14 @@ public class InfrastructureDeploymentTestCaseTest {
         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();
+            assertThat(entity.getLocations().size()).isEqualTo(1);
+            assertThat(entity.sensors().get(SERVICE_UP)).isTrue();
 
+            if (entity instanceof TestInfrastructure  && !seenInfrastructure) {
+                
assertThat(entity.getLocations().iterator().next().getDisplayName()).isEqualTo(LOC_NAME);
                 seenInfrastructure = true;
-            } else if (entity instanceof EmptySoftwareProcess) {
-                assertThat(entity.getLocations().size()).isEqualTo(1);
+            } else if (entity instanceof BasicApplication){
                 
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");
@@ -131,9 +128,9 @@ public class InfrastructureDeploymentTestCaseTest {
         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)));
+        List<EntitySpec<? extends Startable>> testSpecs = 
ImmutableList.<EntitySpec<? extends Startable>>of
+                (EntitySpec.create(BasicApplication.class),
+                        (EntitySpec.create(BasicApplication.class)));
 
         InfrastructureDeploymentTestCase infrastructureDeploymentTestCase = 
app.createAndManageChild(EntitySpec.create(InfrastructureDeploymentTestCase.class));
         
infrastructureDeploymentTestCase.config().set(InfrastructureDeploymentTestCase.INFRASTRUCTURE_SPEC,
 infrastructureSpec);
@@ -149,17 +146,14 @@ public class InfrastructureDeploymentTestCaseTest {
         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();
+            assertThat(entity.sensors().get(SERVICE_UP)).isTrue();
+            assertThat(entity.getLocations().size()).isEqualTo(1);
 
+            if (entity instanceof TestInfrastructure && !seenInfrastructure) {
+                
assertThat(entity.getLocations().iterator().next().getDisplayName()).isEqualTo(LOC_NAME);
                 seenInfrastructure = true;
-            } else if (entity instanceof EmptySoftwareProcess) {
-                assertThat(entity.getLocations().size()).isEqualTo(1);
+            } else if (entity instanceof BasicApplication) {
                 
assertThat(entity.getLocations().iterator().next().getDisplayName()).isEqualTo(INFRASTRUCTURE_LOC_NAME);
-                assertThat(entity.sensors().get(SERVICE_UP)).isTrue();
-
                 entitiesSeen++;
             } else {
                 fail("Unknown child of InfrastructureDeploymentTestCase");
@@ -172,7 +166,7 @@ public class InfrastructureDeploymentTestCaseTest {
 
     @Test
     public void testNoInfrastructureSpec() {
-        List<EntitySpec<? extends SoftwareProcess>> testSpecs = 
ImmutableList.<EntitySpec<? extends 
SoftwareProcess>>of(EntitySpec.create(EmptySoftwareProcess.class));
+        List<EntitySpec<? extends Startable>> testSpecs = 
ImmutableList.<EntitySpec<? extends 
Startable>>of(EntitySpec.create(StartableApplication.class));
 
         InfrastructureDeploymentTestCase infrastructureDeploymentTestCase = 
app.createAndManageChild(EntitySpec.create(InfrastructureDeploymentTestCase.class));
         
infrastructureDeploymentTestCase.config().set(InfrastructureDeploymentTestCase.ENTITY_SPEC_TO_DEPLOY,
 testSpecs);
@@ -203,7 +197,7 @@ public class InfrastructureDeploymentTestCaseTest {
         } catch (Throwable throwable) {
             Asserts.expectedFailureContains(throwable, "entity.specs", "List", 
"not configured");
         }
-        
+
         
assertThat(infrastructureDeploymentTestCase.sensors().get(SERVICE_UP)).isFalse();
     }
 
@@ -212,7 +206,7 @@ public class InfrastructureDeploymentTestCaseTest {
         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));
+        List<EntitySpec<? extends Startable>> testSpecs = 
ImmutableList.<EntitySpec<? extends 
Startable>>of(EntitySpec.create(BasicApplication.class));
 
         InfrastructureDeploymentTestCase infrastructureDeploymentTestCase = 
app.createAndManageChild(EntitySpec.create(InfrastructureDeploymentTestCase.class));
         
infrastructureDeploymentTestCase.config().set(InfrastructureDeploymentTestCase.INFRASTRUCTURE_SPEC,
 infrastructureSpec);
@@ -232,7 +226,7 @@ public class InfrastructureDeploymentTestCaseTest {
     public void testInfrastrucutreHasNoLocation() {
         EntitySpec<TestInfrastructure> infrastructureSpec = 
EntitySpec.create(TestInfrastructure.class);
 
-        List<EntitySpec<? extends SoftwareProcess>> testSpecs = 
ImmutableList.<EntitySpec<? extends 
SoftwareProcess>>of(EntitySpec.create(EmptySoftwareProcess.class));
+        List<EntitySpec<? extends Startable>> testSpecs = 
ImmutableList.<EntitySpec<? extends 
Startable>>of(EntitySpec.create(BasicApplication.class));
 
         InfrastructureDeploymentTestCase infrastructureDeploymentTestCase = 
app.createAndManageChild(EntitySpec.create(InfrastructureDeploymentTestCase.class));
         
infrastructureDeploymentTestCase.config().set(InfrastructureDeploymentTestCase.INFRASTRUCTURE_SPEC,
 infrastructureSpec);
@@ -248,4 +242,4 @@ public class InfrastructureDeploymentTestCaseTest {
 
         
assertThat(infrastructureDeploymentTestCase.sensors().get(SERVICE_UP)).isFalse();
     }
-}
+}
\ No newline at end of file

Reply via email to