You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by al...@apache.org on 2014/09/07 23:28:56 UTC

[7/8] git commit: Move some tests form AbstractEntityLegacyTest to EntitySpecTest

Move some tests form AbstractEntityLegacyTest to EntitySpecTest


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

Branch: refs/heads/master
Commit: 287947a05d68ef35a3472b59f2e7fd2a91be8ae5
Parents: 3d231e8
Author: Aled Sage <al...@gmail.com>
Authored: Fri Sep 5 20:10:32 2014 +0100
Committer: Aled Sage <al...@gmail.com>
Committed: Fri Sep 5 21:52:51 2014 +0100

----------------------------------------------------------------------
 .../entity/basic/AbstractEntityLegacyTest.java  | 29 --------------------
 .../brooklyn/entity/basic/EntitySpecTest.java   | 24 ++++++++++++++--
 2 files changed, 22 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/287947a0/core/src/test/java/brooklyn/entity/basic/AbstractEntityLegacyTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/entity/basic/AbstractEntityLegacyTest.java b/core/src/test/java/brooklyn/entity/basic/AbstractEntityLegacyTest.java
index 344bd06..0555db0 100644
--- a/core/src/test/java/brooklyn/entity/basic/AbstractEntityLegacyTest.java
+++ b/core/src/test/java/brooklyn/entity/basic/AbstractEntityLegacyTest.java
@@ -107,18 +107,6 @@ public class AbstractEntityLegacyTest {
         assertEquals(entity.getConfigureDuringConstructionCount(), 1);
     }
 
-    // TODO move the testNewStyle methods (several of them) to EntitySpecTest ?
-    // make sure to keep them when legacy approach removed!
-    // see https://github.com/apache/incubator-brooklyn/pull/113#discussion-diff-16474353
-    @Test
-    public void testNewStyleCallsConfigureAfterConstruction() throws Exception {
-        app = TestApplication.Factory.newManagedInstanceForTests();
-        MyEntity entity = app.addChild(EntitySpec.create(MyEntity.class));
-        
-        assertEquals(entity.getConfigureCount(), 1);
-        assertEquals(entity.getConfigureDuringConstructionCount(), 0);
-    }
-    
     @Test
     public void testLegacyConstructionSetsDefaultDisplayName() throws Exception {
         app = new TestApplicationImpl();
@@ -140,21 +128,4 @@ public class AbstractEntityLegacyTest {
         assertEquals(entity.getDisplayName(), "entityname");
         assertEquals(entity2.getDisplayName(), "entityname2");
     }
-    
-    @Test
-    public void testNewStyleSetsDefaultDisplayName() throws Exception {
-        app = TestApplication.Factory.newManagedInstanceForTests();
-        MyEntity entity = app.addChild(EntitySpec.create(MyEntity.class));
-        
-        assertTrue(entity.getDisplayName().startsWith("MyEntity:"+entity.getId().substring(0,4)), "displayName="+entity.getDisplayName());
-    }
-    
-    @Test
-    public void testNewStyleUsesCustomDisplayName() throws Exception {
-        app = ApplicationBuilder.newManagedApp(EntitySpec.create(TestApplication.class).displayName("appname"), LocalManagementContextForTests.newInstance());
-        MyEntity entity = app.addChild(EntitySpec.create(MyEntity.class).displayName("entityname"));
-        
-        assertEquals(app.getDisplayName(), "appname");
-        assertEquals(entity.getDisplayName(), "entityname");
-    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/287947a0/core/src/test/java/brooklyn/entity/basic/EntitySpecTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/entity/basic/EntitySpecTest.java b/core/src/test/java/brooklyn/entity/basic/EntitySpecTest.java
index 0a86e31..f80ab04 100644
--- a/core/src/test/java/brooklyn/entity/basic/EntitySpecTest.java
+++ b/core/src/test/java/brooklyn/entity/basic/EntitySpecTest.java
@@ -45,8 +45,6 @@ import com.google.common.collect.Iterables;
 
 public class EntitySpecTest extends BrooklynAppUnitTestSupport {
 
-    private static final int TIMEOUT_MS = 10*1000;
-    
     private SimulatedLocation loc;
     private TestEntity entity;
     
@@ -146,6 +144,28 @@ public class EntitySpecTest extends BrooklynAppUnitTestSupport {
         Asserts.assertEqualsIgnoringOrder(entity.getGroups(), ImmutableSet.of(group));
     }
     
+    @Test
+    public void testCallsConfigureAfterConstruction() throws Exception {
+        AbstractEntityLegacyTest.MyEntity entity = app.createAndManageChild(EntitySpec.create(AbstractEntityLegacyTest.MyEntity.class));
+        
+        assertEquals(entity.getConfigureCount(), 1);
+        assertEquals(entity.getConfigureDuringConstructionCount(), 0);
+    }
+    
+    @Test
+    public void testSetsDefaultDisplayName() throws Exception {
+        TestEntity entity = app.addChild(EntitySpec.create(TestEntity.class));
+        
+        assertTrue(entity.getDisplayName().startsWith("TestEntity:"+entity.getId().substring(0,4)), "displayName="+entity.getDisplayName());
+    }
+    
+    @Test
+    public void testUsesCustomDisplayName() throws Exception {
+        TestEntity entity = app.createAndManageChild(EntitySpec.create(TestEntity.class).displayName("entityname"));
+        
+        assertEquals(entity.getDisplayName(), "entityname");
+    }
+
     public static class MyPolicy extends AbstractPolicy {
         public static final BasicConfigKey<String> CONF1 = new BasicConfigKey<String>(String.class, "testpolicy.conf1", "my descr, conf1", "defaultval1");
         public static final BasicConfigKey<Integer> CONF2 = new BasicConfigKey<Integer>(Integer.class, "testpolicy.conf2", "my descr, conf2", 2);