brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject [4/8] brooklyn-server git commit: Update ConfigMapTest and related tests
Date Mon, 30 May 2016 14:24:38 GMT
Update ConfigMapTest and related tests

Previously it called the entity constructors; changed to use
EntitySpec.


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

Branch: refs/heads/master
Commit: a8f3e82d73581a76a96a2df1d054cc0aad010d02
Parents: 3ce00e8
Author: Aled Sage <aled.sage@gmail.com>
Authored: Sat May 28 00:13:36 2016 +0100
Committer: Aled Sage <aled.sage@gmail.com>
Committed: Sat May 28 15:15:30 2016 +0100

----------------------------------------------------------------------
 .../entity/ConfigEntityInheritanceTest.java     |  23 +---
 .../entity/internal/ConfigMapGroovyTest.groovy  |  31 +++--
 .../core/entity/internal/ConfigMapTest.java     | 115 ++++++-------------
 .../internal/EntityConfigMapUsageTest.java      |  22 ++--
 4 files changed, 70 insertions(+), 121 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/a8f3e82d/core/src/test/java/org/apache/brooklyn/core/entity/ConfigEntityInheritanceTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/entity/ConfigEntityInheritanceTest.java
b/core/src/test/java/org/apache/brooklyn/core/entity/ConfigEntityInheritanceTest.java
index 0334312..93dff9a 100644
--- a/core/src/test/java/org/apache/brooklyn/core/entity/ConfigEntityInheritanceTest.java
+++ b/core/src/test/java/org/apache/brooklyn/core/entity/ConfigEntityInheritanceTest.java
@@ -24,14 +24,12 @@ import org.apache.brooklyn.config.ConfigInheritance;
 import org.apache.brooklyn.config.ConfigKey;
 import org.apache.brooklyn.core.config.ConfigKeys;
 import org.apache.brooklyn.core.entity.AbstractEntity;
-import org.apache.brooklyn.core.entity.Entities;
 import org.apache.brooklyn.core.entity.internal.ConfigMapTest.MyOtherEntity;
+import org.apache.brooklyn.core.entity.internal.ConfigMapTest.MyOtherEntityImpl;
 import org.apache.brooklyn.core.sensor.AttributeSensorAndConfigKey;
 import org.apache.brooklyn.core.sensor.BasicAttributeSensorAndConfigKey.IntegerAttributeSensorAndConfigKey;
-import org.apache.brooklyn.core.test.entity.TestApplication;
+import org.apache.brooklyn.core.test.BrooklynAppUnitTestSupport;
 import org.testng.Assert;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
 /**
@@ -41,20 +39,7 @@ import org.testng.annotations.Test;
  *    interface X extends Y
  *    config C is declared on S and overwritten at Y
  */
-public class ConfigEntityInheritanceTest {
-
-    private TestApplication app;
-
-    @BeforeMethod(alwaysRun=true)
-    public void setUp() {
-        app = TestApplication.Factory.newManagedInstanceForTests();
-        Entities.startManagement(app);
-    }
-
-    @AfterMethod(alwaysRun=true)
-    public void tearDown() throws Exception {
-        if (app != null) Entities.destroyAll(app.getManagementContext());
-    }
+public class ConfigEntityInheritanceTest extends BrooklynAppUnitTestSupport {
 
     protected void checkKeys(Entity entity2, Integer value) {
         Assert.assertEquals(entity2.getConfig(MyOtherEntity.INT_KEY), value);
@@ -75,7 +60,7 @@ public class ConfigEntityInheritanceTest {
         checkKeys(app.addChild(EntitySpec.create(MyOtherEntityOverwritingThenInheriting.class)),
2);
     }
     
-    public static class MyOtherEntityOverwriting extends MyOtherEntity {
+    public static class MyOtherEntityOverwriting extends MyOtherEntityImpl {
         public static final ConfigKey<Integer> INT_KEY = ConfigKeys.newConfigKeyWithDefault(MyOtherEntity.INT_KEY,
2);
         public static final IntegerAttributeSensorAndConfigKey SENSOR_AND_CONFIG_KEY = 
                 new IntegerAttributeSensorAndConfigKey(MyOtherEntity.SENSOR_AND_CONFIG_KEY,
2);

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/a8f3e82d/core/src/test/java/org/apache/brooklyn/core/entity/internal/ConfigMapGroovyTest.groovy
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/entity/internal/ConfigMapGroovyTest.groovy
b/core/src/test/java/org/apache/brooklyn/core/entity/internal/ConfigMapGroovyTest.groovy
index 0327258..c12c197 100644
--- a/core/src/test/java/org/apache/brooklyn/core/entity/internal/ConfigMapGroovyTest.groovy
+++ b/core/src/test/java/org/apache/brooklyn/core/entity/internal/ConfigMapGroovyTest.groovy
@@ -19,9 +19,12 @@
 package org.apache.brooklyn.core.entity.internal;
 
 import static org.testng.Assert.assertEquals
+import static org.testng.Assert.assertFalse
 import static org.testng.Assert.assertTrue
 
+import org.apache.brooklyn.core.test.BrooklynAppUnitTestSupport;
 import org.apache.brooklyn.core.test.entity.TestApplication
+import org.apache.brooklyn.api.entity.EntitySpec;
 import org.apache.brooklyn.core.entity.Entities
 import org.apache.brooklyn.core.entity.internal.ConfigMapTest.MyOtherEntity
 import org.apache.brooklyn.core.entity.internal.ConfigMapTest.MySubEntity
@@ -29,33 +32,37 @@ import org.testng.annotations.AfterMethod
 import org.testng.annotations.BeforeMethod
 import org.testng.annotations.Test
 
-public class ConfigMapGroovyTest {
+import com.google.common.base.Predicate;
+
+public class ConfigMapGroovyTest extends BrooklynAppUnitTestSupport {
 
-    private TestApplication app;
     private MySubEntity entity;
 
     @BeforeMethod(alwaysRun=true)
+    @Override
     public void setUp() {
-        app = TestApplication.Factory.newManagedInstanceForTests();
-        entity = new MySubEntity(app);
-        Entities.manage(entity);
-    }
-
-    @AfterMethod(alwaysRun=true)
-    public void tearDown() throws Exception {
-        if (app != null) Entities.destroyAll(app.getManagementContext());
+        super.setUp();
+        entity = app.addChild(EntitySpec.create(MySubEntity.class));
     }
 
     @Test
     public void testGetConfigOfTypeClosureReturnsClosure() throws Exception {
-        MyOtherEntity entity2 = new MyOtherEntity(app);
+        MyOtherEntity entity2 = app.addChild(EntitySpec.create(MyOtherEntity.class));
         entity2.config().set(MyOtherEntity.CLOSURE_KEY, { return "abc" } );
-        Entities.manage(entity2);
         
         Closure configVal = entity2.getConfig(MyOtherEntity.CLOSURE_KEY);
         assertTrue(configVal instanceof Closure, "configVal="+configVal);
         assertEquals(configVal.call(), "abc");
     }
 
+    @Test
+    public void testGetConfigOfPredicateTaskReturnsCoercedClosure() throws Exception {
+        MyOtherEntity entity2 = app.addChild(EntitySpec.create(MyOtherEntity.class));
+        entity2.setConfig(MyOtherEntity.PREDICATE_KEY, { return it != null } );
 
+        Predicate<?> predicate = entity2.getConfig(MyOtherEntity.PREDICATE_KEY);
+        assertTrue(predicate instanceof Predicate, "predicate="+predicate);
+        assertTrue(predicate.apply(1));
+        assertFalse(predicate.apply(null));
+    }
 }

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/a8f3e82d/core/src/test/java/org/apache/brooklyn/core/entity/internal/ConfigMapTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/entity/internal/ConfigMapTest.java
b/core/src/test/java/org/apache/brooklyn/core/entity/internal/ConfigMapTest.java
index 982d689..f5a84e3 100644
--- a/core/src/test/java/org/apache/brooklyn/core/entity/internal/ConfigMapTest.java
+++ b/core/src/test/java/org/apache/brooklyn/core/entity/internal/ConfigMapTest.java
@@ -21,9 +21,7 @@ package org.apache.brooklyn.core.entity.internal;
 import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertFalse;
 import static org.testng.Assert.assertTrue;
-import groovy.lang.Closure;
 
-import java.util.Map;
 import java.util.concurrent.Callable;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.ExecutorService;
@@ -33,6 +31,8 @@ import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicInteger;
 
 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.mgmt.ExecutionManager;
 import org.apache.brooklyn.api.mgmt.Task;
 import org.apache.brooklyn.config.ConfigKey;
@@ -40,10 +40,9 @@ import org.apache.brooklyn.config.ConfigMap;
 import org.apache.brooklyn.core.config.ConfigKeys;
 import org.apache.brooklyn.core.config.ConfigPredicates;
 import org.apache.brooklyn.core.entity.AbstractEntity;
-import org.apache.brooklyn.core.entity.Entities;
+import org.apache.brooklyn.core.entity.EntityInternal;
 import org.apache.brooklyn.core.sensor.BasicAttributeSensorAndConfigKey.IntegerAttributeSensorAndConfigKey;
 import org.apache.brooklyn.core.test.BrooklynAppUnitTestSupport;
-import org.apache.brooklyn.util.collections.MutableMap;
 import org.apache.brooklyn.util.core.task.BasicTask;
 import org.apache.brooklyn.util.core.task.DeferredSupplier;
 import org.testng.Assert;
@@ -52,10 +51,11 @@ import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
 import com.google.common.base.Predicate;
-import com.google.common.base.Predicates;
 import com.google.common.collect.ImmutableSet;
 import com.google.common.util.concurrent.MoreExecutors;
 
+import groovy.lang.Closure;
+
 public class ConfigMapTest extends BrooklynAppUnitTestSupport {
 
     private static final int TIMEOUT_MS = 10*1000;
@@ -68,8 +68,7 @@ public class ConfigMapTest extends BrooklynAppUnitTestSupport {
     @Override
     public void setUp() throws Exception {
         super.setUp();
-        entity = new MySubEntity(app);
-        Entities.manage(entity);
+        entity = app.addChild(EntitySpec.create(MySubEntity.class));
         executor = MoreExecutors.listeningDecorator(Executors.newCachedThreadPool());
         executionManager = mgmt.getExecutionManager();
     }
@@ -94,15 +93,15 @@ public class ConfigMapTest extends BrooklynAppUnitTestSupport {
 
     @Test
     public void testConfigureFromKey() throws Exception {
-        MySubEntity entity2 = new MySubEntity(MutableMap.of(MySubEntity.SUPER_KEY_1, "changed"),
app);
-        Entities.manage(entity2);
+        MySubEntity entity2 = app.addChild(EntitySpec.create(MySubEntity.class)
+                .configure(MySubEntity.SUPER_KEY_1, "changed"));
         assertEquals(entity2.getConfig(MySubEntity.SUPER_KEY_1), "changed");
     }
 
     @Test
     public void testConfigureFromSuperKey() throws Exception {
-        MySubEntity entity2 = new MySubEntity(MutableMap.of(MyBaseEntity.SUPER_KEY_1, "changed"),
app);
-        Entities.manage(entity2);
+        MySubEntity entity2 = app.addChild(EntitySpec.create(MySubEntity.class)
+                .configure(MyBaseEntity.SUPER_KEY_1, "changed"));
         assertEquals(entity2.getConfig(MySubEntity.SUPER_KEY_1), "changed");
     }
 
@@ -110,31 +109,19 @@ public class ConfigMapTest extends BrooklynAppUnitTestSupport {
     public void testConfigSubMap() throws Exception {
         entity.config().set(MyBaseEntity.SUPER_KEY_1, "s1");
         entity.config().set(MySubEntity.SUB_KEY_2, "s2");
-        ConfigMap sub = entity.getConfigMap().submap(ConfigPredicates.matchingGlob("sup*"));
+        ConfigMap sub = entity.getConfigMap().submap(ConfigPredicates.nameMatchesGlob("sup*"));
         Assert.assertEquals(sub.getConfigRaw(MyBaseEntity.SUPER_KEY_1, true).get(), "s1");
         Assert.assertFalse(sub.getConfigRaw(MySubEntity.SUB_KEY_2, true).isPresent());
     }
 
     @Test(expectedExceptions=IllegalArgumentException.class)
     public void testFailFastOnInvalidConfigKeyCoercion() throws Exception {
-        MyOtherEntity entity2 = new MyOtherEntity(app);
+        MyOtherEntity entity2 = app.addChild(EntitySpec.create(MyOtherEntity.class));
         ConfigKey<Integer> key = MyOtherEntity.INT_KEY;
         entity2.config().set((ConfigKey)key, "thisisnotanint");
     }
 
     @Test
-    public void testGetConfigOfPredicateTaskReturnsCoercedClosure() throws Exception {
-        MyOtherEntity entity2 = new MyOtherEntity(app);
-        entity2.config().set(MyOtherEntity.PREDICATE_KEY, Predicates.notNull());
-        Entities.manage(entity2);
-
-        Predicate predicate = entity2.getConfig(MyOtherEntity.PREDICATE_KEY);
-        assertTrue(predicate instanceof Predicate, "predicate="+predicate);
-        assertTrue(predicate.apply(1));
-        assertFalse(predicate.apply(null));
-    }
-
-    @Test
     public void testGetConfigWithDeferredSupplierReturnsSupplied() throws Exception {
         DeferredSupplier<Integer> supplier = new DeferredSupplier<Integer>()
{
             volatile int next = 0;
@@ -143,9 +130,8 @@ public class ConfigMapTest extends BrooklynAppUnitTestSupport {
             }
         };
 
-        MyOtherEntity entity2 = new MyOtherEntity(app);
-        entity2.setConfig(MyOtherEntity.INT_KEY, supplier);
-        Entities.manage(entity2);
+        MyOtherEntity entity2 = app.addChild(EntitySpec.create(MyOtherEntity.class));
+        entity2.config().set((ConfigKey)MyOtherEntity.INT_KEY, supplier);
 
         assertEquals(entity2.getConfig(MyOtherEntity.INT_KEY), Integer.valueOf(0));
         assertEquals(entity2.getConfig(MyOtherEntity.INT_KEY), Integer.valueOf(1));
@@ -153,12 +139,11 @@ public class ConfigMapTest extends BrooklynAppUnitTestSupport {
 
     @Test
     public void testGetConfigWithFutureWaitsForResult() throws Exception {
-        LatchingCallable work = new LatchingCallable("abc");
+        LatchingCallable<String> work = new LatchingCallable<String>("abc");
         Future<String> future = executor.submit(work);
 
-        final MyOtherEntity entity2 = new MyOtherEntity(app);
+        final MyOtherEntity entity2 = app.addChild(EntitySpec.create(MyOtherEntity.class));
         entity2.config().set((ConfigKey)MyOtherEntity.STRING_KEY, future);
-        Entities.manage(entity2);
 
         Future<String> getConfigFuture = executor.submit(new Callable<String>()
{
             public String call() {
@@ -174,12 +159,11 @@ public class ConfigMapTest extends BrooklynAppUnitTestSupport {
 
     @Test
     public void testGetConfigWithExecutedTaskWaitsForResult() throws Exception {
-        LatchingCallable work = new LatchingCallable("abc");
+        LatchingCallable<String> work = new LatchingCallable<String>("abc");
         Task<String> task = executionManager.submit(work);
 
-        final MyOtherEntity entity2 = new MyOtherEntity(app);
-        entity2.config().set(MyOtherEntity.STRING_KEY, task);
-        Entities.manage(entity2);
+        final MyOtherEntity entity2 = app.addChild(EntitySpec.create(MyOtherEntity.class)
+                .configure(MyOtherEntity.STRING_KEY, task));
 
         Future<String> getConfigFuture = executor.submit(new Callable<String>()
{
             public String call() {
@@ -196,12 +180,11 @@ public class ConfigMapTest extends BrooklynAppUnitTestSupport {
 
     @Test
     public void testGetConfigWithUnexecutedTaskIsExecutedAndWaitsForResult() throws Exception
{
-        LatchingCallable work = new LatchingCallable("abc");
+        LatchingCallable<String> work = new LatchingCallable<String>("abc");
         Task<String> task = new BasicTask<String>(work);
 
-        final MyOtherEntity entity2 = new MyOtherEntity(app);
-        entity2.config().set(MyOtherEntity.STRING_KEY, task);
-        Entities.manage(entity2);
+        final MyOtherEntity entity2 = app.addChild(EntitySpec.create(MyOtherEntity.class)
+                .configure(MyOtherEntity.STRING_KEY, task));
 
         Future<String> getConfigFuture = executor.submit(new Callable<String>()
{
             public String call() {
@@ -216,45 +199,30 @@ public class ConfigMapTest extends BrooklynAppUnitTestSupport {
         assertEquals(work.callCount.get(), 1);
     }
 
-    public static class MyBaseEntity extends AbstractEntity {
+    @ImplementedBy(MyBaseEntityImpl.class)
+    public interface MyBaseEntity extends EntityInternal {
         public static final ConfigKey<String> SUPER_KEY_1 = ConfigKeys.newStringConfigKey("superKey1",
"superKey1 key", "superKey1 default");
         public static final ConfigKey<String> SUPER_KEY_2 = ConfigKeys.newStringConfigKey("superKey2",
"superKey2 key", "superKey2 default");
-        
-        public MyBaseEntity() {
-        }
-        public MyBaseEntity(Map flags) {
-            super(flags);
-        }
-        public MyBaseEntity(Map flags, Entity parent) {
-            super(flags, parent);
-        }
-        public MyBaseEntity(Entity parent) {
-            super(parent);
-        }
+    }
+    
+    public static class MyBaseEntityImpl extends AbstractEntity implements MyBaseEntity {
     }
 
-    public static class MySubEntity extends MyBaseEntity implements MyInterface {
+    @ImplementedBy(MySubEntityImpl.class)
+    public interface MySubEntity extends MyBaseEntity, MyInterface {
         public static final ConfigKey<String> SUPER_KEY_1 = ConfigKeys.newConfigKeyWithDefault(MyBaseEntity.SUPER_KEY_1,
"overridden superKey1 default");
         public static final ConfigKey<String> SUB_KEY_2 = ConfigKeys.newStringConfigKey("subKey2",
"subKey2 key", "subKey2 default");
-        
-        MySubEntity() {
-        }
-        MySubEntity(Map flags) {
-            super(flags);
-        }
-        MySubEntity(Map flags, Entity parent) {
-            super(flags, parent);
-        }
-        MySubEntity(Entity parent) {
-            super(parent);
-        }
+    }
+    
+    public static class MySubEntityImpl extends MyBaseEntityImpl implements MySubEntity {
     }
 
     public interface MyInterface {
         public static final ConfigKey<String> INTERFACE_KEY_1 = ConfigKeys.newStringConfigKey("interfaceKey1",
"interface key 1", "interfaceKey1 default");
     }
 
-    public static class MyOtherEntity extends AbstractEntity {
+    @ImplementedBy(MyOtherEntityImpl.class)
+    public interface MyOtherEntity extends Entity {
         public static final ConfigKey<Integer> INT_KEY = ConfigKeys.newIntegerConfigKey("intKey",
"int key", 1);
         public static final ConfigKey<String> STRING_KEY = ConfigKeys.newStringConfigKey("stringKey",
"string key", null);
         public static final ConfigKey<Object> OBJECT_KEY = ConfigKeys.newConfigKey(Object.class,
"objectKey", "object key", null);
@@ -263,18 +231,9 @@ public class ConfigMapTest extends BrooklynAppUnitTestSupport {
         public static final ConfigKey<Task> TASK_KEY = ConfigKeys.newConfigKey(Task.class,
"taskKey", "task key", null);
         public static final ConfigKey<Predicate> PREDICATE_KEY = ConfigKeys.newConfigKey(Predicate.class,
"predicateKey", "predicate key", null);
         public static final IntegerAttributeSensorAndConfigKey SENSOR_AND_CONFIG_KEY = new
IntegerAttributeSensorAndConfigKey("sensorConfigKey", "sensor+config key", 1);
-        
-        public MyOtherEntity() {
-        }
-        public MyOtherEntity(Map flags) {
-            super(flags);
-        }
-        public MyOtherEntity(Map flags, Entity parent) {
-            super(flags, parent);
-        }
-        public MyOtherEntity(Entity parent) {
-            super(parent);
-        }
+    }
+    
+    public static class MyOtherEntityImpl extends AbstractEntity implements MyOtherEntity
{
     }
 
     static class LatchingCallable<T> implements Callable<T> {

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/a8f3e82d/core/src/test/java/org/apache/brooklyn/core/entity/internal/EntityConfigMapUsageTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/entity/internal/EntityConfigMapUsageTest.java
b/core/src/test/java/org/apache/brooklyn/core/entity/internal/EntityConfigMapUsageTest.java
index e5e39a4..ffaa00f 100644
--- a/core/src/test/java/org/apache/brooklyn/core/entity/internal/EntityConfigMapUsageTest.java
+++ b/core/src/test/java/org/apache/brooklyn/core/entity/internal/EntityConfigMapUsageTest.java
@@ -26,11 +26,9 @@ import java.util.List;
 import java.util.concurrent.Callable;
 import java.util.concurrent.CountDownLatch;
 
-import org.apache.brooklyn.api.entity.EntityLocal;
 import org.apache.brooklyn.api.entity.EntitySpec;
 import org.apache.brooklyn.config.ConfigKey;
 import org.apache.brooklyn.core.config.BasicConfigKey;
-import org.apache.brooklyn.core.entity.Entities;
 import org.apache.brooklyn.core.location.SimulatedLocation;
 import org.apache.brooklyn.core.sensor.DependentConfiguration;
 import org.apache.brooklyn.core.test.BrooklynAppUnitTestSupport;
@@ -124,8 +122,8 @@ public class EntityConfigMapUsageTest extends BrooklynAppUnitTestSupport
{
     @Test
     public void testConfigCanBeSetOnEntity() throws Exception {
         TestEntity entity = app.addChild(EntitySpec.create(TestEntity.class));
-        ((EntityLocal)entity).config().set(strKey, "aval");
-        ((EntityLocal)entity).config().set(intKey, 2);
+        entity.config().set(strKey, "aval");
+        entity.config().set(intKey, 2);
         
         assertEquals(entity.getConfig(strKey), "aval");
         assertEquals(entity.getConfig(intKey), (Integer)2);
@@ -135,7 +133,7 @@ public class EntityConfigMapUsageTest extends BrooklynAppUnitTestSupport
{
     public void testConfigInheritedFromParent() throws Exception {
         TestEntity parent = app.addChild(EntitySpec.create(TestEntity.class)
                 .configure(strKey, "aval"));
-        ((EntityLocal)parent).config().set(intKey, 2);
+        parent.config().set(intKey, 2);
         TestEntity entity = parent.createAndManageChild(EntitySpec.create(TestEntity.class));
         
         assertEquals(entity.getConfig(strKey), "aval");
@@ -157,7 +155,7 @@ public class EntityConfigMapUsageTest extends BrooklynAppUnitTestSupport
{
         TestEntity parent = app.createAndManageChild(EntitySpec.create(TestEntity.class)
                 .configure(strKey, "aval"));
         TestEntity entity = parent.createAndManageChild(EntitySpec.create(TestEntity.class));
-        ((EntityLocal)entity).config().set(strKey, "diffval");
+        entity.config().set(strKey, "diffval");
         
         assertEquals(entity.getConfig(strKey), "diffval");
     }
@@ -166,7 +164,7 @@ public class EntityConfigMapUsageTest extends BrooklynAppUnitTestSupport
{
     public void testConfigSetterOverridesConstructorValue() throws Exception {
         TestEntity entity = app.createAndManageChild(EntitySpec.create(TestEntity.class)
                 .configure(strKey, "aval"));
-        ((EntityLocal)entity).config().set(strKey, "diffval");
+        entity.config().set(strKey, "diffval");
         
         assertEquals(entity.getConfig(strKey), "diffval");
     }
@@ -175,7 +173,7 @@ public class EntityConfigMapUsageTest extends BrooklynAppUnitTestSupport
{
     public void testConfigSetOnParentInheritedByExistingChildren() throws Exception {
         TestEntity parent = app.addChild(EntitySpec.create(TestEntity.class));
         TestEntity entity = parent.createChild(EntitySpec.create(TestEntity.class));
-        ((EntityLocal)parent).config().set(strKey,"aval");
+        parent.config().set(strKey,"aval");
         
         assertEquals(entity.getConfig(strKey), "aval");
     }
@@ -199,7 +197,7 @@ public class EntityConfigMapUsageTest extends BrooklynAppUnitTestSupport
{
         app.start(locs);
         
         try {
-            ((EntityLocal)app).config().set(strKey,"aval");
+            app.config().set(strKey,"aval");
             fail();
         } catch (IllegalStateException e) {
             // success
@@ -265,7 +263,7 @@ public class EntityConfigMapUsageTest extends BrooklynAppUnitTestSupport
{
                 .configure(TestEntity.CONF_NAME, DependentConfiguration.attributeWhenReady(entity,
TestEntity.NAME)));
         app.start(locs);
         
-        ((EntityLocal)entity).sensors().set(TestEntity.NAME, "aval");
+        entity.sensors().set(TestEntity.NAME, "aval");
         assertEquals(entity2.getConfig(TestEntity.CONF_NAME), "aval");
     }
     
@@ -279,7 +277,7 @@ public class EntityConfigMapUsageTest extends BrooklynAppUnitTestSupport
{
                         }})));
         app.start(locs);
         
-        ((EntityLocal)entity).sensors().set(TestEntity.NAME, "aval");
+        entity.sensors().set(TestEntity.NAME, "aval");
         assertEquals(entity2.getConfig(TestEntity.CONF_NAME), "avalmysuffix");
     }
     
@@ -294,7 +292,7 @@ public class EntityConfigMapUsageTest extends BrooklynAppUnitTestSupport
{
             public void run() {
                 try {
                     Thread.sleep(10+EARLY_RETURN_GRACE);
-                    ((EntityLocal)entity).sensors().set(TestEntity.NAME, "aval");
+                    entity.sensors().set(TestEntity.NAME, "aval");
                 } catch (InterruptedException e) {
                     throw Exceptions.propagate(e);
                 }


Mime
View raw message